Exception in template (\Designs\Dwsimple\Paragraph\syseddel.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.ababbfdc.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using System; @using System.Web; @using Pagunette.CustomModules; @using Pagunette.CustomModules.Classes; @using System.Configuration; @using Pagunette.Models; @using Newtonsoft.Json; @using Pagunette.CustomModules.Utils; @using Dynamicweb; @using Dynamicweb.Logging; @using Dynamicweb.Ecommerce.Orders; @{ ILogger logger = LogManager.Current.GetLogger("internalReceipt"); var request = HttpContext.Current.Request; Order ordre = Dynamicweb.Ecommerce.Orders.Order.GetOrderById(request.QueryString["OrderID"]); OrderFieldValueCollection orderFields = ordre.OrderFieldValues; var localeString = "pl-PL"; var printStyle = new HtmlString("@media"); } <html> <head> <meta charset="utf-8"> <style> #cookieWarningDiv { display: none } </style> </head> <body> @{ var logoimage = Dynamicweb.Frontend.PageView.GetPageviewByPageID(ordre.CheckoutPageId).Area.Item["GeneralLogo"].ToString(); var logotext = Dynamicweb.Frontend.PageView.GetPageviewByPageID(ordre.CheckoutPageId).Area.Item["GeneralLogoText"].ToString(); int i = 1; string[] produktionsNumre = new string[0]; } @foreach (OrderLine orderline in ordre.OrderLines) { string productNumber = orderline.ProductNumber; bool isConfiguratorProduct = productNumber == ConfigurationManager.AppSettings["ConfiguratorProductNumber"]; ConfiguratorSelectionModel configuratorSelection = null; ConfiguratorPriceDetailsModel selectionPrices = null; string image = string.Empty; OrderLineFieldValueCollection items = orderline.OrderLineFieldValues; foreach (OrderLineFieldValue item in items) { switch (item.OrderLineFieldSystemName) { case "ConfiguratorData": try { //@item.GetString("Ecom:Order:OrderLine.OrderLineField.Value"); configuratorSelection = JsonConvert.DeserializeObject<ConfiguratorSelectionModel>(item.Value); selectionPrices = ConfiguratorOperations.GetPriceDetails(configuratorSelection, orderline.Quantity, true, true, ordre); if ("PLK" != configuratorSelection.PerfionLanguage) { configuratorSelection.ChangeLanguage(configuratorSelection, "PLK"); } image = PIMComUtilities.GetPerfionImageUrl(configuratorSelection.Vare.Image1, "100x100"); } catch (Exception e) { } break; case "VismaProductionIDs": if (!string.IsNullOrEmpty(item.Value)) { produktionsNumre = item.Value.Split(','); } break; default: break; } } if (string.IsNullOrEmpty(image) && orderline.get_OrderLineFieldValue("MainProductImage") != null) { image = PIMComUtilities.GetPerfionImageUrl(orderline.get_OrderLineFieldValue("MainProductImage").Value.ToString(), "100x100"); } <h2>@Translate("InternalReceipt", "Intern kopi af ordrekvittering", localeString)</h2> <table width="800" border="0" cellspacing="0" cellpadding="0" ID="Table3"> <tr> <td width="50%" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0" ID="Table2"> <tr> <td width="100%" valign="top" colspan="3"><b>@Translate("Billingaddress", "Billing address", localeString)</b></td> </tr> <tr> <td width="40%" valign="top">@Translate("Company", "Company", localeString)</td> <td width="60%" valign="top">@ordre.CustomerCompany</td> </tr> <tr> <td width="40%" valign="top">@Translate("Address", "Address", localeString)</td> <td width="60%" valign="top">@ordre.CustomerAddress</td> </tr> <tr> <td width="40%" valign="top">@Translate("Zipcode", "Zipcode", localeString)</td> <td width="60%" valign="top">@ordre.CustomerZip<text>&nbsp;</text>@ordre.CustomerCity</td> </tr> <tr> <td width="40%" valign="top">@Translate("Country", "Country", localeString)</td> <td width="60%" valign="top">@ordre.CustomerCountry</td> </tr> <tr> <td width="40%" valign="top">@Translate("Phone", "Phone", localeString)</td> <td width="60%" valign="top">@ordre.CustomerPhone</td> </tr> <tr> <td width="40%" valign="top">@Translate("Email", "Email", localeString)</td> <td width="60%" valign="top">@ordre.CustomerEmail</td> </tr> </table> <br> <table width="100%" border="0" cellspacing="0" cellpadding="0" ID="Table5"> <tr> <td width="100%" valign="top" colspan="3"><b>@Translate("Orderinformation", "Orderinformation", localeString)</b></td> </tr> <tr> <td width="40%" valign="top">@Translate("Customer number", "Kundenr", localeString)</td> <td width="60%" valign="top">@ordre.CustomerNumber</td> </tr> <tr> <td width="40%" valign="top">@Translate("Bestillingsnummer", "Bestillingsnummer", localeString)</td> <td width="60%" valign="top">@ordre.Id</td> </tr> <tr> <td width="40%" valign="top">@Translate("VismaSalesnumber", "Sales ordernumber", localeString)</td> <td width="60%" valign="top">@orderFields.GetOrderFieldValue("VismaOrderID").Value.ToString()</td> </tr> @if (!string.IsNullOrWhiteSpace(@ordre.TransactionNumber)) { <tr> <td width="40%" valign="top">@Translate("Transaction number", "Transaction number", localeString)</td> <td width="60%" valign="top">@ordre.TransactionNumber</td> </tr> } <tr> <td width="40%" valign="top">@Translate("ReqNo", "Rekv.nummer", localeString)</td> <td width="60%" valign="top">@orderFields.GetOrderFieldValue("RequisitionNumber").Value.ToString()</td> </tr> <tr> <td width="40%" valign="top">@Translate("Order date", "Order date", localeString)</td> <td width="60%" valign="top">@ordre.CompletedDate.Value.ToString("dd-MM-yyyy")</td> </tr> @if (DateTime.Parse(orderFields.GetOrderFieldValue("DesiredDeliveryDate").Value.ToString()) >= DateTime.UtcNow) { <tr> <td width="40%" valign="top">@Translate("Desired delivery date", "Desired delivery date", localeString)</td> <td width="60%" valign="top">@DateTime.Parse(orderFields.GetOrderFieldValue("DesiredDeliveryDate").Value.ToString()).ToString(Dynamicweb.Dates.DateOnlyFormatStringShort)</td> </tr> } </table> </td> @if (!string.IsNullOrWhiteSpace(ordre.DeliveryAddress)) { <td width="50%" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0" ID="Table4"> <tr> <td width="100%" valign="top" colspan="3"><b>@Translate("Delivery address", "Delivery address", localeString)</b></td> </tr> <tr> <td width="40%" valign="top">@Translate("Company", "Company", localeString)</td> <td width="60%" valign="top">ordre.DeliveryCompany</td> </tr> <tr> <td width="40%" valign="top">@Translate("Att", "Att.", localeString)</td> <td width="60%" valign="top">ordre.DeliveryName</td> </tr> <tr> <td width="40%" valign="top">@Translate("Address", "Address", localeString)</td> <td width="60%" valign="top">ordre.DeliveryAddress</td> </tr> <tr> <td width="40%" valign="top">@Translate("Zipcode", "Zipcode", localeString)</td> <td width="60%" valign="top">ordre.DeliveryZip<text>&nbsp;</text>ordre.DeliveryCity</td> </tr> <tr> <td width="40%" valign="top">@Translate("Country", "Country", localeString)</td> <td width="60%" valign="top">ordre.DeliveryCountry</td> </tr> </table> </td> } </tr> </table> <table cellspacing="0" cellpadding="0" border="0" width="800" style="margin-top: 15px;"> <tr> <td colspan="3"> <b>@Translate("Ordrespecifikation", "Ordrespecifikation", localeString)</b> </td> </tr> <tr class="basketheader"> <th style="text-align:left;">@Translate("Product", "Product2", localeString)</th> <th>&nbsp;</th> <th style="text-align:right;">@Translate("Qty", "Qty", localeString)</th> </tr> <tr class="separator"> <td colspan="3"><hr /></td> </tr> @if (ordre.OrderLines.Count > 0) { <tr> <td colspan="3">@Translate("VismaSalesnumber", "Sales ordernumber", localeString): @orderFields.GetOrderFieldValue("VismaOrderID").Value.ToString(), @Translate("VismaProductionOrder", "Production order", localeString) @orderFields.GetOrderFieldValue("VismaProductionIDs").Value.ToString().Split(',').ElementAtOrDefault((i-1))</td> </tr> <tr> <td colspan="3"><hr /></td> </tr> } <tr> <td width="120"> <img src="@image" class="receipt-image" width="100" height="100" /><br />&nbsp; @if (configuratorSelection == null) { <span class="receipt-p-number"> @orderline.ProductNumber</span> if (orderline.Type == "1") { <small>@Translate("Discount", "Discount", localeString)</small> } } </td> <td> @if (configuratorSelection != null) { <b>@configuratorSelection.Vare.Name</b> } else { <a href="@orderline.Reference"> @orderline.ProductName @if (!string.IsNullOrWhiteSpace(orderline.ProductVariantText)) { @orderline.ProductVariantText; } </a> } @if (orderline.OrderLineFieldValues.Any()) { <table class="table receipt-table"> @foreach (OrderLineFieldValue item in items) { var label = ""; var value = item.Value.ToString(); switch (item.OrderLineFieldSystemName) { case "DesiredDeliveryDate": label = Translate("ReceptOrderLineDeliveryDate", "Ønsket leveringsdato", localeString); if (string.IsNullOrEmpty(value)) { value = Translate("ReceptOrderLineDeliveryDateASAP", "Hurtigst muligt", localeString); } break; case "Comment": if (configuratorSelection != null) { label = null; } else { label = Translate("ReceptOrderLineComment", "Kommentar"); } if (!string.IsNullOrEmpty(value)) { value = value.Replace("\n", "<br/>"); } break; } if (!string.IsNullOrWhiteSpace(label) && !string.IsNullOrWhiteSpace(value)) { <tr> <td>@label</td> <td>@value</td> </tr> } } </table> } </td> <td style="text-align:right;">@orderline.Quantity</td> </tr> @if (isConfiguratorProduct && configuratorSelection != null) { var combined = new ConfiguratorCombinedModel() { selection = configuratorSelection, prices = selectionPrices, dwOrderline = Dynamicweb.Ecommerce.Orders.OrderLine.GetOrderLineById(orderline.Id) }; var imageList = ConfiguratorOperations.GetConfiguratorImages(configuratorSelection); if (imageList.Count() > 0) { foreach (var objWithImage in imageList) { <tr> <td width="120"> <img src='@objWithImage.ImageUrl' width="100" height="100" /> <br />&nbsp; </td> <td>@objWithImage.Name</td> <td></td> </tr> } } <tr> <td colspan="3">@ConfiguratorOperations.GetProductionDescription(combined, configuratorSelection.PerfionLanguage, "syseddel")</td> </tr> } <tr> <td> &nbsp; </td> </tr> <tr> <td colspan="3"> <strong>@Translate("OrderComment", "Comment", localeString)</strong> <br /> @ordre.CustomerComment </td> </tr> </table> if (i < ordre.OrderLines.Count) { <div style="page-break-before:always"> &nbsp;</div> } i++; } @* <table cellspacing="0" cellpadding="0" border="0" width="800" style=""> <tr class="separator"> <td colspan="3">&nbsp;</td> </tr> <tr> <td> <strong>@Translate("OrderComment", "Comment", localeString)</strong> <br /> @ordre.CustomerComment </td> </tr> </table> *@ </body> </html>