Exemple #1
0
        /// <summary>
        /// 获取分页内容
        /// </summary>
        /// <returns></returns>
        public ExtPageModel GetPageModels(System.Web.HttpContext context)
        {
            ExtPageModel  extPageModel = new ExtPageModel();
            string        urlHost      = GetHost(context);
            WebSiteApp    app          = new WebSiteApp();
            WebSiteEntity entity       = app.GetModelByUrlHost(urlHost);

            if (entity != null && !string.IsNullOrWhiteSpace(entity.Id))
            {
                string strRqs = context.Request["pageDatas"];
                if (!string.IsNullOrEmpty(strRqs))
                {
                    ExtPageModel extPageModelReq = Json.ToObject <ExtPageModel>(strRqs);
                    string       cIds            = GetColumnIds(context);
                    extPageModelReq.SourceIds = cIds;

                    string attrDatas = context.Request["attrDatas"];
                    if (!string.IsNullOrEmpty(attrDatas))
                    {
                        extPageModelReq.AttrDatas = Json.ToObject <Dictionary <string, string> >(attrDatas);
                    }
                    extPageModel = new TempHelp().GetContentModels(extPageModelReq, entity.ShortName);
                }
            }
            return(extPageModel);
        }
Exemple #2
0
        /// <summary>
        /// 根据模板名称获取模板信息
        /// </summary>
        /// <returns></returns>
        private string GetHtmlsByTempletName(string name, string Id)
        {
            string          strs       = "";
            C_TempletApp    templetapp = new C_TempletApp();
            C_TempletEntity templet    = templetapp.GetFormByName(name);

            if (templet != null)
            {
                string   templets = System.Web.HttpUtility.HtmlDecode(templet.F_Content);
                TempHelp temphelp = new TempHelp();
                strs = temphelp.GetHtmlPages(templets, Id);
            }
            return(strs);
        }
Exemple #3
0
        /// <summary>
        /// 处理请求
        /// </summary>
        /// <param name="context"></param>
        public void InitRequest(System.Web.HttpContext context)
        {
            if (ConfigHelp.configHelp.ISPROREQUEST)
            {
                string htmls = string.Empty;
                try
                {
                    string urlHost = GetHost(context);
                    string urlRaw  = context.Request.RawUrl.ToString();
                    urlRaw = context.Server.UrlDecode(urlRaw);
                    bool isShoudPre = false;
                    if (IsLoginHost(context))
                    {
                        if (Code.ConfigHelp.configHelp.LOGINHOST != LOGINHOSTCONFIGALLMARK)
                        {
                            if (string.IsNullOrEmpty(urlRaw) || urlRaw == "/")
                            {
                                context.Response.Clear();
                                context.Response.Redirect("/Login/Index", false);
                                context.ApplicationInstance.CompleteRequest();
                            }
                            else
                            if (!IsLoginUrl(context))
                            {
                                isShoudPre = true;
                            }
                        }
                        else
                        if (!IsLoginUrl(context))
                        {
                            isShoudPre = true;
                        }
                    }
                    else
                    {
                        isShoudPre = true;
                    }
                    if (isShoudPre == true)
                    {
                        if (IsProcess(urlHost, urlRaw))
                        {
                            string userAgents = context.Request.UserAgent;
                            bool   isMobile   = IsMobile(userAgents);
                            context.Response.Clear();
                            bool         isNoFind     = false;
                            RequestModel requestModel = new RequestModel();
                            requestModel.UrlHost  = urlHost;
                            requestModel.UrlRaw   = urlRaw;
                            requestModel.IsMobile = isMobile;
                            htmls = new TempHelp().GetHtmlByUrl(requestModel, out isNoFind);
                            if (isNoFind)
                            {
                                context.Response.StatusCode = 404;
                            }
                            else
                            {
                                context.Response.Write(htmls);
                            }
                            //插入访问日志
                            SysPageHelp.sysPageHelp.CreateAccessLog(context, true);
                            context.ApplicationInstance.CompleteRequest();
                        }
                        else
                        {
                            if (IsLoginUrl(context))
                            {
                                context.Response.Clear();
                                context.Response.StatusCode = 404;
                                //插入访问日志
                                SysPageHelp.sysPageHelp.CreateAccessLog(context, true);
                                context.ApplicationInstance.CompleteRequest();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    context.Response.Clear();
                    context.Response.StatusCode = 500;
                    context.ApplicationInstance.CompleteRequest();

                    LogFactory.GetLogger(this.GetType()).Error("异常:" + ex.Message + "\r\n" + JsonConvert.SerializeObject(ex) + "\r\n");
                    //throw;
                }
            }
        }