STICKS FOR PARAKEETS HONEY & NUTS
0211160
Error executing template "Designs/Swift/Paragraph/Swift_ProductStock.cshtml" System.IO.IOException: The process cannot access the file 'D:\dynamicweb.net\Solutions\Nextech\superhome.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Translations.xml' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at Dynamicweb.Rendering.Translation.Source.WriteDocument(XmlDocument document) at Dynamicweb.Rendering.Translation.Source.Save() at Dynamicweb.Rendering.Translation.Source.UpdateTranslationSource(Source source, IEnumerable`1 newKeys, String designName, IEnumerable`1 cultures) at Dynamicweb.Rendering.Template.TranslateText(String text, String defaultValue, String cultureName) at Dynamicweb.Rendering.TemplateBase`1.Translate(String text) at CompiledRazorTemplates.Dynamic.RazorEngine_41763079903147d4b7cfe9ebe069c5b2.Execute() in D:\dynamicweb.net\Solutions\Nextech\superhome.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductStock.cshtml:line 173 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.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using NextechDWAddIn.Helpers 4 5 @{ 6 //Not working on SHC bool isProductDetailsPage = Dynamicweb.Context.Current.Request.QueryString.AllKeys.Contains("ProductID");//CS NT 7 string productId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : ""; 8 bool isProductDetailsPage = !string.IsNullOrEmpty(productId); 9 10 11 ProductViewModel product = null; 12 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 13 { 14 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 15 } 16 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 17 { 18 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 19 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 20 21 if (productList?.Products is object) 22 { 23 product = productList.Products[0]; 24 } 25 } 26 27 bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsWebServiceConnectionAvailable"]); 28 bool hideStock = Model.Item.GetBoolean("HideStockState") || (Pageview.AreaSettings.GetBoolean("ErpDownHideStock") && isErpConnectionDown); 29 30 31 //CS NT PhoneOrder 32 bool isPhoneOrder = false; 33 if (product.ProductFields != null && product.ProductFields.Count > 0) 34 { 35 foreach (var pf in product.ProductFields) 36 { 37 if (pf.Key == "PhoneOrders" && pf.Value != null && !string.IsNullOrWhiteSpace(pf.Value.ToString())) 38 { 39 isPhoneOrder = pf.Value.ToString() == "1" ? true : false; 40 } 41 } 42 } 43 } 44 45 @if (product is object && product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock && !hideStock) 46 { 47 48 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 49 horizontalAlign = horizontalAlign == "center" ? "text-center" : horizontalAlign; 50 horizontalAlign = horizontalAlign == "end" ? "text-end" : horizontalAlign; 51 bool hasExpectedDelivery = product.ExpectedDelivery != null && product.ExpectedDelivery > DateTime.Now; 52 string expectedDeliveryDate = product.ExpectedDelivery?.ToShortDateString() ?? ""; 53 54 string liveInfoClass = ""; 55 string productInfoFeed = ""; 56 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 57 if (isLazyLoadingForProductInfoEnabled) 58 { 59 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 60 { 61 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 62 if (!string.IsNullOrEmpty(productInfoFeed)) 63 { 64 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 65 } 66 } 67 liveInfoClass = "js-live-info"; 68 } 69 70 if (!product.NeverOutOfstock) 71 { 72 string deliveryLabel = !string.IsNullOrEmpty(product.StockDeliveryText) ? $"{product.StockDeliveryText}" : ""; 73 deliveryLabel += !string.IsNullOrEmpty(product.StockDeliveryValue) ? $" {product.StockDeliveryValue}" : ""; 74 75 if (isLazyLoadingForProductInfoEnabled) 76 { 77 string inStockStateLabel = !string.IsNullOrEmpty(product.StockStatus) ? product.StockStatus : Translate("In stock"); 78 string noStockStateLabel = !string.IsNullOrEmpty(product.StockStatus) ? product.StockStatus : Translate("Out of Stock"); 79 80 <div class="js-stock-state @horizontalAlign item_@Model.Item.SystemName.ToLower() @liveInfoClass" data-product-id="@product.Id" data-variant-id="@product.VariantId" @productInfoFeed> 81 <div class="js-stock-state spinner-border"> 82 <div class="small d-none" data-show-if="LiveProductInfo.product.StockLevel > 0"> 83 @if (!Model.Item.GetBoolean("HideInventory")) 84 { 85 <span class="text-success js-text-stock"></span> 86 } 87 <span class="text-success">@inStockStateLabel</span> 88 <span class="opacity-75">@deliveryLabel</span> 89 </div> 90 91 <div class="small text-danger d-none" data-show-if="LiveProductInfo.product.StockLevel <= 0">@noStockStateLabel</div> 92 93 <div class="d-none" data-show-if="LiveProductInfo.product.ExpectedDelivery != null && new Date(LiveProductInfo.product.ExpectedDelivery) > new Date()"> 94 <span>@Translate("Expected back in stock"): </span> 95 <span class="js-text-expected-delivery"></span> 96 </div> 97 </div> 98 </div> 99 } 100 else 101 { 102 string firstUnitId = product?.UnitOptions?.FirstOrDefault() != null ? product.UnitOptions.FirstOrDefault().Id : ""; 103 string defaultUnitId = !string.IsNullOrEmpty(product.DefaultUnitId) ? product.DefaultUnitId : firstUnitId; 104 string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : defaultUnitId; 105 106 double? currentStockLevel = product.StockLevel; 107 108 string stockStateLabel = currentStockLevel > 0 ? Translate("In stock") : Translate("Out of stock"); 109 stockStateLabel = !string.IsNullOrEmpty(product.StockStatus) ? product.StockStatus : stockStateLabel; 110 111 string stockStateCss = currentStockLevel > 0 ? "text-success" : "text-danger"; 112 string stockStateIconCss = currentStockLevel > 0 ? "bg-success" : "bg-danger"; 113 114 115 116 //CS NT color based on stock state 20240716 117 if(!string.IsNullOrEmpty(product.StockStatus)) 118 { 119 stockStateCss = "NTstockState_" + product.StockStatus.Replace(" ",""); 120 } 121 122 123 <div class="js-stock-state @horizontalAlign item_@Model.Item.SystemName.ToLower()"> 124 <div class="small"> 125 @if (!Model.Item.GetBoolean("HideInventory") && currentStockLevel > 0) 126 { 127 <span class="js-text-stock">@currentStockLevel</span> 128 } 129 @if(!isPhoneOrder) 130 { 131 <span class="@stockStateCss stock-icon"></span> 132 <span class="">@stockStateLabel</span> 133 } 134 @if (!string.IsNullOrEmpty(deliveryLabel)) 135 { 136 <span class="opacity-75">@deliveryLabel</span> 137 } 138 </div> 139 140 @if (hasExpectedDelivery) 141 { 142 <div> 143 <span>@Translate("Expected in stock"): </span> 144 <span>@expectedDeliveryDate</span> 145 </div> 146 } 147 </div> 148 } 149 150 151 152 153 154 @* CS NT Stock Per location button-modal..*@ 155 156 if(isProductDetailsPage) 157 { 158 var itemStockPerLocationList = ItemStockHelper.GetStockOfItem(product.Id); 159 if(itemStockPerLocationList != null && itemStockPerLocationList.Count > 0) 160 { 161 162 <!-- Trigger/Open The Modal --> 163 <button id="StockAvailabilityBtn" class="btn btn-primary dw-mod" data-productId="@product.Id" ><i class="fal fa-boxes-alt"></i> @Translate("Stock By Store")</button> 164 165 <!-- The Modal --> 166 <div id="stockModal" class="modal-nextech"> 167 168 <!-- Modal content --> 169 <div class="modal-content-nextech"> 170 171 <table class="stock-table-nextech"> 172 <tr> 173 <th>@Translate("Store")</th> 174 <th>@Translate("Stock") <span class="close-nextech"><i class="fas fa-times"></i></span> </th> 175 </tr> 176 @foreach(var itemStock in itemStockPerLocationList) 177 { 178 string cssClass = "lowStock-Availability-text-color"; 179 if(itemStock.InventoryText == "Out of stock") { cssClass = "outOfStock-Availability-text-color"; } 180 if(itemStock.InventoryText == "In stock") { cssClass = "inStock-Availability-text-color"; } 181 182 <tr> 183 <td class="stockLocationName-AvailabilityByStore">@itemStock.LocationName</td> 184 <td class="@cssClass">@Translate(itemStock.InventoryText)</td> 185 </tr> 186 } 187 </table> 188 </div> 189 190 </div> 191 192 <script> 193 // Get the modal 194 var modal_abs = document.getElementById("stockModal"); 195 196 // Get the button that opens the modal 197 var btn_abs = document.getElementById("StockAvailabilityBtn"); 198 199 // Get the <span> element that closes the modal 200 var span_abs = document.getElementsByClassName("close-nextech")[0]; 201 202 // When the user clicks the button, open the modal 203 btn_abs.onclick = function() { 204 modal_abs.style.display = "block"; 205 } 206 207 // When the user clicks on <span> (x), close the modal 208 span_abs.onclick = function() { 209 modal_abs.style.display = "none"; 210 } 211 212 // When the user clicks anywhere outside of the modal, close it 213 window.onclick = function(event) { 214 if (event.target == modal_abs) { 215 modal_abs.style.display = "none"; 216 } 217 } 218 </script> 219 } 220 } 221 222 223 224 225 226 } 227 else if (Pageview.IsVisualEditorMode) 228 { 229 <div class="alert alert-info">@Translate("No products available")</div> 230 } 231 } 232
Previously Viewed