Error executing template "Designs/Swift/_parsed/Swift_Themes_Collection.parsed.cshtml"
System.IO.IOException: The process cannot access the file 'D:\dynamicweb.net\Solutions\S_DW_Expotape\Files\Templates\Designs\Swift\_parsed\Swift_css\Swift_theme_styles_9.css' 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, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
   at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
   at Dynamicweb.Core.Helpers.TextFileHelper.WriteTextFile(String value, String path, Boolean appendToFile, Encoding encoding)
   at CompiledRazorTemplates.Dynamic.RazorEngine_db5f455b90b5450ebf0e33ead60f9d9b.Execute() in D:\dynamicweb.net\Solutions\S_DW_Expotape\Files\Templates\Designs\Swift\_parsed\Swift_Themes_Collection.parsed.cshtml:line 232
   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.PageViewModel> 2 @using Dynamicweb 3 @using Dynamicweb.Environment 4 5 @{ 6 string swiftVersion = ReadFile("/Files/Templates/Designs/Swift/swift_version.txt"); 7 @* Branding Themes Fonts *@ 8 var brandingPageId = Model.Area.Item.GetLink("BrandingPage") != null ? Model.Area.Item.GetLink("BrandingPage").PageId : 0; 9 var themePageId = Model.Area.Item.GetLink("ThemesPage") != null ? Model.Area.Item.GetLink("ThemesPage").PageId : 0; 10 11 var disableWideBreakpoints = Model.Area?.Item?.GetRawValueString("DisableWideBreakpoints", "default"); 12 13 string customHeaderInclude = Model.Area.Item.GetFile("CustomHeaderInclude") != null ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty; 14 15 string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 16 17 string favicon = Model.Area.Item.GetFile("Favicon") != null ? Model.Area.Item.GetFile("Favicon").Path : "/Files/Templates/Designs/Swift/Assets/Images/favicon.png"; 18 19 var brandingPage = Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId) ?? null; 20 var themesParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault(); 21 var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt; 22 23 var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/css/styles.css")); 24 var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/js/scripts.js")); 25 26 string googleTagManagerID = Model.Area.Item.GetString("GoogleTagManagerID"); 27 string googleAnalyticsMeasurementID = Pageview.AreaSettings.GetString("GoogleAnalyticsMeasurementID"); 28 var cookieOptInLevel = CookieManager.GetCookieOptInLevel(); 29 bool allowTracking = cookieOptInLevel == CookieOptInLevel.All || (cookieOptInLevel == CookieOptInLevel.Functional && CookieManager.GetCookieOptInCategories().Contains("Statistical")); 30 31 // Schema.org details for PDP 32 string productId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : ""; 33 bool isProductDetailsPage = !string.IsNullOrEmpty(productId); 34 bool isArticlePage = Model.ItemType == "Swift_Article"; 35 string schemaOrgType = string.Empty; 36 37 if(isProductDetailsPage) 38 { 39 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\""; 40 } 41 42 if(isArticlePage) 43 { 44 schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\""; 45 } 46 } 47 48 <!doctype html> 49 <html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName"> 50 <head> 51 <!-- @swiftVersion --> 52 @* Required meta tags *@ 53 <meta charset="utf-8"> 54 <meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0"> 55 <link rel="preload" href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" as="style"> 56 <link rel="preload" href="/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks" as="script"> 57 <link rel="preload" href="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" as="script"> 58 59 <link rel="shortcut icon" href="@favicon"> 60 <link rel="apple-touch-icon" href="/Files/Templates/Designs/Swift/Assets/Images/logo_transparent.png"> 61 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 62 <meta name="googlebot-news" content="nosnippet"> 63 64 @Model.MetaTags 65 66 <title>@Model.Title</title> 67 68 @* Bootstrap + Swift stylesheet *@ 69 <link href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css"> 70 71 @if (disableWideBreakpoints != "disableBoth") 72 { 73 <style> 74 @@media ( min-width: 1600px ) { 75 .container-xxl, 76 .container-xl, 77 .container-lg, 78 .container-md, 79 .container-sm, 80 .container { 81 max-width: 1520px; 82 } 83 } 84 </style> 85 86 if (disableWideBreakpoints != "disableUltraWideOnly") 87 { 88 <style> 89 @@media ( min-width: 1920px ) { 90 .container-xxl, 91 .container-xl, 92 .container-lg, 93 .container-md, 94 .container-sm, 95 .container { 96 max-width: 1820px; 97 } 98 } 99 </style> 100 } 101 } 102 103 @* Branding and Themes min stylesheet *@ 104 <link href="/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_@(Model.Area.ID).min.css?@cssLastModified.Ticks" rel="stylesheet" media="all" type="text/css" data-last-modified-content="@cssLastModified"> 105 <script src="/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 106 <script src="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" defer></script> 107 108 <script type="module"> 109 AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') }); 110 </script> 111 112 @* Google tag manager *@ 113 @if (!string.IsNullOrWhiteSpace(googleTagManagerID)) 114 { 115 <script> 116 (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': 117 new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], 118 j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 119 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 120 })(window, document, 'script', 'dataLayer', '@(googleTagManagerID)'); 121 122 function gtag() { dataLayer.push(arguments); } 123 </script> 124 } 125 126 @if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID)) 127 { 128 var GoogleAnalyticsDebugMode = ""; 129 bool isLoggedInBackendUser = false; 130 131 if (Dynamicweb.Security.UserManagement.User.GetCurrentBackendUser() != null) { 132 isLoggedInBackendUser = true; 133 } 134 135 if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode") && @isLoggedInBackendUser) 136 { 137 GoogleAnalyticsDebugMode = ", {'debug_mode': true}"; 138 } 139 140 <script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script> 141 <script> 142 window.dataLayer = window.dataLayer || []; 143 function gtag(){dataLayer.push(arguments);} 144 gtag('js', new Date()); 145 gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode); 146 </script> 147 } 148 149 @if (!string.IsNullOrWhiteSpace(customHeaderInclude)) { 150 @RenderPartial($"Components/Custom/{customHeaderInclude}") 151 } 152 </head> 153 154 <body class="brand @(masterTheme)"> 155 156 <main id="content" @(schemaOrgType)> 157 <div data-intersect></div> 158 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel> 159 160 <style> 161 162 .swift-checkered { 163 background-image: linear-gradient(45deg, #a7a9ac 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #a7a9ac 75%), linear-gradient(45deg, transparent 75%, #a7a9ac 75%), linear-gradient(45deg, #a7a9ac 25%, #bcbec0 25%); 164 background-size: 20px 20px; 165 background-position: 0 0, 0 0, -10px -10px, 10px 10px; 166 } 167 .theme-option { 168 border-radius: 2px; 169 padding: 0.5em; 170 } 171 </style> 172 173 174 175 <div class="container my-5"> 176 <div class="grid gap-3 mb-5 pb-3 text-center border-bottom"> 177 <div class="g-col-12"> 178 <h1 class="h1">@Translate("Themes") </h1> 179 <div class="lead">@Translate("Take full control of all the colors")</div> 180 </div> 181 </div> 182 <div class="grid gap-3"> 183 @Model.Placeholder("content", "content", "default:true;sort:1") 184 </div> 185 </div> 186 187 <script> 188 function fallbackCopyTextToClipboard(text) { 189 var textArea = document.createElement("textarea"); 190 textArea.value = text; 191 192 // Avoid scrolling to bottom 193 textArea.style.top = "0"; 194 textArea.style.left = "0"; 195 textArea.style.position = "fixed"; 196 197 document.body.appendChild(textArea); 198 textArea.focus(); 199 textArea.select(); 200 201 try { 202 var successful = document.execCommand('copy'); 203 var msg = successful ? 'successful' : 'unsuccessful'; 204 console.log('Fallback: Copying text command was ' + msg); 205 } catch (err) { 206 console.error('Fallback: Oops, unable to copy', err); 207 } 208 209 document.body.removeChild(textArea); 210 } 211 function copyTextToClipboard(text) { 212 if (!navigator.clipboard) { 213 fallbackCopyTextToClipboard(text); 214 return; 215 } 216 navigator.clipboard.writeText(text).then(function () { 217 console.log('Async: Copying to clipboard was successful!'); 218 }, function (err) { 219 console.error('Async: Could not copy text: ', err); 220 }); 221 } 222 </script> 223 @{ 224 string tmpPath = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_theme_styles_{Model.Area.ID}.tmp"); 225 226 string cssPathEcommerceBadges = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_ecommerce_badge_styles_{Model.Area.ID}.css"); 227 string cssPathTheme = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_theme_styles_{Model.Area.ID}.css"); 228 string cssPathFont = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_font_styles_{Model.Area.ID}.css"); 229 string cssPathBranding = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_branding_styles_{Model.Area.ID}.css"); 230 string cssPathCombined = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css"); 231 232 Dynamicweb.Core.Helpers.TextFileHelper.WriteTextFile(Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(tmpPath), cssPathTheme, false); 233 System.IO.File.Delete(tmpPath); 234 235 string combinedCss = Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathBranding); 236 combinedCss += Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathTheme); 237 combinedCss += Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathFont); 238 combinedCss += Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathEcommerceBadges); 239 combinedCss = System.Text.RegularExpressions.Regex.Replace(combinedCss, @"\s+(?=([^']*'[^']*')*[^']*$)", ""); //minify the css. 240 combinedCss = combinedCss.Replace("\00a0", " "); //Re-insert spaces for content text 241 Dynamicweb.Core.Helpers.TextFileHelper.WriteTextFile(combinedCss, cssPathCombined, false); 242 } 243 244 </main> 245 246 @* Render any offcanvas menu here *@ 247 @RenderSnippet("offcanvas") 248 </body> 249 250 </html> 251