Beispiel #1
0
        internal static void CreateBegin(ControllerContext controllerContext, AreaRoute areaRoute)
        {
            string action = controllerContext.RouteData.Values["action"] as string;

            switch (action)
            {
            case "Footer":
                switch (areaRoute)
                {
                case AreaRoute.SNS:
                case AreaRoute.CMS:
                    controllerContext.HttpContext.Response.Output.WriteLine("<div id='footer' class='footer'>");
                    break;

                case AreaRoute.Shop:
                    controllerContext.HttpContext.Response.Output.WriteLine("<div id='ft' >");
                    break;

                case AreaRoute.MShop:
                    controllerContext.HttpContext.Response.Output.WriteLine("<div id='footer' class='footer'>");
                    break;
                }
                break;
            }
        }
Beispiel #2
0
        internal static void CreateEnd(ControllerContext controllerContext, AreaRoute areaRoute)
        {
            string str2;
            string str = controllerContext.RouteData.Values["action"] as string;
            if (((str2 = str) != null) && (str2 == "Footer"))
            {
                if (string.IsNullOrEmpty(_productInfo))
                {
                    _productInfo = MvcApplication.ProductInfo.Replace(" ", "");
                }
                switch (areaRoute)
                {
                    case AreaRoute.CMS:
                        controllerContext.HttpContext.Response.Output.WriteLine("<div class=\"bot_menu\">{0}<br/>{1}</div>", MvcApplication.IsAuthorize ? string.Format("{0} {1}", MvcApplication.WebPowerBy, MvcApplication.WebRecord) : string.Format("<div class=\"bot_menu\" >" + DATA + "</div><div class=\"bot_menu\"> {1} {2}</div>", new object[] { MvcApplication.Version, MvcApplication.WebPowerBy, MvcApplication.WebRecord, DateTime.Now.Year, _productInfo }), MvcApplication.PageFootJs);
                        return;

                    case AreaRoute.Shop:
                        controllerContext.HttpContext.Response.Output.WriteLine("<div class='copyright'>{0}<br/>{1}</div>", MvcApplication.IsAuthorize ? string.Format("<p> <span class='mr15'>{0}</span> <span>{1}</span></p>", MvcApplication.WebPowerBy, MvcApplication.WebRecord) : string.Format("<p> <span class='mr15'>{1}</span> <span>{2}</span></p><p><span class='mr15'>" + DATA + "</span></p>", new object[] { MvcApplication.Version, MvcApplication.WebPowerBy, MvcApplication.WebRecord, DateTime.Now.Year, _productInfo }), MvcApplication.PageFootJs);
                        return;

                    case AreaRoute.SNS:
                        controllerContext.HttpContext.Response.Output.WriteLine("<div class='clear'></div><div class='footer_bot' style='margin-top: -23px;margin-bottom: 23px'>{0}<br/>{1}<div class='clear'></div></div></div>", MvcApplication.IsAuthorize ? string.Format("{0}<br/>{1}", MvcApplication.WebPowerBy, MvcApplication.WebRecord) : string.Format("<div style=\"float: left;margin-left: 33px;text-align: left;\">" + DATA + "</div><div style=\"float: right;margin-right: 33px;text-align: right;\"> {1} <br /> {2}</div>", new object[] { MvcApplication.Version + "<br/>", MvcApplication.WebPowerBy, MvcApplication.WebRecord, DateTime.Now.Year, _productInfo }), MvcApplication.PageFootJs);
                        return;
                }
            }
        }
Beispiel #3
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;
            }
        }
Beispiel #4
0
        public MvcApplication()
        {
            IsAutoConn = Common.ConfigHelper.GetConfigBool("AutoConnection");

            IsInstall = Common.ConfigHelper.GetConfigBool("Installer");
            if (!IsInstall)
            {
                return;             //未安装 终止
            }
            if (MainArea == null)
            {
                throw new ArgumentNullException("MvcApplication: MainArea Is NULL!");
            }
            MainAreaRoute = Globals.SafeEnum <AreaRoute>(MainArea, AreaRoute.None, true);
            staticHost    = YSWL.Common.ConfigHelper.GetConfigString("StaticWebUrl");

            if (string.IsNullOrWhiteSpace(staticHost))
            {
                staticHost = "http://static.yuns56.cn";
            }
            else
            {
                staticHost = staticHost.TrimEnd('/');
            }
        }
Beispiel #5
0
 public PseudoSim(UserSettings settings)
 {
     Settings = settings;
     State    = new ProcessState("Updater");
     Thread   = new Thread(UpdaterThread);
     Thread.Start();
     mstsItems = new MSTSItems();
     areaRoute = new AreaRoute();
 }
Beispiel #6
0
        public string GetTagString(AreaRoute areaRoute, ControllerContext context)
        {
            if (areaRoute != AreaRoute.CMS && areaRoute != AreaRoute.SNS && areaRoute != AreaRoute.MShop &&
                areaRoute != AreaRoute.MPage && areaRoute != AreaRoute.Supplier && areaRoute != AreaRoute.Shop && areaRoute != AreaRoute.MB && areaRoute != AreaRoute.MBShop && areaRoute != AreaRoute.BShop)
            {
                return(string.Empty);
            }

            return(applicationOption.GetAreaThemeName(areaRoute));
        }
Beispiel #7
0
 /// <summary>
 /// 获取模版名称
 /// </summary>
 public static string GetCurrentThemeName(AreaRoute currentArea)
 {
     if (currentArea == MainAreaRoute)
     {
         return(ThemeName);
     }
     else
     {
         return(ApplicationOption == null ? "Default" : ApplicationOption.GetAreaThemeName(currentArea));
     }
 }
        public void Should_return_the_are_name_from_IRouteWithArea()
        {
            // Arrange
            var route = new AreaRoute();

            // Act
            var areaName = route.GetAreaName();

            // Assert
            Assert.That(areaName, Is.EqualTo("AreaName"));
        }
Beispiel #9
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));
        }
Beispiel #10
0
        public string GetAreaThemeName(AreaRoute areaRoute, ControllerContext context = null)
        {
            switch (areaRoute)
            {
            case AreaRoute.CMS:
                string cmstheme = ColoPay.BLL.SysManage.ConfigSystem.GetValueByCache("CMS_Theme");
                return(string.IsNullOrWhiteSpace(cmstheme) ? "Default" : cmstheme);

            case AreaRoute.Shop:
                string shoptheme = ColoPay.BLL.SysManage.ConfigSystem.GetValueByCache("Shop_Theme");
                return(string.IsNullOrWhiteSpace(shoptheme) ? "PC01" : shoptheme);

            case AreaRoute.SNS:
                string snstheme = ColoPay.BLL.SysManage.ConfigSystem.GetValueByCache("SNS_Theme");
                return(string.IsNullOrWhiteSpace(snstheme) ? "M1" : snstheme);

            case AreaRoute.MPage:
                string mpageTheme = ColoPay.BLL.SysManage.ConfigSystem.GetValueByCache("MPage_Theme");
                return(string.IsNullOrWhiteSpace(mpageTheme) ? "Wap21" : mpageTheme);

            case AreaRoute.Supplier:
                string supTheme = ColoPay.BLL.SysManage.ConfigSystem.GetValueByCache("Supplier_Theme");
                return(string.IsNullOrWhiteSpace(supTheme) ? "M1" : supTheme);

            case AreaRoute.MShop:
                string mshopTheme = ColoPay.BLL.SysManage.ConfigSystem.GetValueByCache("MShop_Theme");
                return(string.IsNullOrWhiteSpace(mshopTheme) ? "MC01" : mshopTheme);

            case AreaRoute.MSNS:
                string msnstheme = ColoPay.BLL.SysManage.ConfigSystem.GetValueByCache("MSNS_Theme");
                return(string.IsNullOrWhiteSpace(msnstheme) ? "VSNS" : msnstheme);

            case AreaRoute.MBShop:
                string mbshoptheme = "Y1";    //ColoPay.BLL.SysManage.ConfigSystem.GetValueByCache("MBShop_Theme");
                return(string.IsNullOrWhiteSpace(mbshoptheme) ? MvcApplication.ThemeName : mbshoptheme);

            case AreaRoute.MB:
                string mbtheme = ColoPay.BLL.SysManage.ConfigSystem.GetValueByCache("MB_Theme");
                return(string.IsNullOrWhiteSpace(mbtheme) ? "MB01" : mbtheme);

            case AreaRoute.BShop:
                string btheme = ColoPay.BLL.SysManage.ConfigSystem.GetValueByCache("BShop_Theme");
                return(string.IsNullOrWhiteSpace(btheme) ? "PB02" : btheme);

            default:
                return(MvcApplication.ThemeName);
            }
        }
Beispiel #11
0
 public MvcApplication()
 {
     if (IsInstall)
     {
         UploadFolder = ConfigHelper.GetConfigString("UploadFolder");
         if (string.IsNullOrWhiteSpace(UploadFolder))
         {
             UploadFolder = "Upload";
         }
         if (this.MainArea == null)
         {
             throw new ArgumentNullException("MvcApplication: MainArea Is NULL!");
         }
         MainAreaRoute = Globals.SafeEnum<AreaRoute>(this.MainArea, AreaRoute.None, true);
     }
 }
Beispiel #12
0
 /// <summary>
 /// 构造区域路由
 /// </summary>
 /// <param name="currentArea">当前区域枚举</param>
 /// <param name="customAreaName">自定义区域名称</param>
 protected void AreaRegistration(AreaRoute currentArea, string customAreaName = null)
 {
     CurrentArea    = currentArea;
     CustomAreaName = customAreaName;
     if (string.IsNullOrWhiteSpace(CustomAreaName))
     {
         CurrentRouteName = string.Format("{0}_Default", AreaName);
         CurrentRoutePath = MvcApplication.MainAreaRoute == currentArea ? "" : AreaName + "/";
         CustomAreaName   = CurrentArea.ToString();
     }
     else
     {
         CurrentRouteName = string.Format("{0}_{1}_Default", AreaName, CustomAreaName);
         CurrentRoutePath = CustomAreaName + "/";
     }
 }
Beispiel #13
0
        internal static void CreateBegin(ControllerContext controllerContext, AreaRoute areaRoute)
        {
            string str2;
            string str = controllerContext.RouteData.Values["action"] as string;
            if (((str2 = str) != null) && (str2 == "Footer"))
            {
                switch (areaRoute)
                {
                    case AreaRoute.CMS:
                    case AreaRoute.SNS:
                        controllerContext.HttpContext.Response.Output.WriteLine("<div id='footer' class='footer'>");
                        return;

                    case AreaRoute.Shop:
                        controllerContext.HttpContext.Response.Output.WriteLine("<div id='ft' >");
                        return;
                }
            }
        }
Beispiel #14
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));
        }
Beispiel #15
0
        /// <summary>
        /// 当前系统是否有指定区域
        /// </summary>
        /// <remarks>在运行池启动时加载目录</remarks>
        /// <param name="area">Area</param>
        public static bool HasArea(AreaRoute area)
        {
            if (area == AreaRoute.None)
            {
                return(false);
            }

            if (HttpContext.Current == null)
            {
                throw new ArgumentNullException();
            }

            if (AreaList.Count < 1)
            {
                #region 加载区域目录
                string mapPath = HttpContext.Current.Server.MapPath("/Areas");
                if (!System.IO.Directory.Exists(mapPath))
                {
                    return(false);
                }

                System.IO.DirectoryInfo   directoryInfo = new System.IO.DirectoryInfo(mapPath);
                System.IO.DirectoryInfo[] subInfos      = directoryInfo.GetDirectories();
                if (subInfos.Length < 1)
                {
                    return(false);
                }

                foreach (System.IO.DirectoryInfo item in subInfos)
                {
                    AreaList.Add(item.Name);
                }
                #endregion
            }

            return(AreaList.Contains(area.ToString()));
        }
Beispiel #16
0
        /// <summary>
        /// 提示给用户信息
        /// </summary>
        /// <param name="status">支付结果</param>
        protected override void DisplayMessage(string status)
        {
            #region 设置提示信息

            //DONE: 采用网关动态参数传递区域, 解决回跳区域问题 BEN ADD 20140114
            //当前区域名称
            AreaRoute area     = this.GetwayDatas.Length > 1 ? YSWL.Common.Globals.SafeEnum(this.GetwayDatas[1], AreaRoute.None) : MvcApplication.MainAreaRoute;
            string    basePath = MvcApplication.GetCurrentRoutePath(area);

            if (!string.IsNullOrWhiteSpace(this.OrderId))
            {
                HttpContext.Current.Session[KEY_ORDERID] = this.OrderId;
            }

            HttpContext.Current.Session[KEY_STATUS] = status;
            #endregion


            switch (status)
            {
            case "success":      //支付成功
                #region 跳转到支付成功页面
                HttpContext.Current.Response.Redirect(basePath + "PayResult/Success");
                #endregion
                return;

            case "gatewaynotfound":     //支付网关不存在
            case "verifyfaild":         //签名验证失败
            case "fail":                //支付失败
            default:
                #region 跳转到支付失败页面
                HttpContext.Current.Response.Redirect(basePath + "PayResult/Fail");
                #endregion
                return;
            }
        }
Beispiel #17
0
 /// <summary>
 /// 构造区域路由
 /// </summary>
 /// <param name="currentArea">当前区域枚举</param>
 /// <param name="customAreaName">自定义区域名称</param>
 protected AreaRegistrationBase(AreaRoute currentArea, string customAreaName = null)
 {
     AreaRegistration(currentArea, customAreaName);
 }
Beispiel #18
0
 public string GetTagString(AreaRoute areaRoute, ControllerContext controllerContext)
 {
     return(string.Empty);
 }
Beispiel #19
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);
        }
Beispiel #20
0
        private ViewEngineResult FindView(AreaRoute areaRoute, ControllerContext controllerContext, string viewName,
                                          bool useCache, bool isPartialView, string masterName = null)
        {
            // Get the name of the controller from the path
            string controller       = controllerContext.RouteData.Values["controller"].ToString();
            string controllerspaces = controllerContext.RouteData.DataTokens["Space"] as string;
            string viewSpaces       = string.Empty;

            //检测命名空间, 识别第二代MVC结构
            //if (namespaces != null && namespaces.Length > 0)
            //{
            //    foreach (string ns in namespaces)
            //    {
            //        if (!ns.EndsWith(".*") && !ns.EndsWith(".Controllers"))
            //        {
            //            controllerFolder = ns.Substring(ns.LastIndexOf('.') + 1);
            //            break;
            //        }
            //    }
            //}
            if (!string.IsNullOrWhiteSpace(controllerspaces))
            {
                viewSpaces = controllerspaces;
            }

            string area = areaRoute.ToString();

            //DONE: 非空时标识使用自定义引擎 子引擎的缓存差异标识 注册子引擎路由时追加, 此参数在回调时回传
            string tmpTag = SubAreaViewEngine.SubEngineMap.ContainsKey(areaRoute)
                ? SubAreaViewEngine.GetTagString(areaRoute, controllerContext)
                : string.Empty;

            // Create the key for caching purposes
            string keyPath = System.IO.Path.Combine(area, controller, MainThemeName, viewSpaces, viewName, tmpTag);

            // Try the cache
            if (useCache)
            {
                //If using the cache, check to see if the location is cached.
                string cacheLocation = ViewLocationCache.GetViewLocation(controllerContext.HttpContext, keyPath);
                if (!string.IsNullOrWhiteSpace(cacheLocation))
                {
                    return(isPartialView
                        ? new ViewEngineResult(CreatePartialView(controllerContext, cacheLocation), this)
                        : new ViewEngineResult(CreateView(controllerContext, cacheLocation, masterName), this));
                }
            }

            // Remember the attempted paths, if not found display the attempted paths in the error message.
            var attempts = new List <string>();

            // Check ViewName 是否是具体路径 具体路径时, 不再以FormatViewPath方式查找
            bool isSpecificPath = viewName.StartsWith("~") || viewName.StartsWith("/");

            if (isSpecificPath)
            {
                if (FileExists(controllerContext, viewName))
                {
                    ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, keyPath, viewName);

                    return(isPartialView
                        ? new ViewEngineResult(CreatePartialView(controllerContext, viewName), this)
                        : new ViewEngineResult(CreateView(controllerContext, viewName, masterName), this));
                }

                // If not found, add to the list of attempts.
                attempts.Add(viewName);
            }
            else
            {
                string[] locationFormats;
                if (areaRoute == AreaRoute.None)
                {
                    locationFormats = ViewLocationFormats;
                }
                else if (SubAreaViewEngine.SubEngineMap.ContainsKey(areaRoute) &&
                         !string.IsNullOrWhiteSpace(tmpTag))
                {
                    locationFormats = SubAreaViewEngine.SubEngineMap[areaRoute](controllerContext,
                                                                                BaseAreaViewLocationFormat, tmpTag);
                }
                else if (SubAreaViewEngine.SubEngineMap.ContainsKey(areaRoute))
                {
                    locationFormats = SubAreaViewEngine.SubEngineMap[areaRoute](controllerContext,
                                                                                BaseAreaViewLocationFormat, string.Empty);
                }
                else
                {
                    locationFormats = AreaViewLocationFormats;
                }

                // for each of the paths defined, format the string and see if that path exists. When found, cache it.
                foreach (string rootPath in locationFormats)
                {
                    string currentPath;
                    if (areaRoute == AreaRoute.None)
                    {
                        //默认模版路径
                        currentPath = string.Format(rootPath, viewName, controller);
                    }
                    else if (string.IsNullOrWhiteSpace(viewSpaces))
                    {
                        //第一代MVC(默认)路径
                        currentPath = string.Format(rootPath, viewName, controller, area);
                    }
                    else
                    {
                        //第二代MVC路径
                        currentPath = string.Format(rootPath, controller + "/" + viewName, viewSpaces, area);
                    }

                    if (FileExists(controllerContext, currentPath))
                    {
                        ViewLocationCache.InsertViewLocation(controllerContext.HttpContext, keyPath, currentPath);

                        return(isPartialView
                            ? new ViewEngineResult(CreatePartialView(controllerContext, currentPath), this)
                            : new ViewEngineResult(CreateView(controllerContext, currentPath, masterName), this));
                    }

                    // If not found, add to the list of attempts.
                    attempts.Add(currentPath);
                }
            }

            // if not found by now, simply return the attempted paths.
            return(new ViewEngineResult(attempts.Distinct().ToList()));
        }
 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     if (!MvcApplication.IsInstall)
     {
         filterContext.Result = this.Redirect("/Installer/Default.aspx");
     }
     else
     {
         this.CurrentArea = MvcApplication.GetCurrentAreaRoute(filterContext.RouteData.DataTokens["area"]);
         ((dynamic) base.ViewBag).BasePath = MvcApplication.GetCurrentRoutePath(this.CurrentArea);
         this.CurrentThemeName = MvcApplication.ThemeName;
         this.CurrentThemeName = Directory.Exists(filterContext.HttpContext.Server.MapPath(string.Concat(new object[] { "/Areas/", MvcApplication.MainAreaRoute, "/Themes/", this.CurrentThemeName }))) ? this.CurrentThemeName : "Default";
         this.CurrentThemeViewPath = MvcApplication.GetCurrentViewPath(this.CurrentArea);
         if (this.CurrentThemeName == "TufenXiang")
         {
             this.IncludeProduct = false;
             this.UserAlbumDetailType = 0;
         }
         ((dynamic) base.ViewBag).SiteName = MvcApplication.SiteName;
         ((dynamic) base.ViewBag).CurrentUid = 0;
         if (this.InitializeComponent(filterContext))
         {
             ActHashtab = new Actions().GetHashListByCache();
             if (((ActHashtab != null) && (this.UserPrincipal != null)) && !this.UserPrincipal.HasPermissionID(this.GetPermidByActID(this.Act_DeleteList)))
             {
                 ((dynamic) base.ViewBag).DeleteAuthority = true;
             }
             base.OnActionExecuting(filterContext);
         }
     }
 }
 public AreaRegistrationBase(AreaRoute currentArea)
 {
     this.CurrentArea = currentArea;
     this.CurrentRouteName = string.Format("{0}_Default", this.AreaName);
     this.CurrentRoutePath = (Maticsoft.Components.MvcApplication.MainAreaRoute == currentArea) ? "" : (this.AreaName + "/");
 }
Beispiel #23
0
 /// <summary>
 /// 获取当前路由的访问路径(前缀)
 /// </summary>
 /// <param name="currentArea">当前路由</param>
 /// <returns>访问前缀</returns>
 public static string GetCurrentRoutePath(AreaRoute currentArea)
 {
     return(currentArea != MvcApplication.MainAreaRoute
                 ? string.Format("/{0}/", currentArea)
                 : "/");
 }
        public void Should_return_the_are_name_from_IRouteWithArea()
        {
            // Arrange
            var route = new AreaRoute();

            // Act
            var areaName = route.GetAreaName();

            // Assert
            Assert.That(areaName, Is.EqualTo("AreaName"));
        }
Beispiel #25
0
 /// <summary>
 /// 上传文件基础路径
 /// </summary>
 /// <example>/Upload/Shop/</example>
 protected static string PathUploadFolderBase(AreaRoute currentArea)
 {
     return(string.Format("/{0}/{1}/", MvcApplication.UploadFolder, currentArea));
 }
Beispiel #26
0
 /// <summary>
 /// 获取当前View的访问路径(前缀)
 /// </summary>
 /// <param name="currentArea">当前路由</param>
 /// <returns>View路径前缀</returns>
 public static string GetCurrentViewPath(AreaRoute currentArea)
 {
     return(currentArea != AreaRoute.None
                 ? string.Format("~/Areas/{0}/Themes/{1}/Views/", currentArea, GetCurrentThemeName(currentArea))
                 : string.Format("~/Views/"));
 }
Beispiel #27
0
        internal static void CreateEnd(ControllerContext controllerContext, AreaRoute areaRoute)
        {
            string action = controllerContext.RouteData.Values["action"] as string;

            switch (action)
            {
            case "Footer":
                if (string.IsNullOrEmpty(_productInfo))
                {
                    _productInfo = MvcApplication.ProductInfo;
                }
                switch (areaRoute)
                {
                case AreaRoute.CMS:
                    controllerContext.HttpContext.Response.Output.WriteLine(
                        "<div class=\"bot_menu\">{0}<br/>{1}</div>",
                        (MvcApplication.IsAuthorize)
                                         ? string.Format("{0} {1}", MvcApplication.WebPowerBy, MvcApplication.WebRecord)
                                         : string.Format(
                            "<div class=\"bot_menu\" >" + DATA + "</div><div class=\"bot_menu\"> {1} {2}</div>",
                            MvcApplication.Version, MvcApplication.WebPowerBy, MvcApplication.WebRecord, DateTime.Now.Year,
                            _productInfo), MvcApplication.PageFootJs);
                    break;

                case AreaRoute.SNS:
                    controllerContext.HttpContext.Response.Output.WriteLine(
                        "<div class='clear'></div><div class='footer_bot' style='margin-top: -23px;margin-bottom: 23px'>{0}<br/>{1}<div class='clear'></div></div></div>",
                        (MvcApplication.IsAuthorize)
                                        ? string.Format("{0}<br/>{1}", MvcApplication.WebPowerBy, MvcApplication.WebRecord)
                                        : string.Format(
                            "<div style=\"float: left;margin-left: 33px;text-align: left;\">" + DATA + "</div><div style=\"float: right;margin-right: 33px;text-align: right;\"> {1} <br /> {2}</div>",
                            MvcApplication.Version + "<br/>", MvcApplication.WebPowerBy, MvcApplication.WebRecord, DateTime.Now.Year,
                            _productInfo), MvcApplication.PageFootJs);
                    break;

                case AreaRoute.Shop:
                    controllerContext.HttpContext.Response.Output.WriteLine(
                        "<div class='copyright'>{0}<br/>{1}</div>",
                        (MvcApplication.IsAuthorize)
                                        ? string.Format("<p> <span class='mr15'>{0}</span> <span>{1}</span></p>", MvcApplication.WebPowerBy, MvcApplication.WebRecord)
                                        : string.Format(
                            "<p> <span class='mr15'>{1}</span> <span>{2}</span></p><p><span class='mr15'>" + DATA + "</span></p>",
                            MvcApplication.Version, MvcApplication.WebPowerBy, MvcApplication.WebRecord, DateTime.Now.Year,
                            _productInfo), MvcApplication.PageFootJs);
                    break;

                case AreaRoute.MShop:
                    controllerContext.HttpContext.Response.Output.WriteLine(
                        "<div class='copyright'>{0}{1}</div>",
                        (MvcApplication.IsAuthorize)
                                    ? (string.IsNullOrWhiteSpace(MvcApplication.WebPowerBy)
                                        ? string.Empty
                                        : string.Format("<p> <span class='mr15'>{0}</span> </p>",
                                                        MvcApplication.WebPowerBy))
                                    : (string.Format(
                                           "<p> <span class='mr15'>{0}</span> </p><p><span class='mr15'>" + DATA2 +
                                           "</span></p>",
                                           MvcApplication.WebPowerBy)), MvcApplication.PageFootJs);
                    break;
                }
                break;
            }
        }
Beispiel #28
0
 public static string GetCurrentViewPath(AreaRoute currentArea)
 {
     if (currentArea == AreaRoute.None)
     {
         return string.Format("~/Views/", new object[0]);
     }
     return string.Format("~/Areas/{0}/Themes/{1}/Views/", currentArea, ThemeName);
 }
Beispiel #29
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()));
        }
Beispiel #30
0
 public static string GetCurrentRoutePath(AreaRoute currentArea)
 {
     if (currentArea == MainAreaRoute)
     {
         return "/";
     }
     return string.Format("/{0}/", currentArea);
 }
 protected static string PathUploadFolderBase(AreaRoute currentArea)
 {
     return string.Format("/{0}/{1}/", Maticsoft.Components.MvcApplication.UploadFolder, currentArea.ToString());
 }