Ejemplo n.º 1
0
    public static int CreateLayout(string FilePath, string Xml, string TemplateName)
    {
        string templatePath = Decide.IsTemplateDefault(TemplateName.Trim()) ? Utils.GetTemplatePath_Default(TemplateName) : Utils.GetTemplatePath(TemplateName);
        string filePath     = templatePath + "/layouts/" + Utils.GetFileNameWithExtension(FilePath, "xml");
        int    status       = 0;

        try
        {
            if (Decide.IsXmlInputValid(Xml))
            {
                using (StreamWriter sw = new StreamWriter(filePath))
                {
                    if (!Utils.ContainsXmlHeader(Xml))
                    {
                        sw.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    }
                    sw.Write(Xml);
                }
                CreateLayoutControls(TemplateName.Trim(), filePath);
            }
            else
            {
                status = 1;
            }
            return(status);
        }
        catch (Exception)
        {
            throw;
        }
    }
Ejemplo n.º 2
0
    public static int UpdateLayout(string FilePath, string Xml, string TemplateName)
    {
        int status = 0;

        TemplateName = TemplateName.Trim();
        if (!Utils.ContainsXmlHeader(Xml))
        {
            Xml = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?>{0}", Xml);
        }
        if (Decide.IsXmlInputValid(Xml))
        {
            string templatePath = Decide.IsTemplateDefault(TemplateName) ? Utils.GetTemplatePath_Default(TemplateName) : Utils.GetTemplatePath(TemplateName);
            //string filePath = string.Format("{0}/layouts/{1}.xml",templatePath,FilePath);
            string filePath = FilePath.ToLower().Equals("core") ? string.Format("{0}/Layouts/standard/All.xml", Utils.GetTemplatePath_Default("Default")) : string.Format("{0}/layouts/{1}.xml", templatePath, FilePath);

            using (StreamWriter sw = new StreamWriter(filePath))
            {
                sw.Write(Xml);
            }
            CreateLayoutControls(TemplateName, filePath);
        }
        else
        {
            status = 1;
        }
        return(status);
    }