Error executing template "Designs/Dwsimple/Paragraph/Calendar.cshtml"
System.Net.WebException: The remote server returned an error: (503) Server Unavailable.
at System.Net.HttpWebRequest.GetResponse()
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.FinishInitUriString()
at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)
at CompiledRazorTemplates.Dynamic.RazorEngine_b50a031288f946b59c68fc16121019ac.b__12_0(TextWriter __razor_helper_writer) in E:\Dynamicweb.net\Solutions\Degngrafisk\vesterborglandetrydekirker.dw9.dynamicweb-cms.com\files\Templates\Designs\Dwsimple\Paragraph\Calendar.cshtml:line 189
at CompiledRazorTemplates.Dynamic.RazorEngine_b50a031288f946b59c68fc16121019ac.Execute() in E:\Dynamicweb.net\Solutions\Degngrafisk\vesterborglandetrydekirker.dw9.dynamicweb-cms.com\files\Templates\Designs\Dwsimple\Paragraph\Calendar.cshtml:line 59
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @using System.Xml.Linq;
2 @using System.Text;
3 @using System.Globalization;
4
5 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
6
7 @{
8 init();
9 }
10
11 @functions {
12 private int columnsWritten { get; set; }
13 private int columns { get; set; }
14
15 public void init()
16 {
17 columnsWritten = Dynamicweb.Core.Converter.ToInt32(System.Web.HttpContext.Current.Items["currentColumns"]);
18 columns = GetInteger("Item.Width");
19 System.Web.HttpContext.Current.Items["currentColumns"] = columnsWritten + GetInteger("Item.Width");
20 }
21
22 public void Fluid()
23 {
24 columnsWritten = Dynamicweb.Core.Converter.ToInt32(System.Web.HttpContext.Current.Items["currentColumns"]);
25 columns = 12;
26 System.Web.HttpContext.Current.Items["currentColumns"] = columnsWritten + 12;
27 }
28
29 public string ColumnClass()
30 {
31 if (GetString("Item.WidthMobile") == "hide"){
32 return "col-md-" + GetString("Item.Width") + " hidden-xs";
33 } else {
34 return "col-md-" + GetString("Item.Width") + " col-xs-" + GetString("Item.WidthMobile");
35 }
36 }
37
38 public string NewRow()
39 {
40 if (columns + columnsWritten > 12)
41 {
42 System.Web.HttpContext.Current.Items["currentColumns"] = columns;
43 return "</div><div class=\"row\">";
44 }
45 else
46 {
47 return string.Empty;
48 }
49
50 }
51 }
52
53
54 @NewRow()
55
56 <div class="@ColumnClass()">
57
58 @if (@GetString("Item.LayoutMode") == "list") {
59 @CalendarList();
60 } else {
61 string thisyear = "";
62
63 <ul class="timeline hidden-xs">
64 @{
65 DateTime EndDate = DateTime.Now.AddDays(GetInteger("Item.Days"));
66 String StartDate = DateTime.Now.ToString("dd/MM/yyyy");
67 String Limit = int.Parse(GetString("Item.CountLimit"), NumberStyles.AllowThousands).ToString();
68
69 if (GetBoolean("Item.StartDateNow") == false){
70 EndDate = Convert.ToDateTime(GetString("Item.StartDate")).AddDays(GetInteger("Item.Days"));
71 StartDate = GetString("Item.StartDate");
72 }
73
74 string linkstring = GetString("Item.FeedLink")+"&InKontonr="+GetString("Item.AccountNumber")+"&InMaksAntalAftaler="+Limit+"&InDatoFra="+StartDate+"&InDatoTil="+EndDate.ToString("dd/MM/yyyy");
75
76 if (GetString("Item.Show.Filter") != "alle"){
77 linkstring += "&InAftaletypeID=" + GetString("Item.Show.Filter");
78 }
79
80 XDocument xdoc = XDocument.Load(linkstring);
81 var elements = xdoc.Element("DATA").Elements("AFTALE");
82
83 foreach (var el in elements)
84 {
85 string id = "0";
86 string type = "alle";
87 DateTime date;
88 string title = "Title";
89 string description = "Description";
90 string fulldate = "Date";
91 string cleanDate = "";
92 string location = "";
93 string document = "";
94 string document_type = "document";
95
96 if (el.Elements("ID").Any()){
97 id = el.Element("ID").Value;
98 }
99
100 if (el.Elements("AFTALETYPE").Any()){
101 type = el.Element("AFTALETYPE").Value;
102 }
103
104 if (el.Elements("DATO_FRA").Any() && el.Elements("KL_FRA").Any()) {
105 date = DateTime.Parse(el.Element("DATO_FRA").Value + " " + el.Element("KL_FRA").Value, new CultureInfo("da-DK"));
106 cleanDate = date.ToString("dddd d. MMMM kl. HH:mm", new CultureInfo("da-DK"));
107 }
108
109 if (el.Elements("OVERSKRIFT").Any()){
110 title = el.Element("OVERSKRIFT").Value;
111 }
112
113 if (el.Elements("BESKRIVELSE").Any()){
114 description = el.Element("BESKRIVELSE").Value;
115 }
116
117 if (el.Elements("DATO_FORMATERET").Any()){
118 fulldate = el.Element("DATO_FORMATERET").Value;
119 }
120
121 if (el.Elements("STED").Any()){
122 location = el.Element("STED").Value;
123 }
124
125 if (el.Elements("OFFENTLIGE_DOKUMENTER").Any() && el.Element("OFFENTLIGE_DOKUMENTER").Elements("DOKUMENT").Any() && el.Element("OFFENTLIGE_DOKUMENTER").Element("DOKUMENT").Elements("URL").Any()){
126 document = "http://kalender.brandsoft.dk/bska/" + el.Element("OFFENTLIGE_DOKUMENTER").Element("DOKUMENT").Element("URL").Value;
127 }
128
129 if (el.Elements("OFFENTLIGE_DOKUMENTER").Any() && el.Element("OFFENTLIGE_DOKUMENTER").Elements("DOKUMENT").Any() && el.Element("OFFENTLIGE_DOKUMENTER").Element("DOKUMENT").Elements("DOKUMENTTYPE").Any()){
130 document_type = el.Element("OFFENTLIGE_DOKUMENTER").Element("DOKUMENT").Element("DOKUMENTTYPE").Value;
131 }
132
133
134 <li class="event">
135 <div class="event-date">
136 <h3>@title</h3>
137 </div>
138 <div class="event-body">
139 <div class="row">
140 <div class="col-md-12">
141 <p>
142 @description
143 </p>
144
145 @if (location != ""){
146 <p><i>@location</i></p>
147 }
148
149 @if (document != ""){
150 <a href="@document" class="btn btn-dw-primary pull-right" download>Download dokument</a>
151 }
152 </div>
153 </div>
154 </div>
155 <div class="event-footer">
156 <ul class="aux-info-cells">
157 <li><span class="label label-default">@type</span> @fulldate</li>
158 </ul>
159 </div>
160 </li>
161 }
162 }
163 </ul>
164
165 <div class="hidden-lg hidden-md hidden-sm">
166 @CalendarList();
167 </div>
168 }
169 </div>
170
171 @helper CalendarList(){
172 <ul class="list-listings blog-list">
173 @{
174 DateTime EndDate = DateTime.Now.AddDays(GetInteger("Item.Days"));
175 String StartDate = DateTime.Now.ToString("dd/MM/yyyy");
176 String Limit = int.Parse(GetString("Item.CountLimit"), NumberStyles.AllowThousands).ToString();
177
178 if (GetBoolean("Item.StartDateNow") == false){
179 EndDate = Convert.ToDateTime(GetString("Item.StartDate")).AddDays(GetInteger("Item.Days"));
180 StartDate = GetString("Item.StartDate");
181 }
182
183 string linkstring = GetString("Item.FeedLink")+"&InKontonr="+GetString("Item.AccountNumber")+"&InMaksAntalAftaler="+Limit+"&InDatoFra="+StartDate+"&InDatoTil="+EndDate.ToString("dd/MM/yyyy");
184
185 if (GetString("Item.Show.Filter") != "alle"){
186 linkstring += "&InAftaletypeID=" + GetString("Item.Show.Filter");
187 }
188
189 XDocument xdoc = XDocument.Load(linkstring);
190 var elements = xdoc.Element("DATA").Elements("AFTALE");
191
192 foreach (var el in elements)
193 {
194 string id = "0";
195 string type = "alle";
196 DateTime date;
197 string title = "Title";
198 string description = "Description";
199 string fulldate = "Date";
200 string cleanDate = "";
201 string day = "";
202 string month = "";
203 string location = "";
204 string document = "";
205
206 if (el.Elements("ID").Any()){
207 id = el.Element("ID").Value;
208 }
209
210 if (el.Elements("AFTALETYPE").Any()){
211 type = el.Element("AFTALETYPE").Value;
212 }
213
214 if (el.Elements("DATO_FRA").Any() && el.Elements("KL_FRA").Any()) {
215 date = DateTime.Parse(el.Element("DATO_FRA").Value + " " + el.Element("KL_FRA").Value, new CultureInfo("da-DK"));
216 cleanDate = date.ToString("dddd d. MMMM kl. HH:mm", new CultureInfo("da-DK"));
217 day = date.ToString(" d", new CultureInfo("da-DK"));
218 month = date.ToString("MMM", new CultureInfo("da-DK"));
219 }
220
221 if (el.Elements("OVERSKRIFT").Any()){
222 title = el.Element("OVERSKRIFT").Value;
223 }
224
225 if (el.Elements("BESKRIVELSE").Any()){
226 description = el.Element("BESKRIVELSE").Value;
227 }
228
229 if (el.Elements("DATO_FORMATERET").Any()){
230 fulldate = el.Element("DATO_FORMATERET").Value;
231 }
232
233 if (el.Elements("STED").Any()){
234 location = el.Element("STED").Value;
235 }
236
237 if (el.Elements("OFFENTLIGE_DOKUMENTER").Any() && el.Element("OFFENTLIGE_DOKUMENTER").Elements("DOKUMENT").Any()){
238 foreach(var doc in el.Element("OFFENTLIGE_DOKUMENTER").Elements("DOKUMENT")) {
239 if (doc.Element("DOKUMENTTYPE").Value == "OFFENTLIGT_AFTALE_BILLEDE"){
240 document = "http://kalender.brandsoft.dk/bska/" + doc.Element("URL").Value;
241 break;
242 }
243 }
244 }
245
246
247
248 string link_start = "";
249 string link_end = "";
250 if (GetString("Item.ShowInfo") != "Hidden"){
251 link_start = "<div href=\"#\" onclick=\"toggle_visibility("+id+");\" style=\"cursor:pointer\">";
252 link_end = "</div>";
253 }
254 string registration_url = "https://kalenderhtml5.brandsoft.dk/#/event/" + GetString("Item.AccountNumber") + "/" + id;
255
256
257
258 @*@link_start*@
259 <div class="row">
260 <div class="media col-md-12">
261
262 <div class="media-left">
263
264 <div class="media-object calendar-date bg-primary color-secondary text-center"><span>@day</span> @month</div>
265
266 </div>
267 <div class="media-body">
268 <h2 class="media-heading color-primary">@title</h2>
269 @* <a href="@registration_url" target="_blank">Tilmeld</a> *@
270
271 <p class="list-item-info">@type</p>
272 <p class="list-item-info nomargin"><i class="fa fa-fw fa-calendar-o"></i> @fulldate</p>
273 <p class="list-item-info nomargin"><i class="fa fa-fw fa-map-marker"></i> @location</p>
274
275
276
277 @{
278 string isHidden = "";
279 if (GetString("Item.ShowInfo") == "Closed" || GetString("Item.ShowInfo") == "Hidden"){
280 isHidden = "style=\"display:nones;\"";
281 }
282 }
283
284 <div id="@id" @isHidden>
285 <p>@description</p>
286
287 @{
288 var document_elements = el.Element("OFFENTLIGE_DOKUMENTER").Elements("DOKUMENT");
289 foreach(var doc in document_elements) {
290 if(doc.Element("DOKUMENTTYPE").Value == "OFFENTLIGT_DOKUMENT") {
291 string name = doc.Element("ORG_FILNAVN").Value;
292 string url = "http://kalender.brandsoft.dk/bska/" + doc.Element("URL").Value;
293 <br>
294 <i class="fa fa-fw fa-file-o list-item-info"></i><a href="@url" target="_blank" class="document-link">@name</a>
295 }
296 }
297 }
298 </div>
299
300
301 </div>
302 <div class="media-right hidden-xs" style="width: 33%;">
303 @if (document != ""){
304 if (GetString("Item.ShowInfo") == "Open"){
305 <img class="img-responsive bigPic" src="@document" alt="" id="@(id)_img" style="max-height: 500px; float:right; position: relative;"></img>
306 } else {
307 <img class="img-responsive" src="@document" alt="" id="@(id)_img" style="max-height: 100px; float:right; position: relative;"></img>
308 }
309 }
310 </div>
311
312 </div>
313 </div>
314 @*
315 if (!string.IsNullOrWhiteSpace(description) || !string.IsNullOrWhiteSpace(document)){
316 if (GetString("Item.ShowInfo") == "Open"){
317 <p id="@(id)_chevron" class="text-center chevron"></p>
318 } else if (GetString("Item.ShowInfo") == "Closed") {
319 <p id="@(id)_chevron" class="text-center chevron bottom"></p>
320 }
321 }
322 *@
323 @*@link_end*@
324
325 <hr>
326
327
328 }
329 }
330 </ul>
331 }
332
333 <script type="text/javascript">
334 function toggle_visibility(id) {
335 if($('#' + id + "_chevron").length){
336 $('#' + id).stop().slideToggle('slow');
337 $('#' + id + "_chevron").toggleClass('bottom');
338
339 var image = $('#' + id + "_img")
340 if(image.length && !image.hasClass('bigPic')){
341
342 var container_width = image.parent().width();
343 var image_height;
344 var natural_width = document.getElementById(id + "_img").naturalWidth;
345 var natural_height = document.getElementById(id + "_img").naturalHeight;
346
347 if(natural_width < container_width){ //>
348 container_width = natural_width;
349 }
350
351 var res = container_width / natural_width;
352
353 image_height = natural_height * res;
354
355 if(image_height > 400){
356 image_height = 400;
357 }
358
359 image.addClass('bigPic');
360 image.css('max-height', image_height + "px");
361 }else{
362 image.removeClass('bigPic');
363 image.css('max-height', "100px");
364 }
365 }
366 }
367 </script>
368