예제 #1
0
        public string GetTemplateJson(System.Web.HttpContext context, int id)
        {
            string result;

            try
            {
                CustomPage customPageByID = CustomPageHelp.GetCustomPageByID(id);
                if (customPageByID == null)
                {
                    result = "";
                }
                else if (customPageByID.Status == 0)
                {
                    result = customPageByID.FormalJson.Replace("\r\n", "").Replace("\n", "");
                }
                else
                {
                    result = customPageByID.DraftJson.Replace("\r\n", "").Replace("\n", "");
                }
            }
            catch
            {
                result = "";
            }
            return(result);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack)
     {
         this.id             = base.Request.QueryString["id"];
         this.model          = CustomPageHelp.GetCustomPageByID(Convert.ToInt32(this.id));
         this.j_pageID.Value = this.id;
         this.La_script.Text = this.GetTemplatescript(this.model.TempIndexName);
         this.isModuleEdit   = true;
         this.modelStatus    = this.model.Status;
         if (!string.IsNullOrEmpty(this.model.TempIndexName) && (this.model.TempIndexName != "none"))
         {
             this.cssSrc        = this.cssSrc + this.model.TempIndexName + "/css/head.css";
             this.scriptSrc     = this.scriptSrc + this.model.TempIndexName + "/script/head.js";
             this.scriptLinkSrc = "<script src=\"" + this.scriptSrc + "\"></script>";
             this.cssLinkSrc    = "<link rel=\"stylesheet\" href=\"" + this.cssSrc + "\">";
         }
     }
 }
 public string GetTemplateJson(HttpContext context, int id)
 {
     try
     {
         CustomPage customPageByID = CustomPageHelp.GetCustomPageByID(id);
         if (customPageByID == null)
         {
             return("");
         }
         if (customPageByID.Status == 0)
         {
             return(customPageByID.FormalJson.Replace("\r\n", "").Replace("\n", ""));
         }
         return(customPageByID.DraftJson.Replace("\r\n", "").Replace("\n", ""));
     }
     catch
     {
         return("");
     }
 }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string           str     = context.Request.Form["content"];
            string           str2    = context.Request.Form["id"];
            CustomPageStatus status  = (context.Request.Form["type"] != null) ? ((CustomPageStatus)Convert.ToInt32(context.Request.Form["type"])) : CustomPageStatus.草稿;
            JObject          jo      = (JObject)JsonConvert.DeserializeObject(str);
            string           message = "保存成功";
            string           str4    = "1";

            try
            {
                CustomPage customPageByID = CustomPageHelp.GetCustomPageByID(Convert.ToInt32(str2));
                if (customPageByID == null)
                {
                    context.Response.Write("{\"status\":" + 0 + ",\"msg\":\"找不到相关页面\"}");
                    return;
                }
                if (status == CustomPageStatus.正常)
                {
                    customPageByID.PageUrl    = jo["page"]["pageurl"].ToString().Trim();
                    customPageByID.Name       = jo["page"]["title"].ToString();
                    customPageByID.IsShowMenu = Convert.ToBoolean(jo["page"]["isshowmenu"]);
                    customPageByID.Details    = jo["page"]["subtitle"].ToString();
                    customPageByID.FormalJson = str;
                }
                else
                {
                    customPageByID.DraftPageUrl    = jo["page"]["pageurl"].ToString().Trim();
                    customPageByID.DraftName       = jo["page"]["title"].ToString();
                    customPageByID.DraftIsShowMenu = Convert.ToBoolean(jo["page"]["isshowmenu"]);
                    customPageByID.DraftDetails    = jo["page"]["subtitle"].ToString();
                    customPageByID.DraftJson       = str;
                }
                customPageByID.Status = (int)status;
                if (!CustomPageHelp.Update(customPageByID))
                {
                    context.Response.Write("{\"status\":" + 0 + ",\"msg\":\"保存失败\"}");
                    return;
                }
                if (status == CustomPageStatus.正常)
                {
                    string str5 = "<%@ Control Language=\"C#\" %>\n<%@ Register TagPrefix=\"Hi\" Namespace=\"HiTemplate\" Assembly=\"HiTemplate\" %>";
                    str5 = str5 + this.GetPModulesHtml(context, jo);
                    string lModulesHtml = this.GetLModulesHtml(context, jo);
                    str5 = str5 + lModulesHtml;
                    string path = "/Templates/vshop/custom/" + customPageByID.PageUrl;
                    if (!Directory.Exists(context.Server.MapPath(path)))
                    {
                        Directory.CreateDirectory(context.Server.MapPath(path));
                    }
                    StreamWriter writer = new StreamWriter(context.Server.MapPath(path + "/Skin-HomePage.html"), false, Encoding.UTF8);
                    foreach (char ch in str5)
                    {
                        writer.Write(ch);
                    }
                    writer.Close();
                }
                else
                {
                    string str8 = "<%@ Control Language=\"C#\" %>\n<%@ Register TagPrefix=\"Hi\" Namespace=\"HiTemplate\" Assembly=\"HiTemplate\" %>";
                    str8 = str8 + this.GetPModulesHtml(context, jo);
                    string str9 = this.GetLModulesHtml(context, jo);
                    str8 = str8 + str9;
                    string str10 = "/Templates/vshop/custom/draft/" + customPageByID.DraftPageUrl;
                    if (!Directory.Exists(context.Server.MapPath(str10)))
                    {
                        Directory.CreateDirectory(context.Server.MapPath(str10));
                    }
                    StreamWriter writer2 = new StreamWriter(context.Server.MapPath(str10 + "/Skin-HomePage.html"), false, Encoding.UTF8);
                    foreach (char ch2 in str8)
                    {
                        writer2.Write(ch2);
                    }
                    writer2.Close();
                }
            }
            catch (Exception exception)
            {
                message = exception.Message;
                str4    = "0";
            }
            if (context.Request.Form["is_preview"] == "1")
            {
                context.Response.Write("{\"status\":" + str4 + ",\"msg\":\"" + message + "\",\"link\":\"default.aspx\"}");
            }
            else
            {
                context.Response.Write("{\"status\":" + str4 + ",\"msg\":\"" + message + "\"}");
            }
        }
        public void ProcessRequest(System.Web.HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string           text             = context.Request.Form["content"];
            string           value            = context.Request.Form["id"];
            CustomPageStatus customPageStatus = (CustomPageStatus)((context.Request.Form["type"] != null) ? System.Convert.ToInt32(context.Request.Form["type"]) : 1);
            JObject          jObject          = (JObject)JsonConvert.DeserializeObject(text);
            string           text2            = "保存成功";
            string           text3            = "1";

            try
            {
                CustomPage customPageByID = CustomPageHelp.GetCustomPageByID(System.Convert.ToInt32(value));
                if (customPageByID == null)
                {
                    context.Response.Write("{\"status\":" + 0 + ",\"msg\":\"找不到相关页面\"}");
                    return;
                }
                if (customPageStatus == CustomPageStatus.正常)
                {
                    customPageByID.PageUrl    = jObject["page"]["pageurl"].ToString().Trim();
                    customPageByID.Name       = jObject["page"]["title"].ToString();
                    customPageByID.IsShowMenu = System.Convert.ToBoolean(jObject["page"]["isshowmenu"]);
                    customPageByID.Details    = jObject["page"]["subtitle"].ToString();
                    customPageByID.FormalJson = text;
                }
                else
                {
                    customPageByID.DraftPageUrl    = jObject["page"]["pageurl"].ToString().Trim();
                    customPageByID.DraftName       = jObject["page"]["title"].ToString();
                    customPageByID.DraftIsShowMenu = System.Convert.ToBoolean(jObject["page"]["isshowmenu"]);
                    customPageByID.DraftDetails    = jObject["page"]["subtitle"].ToString();
                    customPageByID.DraftJson       = text;
                }
                customPageByID.Status = (int)customPageStatus;
                if (!CustomPageHelp.Update(customPageByID))
                {
                    context.Response.Write("{\"status\":" + 0 + ",\"msg\":\"保存失败\"}");
                    return;
                }
                if (customPageStatus == CustomPageStatus.正常)
                {
                    string text4 = "<%@ Control Language=\"C#\" %>\n<%@ Register TagPrefix=\"Hi\" Namespace=\"HiTemplate\" Assembly=\"HiTemplate\" %>";
                    text4 += this.GetPModulesHtml(context, jObject);
                    string lModulesHtml = this.GetLModulesHtml(context, jObject);
                    text4 += lModulesHtml;
                    string text5 = "/Templates/vshop/custom/" + customPageByID.PageUrl;
                    if (!System.IO.Directory.Exists(context.Server.MapPath(text5)))
                    {
                        System.IO.Directory.CreateDirectory(context.Server.MapPath(text5));
                    }
                    System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(context.Server.MapPath(text5 + "/Skin-HomePage.html"), false, System.Text.Encoding.UTF8);
                    string text6 = text4;
                    for (int i = 0; i < text6.Length; i++)
                    {
                        char value2 = text6[i];
                        streamWriter.Write(value2);
                    }
                    streamWriter.Close();
                }
                else
                {
                    string text7 = "<%@ Control Language=\"C#\" %>\n<%@ Register TagPrefix=\"Hi\" Namespace=\"HiTemplate\" Assembly=\"HiTemplate\" %>";
                    text7 += this.GetPModulesHtml(context, jObject);
                    string lModulesHtml2 = this.GetLModulesHtml(context, jObject);
                    text7 += lModulesHtml2;
                    string text8 = "/Templates/vshop/custom/draft/" + customPageByID.DraftPageUrl;
                    if (!System.IO.Directory.Exists(context.Server.MapPath(text8)))
                    {
                        System.IO.Directory.CreateDirectory(context.Server.MapPath(text8));
                    }
                    System.IO.StreamWriter streamWriter2 = new System.IO.StreamWriter(context.Server.MapPath(text8 + "/Skin-HomePage.html"), false, System.Text.Encoding.UTF8);
                    string text9 = text7;
                    for (int j = 0; j < text9.Length; j++)
                    {
                        char value3 = text9[j];
                        streamWriter2.Write(value3);
                    }
                    streamWriter2.Close();
                }
            }
            catch (System.Exception ex)
            {
                text2 = ex.Message;
                text3 = "0";
            }
            if (context.Request.Form["is_preview"] == "1")
            {
                context.Response.Write(string.Concat(new string[]
                {
                    "{\"status\":",
                    text3,
                    ",\"msg\":\"",
                    text2,
                    "\",\"link\":\"default.aspx\"}"
                }));
                return;
            }
            context.Response.Write(string.Concat(new string[]
            {
                "{\"status\":",
                text3,
                ",\"msg\":\"",
                text2,
                "\"}"
            }));
        }