예제 #1
0
파일: Custom.cs 프로젝트: llenroc/kangaroo
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string text = (this.Page.RouteData.Values["custpath"] != null) ? this.Page.RouteData.Values["custpath"].ToString() : "notfound";

            this.H_Page.CustomPagePath = text;
            CustomPage customPageByPath = CustomPageHelp.GetCustomPageByPath(text);

            if (customPageByPath == null)
            {
                base.Response.Redirect("/default.aspx");
            }
            this.IsShowMenu = customPageByPath.IsShowMenu;
            string value = base.Request.QueryString["ReferralId"];

            if (!string.IsNullOrEmpty(value))
            {
                customPageByPath.PV++;
                CustomPageHelp.Update(customPageByPath);
            }
            if (!string.IsNullOrEmpty(customPageByPath.TempIndexName))
            {
                this.cssSrc     = this.cssSrc + customPageByPath.TempIndexName + "/css/head.css";
                this.cssLinkStr = "<link rel=\"stylesheet\" href=\"" + this.cssSrc + "\">";
            }
            this.siteSettings  = SettingsManager.GetMasterSettings(true);
            this.htmlTitleName = customPageByPath.Name;
            this.Desc          = customPageByPath.Details;
            string userAgent = this.Page.Request.UserAgent;

            if (!base.IsPostBack)
            {
                HiAffiliation.LoadPage();
                string getCurrentWXOpenId = Globals.GetCurrentWXOpenId;
                int    num = Globals.RequestQueryNum("go");
                if (userAgent.ToLower().Contains("micromessenger") && string.IsNullOrEmpty(getCurrentWXOpenId) && this.siteSettings.IsValidationService && num != 1)
                {
                    this.Page.Response.Redirect("Follow.aspx?ReferralId=" + Globals.GetCurrentDistributorId());
                    this.Page.Response.End();
                }
                if (Globals.GetCurrentMemberUserId(false) == 0 && this.siteSettings.IsAutoToLogin && userAgent.ToLower().Contains("micromessenger"))
                {
                    System.Uri arg_1DF_0   = System.Web.HttpContext.Current.Request.Url;
                    string     urlToEncode = Globals.GetWebUrlStart() + "/default.aspx?ReferralId=" + Globals.RequestQueryNum("ReferralId").ToString();
                    base.Response.Redirect("/UserLogining.aspx?returnUrl=" + Globals.UrlEncode(urlToEncode));
                    base.Response.End();
                }
                this.showMenu = this.siteSettings.EnableShopMenu;
                this.BindWXInfo();
            }
        }
        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 + "\"}");
            }
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string custPath = Page.RouteData.Values["custpath"] != null ? Page.RouteData.Values["custpath"].ToString() : "notfound";

            H_Page.CustomPagePath = custPath;
            var model = CustomPageHelp.GetCustomPageByPath(custPath);

            if (model == null)
            {
                Response.Redirect("/default.aspx");
            }

            IsShowMenu = model.IsShowMenu;
            string reId = Request.QueryString["ReferralId"];

            if (!string.IsNullOrEmpty(reId))
            {
                model.PV += 1;
                CustomPageHelp.Update(model);
            }
            if (!string.IsNullOrEmpty(model.TempIndexName))
            {
                cssSrc    += model.TempIndexName + "/css/head.css";
                cssLinkStr = "<link rel=\"stylesheet\" href=\"" + cssSrc + "\">";
            }
            siteSettings = SettingsManager.GetMasterSettings(true);
            //ShowCopyRight = siteSettings.ShowCopyRight;
            htmlTitleName = model.Name;
            Desc          = model.Details;
            string userAgent = Page.Request.UserAgent;//获取浏览器信息

            //EnabeHomePageBottomLink = siteSettings.EnabeHomePageBottomLink;//控制底部菜单是否显示
            //EnableHomePageBottomCopyright = siteSettings.EnableHomePageBottomCopyright;//控制是否显示版权信息
            //EnableGuidePageSet = siteSettings.EnableGuidePageSet;
            //IsAutoGuide = siteSettings.IsAutoGuide;
            //IsMustConcern = siteSettings.IsMustConcern;
            //DistributionLinkName = siteSettings.DistributionLinkName;//分销申请栏目名称
            //DistributionLink = string.IsNullOrEmpty(siteSettings.DistributionLink) ? "javascript:void(0);" : siteSettings.DistributionLink; //分销申请链接
            //CopyrightLinkName = siteSettings.CopyrightLinkName;//版本信息文字
            //CopyrightLink = string.IsNullOrEmpty(siteSettings.CopyrightLink) ? "javascript:void(0);" : siteSettings.CopyrightLink; //文字对应跳转链接

            //if (siteSettings.EnableAliPayFuwuGuidePageSet)
            //{
            //    AlinfollowUrl = siteSettings.AliPayFuwuGuidePageSet;//服务窗口关注连接
            //}
            //if (siteSettings.EnableGuidePageSet)
            //{
            //    WeixinfollowUrl = siteSettings.GuidePageSet; //微信关注连接
            //}

            if (!IsPostBack)
            {
                HiAffiliation.LoadPage();//放在前面,防止参数丢失

                string weiXinOpenID = Globals.GetCurrentWXOpenId;
                int    goId         = Globals.RequestQueryNum("go");
                if (userAgent.ToLower().Contains("micromessenger") && string.IsNullOrEmpty(weiXinOpenID) && siteSettings.IsValidationService && goId != 1)   //判断是否是在微信中打开
                {
                    Page.Response.Redirect("Follow.aspx?ReferralId=" + Globals.GetCurrentDistributorId());
                    Page.Response.End();
                }
                int memberID = Globals.GetCurrentMemberUserId();
                if (memberID == 0 && siteSettings.IsAutoToLogin && userAgent.ToLower().Contains("micromessenger"))//判断是否是在微信中打开
                {
                    Uri    linkUri = HttpContext.Current.Request.Url;
                    string toUrl   = Globals.GetWebUrlStart() + "/default.aspx?ReferralId=" + Globals.RequestQueryNum("ReferralId").ToString();
                    Response.Redirect("/UserLogining.aspx?returnUrl=" + Globals.UrlEncode(toUrl));
                    Response.End();
                }


                showMenu = siteSettings.EnableShopMenu;

                BindWXInfo();
            }
        }
        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,
                "\"}"
            }));
        }