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;
            }


        }
Exemplo n.º 2
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);
            }


        }