/// <summary> Get the indicated item layour objecty </summary> /// <param name="LayoutName"> Name of the layout to get </param> /// <returns> Either the indicated layout, or the default, if the indicated one does not exist </returns> public static HtmlLayoutInfo GetItemLayout(string LayoutName) { lock (itemLayoutLock) { // Does this already exist? if (itemLayout != null) { return(itemLayout); } // Did not exist, so parse it string source_file_name = UI_ApplicationCache_Gateway.Configuration.UI.WriterViewers.Items.Layout.Source; string source_file = Path.Combine(UI_ApplicationCache_Gateway.Settings.Servers.Application_Server_Network, "config", "html", source_file_name); // If the source file is missing, make an error template if (!File.Exists(source_file)) { // Just create a dummy here itemLayout = new HtmlLayoutInfo(); HtmlLayoutSection errorSection = new HtmlLayoutSection { Name = "Error", Type = HtmlLayoutSectionTypeEnum.Static_HTML, HTML = "Unable to find the HTML source template file under the web application ( config/html/" + source_file_name + " )" }; itemLayout.Sections.Add(errorSection); return(itemLayout); } // Use the HTML layout parser to read this itemLayout = HtmlLayoutParser.Parse(source_file); return(itemLayout); } }
/// <summary> Get the indicated item layour objecty </summary> /// <param name="LayoutConfig"> Configuration for this layout </param> /// <returns> Either the indicated layout, or the default, if the indicated one does not exist </returns> public static HtmlLayoutInfo GetItemLayout(ItemWriterLayoutConfig LayoutConfig) { lock (itemLayoutLock) { // Does this already exist? if (itemLayout.ContainsKey(LayoutConfig.ID)) { return(itemLayout[LayoutConfig.ID]); } // Get the lay // Did not exist, so parse it string source_file_name = LayoutConfig.Source; string source_file = Path.Combine(UI_ApplicationCache_Gateway.Settings.Servers.Application_Server_Network, "config", "html", source_file_name); // If the source file is missing, make an error template if (!File.Exists(source_file)) { // Just create a dummy here HtmlLayoutInfo thisItemLayout = new HtmlLayoutInfo(); HtmlLayoutSection errorSection = new HtmlLayoutSection { Name = "Error", Type = HtmlLayoutSectionTypeEnum.Static_HTML, HTML = "Unable to find the HTML source template file under the web application ( config/html/" + source_file_name + " )" }; thisItemLayout.Sections.Add(errorSection); return(thisItemLayout); } // Use the HTML layout parser to read this HtmlLayoutInfo readItemLayout = HtmlLayoutParser.Parse(source_file); // Save this itemLayout[LayoutConfig.ID] = readItemLayout; // Also return this return(readItemLayout); } }