示例#1
0
        /// <summary>
        /// Load active page preset.
        /// </summary>
        /// <param name="TemplateName">Template name.</param>
        /// <param name="PageName">Page name.</param>
        /// <returns>Object of PresetInfo class.</returns>
        public static PresetInfo LoadActivePagePreset(string TemplateName, string PageName)
        {
            string     presetPath       = TemplateName.ToLower().Equals("default") ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName);
            string     pagepreset       = presetPath + "/" + TemplateConstants.PagePresetFile;
            PresetInfo pagepresetactive = new PresetInfo();

            pagepresetactive = LoadPresetDetails(pagepreset);
            string defaultPreset = string.Empty;

            foreach (KeyValue kvp in pagepresetactive.lstLayouts)
            {
                string   presetPathFull = string.Empty;
                string[] arrPages       = kvp.Value.ToString().Split(',');
                foreach (string page in arrPages)
                {
                    if (page.ToLower().Equals(PageName.ToLower()))
                    {
                        pagepresetactive.ActiveLayout = kvp.Key;
                        break;
                    }
                }
                if (kvp.Value.Equals("all") || kvp.Value.Equals("All") || kvp.Value.Equals("*") || kvp.Value.Equals(""))
                {
                    defaultPreset = kvp.Key;
                }
            }
            if (pagepresetactive.ActiveLayout == "" || pagepresetactive.ActiveLayout == null)
            {
                pagepresetactive.ActiveLayout = defaultPreset;
            }
            return(pagepresetactive);
        }
示例#2
0
        public static List <PresetInfo> ParsePreset(string xmlFile, string startParseNode, out List <string> lstAllPages)
        {
            List <PresetInfo> lstPreset     = new List <PresetInfo>();
            XmlDocument       doc           = XmlHelper.LoadXMLDocument(xmlFile);
            XmlNodeList       sectionList   = doc.SelectNodes(startParseNode);
            List <string>     lstAllPagesIn = new List <string>();

            foreach (XmlNode preset in sectionList)
            {
                PresetInfo tag = new PresetInfo();
                tag.PresetName = preset.Attributes["preset"].Value;
                tag.LSTPages   = PageList(preset.InnerText);
                lstPreset.Add(tag);
                if (preset.InnerText.Contains("All") || preset.InnerText.Equals("All") || preset.InnerText.Equals("All"))
                {
                    tag.IsDefault = true;
                }
                else
                {
                    tag.IsDefault = false;
                }
                foreach (string page in tag.LSTPages)
                {
                    lstAllPagesIn.Add(page);
                }
            }
            lstAllPages = lstAllPagesIn;
            return(lstPreset);
        }
        public static void CreateLayoutControls(string TemplateName, PresetInfo PresetObj)
        {
            string templatePath       = Utils.GetTemplatePath(TemplateName);
            string presetPath         = Utils.GetPresetPath(TemplateName);
            LayoutControlGenerator lg = new LayoutControlGenerator();
            XmlParser parser          = new XmlParser();

            PresetInfo    presetdetails = PresetHelper.LoadPresetDetails(presetPath + "/" + PresetObj.PresetName.Replace(".xml", "") + ".xml");
            List <XmlTag> lstXmlTag     = parser.GetXmlTags(templatePath + "/layouts/default/" + presetdetails.ActiveLayout.Replace(".xml", "") + ".xml", "layout/section");
            string        html          = lg.GenerateHTML(lstXmlTag);
            string        controlname   = PresetObj.ActiveLayout + ".ascx";

            if (!File.Exists(templatePath + "/" + controlname))
            {
                FileStream fs = null;
                using (fs = File.Create(templatePath + "/" + controlname))
                {
                }
            }
            else
            {
                File.Delete(templatePath + "/" + controlname);
                FileStream fs = null;
                using (fs = File.Create(templatePath + "/" + controlname))
                {
                }
            }

            using (StreamWriter sw = new StreamWriter(templatePath + "/" + controlname))
            {
                sw.Write("<%@ Control Language=\"C#\" ClassName=" + PresetObj.PresetName + " %>");
                sw.Write(html);
            }
        }
示例#4
0
        public static List<PresetInfo> ParsePreset(string xmlFile, string startParseNode,out List<string> lstAllPages)
        {
            List<PresetInfo> lstPreset = new List<PresetInfo>();
            XmlDocument doc = XmlHelper.LoadXMLDocument(xmlFile);
            XmlNodeList sectionList = doc.SelectNodes(startParseNode);
            List<string> lstAllPagesIn = new List<string>();
            foreach (XmlNode preset in sectionList)
            {
                PresetInfo tag = new PresetInfo();
                tag.PresetName = preset.Attributes["preset"].Value;
                tag.LSTPages = PageList(preset.InnerText);                
                lstPreset.Add(tag);
                if (preset.InnerText.Contains("All") || preset.InnerText.Equals("All") || preset.InnerText.Equals("All"))
                {
                    tag.IsDefault = true;
                }
                else
                {
                    tag.IsDefault = false;
                }
                foreach (string page in tag.LSTPages)
                {
                    lstAllPagesIn.Add(page);
                }

            }
            lstAllPages = lstAllPagesIn;
            return lstPreset;
        }
示例#5
0
        /// <summary>
        /// Write new preset.
        /// </summary>
        /// <param name="xmlpath">Path for xml file.</param>
        /// <param name="objPreset">Object of PresetInfo class.</param>
        static void WriteNewPreset(string xmlpath, PresetInfo objPreset)
        {
            using (XmlTextWriter writer = new XmlTextWriter(xmlpath, Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.WriteStartDocument();
                writer.WriteStartElement("pagepreset");


                writer.WriteStartElement("layout");
                foreach (KeyValue kvp in objPreset.lstLayouts)
                {
                    writer.WriteStartElement("preset");
                    writer.WriteAttributeString("layout", kvp.Key);
                    writer.WriteString(Utils.GetSEOName(kvp.Value, "-"));
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
                writer.WriteStartElement("theme");
                writer.WriteString(objPreset.ActiveTheme);
                writer.WriteEndElement();

                writer.WriteStartElement("width");
                writer.WriteString(objPreset.ActiveWidth);
                writer.WriteEndElement();

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();
            }
        }
示例#6
0
 public static void WritePreset(string xmlpath, PresetInfo objPreset)
 {
     if (File.Exists(xmlpath))
     {
         File.Delete(xmlpath);
         WriteNewPreset(xmlpath, objPreset);
     }
     else
     {
         WriteNewPreset(xmlpath, objPreset);
     }
 }
示例#7
0
        public static void UpdatePreset(PresetInfo preset, string TemplateName)
        {
            string presetPath = Utils.GetPresetPath(TemplateName);

            try
            {
                WritePreset(presetPath + "/" + preset.PresetName + ".xml", preset);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#8
0
        /// <summary>
        /// Update existing preset.
        /// </summary>
        /// <param name="preset">Object of PresetInfo class.</param>
        /// <param name="TemplateName">Template name.</param>
        public static void UpdatePreset(PresetInfo preset, string TemplateName)
        {
            string presetPath = TemplateName.ToLower().Equals("default") ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName);

            try
            {
                WritePreset(string.Format("{0}/pagepreset.xml", presetPath), preset);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public static void CreateLayoutControls(string TemplateName, PresetInfo PresetObj)
        {
            string templatePath = TemplateName.ToLower().Equals("default") ? Utils.GetTemplatePath_Default(TemplateName) : Utils.GetTemplatePath(TemplateName);
            string presetPath = TemplateName.ToLower().Equals("default") ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName);
            ModulePaneGenerator mg = new ModulePaneGenerator();
            string filePath = templatePath + "/layouts/" + PresetObj.ActiveLayout.Replace(".xml", "") + ".xml";
            XmlParser parser = new XmlParser();
            try
            {
                List<XmlTag> lstXmlTag = parser.GetXmlTags(filePath, "layout/section");
                List<XmlTag> lstWrappers = parser.GetXmlTags(filePath, "layout/wrappers");

                string html = mg.GenerateHTML(lstXmlTag, lstWrappers, 2);
                string controlclass = Path.GetFileNameWithoutExtension(filePath);
                string controlname = string.Format("{0}.ascx", controlclass);
                if (!File.Exists(templatePath + "/" + controlname))
                {
                    FileStream fs = null;
                    using (fs = File.Create(templatePath + "/" + controlname))
                    {

                    }

                }
                else
                {
                    File.Delete(templatePath + "/" + controlname);
                    FileStream fs = null;
                    using (fs = File.Create(templatePath + "/" + controlname))
                    {

                    }
                }

                using (StreamWriter sw = new StreamWriter(templatePath + "/" + controlname))
                {
                    sw.Write("<%@ Control Language=\"C#\" ClassName=" + controlclass + " %>");
                    sw.Write(html);
                }


            }
            catch (Exception)
            {

                throw;
            }


        }
示例#10
0
        public static List<PresetInfo> ParsePreset(string xmlFile, string startParseNode)
        {
            List<PresetInfo> lstPreset = new List<PresetInfo>();
            XmlDocument doc = XmlHelper.LoadXMLDocument(xmlFile);
            XmlNodeList sectionList = doc.SelectNodes(startParseNode);
            foreach (XmlNode preset in sectionList)
            {
                PresetInfo tag = new PresetInfo();
                tag.PresetName = preset.Attributes["preset"].Value;
                tag.LSTPages = PageList(preset.InnerText);
                lstPreset.Add(tag);

            }
            return lstPreset;
        }
示例#11
0
        public static List <PresetInfo> ParsePreset(string xmlFile, string startParseNode)
        {
            List <PresetInfo> lstPreset   = new List <PresetInfo>();
            XmlDocument       doc         = XmlHelper.LoadXMLDocument(xmlFile);
            XmlNodeList       sectionList = doc.SelectNodes(startParseNode);

            foreach (XmlNode preset in sectionList)
            {
                PresetInfo tag = new PresetInfo();
                tag.PresetName = preset.Attributes["preset"].Value;
                tag.LSTPages   = PageList(preset.InnerText);
                lstPreset.Add(tag);
            }
            return(lstPreset);
        }
示例#12
0
        /// <summary>
        /// Load assigne preset for associate page.
        /// </summary>
        /// <param name="TemplateName">Template name.</param>
        /// <param name="PageName">Page name.</param>
        /// <returns>Preset path.</returns>
        public static string LoadActivePresetForPage(string TemplateName, string PageName)
        {
            string            presetPath       = TemplateName.ToLower().Equals("default")?Utils.GetPresetPath_DefaultTemplate(TemplateName):Utils.GetPresetPath(TemplateName);
            List <PresetInfo> lstActivePresets = new List <PresetInfo>();
            string            pagepreset       = presetPath + "/" + TemplateConstants.PagePresetFile;
            List <string>     lstAllPages      = new List <string>();

            if (File.Exists(pagepreset))
            {
                if (!CacheHelper.Get("PresetList", out lstActivePresets))
                {
                    lstActivePresets = PresetHelper.ParsePreset(pagepreset, "pagepreset/layout/preset", out lstAllPages);
                    CacheHelper.Add(lstActivePresets, "PresetList");
                }
            }
            else
            {
                lstActivePresets.Add(PresetInfo.GetPresetPages("default", "*"));
            }
            string pagepresetactive = string.Empty;
            string defaultpreset    = "layout.ascx";

            foreach (PresetInfo preset in lstActivePresets)
            {
                if (preset.IsDefault)
                {
                    defaultpreset = string.Format("{0}.ascx", preset.PresetName);;
                }
                else
                {
                    string presetPathFull = string.Empty;
                    foreach (string page in preset.LSTPages)
                    {
                        if (page.ToLower().Equals(PageName.ToLower()))
                        {
                            pagepresetactive = string.Format("{0}.ascx", preset.PresetName);;
                            break;
                        }
                    }
                }
            }
            if (pagepresetactive == string.Empty)
            {
                pagepresetactive = defaultpreset;
            }
            pagepresetactive = Decide.IsTemplateDefault(TemplateName)?string.Format("~/Core/Template/{1}", TemplateName, pagepresetactive):string.Format("~/Templates/{0}/{1}", TemplateName, pagepresetactive);
            return(pagepresetactive);
        }
示例#13
0
        public static PresetInfo LoadPresetDetails(string xmlPath)
        {
            XmlDocument doc      = XmlHelper.LoadXMLDocument(xmlPath);
            XmlNode     xnpreset = doc.SelectSingleNode("preset");
            XmlNodeList xnlist   = xnpreset.ChildNodes;
            PresetInfo  preset   = new PresetInfo();

            preset.PresetName = doc.SelectSingleNode("preset").Attributes["name"].Value;
            foreach (XmlNode node in xnlist)
            {
                switch (node.Name)
                {
                case "activelayout":
                    preset.ActiveLayout = node.InnerText;
                    break;

                case "activetheme":
                    preset.ActiveTheme = node.InnerText;
                    break;

                case "activewidth":
                    preset.ActiveWidth = node.InnerText;
                    break;

                case "cssopt":
                    preset.IsCssOptimizationEnabled = bool.Parse(node.InnerText);
                    break;

                case "jsopt":
                    preset.IsJsOptimizationEnabled = bool.Parse(node.InnerText);
                    break;

                case "cpanel":
                    preset.CPanel = bool.Parse(node.InnerText);
                    break;

                case "handheld":
                    preset.HandHeld = bool.Parse(node.InnerText);
                    break;

                case "handheldlayout":
                    preset.HandHeldLayout = node.InnerText;
                    break;
                }
            }
            return(preset);
        }
示例#14
0
        static void WriteNewPreset(string xmlpath, PresetInfo objPreset)
        {
            using (XmlTextWriter writer = new XmlTextWriter(xmlpath, Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.WriteStartDocument();
                writer.WriteStartElement("preset");
                writer.WriteAttributeString("name", Path.GetFileNameWithoutExtension(objPreset.PresetName));
                writer.WriteStartElement("activetheme");
                writer.WriteString(objPreset.ActiveTheme);
                writer.WriteEndElement();

                writer.WriteStartElement("activelayout");
                writer.WriteString(objPreset.ActiveLayout);
                writer.WriteEndElement();

                writer.WriteStartElement("activewidth");
                writer.WriteString(objPreset.ActiveWidth);
                writer.WriteEndElement();

                writer.WriteStartElement("cssopt");
                writer.WriteString(objPreset.IsCssOptimizationEnabled.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("jsopt");
                writer.WriteString(objPreset.IsJsOptimizationEnabled.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("cpanel");
                writer.WriteString(objPreset.CPanel.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("handheld");
                writer.WriteString(objPreset.HandHeld.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("handheldlayout");
                writer.WriteString(objPreset.HandHeldLayout);
                writer.WriteEndElement();


                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();
            }
        }
示例#15
0
        public static string LoadActivePresetForPage(string TemplateName, string PageName)
        {
            string            presetPath       = Utils.GetPresetPath(TemplateName);
            List <PresetInfo> lstActivePresets = new List <PresetInfo>();
            string            pagepreset       = presetPath + "/" + TemplateConstants.PagePresetFile;
            List <string>     lstAllPages      = new List <string>();

            if (File.Exists(pagepreset))
            {
                lstActivePresets = PresetHelper.ParsePreset(pagepreset, "pagepresets/page", out lstAllPages);
            }
            else
            {
                lstActivePresets.Add(PresetInfo.GetPresetPages("default", "*"));
            }

            string pagepresetactive = "layout.ascx";

            foreach (PresetInfo preset in lstActivePresets)
            {
                if (preset.IsDefault)
                {
                    string     presetPathFull = presetPath + "/" + preset.PresetName + ".xml";
                    PresetInfo presetdetail   = LoadPresetDetails(presetPathFull);
                    pagepresetactive = presetdetail.ActiveLayout.ToLower() + ".ascx";
                }
                else
                {
                    string     presetPathFull = presetPath + "/" + preset.PresetName + ".xml";
                    PresetInfo presetdetail   = LoadPresetDetails(presetPathFull);
                    foreach (string page in preset.LSTPages)
                    {
                        if (page.ToLower().Equals(PageName.ToLower()))
                        {
                            pagepresetactive = presetdetail.ActiveLayout.ToLower() + ".ascx";
                            break;
                        }
                    }
                }
            }

            pagepresetactive = "~/Templates/" + TemplateName + "/" + pagepresetactive;

            return(pagepresetactive);
        }
示例#16
0
        /// <summary>
        /// Create layouts.
        /// </summary>
        /// <param name="TemplateName">Template name.</param>
        /// <param name="PresetObj">Object of PresetInfo class.</param>
        public static void CreateLayoutControls(string TemplateName, PresetInfo PresetObj)
        {
            string templatePath    = TemplateName.ToLower().Equals("default") ? Utils.GetTemplatePath_Default(TemplateName) : Utils.GetTemplatePath(TemplateName);
            string presetPath      = TemplateName.ToLower().Equals("default") ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName);
            ModulePaneGenerator mg = new ModulePaneGenerator();
            string    filePath     = templatePath + "/layouts/" + PresetObj.ActiveLayout.Replace(".xml", "") + ".xml";
            XmlParser parser       = new XmlParser();

            try
            {
                List <XmlTag> lstXmlTag   = parser.GetXmlTags(filePath, "layout/section");
                List <XmlTag> lstWrappers = parser.GetXmlTags(filePath, "layout/wrappers");

                string html         = mg.GenerateHTML(lstXmlTag, lstWrappers, 2);
                string controlclass = Path.GetFileNameWithoutExtension(filePath);
                string controlname  = string.Format("{0}.ascx", controlclass);
                if (!File.Exists(templatePath + "/" + controlname))
                {
                    FileStream fs = null;
                    using (fs = File.Create(templatePath + "/" + controlname))
                    {
                    }
                }
                else
                {
                    File.Delete(templatePath + "/" + controlname);
                    FileStream fs = null;
                    using (fs = File.Create(templatePath + "/" + controlname))
                    {
                    }
                }

                using (StreamWriter sw = new StreamWriter(templatePath + "/" + controlname))
                {
                    sw.Write("<%@ Control Language=\"C#\" ClassName=" + controlclass + " %>");
                    sw.Write(html);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#17
0
        public static PresetInfo LoadPresetDetails(string xmlPath)
        {
            XmlDocument doc = XmlHelper.LoadXMLDocument(xmlPath);
            XmlNode xnpreset = doc.SelectSingleNode("preset");
            XmlNodeList xnlist = xnpreset.ChildNodes;
            PresetInfo preset = new PresetInfo();
            preset.PresetName = doc.SelectSingleNode("preset").Attributes["name"].Value;
            foreach (XmlNode node in xnlist)
            {
                switch (node.Name)
                {
                    case "activelayout":
                        preset.ActiveLayout = node.InnerText;
                        break;
                    case "activetheme":
                        preset.ActiveTheme = node.InnerText;
                        break;
                    case "activewidth":
                        preset.ActiveWidth = node.InnerText;
                        break;
                    case "cssopt":
                        preset.IsCssOptimizationEnabled = bool.Parse(node.InnerText);
                        break;
                    case "jsopt":
                        preset.IsJsOptimizationEnabled = bool.Parse(node.InnerText);
                        break;
                    case "cpanel":
                        preset.CPanel = bool.Parse(node.InnerText);
                        break;
                    case "handheld":
                        preset.HandHeld = bool.Parse(node.InnerText);
                        break;
                    case "handheldlayout":
                        preset.HandHeldLayout = node.InnerText;
                        break;

                }

            }
            return preset;

        }
示例#18
0
        public static void CreateLayoutControls(string TemplateName, PresetInfo PresetObj)
        {

            string templatePath = Utils.GetTemplatePath(TemplateName);
            string presetPath = Utils.GetPresetPath(TemplateName);
            LayoutControlGenerator lg = new LayoutControlGenerator();
            XmlParser parser = new XmlParser();

            PresetInfo presetdetails = PresetHelper.LoadPresetDetails(presetPath + "/" + PresetObj.PresetName.Replace(".xml", "") + ".xml");
            List<XmlTag> lstXmlTag = parser.GetXmlTags(templatePath + "/layouts/default/" + presetdetails.ActiveLayout.Replace(".xml", "") + ".xml", "layout/section");
            string html = lg.GenerateHTML(lstXmlTag);
            string controlname = PresetObj.ActiveLayout + ".ascx";
            if (!File.Exists(templatePath + "/" + controlname))
            {
                FileStream fs = null;
                using (fs = File.Create(templatePath + "/" + controlname))
                {

                }

            }
            else
            {
                File.Delete(templatePath + "/" + controlname);
                FileStream fs = null;
                using (fs = File.Create(templatePath + "/" + controlname))
                {

                }
            }

            using (StreamWriter sw = new StreamWriter(templatePath + "/" + controlname))
            {
                sw.Write("<%@ Control Language=\"C#\" ClassName=" + PresetObj.PresetName + " %>");
                sw.Write(html);
            }


        }
示例#19
0
        /// <summary>
        /// preset details.
        /// </summary>
        /// <param name="xmlPath">String format of XML.</param>
        /// <returns>object of PresetInfo class.</returns>
        public static PresetInfo LoadPresetDetails(string xmlPath)
        {
            if (!File.Exists(xmlPath))
            {
                xmlPath = string.Format("{0}/pagepreset.xml", Utils.GetPresetPath_DefaultTemplate("default"));
            }
            XmlDocument     doc        = XmlHelper.LoadXMLDocument(xmlPath);
            XmlNode         xnpreset   = doc.SelectSingleNode("pagepreset");
            XmlNodeList     xnlist     = xnpreset.ChildNodes;
            PresetInfo      preset     = new PresetInfo();
            List <KeyValue> lstLayouts = new List <KeyValue>();

            foreach (XmlNode node in xnlist)
            {
                switch (node.Name)
                {
                case "layout":
                    XmlNodeList layouts = node.ChildNodes;

                    foreach (XmlNode layout in layouts)
                    {
                        lstLayouts.Add(new KeyValue(layout.Attributes["layout"].Value, layout.InnerText));
                    }
                    break;

                case "theme":
                    preset.ActiveTheme = node.InnerText;
                    break;

                case "width":
                    preset.ActiveWidth = node.InnerText;
                    break;
                }
                preset.lstLayouts = lstLayouts;
            }
            return(preset);
        }
示例#20
0
        public static int UpdatePresetPages(PresetInfo objPreset, string xmlpath)
        {
            XmlDocument doc      = XmlHelper.LoadXMLDocument(xmlpath);
            XmlNode     xnpreset = doc.SelectSingleNode("pagepresets");
            XmlNodeList xnlist   = xnpreset.ChildNodes;

            bool isApplied        = false;
            bool isAllPageApplied = false;
            bool isPageApplied    = false;
            int  nodecount        = 0;

            foreach (XmlNode node in xnlist)
            {
                if (node.Attributes["preset"].Value == objPreset.PresetName || node.Attributes["preset"].Value == Path.GetFileNameWithoutExtension(objPreset.PresetName.ToLower()))
                {
                    isApplied      = true;
                    node.InnerText = objPreset.Pages;
                }
                if (node.InnerText.ToLower() == "" || node.InnerText.ToLower() == "none")
                {
                    xnlist[nodecount].ParentNode.RemoveChild(xnlist[nodecount]);
                }
                else if (node.InnerText.ToLower() == "all" && objPreset.Pages.ToLower() == "all")
                {
                    isAllPageApplied = true;
                }
                if (node.InnerText.ToLower() != "all" && Path.GetFileNameWithoutExtension(objPreset.Pages.ToLower()) != "all")
                {
                    string[]      arrPages      = node.InnerText.ToLower().Split(',');
                    string[]      arrPagesNew   = objPreset.Pages.ToLower().Split(',');
                    List <string> arrFinalPages = new List <string>();

                    foreach (string page in arrPagesNew)
                    {
                        if (!arrPages.Contains(page) && page != "all")
                        {
                            arrFinalPages.Add(page);
                        }
                        else
                        {
                            isPageApplied = true;
                        }
                    }
                    objPreset.Pages = string.Join(",", arrFinalPages.ToArray());
                }
                nodecount++;
            }

            if (!isApplied && !isAllPageApplied && objPreset.Pages != "" && objPreset.Pages != "none")
            {
                XmlElement elem = doc.CreateElement("page");
                elem.SetAttribute("preset", Path.GetFileNameWithoutExtension(objPreset.PresetName));
                elem.InnerText = objPreset.Pages;
                xnpreset.AppendChild(elem);
            }
            doc.Save(xmlpath);

            return(isAllPageApplied?1:isPageApplied?2:0);
            ///Return Login
            ///0:Everything is normal
            ///1:A few pages are already applied to presets
            ///2:All Page is already applied
        }
示例#21
0
 /// <summary>
 /// Returns color css path based on active template
 /// </summary>
 /// <param name="activeTemplate"> active template name</param>
 /// <param name="preset">PresetInfo object</param>
 /// <returns>Returns color css path</returns>
 private string cssColorTemplate(string activeTemplate, PresetInfo preset)
 {
     string cssColorTemplate = !IsHandheld() ? Decide.IsTemplateDefault(activeTemplate)
                                     ? string.Format("~/Core/Template/themes/{0}/css/color.css", preset.ActiveTheme)
                                     : string.Format("~/Templates/{0}/themes/{1}/css/color.css", activeTemplate, preset.ActiveTheme)
                                     : string.Format("~/Templates/{0}/css/handheld/color.css", TemplateName);
     return cssColorTemplate;
 }
 public static PresetInfo GetPresetDetails(string TemplateName, int PortalID)
 {
     string presetPath = Decide.IsTemplateDefault(TemplateName.Trim()) ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName);
     presetPath += "/" + "pagepreset.xml";
     PresetInfo objPreset = new PresetInfo();
     try
     {
         objPreset = PresetHelper.LoadPresetDetails(presetPath);
         PageController objPageController = new PageController();
         List<PageEntity> lstMenu = objPageController.GetMenuFront(PortalID, false);
         foreach (PageEntity obj in lstMenu)
         {
             obj.ChildCount = lstMenu.Count(
                 delegate(PageEntity objMenu)
                 {
                     return (objMenu.ParentID == obj.PageID);
                 }
                 );
         }
         List<string> lstPages = new List<string>();
         List<KeyValue> lstLayout = new List<KeyValue>();
         foreach (KeyValue kvp in objPreset.lstLayouts)
         {
             string[] arrPage = kvp.Value.Split(',');
             List<string> lstNewPage = new List<string>();
             foreach (string page in arrPage)
             {
                 bool exists = lstMenu.Exists(
                        delegate(PageEntity obj)
                        {
                            return obj.PageName.TrimStart('-') == page;
                        }
                     );
                 if (exists || page.ToLower() == "all")
                 {
                     lstNewPage.Add(page);
                 }
             }
             if (lstNewPage.Count > 0)
             {
                 lstLayout.Add(new KeyValue(kvp.Key, string.Join(",", lstNewPage.ToArray())));
             }
         }
         objPreset.lstLayouts = lstLayout;
         PresetHelper.WritePreset(presetPath, objPreset);
         return objPreset;
     }
     catch (Exception)
     {
         throw;
     }
 }
    public static int SavePreset(string TemplateName, string ActiveTheme, string ActiveWidth, List<PresetKeyValue> lstLayouts, int portalID)
    {
        List<KeyValue> lstLyts = new List<KeyValue>();
        foreach (PresetKeyValue kvp in lstLayouts)
        {
            lstLyts.Add(new KeyValue(kvp.Key, kvp.Value));
        }
        PresetInfo PresetObj = new PresetInfo();
        PresetObj.ActiveTheme = ActiveTheme;
        PresetObj.ActiveWidth = ActiveWidth;
        PresetObj.lstLayouts = lstLyts;
        string presetPath = Decide.IsTemplateDefault(TemplateName.Trim()) ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName);
        string pagepreset = presetPath + "/" + TemplateConstants.PagePresetFile;
        presetPath += "/" + "pagepreset.xml";
        int presetstatus = 0;
        try
        {
            PresetHelper.WritePreset(presetPath, PresetObj);
            AppErazer.ClearSysHash(ApplicationKeys.ActivePagePreset + "_" + portalID);
            return presetstatus;
        }
        catch (Exception)
        {
            throw;
        }

    }
 protected void btnApply_Click(object sender, EventArgs e)
 {
     HttpRuntime.Cache.Remove(CacheKeys.SageFrameJs);
     HttpRuntime.Cache.Remove(CacheKeys.SageFrameCss);
     string optimized_path = Server.MapPath(SageFrameConstants.OptimizedResourcePath);
     IOHelper.DeleteDirectoryFiles(optimized_path, ".js,.css");
     if (File.Exists(Server.MapPath(SageFrameConstants.OptimizedCssMap)))
     {
         XmlHelper.DeleteNodes(Server.MapPath(SageFrameConstants.OptimizedCssMap), "resourcemaps/resourcemap");
     }
     if (File.Exists(Server.MapPath(SageFrameConstants.OptimizedJsMap)))
     {
         XmlHelper.DeleteNodes(Server.MapPath(SageFrameConstants.OptimizedJsMap), "resourcemap/resourcemap");
     }
     PresetInfo preset = new PresetInfo();
     preset = PresetHelper.LoadActivePagePreset(TemplateName, GetPageSEOName(Request.Url.ToString()));
     if (ddlScreen.SelectedItem.ToString() != string.Empty)
     {
         preset.ActiveWidth = ddlScreen.SelectedItem.ToString();
     }
     if (ddlThemes.SelectedItem != null && ddlThemes.SelectedItem.ToString() != string.Empty)
     {
         preset.ActiveTheme = ddlThemes.SelectedItem.ToString();
     }
     if (ddlLayout.SelectedItem != null && ddlLayout.SelectedItem.ToString() != string.Empty)
     {
         preset.ActiveLayout = Path.GetFileNameWithoutExtension(ddlLayout.SelectedItem.ToString());
     }
     List<KeyValue> lstLayouts = preset.lstLayouts;
     string pageName = Request.Url.ToString();
     SageFrameConfig sfConfig = new SageFrameConfig();
     pageName = Path.GetFileNameWithoutExtension(pageName);
     pageName = pageName.ToLower().Equals("default") ? sfConfig.GetSettingsByKey(SageFrameSettingKeys.PortalDefaultPage) : pageName;
     bool isNewLayout = false;
     int oldPageCount = 0;
     bool isNewPage = false;
     bool deleteRepeat = false;
     List<string> pageList = new List<string>();
     foreach (KeyValue kvp in lstLayouts)
     {
         string[] pages = kvp.Value.Split(',');
         pageList.Add(string.Join(",", pages));
         if (pages.Count() == 1 && pages.Contains(pageName)) // for single pagename and if page = currentpageName
         {
             kvp.Key = preset.ActiveLayout;
         }
         else if (pages.Count() > 1 && pages.Contains(pageName))// for multiple pagename and if page = currentpageName
         {
             isNewLayout = true;                             //its because we have to insert another layout
             List<string> lstnewpage = new List<string>();
             foreach (string page in pages)
             {
                 if (page.ToLower() != pageName.ToLower())
                 {
                     lstnewpage.Add(page);
                 }
             }
             kvp.Value = string.Join(",", lstnewpage.ToArray());
             pageList.Add(kvp.Value);
         }
         else
         {
             oldPageCount++;
         }
         if (kvp.Value == "All" && kvp.Key == preset.ActiveLayout)
         {
             deleteRepeat = true;
         }
     }
     if (lstLayouts.Count == oldPageCount)
     {
         isNewPage = true;
     }
     List<KeyValue> lstNewLayouts = new List<KeyValue>();
     if (isNewPage)
     {
         bool isAppended = false;
         foreach (KeyValue kvp in lstLayouts)
         {
             if (kvp.Key == preset.ActiveLayout)
             {
                 if (kvp.Value.ToLower() != "all")
                 {
                     kvp.Value += "," + pageName;
                 }
                 isAppended = true;
             }
             lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value));
         }
         if (!isAppended)
         {
             lstNewLayouts.Add(new KeyValue(preset.ActiveLayout, pageName));
         }
         lstLayouts = lstNewLayouts;
     }
     else if (isNewLayout)
     {
         bool isAppended = false;
         bool isAll = false;
         foreach (KeyValue kvp in lstLayouts)
         {
             if (kvp.Key == preset.ActiveLayout)
             {
                 if (kvp.Value.ToLower() != "all")
                 {
                     kvp.Value += "," + pageName;
                     isAll = true;
                 }
                 isAppended = true;
             }
             lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value));
         }
         if (!isAppended && !isAll)
         {
             lstNewLayouts.Add(new KeyValue(preset.ActiveLayout, pageName));
         }
         lstLayouts = lstNewLayouts;
     }
     else if (deleteRepeat)
     {
         foreach (KeyValue kvp in lstLayouts)
         {
             if (kvp.Value.ToLower() != pageName.ToLower())
             {
                 lstNewLayouts.Add(new KeyValue(kvp.Key, kvp.Value));
             }
         }
         lstLayouts = lstNewLayouts;
     }
     preset.lstLayouts = lstLayouts;
     string presetPath = Decide.IsTemplateDefault(TemplateName.Trim()) ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName);
     string pagepreset = presetPath + "/" + TemplateConstants.PagePresetFile;
     presetPath += "/" + "pagepreset.xml";
     AppErazer.ClearSysHash(ApplicationKeys.ActivePagePreset + "_" + GetPortalID);
     PresetHelper.WritePreset(presetPath, preset);
     Response.Redirect(Request.Url.OriginalString);
 }
        static void WriteNewPreset(string xmlpath, PresetInfo objPreset)
        {
            using (XmlTextWriter writer = new XmlTextWriter(xmlpath, Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.WriteStartDocument();
                writer.WriteStartElement("pagepreset");
               

                writer.WriteStartElement("layout");
                foreach (KeyValue kvp in objPreset.lstLayouts)
                {
                    writer.WriteStartElement("preset");
                    writer.WriteAttributeString("layout", kvp.Key);
                    writer.WriteString(Utils.GetSEOName(kvp.Value,"-"));
                    writer.WriteEndElement();
                }
                
                writer.WriteEndElement();
                writer.WriteStartElement("theme");
                writer.WriteString(objPreset.ActiveTheme);
                writer.WriteEndElement();

                writer.WriteStartElement("width");
                writer.WriteString(objPreset.ActiveWidth);
                writer.WriteEndElement();

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();
            }
        }
        public static PresetInfo LoadActivePagePreset(string TemplateName, string PageName)
        {
            string presetPath = TemplateName.ToLower().Equals("default") ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName);           
            string pagepreset = presetPath + "/" + TemplateConstants.PagePresetFile;           
            PresetInfo pagepresetactive = new PresetInfo();
            pagepresetactive = LoadPresetDetails(pagepreset);
            string defaultPreset = string.Empty;
            foreach (KeyValue kvp in pagepresetactive.lstLayouts)
            {                
                    string presetPathFull = string.Empty;
                    string[] arrPages = kvp.Value.ToString().Split(',');
                    foreach (string page in arrPages)
                    {
                        if (page.ToLower().Equals(PageName.ToLower()))
                        {
                            pagepresetactive.ActiveLayout = kvp.Key;
                            break;
                        }
                    }

                    if (kvp.Value.Equals("all") || kvp.Value.Equals("All") || kvp.Value.Equals("*") || kvp.Value.Equals(""))
                    {
                        defaultPreset = kvp.Key;
                    }
            }
            if (pagepresetactive.ActiveLayout == "" || pagepresetactive.ActiveLayout == null)
            {
                pagepresetactive.ActiveLayout = defaultPreset;
            }
            return pagepresetactive;
        }
 public PresetInfo LoadActivePagePreset()
 {
     PresetInfo presetInfo = new PresetInfo();
     if (Globals.sysHst[ApplicationKeys.ActivePagePreset + "_" + currentportalID] != null)
     {
         presetInfo = (PresetInfo)Globals.sysHst[ApplicationKeys.ActivePagePreset + "_" + currentportalID];
     }
     else
     {
         presetInfo = PresetHelper.LoadActivePagePreset(activeTemplate, GetPageSEOName(Request.Url.ToString()));
         Globals.sysHst[ApplicationKeys.ActivePagePreset + "_" + currentportalID] = presetInfo;
     }
     return presetInfo;
 }
示例#28
0
 public static void UpdatePreset(PresetInfo preset, string TemplateName)
 {
     string presetPath = Utils.GetPresetPath(TemplateName);
     try
     {
         WritePreset(presetPath + "/" + preset.PresetName + ".xml", preset);
     }
     catch (Exception)
     {
         
         throw;
     }
 }
 public static void UpdatePreset(PresetInfo preset, string TemplateName)
 {
     string presetPath = TemplateName.ToLower().Equals("default") ? Utils.GetPresetPath_DefaultTemplate(TemplateName) : Utils.GetPresetPath(TemplateName);
    
     try
     {
         WritePreset(string.Format("{0}/pagepreset.xml",presetPath), preset);
     }
     catch (Exception)
     {
         
         throw;
     }
 }
示例#30
0
        public static PresetInfo LoadActivePagePreset(string TemplateName, string PageName)
        {
            string presetPath = Utils.GetPresetPath(TemplateName);
            List<PresetInfo> lstActivePresets = new List<PresetInfo>();
            string pagepreset = presetPath + "/" + TemplateConstants.PagePresetFile;
            List<string> lstAllPages = new List<string>();
            PresetInfo pagepresetactive = new PresetInfo();
            if (File.Exists(pagepreset))
            {

                lstActivePresets = PresetHelper.ParsePreset(pagepreset, "pagepresets/page", out lstAllPages);
            }
            else
            {
                lstActivePresets.Add(PresetInfo.GetPresetPages("default", "*"));

            }

           
            foreach (PresetInfo preset in lstActivePresets)
            {
                if (preset.IsDefault)
                {
                    string presetPathFull = presetPath + "/" + preset.PresetName + ".xml";
                    PresetInfo presetdetail = LoadPresetDetails(presetPathFull);
                    pagepresetactive = presetdetail;
                }
                else
                {
                    string presetPathFull = presetPath + "/" + preset.PresetName + ".xml";
                    PresetInfo presetdetail = LoadPresetDetails(presetPathFull);
                    foreach (string page in preset.LSTPages)
                    {
                        if (page.ToLower().Equals(PageName.ToLower()))
                        {
                            pagepresetactive = LoadPresetDetails(presetPathFull);
                            break;
                        }
                    }
                }


            }


            return pagepresetactive;

        }
        public static PresetInfo LoadPresetDetails(string xmlPath)
        {
            if (!File.Exists(xmlPath))
            {
                xmlPath = string.Format("{0}/pagepreset.xml",Utils.GetPresetPath_DefaultTemplate("default"));
            }
            XmlDocument doc = XmlHelper.LoadXMLDocument(xmlPath);
            XmlNode xnpreset = doc.SelectSingleNode("pagepreset");
            XmlNodeList xnlist = xnpreset.ChildNodes;
            PresetInfo preset = new PresetInfo();
            List<KeyValue> lstLayouts = new List<KeyValue>();
            
            foreach (XmlNode node in xnlist)
            {
                switch (node.Name)
                {
                    case "layout":
                        XmlNodeList layouts = node.ChildNodes;
                      
                        foreach (XmlNode layout in layouts)
                        {
                            lstLayouts.Add(new KeyValue(layout.Attributes["layout"].Value, layout.InnerText));
                        }                        
                        break;
                    case "theme":
                        preset.ActiveTheme = node.InnerText;
                        break;
                    case "width":
                        preset.ActiveWidth = node.InnerText;
                        break;                

                }
                preset.lstLayouts = lstLayouts;

            }
            return preset;

        }
示例#32
0
        public static int UpdatePresetPages(PresetInfo objPreset, string xmlpath)
        {
            XmlDocument doc = XmlHelper.LoadXMLDocument(xmlpath);
            XmlNode xnpreset = doc.SelectSingleNode("pagepresets");
            XmlNodeList xnlist = xnpreset.ChildNodes;
                        
            bool isApplied = false;
            bool isAllPageApplied = false;
            bool isPageApplied = false;
            int nodecount = 0;
            foreach (XmlNode node in xnlist)
            {

                if (node.Attributes["preset"].Value == objPreset.PresetName || node.Attributes["preset"].Value == Path.GetFileNameWithoutExtension(objPreset.PresetName.ToLower()))
                {
                    isApplied = true;
                    node.InnerText = objPreset.Pages;                   
                }
                if (node.InnerText.ToLower() == "" || node.InnerText.ToLower() == "none")
                {
                    xnlist[nodecount].ParentNode.RemoveChild(xnlist[nodecount]);
                }
                else if (node.InnerText.ToLower() == "all" && objPreset.Pages.ToLower()=="all")
                {
                    isAllPageApplied = true;
                }
                if (node.InnerText.ToLower() != "all" && Path.GetFileNameWithoutExtension(objPreset.Pages.ToLower()) != "all")
                {
                    string[] arrPages = node.InnerText.ToLower().Split(',');
                    string[] arrPagesNew=objPreset.Pages.ToLower().Split(',');
                    List<string> arrFinalPages=new List<string>();
                    
                    foreach (string page in arrPagesNew)
                    {
                        if (!arrPages.Contains(page) && page!="all")
                        {
                            arrFinalPages.Add(page);
                        }
                        else
                        {
                            isPageApplied = true;
                        }
                    }
                    objPreset.Pages = string.Join(",", arrFinalPages.ToArray());
                }
                nodecount++;
                
            }
            
            if (!isApplied && !isAllPageApplied && objPreset.Pages!="" && objPreset.Pages!="none")
            {
                XmlElement elem = doc.CreateElement("page");
                elem.SetAttribute("preset",Path.GetFileNameWithoutExtension(objPreset.PresetName));
                elem.InnerText = objPreset.Pages;
                xnpreset.AppendChild(elem);
            }
            doc.Save(xmlpath);

            return(isAllPageApplied?1:isPageApplied?2:0);
            ///Return Login
            ///0:Everything is normal
            ///1:A few pages are already applied to presets
            ///2:All Page is already applied


        }
示例#33
0
        static void WriteNewPreset(string xmlpath, PresetInfo objPreset)
        {
            using (XmlTextWriter writer = new XmlTextWriter(xmlpath, Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                writer.WriteStartDocument();
                writer.WriteStartElement("preset");
                writer.WriteAttributeString("name", Path.GetFileNameWithoutExtension(objPreset.PresetName));
                writer.WriteStartElement("activetheme");
                writer.WriteString(objPreset.ActiveTheme);
                writer.WriteEndElement();

                writer.WriteStartElement("activelayout");
                writer.WriteString(objPreset.ActiveLayout);
                writer.WriteEndElement();

                writer.WriteStartElement("activewidth");
                writer.WriteString(objPreset.ActiveWidth);
                writer.WriteEndElement();

                writer.WriteStartElement("cssopt");
                writer.WriteString(objPreset.IsCssOptimizationEnabled.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("jsopt");
                writer.WriteString(objPreset.IsJsOptimizationEnabled.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("cpanel");
                writer.WriteString(objPreset.CPanel.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("handheld");
                writer.WriteString(objPreset.HandHeld.ToString());
                writer.WriteEndElement();

                writer.WriteStartElement("handheldlayout");
                writer.WriteString(objPreset.HandHeldLayout);
                writer.WriteEndElement();


                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();
            }
        }
示例#34
0
        public static void WritePreset(string xmlpath, PresetInfo objPreset)
        {
            if (File.Exists(xmlpath))
            {
                File.Delete(xmlpath);
                WriteNewPreset(xmlpath, objPreset);

            }
            else
            {
                WriteNewPreset(xmlpath, objPreset);
            }
        }