Esempio n. 1
0
        protected void UseAction(ControllerContext controllerContext,
                                 Action <ControllerContext, AreaRoute> action)
        {
            AreaRoute areaRoute = AreaRoute.None;

            if (controllerContext.RouteData != null && controllerContext.RouteData.DataTokens != null &&
                controllerContext.RouteData.DataTokens.ContainsKey("area"))
            {
                areaRoute = MvcApplication.GetCurrentAreaRoute(
                    controllerContext.RouteData.DataTokens["area"]);
            }
            //TODO: 暂时仅对CMS/SNS/Shop/MShop进行版本保护 BEN ADD 20130312
            switch (areaRoute)
            {
            case AreaRoute.SNS:
            case AreaRoute.CMS:
            case AreaRoute.Shop:
            case AreaRoute.MShop:
                action(controllerContext, areaRoute);
                break;

            case AreaRoute.None:
            case AreaRoute.UserCenter:
            case AreaRoute.Tao:
            case AreaRoute.COM:
            default:
                break;
            }
        }
Esempio n. 2
0
        public override ViewEngineResult FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache)
        {
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }
            if (string.IsNullOrEmpty(partialViewName))
            {
                throw new ArgumentException("partialViewName must be specified.", "partialViewName");
            }

            AreaRoute areaRoute = MvcApplication.GetCurrentAreaRoute(controllerContext);

            return(FindView(areaRoute, controllerContext, partialViewName, useCache, true));
        }
Esempio n. 3
0
        public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName,
                                                  string masterName, bool useCache)
        {
            if (controllerContext == null)
            {
                throw new ArgumentNullException("controllerContext");
            }

            if (!MvcApplication.IsInstall)  //安装检测
            {
                controllerContext.HttpContext.Response.Redirect("/Installer/Default.aspx", true);
                controllerContext.HttpContext.Response.End();
                return(null);
            }
            if (string.IsNullOrEmpty(viewName))
            {
                throw new ArgumentException("FindView ArgumentException: viewName must be specified.", "viewName");
            }

            AreaRoute areaRoute = MvcApplication.GetCurrentAreaRoute(controllerContext);

            return(FindView(areaRoute, controllerContext, viewName, useCache, false, masterName));
        }
Esempio n. 4
0
        public static MvcHtmlString YSWLSEO(this HtmlHelper htmlHelper, bool PoweredBy = true, string Title = null, string Keywords = null, string Description = null)
        {
            bool hasTitle       = !string.IsNullOrWhiteSpace(Title);
            bool hasKeywords    = !string.IsNullOrWhiteSpace(Keywords);
            bool hasDescription = !string.IsNullOrWhiteSpace(Description);

            Title += !MvcApplication.IsAuthorize && PoweredBy ? P_DATA : string.Empty;
            string newline = htmlHelper.ViewContext.HttpContext.Response.Output.NewLine + "        ";

            System.Text.StringBuilder baseHead = new System.Text.StringBuilder();
            baseHead.AppendFormat("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />{0}", newline);

            if (!hasTitle && htmlHelper.ViewData.ContainsKey("Title"))
            {
                Title = htmlHelper.ViewData["Title"] + Title;
            }

            baseHead.AppendFormat("<title>{1}</title>{0}", newline, Title);

            if (!MvcApplication.IsAuthorize)
            {
                baseHead.AppendFormat("<meta name=\"generator\" content=\"{0} {1}\" />{2}", MvcApplication.ProductInfo, MvcApplication.Version, newline);
                baseHead.AppendFormat("<meta name=\"author\" content=\"{0}\" />{1}", C_DATA, newline);
                baseHead.AppendFormat("<meta name=\"copyright\" content=\"2011-{0} YSWL Inc.\" />{1}", DateTime.Now.Year, newline);
            }

            if (!hasKeywords && htmlHelper.ViewData.ContainsKey("Keywords"))
            {
                Keywords = htmlHelper.ViewData["Keywords"] + Keywords;
            }

            if (!hasDescription && htmlHelper.ViewData.ContainsKey("Description"))
            {
                Description = htmlHelper.ViewData["Description"] + Description;
            }

            baseHead.AppendFormat("<meta name=\"keywords\" content=\"{1}\">{0}", newline, Keywords);
            baseHead.AppendFormat("<meta name=\"description\" content=\"{1}\">{0}", newline, Description);

            AreaRoute areaRoute = AreaRoute.None;

            if (htmlHelper.ViewContext.RouteData != null &&
                htmlHelper.ViewContext.RouteData.DataTokens != null &&
                htmlHelper.ViewContext.RouteData.DataTokens.ContainsKey("area"))
            {
                areaRoute = MvcApplication.GetCurrentAreaRoute(
                    htmlHelper.ViewContext.RouteData.DataTokens["area"]);
            }
            switch (areaRoute)
            {
            case AreaRoute.SNS:
                //baseHead.AppendFormat(
                //    "<link href=\"/Areas/SNS/Themes/" + ThemeName + "/Content/css/style.css\" rel=\"stylesheet\" type=\"text/css\" />");
                break;

            case AreaRoute.CMS:
                baseHead.AppendFormat(
                    "<link href=\"/Areas/CMS/Themes/" + MvcApplication.ThemeName + "/Content/Css/Site.css\" rel=\"stylesheet\" type=\"text/css\" />");
                break;

            case AreaRoute.None:
            case AreaRoute.Shop:
            case AreaRoute.UserCenter:
            case AreaRoute.Tao:
            case AreaRoute.COM:
            default:
                break;
            }
            return(new MvcHtmlString(baseHead.ToString()));
        }
Esempio n. 5
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            #region 安装检测
            if (!MvcApplication.IsInstall)
            {
                filterContext.Result = Redirect("/Installer/Default.aspx");
                return; //未安装 终止
            }
            #endregion


            string tagStr = Request.Params["tag"];
            #region 设置企业标识

            long enterpriseId = 0;
            if (MvcApplication.IsAutoConn)
            {
                #region 读取APP加密企业ID

                if (enterpriseId == 0)
                {
                    //手机登录时候做处理
                    string userAgent       = Request.UserAgent;
                    string enterPriseValue = Request.Headers["YSWL_SAAS_EnterpriseID"];
                    string userValue       = Request.Headers["YSWL_SAAS_UserName"];
                    if (!string.IsNullOrEmpty(userAgent) && userAgent.Contains("ys56") &&
                        !string.IsNullOrEmpty(enterPriseValue) && !string.IsNullOrEmpty(userValue))
                    {
                        enterpriseId = Common.DEncrypt.DEncrypt.ConvertToNumber(enterPriseValue);
                    }
                }
                #endregion

                //优先处理传值过来的
                if (!string.IsNullOrWhiteSpace(tagStr))
                {
                    enterpriseId = Common.DEncrypt.DEncrypt.ConvertToNumber(tagStr);
                }

                if (enterpriseId == 0)
                {
                    Session.Timeout = 60;
                    enterpriseId    = Globals.SafeLong(Session["YSWL_Auto_EnterpriseID"], 0);//保存在session里面
                }

                //Shop域名
                if (enterpriseId == 0 && MvcApplication.ProductInfo.Contains("Mall"))
                {
                    string host = string.Empty;
                    if (filterContext.HttpContext.Request.Url != null)
                    {
                        host = filterContext.HttpContext.Request.Url.Host.ToLower();
                    }
                }

                if (enterpriseId == 0)
                {
                    //获取cookie中的企业标识
                    string tag = Common.Cookies.getKeyCookie("YSWL_SAAS_EnterpriseID");
                    if (!String.IsNullOrWhiteSpace(tag) && Common.DEncrypt.DEncrypt.ConvertToNumber(tag) > 0)
                    {
                        enterpriseId = Common.DEncrypt.DEncrypt.ConvertToNumber(tag);
                    }
                }

                if (enterpriseId < 1 && MvcApplication.ProductInfo.Contains("Mall"))
                {
                    //域名未登记, 返回404
                    filterContext.Result = new HttpNotFoundResult();
                    FileManage.WriteText(new System.Text.StringBuilder(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + " filterContext.HttpContext.Request.Url.Host:" + filterContext.HttpContext.Request.Url.Host));
                    //                        FileManage.WriteText(new System.Text.StringBuilder("filterContext.HttpContext.Request.ServerVariables['HTTP_HOST']:" + filterContext.HttpContext.Request.ServerVariables["HTTP_HOST"]));
                    return;
                }

                if (enterpriseId > 0)
                {
                    Common.CallContextHelper.SetAutoTag(enterpriseId);
                    Session["YSWL_Auto_EnterpriseID"] = enterpriseId;
                }
                else
                {
                    string returnUrl = Common.ConfigHelper.GetConfigString("SAASLoginUrl");
                    filterContext.Result = Redirect(returnUrl);
                    return; //没有企业信息 跳转到SAAS登陆页面
                }
            }

            #region 个性域名检测
            //SaaS域名
            if (enterpriseId == 0 && MvcApplication.ProductInfo.Contains("SAAS"))
            {
                string host = string.Empty;
                if (filterContext.HttpContext.Request.Url != null)
                {
                    host = filterContext.HttpContext.Request.Url.Host.ToLower();
                }
                //启用个性域名访问
                int entId = 0;//SAASInfo.GetSAASEnterpriseIdByDomain(host);
                //FileManage.WriteText(new System.Text.StringBuilder(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + host + " entId:" + entId));
                if (entId < 0)
                {
                    //域名未登记, 返回404
                    filterContext.Result = new HttpNotFoundResult();
                    FileManage.WriteText(new System.Text.StringBuilder(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff") + " filterContext.HttpContext.Request.Url.Host:" + filterContext.HttpContext.Request.Url.Host));
                    //                        FileManage.WriteText(new System.Text.StringBuilder("filterContext.HttpContext.Request.ServerVariables['HTTP_HOST']:" + filterContext.HttpContext.Request.ServerVariables["HTTP_HOST"]));
                    return;
                }
                if (entId > 0)
                {
                    Common.CallContextHelper.SetAutoTag(entId);
                    Session["YSWL_Auto_EnterpriseID"] = entId;
                }
            }
            #endregion
            #endregion

            #region 动态获取当前区域的基础路径
            ViewBag.CurrentArea = CurrentArea = MvcApplication.GetCurrentAreaRoute(
                filterContext.RouteData.DataTokens["area"]);
            ViewBag.BasePath = MvcApplication.GetCurrentRoutePath(CurrentArea);
            #endregion


            #region 静态站域名
            ViewBag.CurrentArea = CurrentArea = MvcApplication.GetCurrentAreaRoute(
                filterContext.RouteData.DataTokens["area"]);
            ViewBag.BasePath = MvcApplication.GetCurrentRoutePath(CurrentArea);

            ViewBag.StaticHost = MvcApplication.StaticHost;
            #endregion

            #region 获取网站公共设置数据
            CurrentThemeName = MvcApplication.GetCurrentThemeName(CurrentArea);
            //DONE: 更正为动态区域, 模版使用主区域Check是否存在 BEN Modify 2013-05-17
            CurrentThemeName = System.IO.Directory.Exists(
                filterContext.HttpContext.Server.MapPath(
                    "/Areas/" + MvcApplication.MainAreaRoute + "/Themes/" + CurrentThemeName))
                            ? CurrentThemeName
                            : "Default";

            CurrentThemeViewPath = MvcApplication.GetCurrentViewPath(CurrentArea);

            //TODO: 应更正为一个值去处理 TO: 涂 BEN ADD 2013-05-17
            if (CurrentThemeName == "TufenXiang")
            {
                IncludeProduct      = false;
                UserAlbumDetailType = 0;
            }
            ViewBag.SiteName = MvcApplication.SiteName;
            #endregion

            ViewBag.CurrentUserId = -1;
#if isFirstProgram
            //加载已登录用户对象和Style数据, 由子类实现
            if (!InitializeComponent(filterContext))
            {
                return;
            }
#else
            if (InitializeComponent(requestContext.HttpContext))
            {
                base.Initialize(requestContext);
            }
#endif
            //SingleLogin slogin = new SingleLogin();
            //if (slogin.ValidateForceLogin())
            //{
            //    requestContext.HttpContext.Response.Write("<script defer>window.alert('" + Resources.Site.TooltipForceLogin + "');parent.location='" + DefaultLogin + "';</script>");
            //}

            Actions bllAction = new Actions();
            ActHashtab = bllAction.GetHashListByCache();
            if (ActHashtab != null && UserPrincipal != null)
            {
                if (!UserPrincipal.HasPermissionID(GetPermidByActID(Act_DeleteList)))
                {
                    ViewBag.DeleteAuthority = true;
                }
            }
            base.OnActionExecuting(filterContext);
        }