Пример #1
0
        private void SaveDesignTemplate(System.Web.HttpContext context)
        {
            string jsonViewList = context.Request["viewList"];

            VshopDesignTemplate template     = StoreHelper.GetVshopDesignTemplate(1, true);
            StringBuilder       stringBuider = new StringBuilder();

            stringBuider.Append("{");
            if (template == null)
            {
                VshopDesignTemplate newTemplate = new VshopDesignTemplate();
                newTemplate.AddTime      = DateTime.Now;
                newTemplate.TemplateName = "首页模版";
                newTemplate.TemplateType = 1;
                newTemplate.InUse        = false;
                newTemplate.Content      = jsonViewList;
                newTemplate.SupplierId   = CheckSupplierRole();
                if (StoreHelper.AddVshopDesignTemplate(newTemplate))
                {
                    stringBuider.Append("\"success\":1,");
                    stringBuider.Append("\"mesg:\",\"添加成功\"");
                }
                else
                {
                    stringBuider.Append("\"success\":0,");
                    stringBuider.Append("\"mesg:\",\"添加失败\"");
                }
            }
            else
            {
                template.Content    = jsonViewList;
                template.SupplierId = CheckSupplierRole();
                if (StoreHelper.UpdateVshopDesignTemplate(template))
                {
                    if (!string.IsNullOrEmpty(context.Request["strHtml"]))
                    {
                        string path = HttpContext.Current.Server.MapPath("/Vshop/index.html");
                        if (File.Exists(path))
                        {
                            File.Delete(path);
                            CreateHtml(context.Request["strHtml"]);
                        }
                    }
                    stringBuider.Append("\"success\":1,");
                    stringBuider.Append("\"mesg:\",\"更新成功\"");
                }
                else
                {
                    stringBuider.Append("\"success\":0,");
                    stringBuider.Append("\"mesg:\",\"更新失败\"");
                }
            }
            stringBuider.Append("}");
            context.Response.Write(stringBuider.ToString());
            context.Response.End();
        }