Beispiel #1
0
        public string EditMenu(HttpContext context)
        {
            int    pi = 0;
            int    si = -1;
            string mi = context.Request["mi"];

            if (mi.Contains("-"))
            {
                string[] arr = mi.Split('-');
                pi = int.Parse(arr[0]) - 1;
                si = int.Parse(arr[1]) - 1;
            }
            else
            {
                pi = int.Parse(mi) - 1;
            }

            TemplatePage page       = this._app.GetPage(this._plugin, "mg/menu_edit.html");
            String       entityJson = JsonConvert.SerializeObject(WeixinHelper.GetMenuNode(pi, si));

            page.AddVariable("entity", entityJson);
            page.AddVariable("pi", pi);
            page.AddVariable("si", si);
            return(page.ToString());
        }
        public string Export_Import(HttpContext context)
        {
            TemplatePage page = Cms.Plugins.GetPage <Main>("admin/export_import.html");

            page.AddVariable("page", new PageVariable());
            page.AddVariable("case", new { json = new object() });
            return(page.ToString());
        }
        public string Export_Setup(HttpContext context)
        {
            TemplatePage page = Cms.Plugins.GetPage <Main>("admin/export_setup.html");

            page.AddVariable("page", new PageVariable());
            page.AddVariable("export", new { setup = ExportHandle.Setup(context.Request["portal"]) });
            return(page.ToString());
        }
Beispiel #4
0
        public string CreateTextRes(HttpContext context)
        {
            TemplatePage page = this._app.GetPage(this._plugin, "mg/text_res.html");

            page.AddVariable("entity", "{Id:0}");
            page.AddVariable("content", "");

            return(page.ToString());
        }
        public string Case_Gallery(HttpContext context)
        {
            int          caseId = int.Parse(context.Request["caseId"]);
            TemplatePage page   = Cms.Plugins.GetPage <Main>("admin/case_gallery.html");

            page.AddVariable("page", new PageVariable());
            page.AddVariable("case", new { Id = caseId });
            return(page.ToString());
        }
Beispiel #6
0
        public TemplatePage GetTemplatePage(string filePath, PluginPackAttribute attr)
        {
            string pluginDirPath = attr.WorkSpace;


            string cacheId = String.Concat("plugin", "_tpl_", attr.WorkIndent, filePath);
            string html    = WebCtx.Current.Cache.Get(cacheId) as string;

            if (html == null)
            {
                //模板文件放在/plugins/com.spdepository/pages/下
                string tplFilePath = pluginDirPath + filePath;

                try
                {
                    using (TextReader tr = new StreamReader(tplFilePath))
                    {
                        html = tr.ReadToEnd();
                        tr.Dispose();
                    }

                    WebCtx.Current.Cache.Insert(cacheId, html, tplFilePath);
                }
                catch (Exception exc)
                {
                    throw new Exception(exc.Message + ", File:" + tplFilePath);
                }
            }

            TemplatePage tpl = new TemplatePage();

            tpl.TemplateContent = html;

            string pluginPath = this._pluginPath + attr.WorkIndent;

            tpl.AddVariable("os", new
            {
                version = FwCtx.Version.GetVersion(),
                domain  = WebCtx.Current.Domain,
                ppath   = pluginPath,
                fpath   = this._fpath,
                mjs     = this._shareJs,
                sjs     = this._shareJs,
                scss    = this._shareCss,
                mcss    = this._shareCss
            });

            tpl.AddVariable("plugin", new
            {
                path   = pluginPath,
                indent = attr.WorkIndent,
                name   = attr.Name
            });

            return(tpl);
        }
Beispiel #7
0
        public string CreateMenu(HttpContext context)
        {
            int          pi       = int.Parse(context.Request["pi"]) - 1;
            TemplatePage page     = this._app.GetPage(this._plugin, "mg/menu_create.html");
            String       menuJson = JsonConvert.SerializeObject(WeixinHelper.GetMenuTreeNode());

            page.AddVariable("menu", menuJson);
            page.AddVariable("pi", pi);
            return(page.ToString());
        }
Beispiel #8
0
        public string CreateArticleItem(HttpContext context)
        {
            string       resId = context.Request["res_id"];
            TemplatePage page  = this._app.GetPage(this._plugin, "mg/article_item.html");

            page.AddVariable("entity", "{Id:0,Enabled:true}");
            page.AddVariable("resId", resId);
            page.AddVariable("content", "");
            page.AddVariable("description", "");

            return(page.ToString());
        }
Beispiel #9
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string Export_Setup(HttpContext context)
        {
            if (!RequestProxry.VerifyLogin(context))
            {
                return(null);
            }

            TemplatePage page = Cms.Plugins.GetPage <Main>("mg/export_setup.html");

            page.AddVariable("page", new PageVariable());
            page.AddVariable("export", new { setup = ExportHandle.Setup(context.Request["portal"]) });
            return(page.ToString());
        }
Beispiel #10
0
        public string CreateArticleRes(HttpContext context)
        {
            TemplatePage page = this._app.GetPage(this._plugin, "mg/article_res.html");

            page.AddVariable("entity", "{Id:0}");
            page.AddVariable("data", new
            {
                content     = "",
                description = ""
            });

            return(page.ToString());
        }
Beispiel #11
0
        public string Export_Import(HttpContext context)
        {
            if (!RequestProxry.VerifyLogin(context))
            {
                return(null);
            }

            TemplatePage page = Cms.Plugins.GetPage <Main>("admin/export_import.html");

            page.AddVariable("page", new PageVariable());
            page.AddVariable("case", new { json = new object() });
            return(page.ToString());
        }
Beispiel #12
0
        public string EditArticleItem(HttpContext context)
        {
            string         resId = context.Request["res_id"];
            int            id    = int.Parse(context.Request["id"]);
            TemplatePage   page  = this._app.GetPage(this._plugin, "mg/article_item.html");
            ArticleResItem res   = IocObject.WeixinRes.GetArticleItem(id);

            page.AddVariable("content", res.Content);
            page.AddVariable("description", res.Description);
            res.Content     = null;
            res.Description = null;
            page.AddVariable("entity", res != null ? JsonConvert.SerializeObject(res) : "{}");
            page.AddVariable("resId", resId);
            return(page.ToString());
        }
        public string Case_List(HttpContext context)
        {
            TemplatePage page = Cms.Plugins.GetPage <Main>("admin/case_list.html");

            page.AddVariable("page", new PageVariable());
            return(page.ToString());
        }
Beispiel #14
0
        public string BasicSetting(HttpContext context)
        {
            PluginPackAttribute attr = this._plugin.GetAttribute();
            TemplatePage        page = this._app.GetPage(this._plugin, "mg/basic_setting.html");

            string url = String.Format("http://{0}/{1}.sh.aspx/serve",
                                       context.Request.Url.Host, attr.WorkIndent);
            string token = attr.Settings["Weixin_Token"] ??
                           String.Empty.RandomLetters(6);
            string appId              = attr.Settings["Weixin_AppId"] ?? "";
            string appSecret          = attr.Settings["Weixin_AppSecret"] ?? "";
            string appEncodeString    = attr.Settings["Weixin_AppEncodeString"] ?? "";
            string wlc                = attr.Settings["Weixin_WelcomeMessage"] ?? "";
            string enterMessage       = attr.Settings["Weixin_EnterMessage"] ?? "";
            string defaultRspMesssage = attr.Settings["Weixin_DefaultResponseMessage"] ?? "";

            page.AddVariable("data", new
            {
                url               = url,
                token             = token,
                appId             = appId,
                appSecret         = appSecret,
                aes               = appEncodeString,
                welcomeMessage    = wlc,
                enterMessage      = enterMessage,
                defaultRspMessage = defaultRspMesssage,
            });
            return(page.ToString());
        }
Beispiel #15
0
        public string ArticleItems(HttpContext context)
        {
            string       resId = context.Request["res_id"];
            TemplatePage page  = this._app.GetPage(this._plugin, "mg/article_itemlist.html");

            page.AddVariable("resId", resId);
            return(page.ToCompressedString());
        }
Beispiel #16
0
        public string Menu(HttpContext context)
        {
            TemplatePage page     = this._app.GetPage(this._plugin, "mg/menu.html");
            String       menuJson = JsonConvert.SerializeObject(WeixinHelper.GetMenuTreeNode());

            page.AddVariable("menu", menuJson);
            return(page.ToString());
        }
Beispiel #17
0
 private void Main()
 {
     TemplatePage tp = new TemplatePage();
     tp.TemplateContent = "$m=item  KEY:${item.key} Note:${item.note}<br />${m.key}";
     tp.AddVariable("item", new {Key = "Key", Note = "Note"});
     var x = System.Web.HttpContext.Current.Items;
     string y = tp.ToString();
     // return y;
 }
Beispiel #18
0
        public string EditTextRes(HttpContext context)
        {
            int          id   = int.Parse(context.Request["id"]);
            TemplatePage page = this._app.GetPage(this._plugin, "mg/text_res.html");
            TextRes      res  = IocObject.WeixinRes.GetResById(id) as TextRes;

            if (res == null)
            {
                page.AddVariable("content", "");
                page.AddVariable("entity", "{}");
            }
            else
            {
                page.AddVariable("content", res.Content == null ? "" : res.Content);
                page.AddVariable("entity", JsonConvert.SerializeObject(res));
            }

            return(page.ToString());
        }
Beispiel #19
0
        private void Main()
        {
            TemplatePage tp = new TemplatePage();

            tp.TemplateContent = "$m=item  KEY:${item.key} Note:${item.note}<br />${m.key}";
            tp.AddVariable("item", new { Key = "Key", Note = "Note" });
            var    x = System.Web.HttpContext.Current.Items;
            string y = tp.ToString();
            // return y;
        }
Beispiel #20
0
        public string EditArticleRes(HttpContext context)
        {
            int          id   = int.Parse(context.Request["id"]);
            TemplatePage page = this._app.GetPage(this._plugin, "mg/article_res.html");
            ArticleRes   res  = IocObject.WeixinRes.GetResById(id) as ArticleRes;

            res.Items = null;
            page.AddVariable("entity", res != null ? JsonConvert.SerializeObject(res) : "{}");

            return(page.ToString());
        }
        public string Partner(HttpContext context)
        {
            string template = Helper.IsWapPortal(context.Request)
                ? "html/partner_mobile.html"
                : "html/partner.html";

            TemplatePage page = Cms.Plugins.GetPage <Main>(template);

            page.AddVariable("page", new PageVariable());
            return(page.ToString());
        }
Beispiel #22
0
        private void Main()
        {
            IDataContainer dc = new BasicDataContainer(null);
            TemplatePage   tp = new TemplatePage(dc);

            tp.SetTemplateContent("$m=item  KEY:${item.key} Note:${item.note}<br />${m.key}");
            tp.AddVariable("item", new { Key = "Key", Note = "Note" });
            //var x = System.Web.HttpContext.Current.Items;
            string y = tp.ToString();
            // return y;
        }
Beispiel #23
0
        /// <summary>
        /// 获取模板页
        /// </summary>
        /// <param name="filePath">相对于插件目录的文件路径,如插件com.demo引用模板test.html,将test.html放在/plugins/com.demo/下就可以了</param>
        /// <returns></returns>
        public TemplatePage GetPage <T>(string filePath) where T : IPlugin
        {
            if (!this.loaded)
            {
                this.loaded = true;
                this._fpath = String.Format("{0}{1}", Cms.Context.StaticDomain,
                                            CmsVariables.FRAMEWORK_ASSETS_PATH
                                            .Substring(0, CmsVariables.FRAMEWORK_ASSETS_PATH.Length - 1)
                                            );
                this._admJs  = String.Concat("/", Settings.SYS_ADMIN_TAG, "?res=c2NyaXB0&amp;0.5.1.js&amp;ver=", Cms.Version);
                this._admCss = String.Concat("/", Settings.SYS_ADMIN_TAG, "?res=c3R5bGU=&amp;0.5.1.css&amp;ver=", Cms.Version);
            }

            PluginPackAttribute attr = PluginUtil.GetAttribute <T>();
            string pluginDirPath     = String.Concat(PluginConfig.PLUGIN_DIRECTORY, attr.WorkIndent);

            string cacheID = String.Concat("plugin", "_tpl_", attr.WorkIndent, filePath);
            string html    = Cms.Cache.Get(cacheID) as string;

            if (html == null)
            {
                //模板文件放在/plugins/com.spdepository/pages/下
                string tplFilePath = String.Concat(
                    Cms.PyhicPath,
                    pluginDirPath, "/",
                    filePath);

                using (TextReader tr = new StreamReader(tplFilePath))
                {
                    html = tr.ReadToEnd();
                    tr.Dispose();
                }

                Cms.Cache.Insert(cacheID, html, tplFilePath);
            }



            TemplatePage tpl = new TemplatePage();

            tpl.TemplateContent = html;

            tpl.AddVariable("os", new
            {
                version = Cms.Version,
                ppath   = "/" + pluginDirPath,
                fpath   = this._fpath,
                mjs     = this._admJs,
                mcss    = this._admCss
            });
            return(tpl);
        }
Beispiel #24
0
        public string Case_List(HttpContext context)
        {
            if (!RequestProxry.VerifyLogin(context))
            {
                return(null);
            }

            IocObject.Case.UpgradeCaseState();

            TemplatePage page = Cms.Plugins.GetPage <Main>("admin/case_list.html");

            page.AddVariable("page", new PageVariable());
            return(page.ToString());
        }
        public string Partner_VerifyCase_post(HttpContext context)
        {
            string cashNo      = context.Request["s_cashNo"];
            string partnerCode = context.Request["s_partnerCode"];
            string verifyCode  = context.Request["verifyCode"];

            if (!VerifyCodeManager.Compare(verifyCode))
            {
                return(JsonConvert.SerializeObject(new { result = false, message = "验证码不正确!" }));
            }

            Case _case = IocObject.Case.GetCaseByPartnerCodeAndCashNo(partnerCode, cashNo);

            if (_case == null)
            {
                return(JsonConvert.SerializeObject(new { result = false, message = "" }));
            }
            else
            {
                context.Session["partnerCode"] = partnerCode;

                if (_case.State == -2 || _case.State == -1)
                {
                    return(JsonConvert.SerializeObject(new { result = false, message = "案件不存在" }));
                }
                else if (_case.State == 2)
                {
                    return(JsonConvert.SerializeObject(new { result = false, message = "exists" }));
                }
                else
                {
                    TemplatePage page        = Cms.Plugins.GetPage <Main>("html/partner_saveCase.html");
                    string       entityJson  = JsonConvert.SerializeObject(_case);
                    string       galleryJson = JsonConvert.SerializeObject(IocObject.Case.GetGalleryOfCase(_case.Id));
                    page.AddVariable("entity", new { json = entityJson, galleryJson = galleryJson });

                    return(JsonConvert.SerializeObject(new { result = true, html = page.ToString() }));
                }
            }
        }
Beispiel #26
0
        /// <summary>
        /// 获取模板页
        /// </summary>
        /// <param name="filePath">相对于插件目录的文件路径,如插件com.demo引用模板test.html,将test.html放在/plugins/com.demo/下就可以了</param>
        /// <returns></returns>
        public TemplatePage GetPage <T>(string filePath) where T : IPlugin
        {
            PluginPackAttribute attr = PluginUtil.GetAttribute <T>();
            string pluginDirPath     = String.Concat(PluginConfig.PLUGIN_DIRECTORY, attr.WorkIndent);

            string cacheID = String.Concat("plugin", "_tpl_", attr.WorkIndent, filePath);
            string html    = Cms.Cache.Get(cacheID) as string;

            if (html == null)
            {
                //模板文件放在/plugins/com.spdepository/pages/下
                string tplFilePath = String.Concat(
                    Cms.PyhicPath,
                    pluginDirPath, "/",
                    filePath);

                using (TextReader tr = new StreamReader(tplFilePath))
                {
                    html = tr.ReadToEnd();
                    tr.Dispose();
                }
                Cms.Cache.Insert(cacheID, html, tplFilePath);
            }


            TemplatePage tpl = new TemplatePage();

            tpl.TemplateContent = html;
            tpl.AddVariable("os", new
            {
                version = Cms.Version,
                ppath   = String.Format("/{0}", pluginDirPath),
                fpath   = String.Format("{0}{1}", Cms.Context.StaticDomain,
                                        CmsVariables.FRAMEWORK_ASSETS_PATH
                                        .Substring(0, CmsVariables.FRAMEWORK_ASSETS_PATH.Length - 1)
                                        )
            });
            return(tpl);
        }