Skip to content

Passenger numbers - month by month

Error executing template "Designs/aal/ItemPublisher/List/passager-numbers-monthly.cshtml"
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at CompiledRazorTemplates.Dynamic.RazorEngine_80ad94202c00411095d74140eb748179.Execute() in E:\Dynamicweb.net\Solutions\aal.dw9.dynamicweb-cms.com\files\Templates\Designs\aal\ItemPublisher\List\passager-numbers-monthly.cshtml:line 39
   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 @{ 2 List<string> monthList = new List<string> { Translate("PassengerNumbersJanuary", "Januar"), Translate("PassengerNumbersFebruary", "Februar"), Translate("PassengerNumbersMarch", "Marts"), Translate("PassengerNumbersApril", "April"), Translate("PassengerNumbersMay", "Maj"), Translate("PassengerNumbersJune", "Juni"), Translate("PassengerNumbersJuly", "Juli"), Translate("PassengerNumbersAugust", "August"), Translate("PassengerNumbersSeptember", "September"), Translate("PassengerNumbersOctober", "Oktober"), Translate("PassengerNumbersNovember", "November"), Translate("PassengerNumbersDecember", "December") }; 3 } 4 5 @foreach (var year in GetLoop("ItemPublisher:Items.List")) { 6 var previousYear = GetLoop("ItemPublisher:Items.List").Find(x => (year.GetInteger("ItemPublisher:Item.Year") - 1) == x.GetInteger("ItemPublisher:Item.Year")); 7 8 List<LoopItem> previousYearMonths = new List<LoopItem>(); 9 10 if (previousYear != null) { 11 previousYearMonths = (previousYear.GetLoop("ItemPublisher:Item.Months").OrderBy(x => x.GetInteger("ItemPublisher:Item.Months.Month")).ToList()); 12 } 13 14 <canvas id='passenger-numbers-@year.GetInteger("ItemPublisher:Item.Year")' class="passenger-numbers-chart" width="60" height="25"></canvas> 15 16 foreach(var month in year.GetLoop("ItemPublisher:Item.Months")) { 17 <div id='passenger-numbers-@year.GetInteger("ItemPublisher:Item.Year")-@month.GetInteger("ItemPublisher:Item.Months.Month")' class="table-responsive passenger-numbers-table"> 18 <table> 19 <thead> 20 <tr> 21 <th>@monthList[month.GetInteger("ItemPublisher:Item.Months.Month") - 1]</th> 22 @if (previousYear != null) { 23 <th class="result">@previousYear.GetInteger("ItemPublisher:Item.Year")</th> 24 } 25 <th class="result">@year.GetInteger("ItemPublisher:Item.Year")</th> 26 @if (previousYear != null) { 27 <th class="result">@Translate("PassengerNumbersChanges", "&AElig;ndringer")</th> 28 <th class="result">@Translate("PassengerNumbersChangesPercent", "I %")</th> 29 } 30 </tr> 31 </thead> 32 33 @{ 34 double monthTotal = (month.GetDouble("ItemPublisher:Item.Months.Domestic") + month.GetDouble("ItemPublisher:Item.Months.Foreign") + month.GetDouble("ItemPublisher:Item.Months.Charter") + month.GetDouble("ItemPublisher:Item.Months.Transit") + month.GetDouble("ItemPublisher:Item.Months.Other")); 35 36 double previousMonthTotal = 0; 37 38 if (previousYear != null) { 39 previousMonthTotal = previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Domestic") + previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Foreign") + previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Charter") + previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Transit") + previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Other"); 40 } 41 } 42 43 <tbody> 44 <tr> 45 <td>@Translate("PassengerNumbersDomestic", "Indenrigs")</td> 46 @if (previousYear != null) { 47 <td class="result">@thousandSeperator(previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetString("ItemPublisher:Item.Months.Domestic"))</td> 48 } 49 <td class="result">@thousandSeperator(month.GetString("ItemPublisher:Item.Months.Domestic"))</td> 50 @if (previousYear != null) { 51 <td class="result"> 52 @{ 53 double domesticChanges = month.GetDouble("ItemPublisher:Item.Months.Domestic") - previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Domestic"); 54 } 55 @thousandSeperator(domesticChanges.ToString()) 56 </td> 57 <td class="result"> 58 @{ 59 double domesticPercent = domesticChanges / previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Domestic") * 100; 60 } 61 @domesticPercent.ToString("0.0") 62 </td> 63 } 64 </tr> 65 <tr> 66 <td>@Translate("PassengerNumbersForeign", "Udenrigs")</td> 67 @if (previousYear != null) { 68 <td class="result">@thousandSeperator(previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetString("ItemPublisher:Item.Months.Foreign"))</td> 69 } 70 <td class="result">@thousandSeperator(month.GetString("ItemPublisher:Item.Months.Foreign"))</td> 71 @if (previousYear != null) { 72 <td class="result"> 73 @{ 74 double foreignChanges = month.GetDouble("ItemPublisher:Item.Months.Foreign") - previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Foreign"); 75 } 76 @thousandSeperator(foreignChanges.ToString()) 77 </td> 78 <td class="result"> 79 @{ 80 double foreignPercent = foreignChanges / previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Foreign") * 100; 81 } 82 @foreignPercent.ToString("0.0") 83 </td> 84 } 85 </tr> 86 <tr> 87 <td>@Translate("PassengerNumbersCharter", "Charter")</td> 88 @if (previousYear != null) { 89 <td class="result">@thousandSeperator(previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetString("ItemPublisher:Item.Months.Charter"))</td> 90 } 91 <td class="result">@thousandSeperator(month.GetString("ItemPublisher:Item.Months.Charter"))</td> 92 @if (previousYear != null) { 93 <td class="result"> 94 @{ 95 double charterChanges = month.GetDouble("ItemPublisher:Item.Months.Charter") - previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Charter"); 96 } 97 @thousandSeperator(charterChanges.ToString()) 98 </td> 99 <td class="result"> 100 @{ 101 double charterPercent = charterChanges / previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Charter") * 100; 102 } 103 @charterPercent.ToString("0.0") 104 </td> 105 } 106 </tr> 107 <tr> 108 <td>@Translate("PassengerNumbersTransit", "Transit")</td> 109 @if (previousYear != null) { 110 <td class="result">@thousandSeperator(previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetString("ItemPublisher:Item.Months.Transit"))</td> 111 } 112 <td class="result">@thousandSeperator(month.GetString("ItemPublisher:Item.Months.Transit"))</td> 113 @if (previousYear != null) { 114 <td class="result"> 115 @{ 116 double transitChanges = month.GetDouble("ItemPublisher:Item.Months.Transit") - previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Transit"); 117 } 118 @thousandSeperator(transitChanges.ToString()) 119 </td> 120 <td class="result"> 121 @{ 122 double transitPercent = transitChanges / previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Transit") * 100; 123 } 124 @transitPercent.ToString("0.0") 125 </td> 126 } 127 </tr> 128 <tr> 129 <td>@Translate("PassengerNumbersOther", "Anden trafik")</td> 130 @if (previousYear != null) { 131 <td class="result">@thousandSeperator(previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetString("ItemPublisher:Item.Months.Other"))</td> 132 } 133 <td class="result">@thousandSeperator(month.GetString("ItemPublisher:Item.Months.Other"))</td> 134 @if (previousYear != null) { 135 <td class="result"> 136 @{ 137 double otherChanges = month.GetDouble("ItemPublisher:Item.Months.Other") - previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Other"); 138 } 139 @thousandSeperator(otherChanges.ToString()) 140 </td> 141 <td class="result"> 142 @{ 143 double otherPercent = otherChanges / previousYearMonths[month.GetInteger("ItemPublisher:Item.Months.Month") - 1].GetDouble("ItemPublisher:Item.Months.Other") * 100; 144 } 145 @otherPercent.ToString("0.0") 146 </td> 147 } 148 </tr> 149 <tr> 150 <td>@Translate("PassengerNumbersTotal", "Total")</td> 151 @if (previousYear != null) { 152 <td class="result">@thousandSeperator(previousMonthTotal.ToString())</td> 153 } 154 <td class="result">@thousandSeperator(monthTotal.ToString())</td> 155 @if (previousYear != null) { 156 <td class="result"> 157 @{ 158 double totalChanges = monthTotal - previousMonthTotal; 159 } 160 @thousandSeperator(totalChanges.ToString()) 161 </td> 162 <td class="result"> 163 @{ 164 double totalPercent = totalChanges / previousMonthTotal * 100; 165 } 166 @totalPercent.ToString("0.0") 167 </td> 168 } 169 </tr> 170 </tbody> 171 </table> 172 </div> 173 } 174 } 175 176 @if (GetLoop("ItemPublisher:Items.List").Any()) { 177 @SnippetStart("JavaScriptBottom") 178 <script src="/Files/Templates/Designs/aal/assets/js/Chart.min.js"></script> 179 <script> 180 var thousandsSeperator = function (value, seperator, decimals) { 181 value = value.toString(); 182 183 if (value.indexOf('.') > -1) { 184 var value_split = value.split('.'); 185 value = value_split[0]; 186 var decimals = value_split[1]; 187 } 188 189 if (value.length > 3) { 190 var result = []; 191 while (value.length) { 192 result.push(value.substring(value.length - 3, value.length)); 193 value = value.substring(0, value.length - 3); 194 } 195 196 value = result.reverse().join(','); 197 } 198 199 if (decimals !== undefined) { 200 value = value + '.' + decimals; 201 } 202 203 return value; 204 }; 205 206 var monthList = ['@Translate("PassengerNumbersJanuary", "Januar")', '@Translate("PassengerNumbersFebruary", "Februar")', '@Translate("PassengerNumbersMarch", "Marts")', '@Translate("PassengerNumbersApril", "April")', '@Translate("PassengerNumbersMay", "Maj")', '@Translate("PassengerNumbersJune", "Juni")', '@Translate("PassengerNumbersJuly", "Juli")', '@Translate("PassengerNumbersAugust", "August")', '@Translate("PassengerNumbersSeptember", "September")', '@Translate("PassengerNumbersOctober", "Oktober")', '@Translate("PassengerNumbersNovember", "November")', '@Translate("PassengerNumbersDecember", "December")']; 207 var monthListShort = ['@Translate("PassengerNumbersJanuaryShort", "Jan.")', '@Translate("PassengerNumbersFebruaryShort", "Feb.")', '@Translate("PassengerNumbersMarchShort", "Mar.")', '@Translate("PassengerNumbersAprilShort", "Apr.")', '@Translate("PassengerNumbersMayShort", "Maj")', '@Translate("PassengerNumbersJuneShort", "Juni")', '@Translate("PassengerNumbersJulyShort", "Juli")', '@Translate("PassengerNumbersAugustShort", "Aug.")', '@Translate("PassengerNumbersSeptemberShort", "Sep.")', '@Translate("PassengerNumbersOctoberShort", "Okt.")', '@Translate("PassengerNumbersNovemberShort", "Nov.")', '@Translate("PassengerNumbersDecemberShort", "Dec.")']; 208 209 var chartClick = function (event) { 210 var element = event.target, 211 activePoints = passengerNumbersChart.getElementsAtEvent(event); 212 213 if (activePoints[0] !== undefined) { 214 var tables = document.querySelectorAll('.passenger-numbers-table'); 215 216 for (var t = 0, tl = tables.length; t < tl; t++) { 217 if (tables[t].id === element.id + '-' + (activePoints[0]._index + 1)) { 218 tables[t].classList.add('js-active'); 219 } else { 220 tables[t].classList.remove('js-active'); 221 } 222 } 223 } 224 }; 225 var passengerNumbersOptions = { 226 onClick: chartClick, 227 228 padding: 10, 229 230 title: { 231 display: true, 232 fontSize: 16, 233 fontFamily: "'ScenePro', Arial, sans-serif", 234 fontColor: '#002f5f', 235 fontStyle: 'bold', 236 padding: 24, 237 text: '@Translate("PassengerNumbersChartTitle", "Passagerstatistik for")' 238 }, 239 240 legend: { 241 display: false 242 }, 243 244 tooltips: { 245 backgroundColor: 'rgba(0, 0, 0, 0.8)', 246 247 titleFontFamily: "'ScenePro', Arial, sans-serif", 248 titleFontSize: 16, 249 titleMarginBottom: 6, 250 251 bodyFontFamily: "'ScenePro', Arial, sans-serif", 252 bodyFontSize: 16, 253 254 xPadding: 12, 255 yPadding: 12, 256 257 caretSize: 6, 258 259 cornerRadius: 3, 260 261 displayColors: false, 262 263 callbacks: { 264 title: function(tooltipItem, data) { 265 return data.datasets[tooltipItem[0].datasetIndex].label; 266 }, 267 label: function(tooltipItem, data) { 268 return monthList[tooltipItem.index] + ': ' + thousandsSeperator(tooltipItem.yLabel); 269 } 270 } 271 }, 272 273 scales: { 274 xAxes: [{ 275 stacked: false, 276 gridLines: { 277 display: false 278 }, 279 ticks: { 280 fontColor: '#002f5f', 281 labelOffset: 0, 282 maxRotation: 45 283 } 284 }], 285 yAxes: [{ 286 stacked: false, 287 gridLines: { 288 tickMarkLength: 6 289 }, 290 ticks: { 291 autoSkip: true, 292 callback: function(value) { 293 return thousandsSeperator(value); 294 }, 295 fontColor: '#002f5f', 296 padding: 12, 297 298 beginAtZero: true, 299 suggestedMin: 40000 300 } 301 }] 302 } 303 }; 304 </script> 305 foreach (var year in GetLoop("ItemPublisher:Items.List")) { 306 <script> 307 var passengerNumbersData = { 308 datasets: [{ 309 data: [ 310 @foreach(var month in year.GetLoop("ItemPublisher:Item.Months")) { 311 <text>@((month.GetDouble("ItemPublisher:Item.Months.Domestic") + month.GetDouble("ItemPublisher:Item.Months.Foreign") + month.GetDouble("ItemPublisher:Item.Months.Charter") + month.GetDouble("ItemPublisher:Item.Months.Transit") + month.GetDouble("ItemPublisher:Item.Months.Other")).ToString()),</text> 312 } 313 ], 314 label: '@Translate("PassengerNumbersChartLabel", "Antal passagerer")', 315 316 backgroundColor: 'rgba(0, 47, 95, 0.6)', 317 borderWidth: 0, 318 hoverBackgroundColor: 'rgba(0, 47, 95, 0.3)', 319 320 maxBarThickness: 21 321 }], 322 labels: monthListShort 323 }; 324 325 passengerNumbersOptions.title.text = '@Translate("PassengerNumbersChartTitle", "Passagerstatistik for") @year.GetInteger("ItemPublisher:Item.Year")'; 326 327 var passengerNumbersChart = new Chart(document.getElementById('passenger-numbers-@year.GetInteger("ItemPublisher:Item.Year")'), { 328 type: 'bar', 329 data: passengerNumbersData, 330 options: passengerNumbersOptions 331 }); 332 </script> 333 } 334 @SnippetEnd("JavaScriptBottom") 335 } 336 337 @functions{ 338 public static string thousandSeperator (string number) { 339 if (number.Length > 3) { 340 number = number.Insert(number.Length - 3, "."); 341 } 342 343 return number; 344 } 345 } 346 347 @SnippetStart("JavaScriptBottom") 348 @if (System.Web.HttpContext.Current.Items["TablesJSLoaded"] != "true") { 349 System.Web.HttpContext.Current.Items["TablesJSLoaded"] = "true"; 350 351 <script src="/Files/Templates/Designs/aal/assets/js/tables.min.js" async></script> 352 } 353 @SnippetEnd("JavaScriptBottom") 354

Stay updated on travel requirements you need to be aware of              -             Face Masks/visor are mandatory at Aalborg Airport         -          You can get a quick test at Falck or a PCR-test at Pentabase