/// <summary>
        /// 返回URL对应路由信息
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        //TODO:DZY[150730] 路由信息获取

        /*
         * TODO可移除
         */
        public JumpUrlRoute GetRouteUrl(string controller, string action, string area, string url)
        {
            InitJumpUrlRoute();
            JumpUrlRoute result = null;

            url        = url.ToLower();
            controller = controller.ToLower();
            action     = action.ToLower();
            area       = area.ToLower();
            List <JumpUrlRoute> sql = JumpUrlRouteData;

            if (!string.IsNullOrWhiteSpace(area))
            {
                sql = sql.FindAll(d => d.Area.ToLower() == area);
            }
            if (!string.IsNullOrWhiteSpace(controller))
            {
                sql = sql.FindAll(d => d.Controller.ToLower() == controller);
            }
            if (!string.IsNullOrWhiteSpace(action))
            {
                sql = sql.FindAll(d => d.Action.ToLower() == action);
            }
            result = sql.Count > 0 ? sql[0] : null;

            if (result == null)
            {
                result = new JumpUrlRoute()
                {
                    PC = url, WAP = url, WX = url
                };
            }
            return(result);
        }
        /// <summary>
        /// 初始移动页面跳转路由列表
        /// </summary>
        //TODO:DZY[150730] 路由初始

        /*
         * _JumpUrlRouteData , 是否需要确认带下划线的成员变量规范
         */
        public void InitJumpUrlRoute()
        {
            _JumpUrlRouteData = new System.Collections.Generic.List <JumpUrlRoute>();
            JumpUrlRoute _tmp = new JumpUrlRoute()
            {
                Action = "Index", Area = "Web", Controller = "UserOrder", PC = @"/userorder", WAP = @"/member/orders", WX = @"/member/orders"
            };

            _JumpUrlRouteData.Add(_tmp);
            _tmp = new JumpUrlRoute()
            {
                Action = "Index", Area = "Web", Controller = "UserCenter", PC = @"/usercenter", WAP = @"/member/center", WX = @"/member/center"
            };
            _JumpUrlRouteData.Add(_tmp);
            _tmp = new JumpUrlRoute()
            {
                Action = "Index", Area = "Web", Controller = "Login", PC = @"/login", WAP = @"/login/entrance", WX = @"/login/entrance"
            };
            _JumpUrlRouteData.Add(_tmp);
            _tmp = new JumpUrlRoute()
            {
                Action = "Home", Area = "Web", Controller = "Shop", PC = @"/shop", WAP = @"/vshop/detail", WX = @"/vshop/detail", IsSpecial = true
            };
            _JumpUrlRouteData.Add(_tmp);
            _tmp = new JumpUrlRoute()
            {
                Action = "Submit", Area = "Web", Controller = "Order", PC = @"/order/submit", WAP = @"/order/SubmiteByCart", WX = @"/order/SubmiteByCart", IsSpecial = true
            };
            _JumpUrlRouteData.Add(_tmp);
        }
        public void InitJumpUrlRoute()
        {
            this._JumpUrlRouteData = new List <JumpUrlRoute>();
            JumpUrlRoute item = new JumpUrlRoute
            {
                Action     = "Index",
                Area       = "Web",
                Controller = "UserOrder",
                PC         = "/userorder",
                WAP        = "/member/orders",
                WX         = "/member/orders"
            };

            this._JumpUrlRouteData.Add(item);
            item = new JumpUrlRoute
            {
                Action     = "Index",
                Area       = "Web",
                Controller = "UserCenter",
                PC         = "/usercenter",
                WAP        = "/member/center",
                WX         = "/member/center"
            };
            this._JumpUrlRouteData.Add(item);
            item = new JumpUrlRoute
            {
                Action     = "Index",
                Area       = "Web",
                Controller = "Login",
                PC         = "/login",
                WAP        = "/login/entrance",
                WX         = "/login/entrance"
            };
            this._JumpUrlRouteData.Add(item);
            item = new JumpUrlRoute
            {
                Action     = "Home",
                Area       = "Web",
                Controller = "Shop",
                PC         = "/shop",
                WAP        = "/vshop/detail",
                WX         = "/vshop/detail",
                IsSpecial  = true
            };
            this._JumpUrlRouteData.Add(item);
            item = new JumpUrlRoute
            {
                Action     = "Submit",
                Area       = "Web",
                Controller = "Order",
                PC         = "/order/submit",
                WAP        = "/order/SubmiteByCart",
                WX         = "/order/SubmiteByCart",
                IsSpecial  = true
            };
            this._JumpUrlRouteData.Add(item);
        }
        public JumpUrlRoute GetRouteUrl(string controller, string action, string area, string url)
        {
            Predicate <JumpUrlRoute> match      = null;
            Predicate <JumpUrlRoute> predicate2 = null;
            Predicate <JumpUrlRoute> predicate3 = null;

            this.InitJumpUrlRoute();
            JumpUrlRoute route = null;

            url        = url.ToLower();
            controller = controller.ToLower();
            action     = action.ToLower();
            area       = area.ToLower();
            List <JumpUrlRoute> jumpUrlRouteData = this.JumpUrlRouteData;

            if (!string.IsNullOrWhiteSpace(area))
            {
                if (match == null)
                {
                    match = d => d.Area.ToLower() == area;
                }
                jumpUrlRouteData = jumpUrlRouteData.FindAll(match);
            }
            if (!string.IsNullOrWhiteSpace(controller))
            {
                if (predicate2 == null)
                {
                    predicate2 = d => d.Controller.ToLower() == controller;
                }
                jumpUrlRouteData = jumpUrlRouteData.FindAll(predicate2);
            }
            if (!string.IsNullOrWhiteSpace(action))
            {
                if (predicate3 == null)
                {
                    predicate3 = d => d.Action.ToLower() == action;
                }
                jumpUrlRouteData = jumpUrlRouteData.FindAll(predicate3);
            }
            route = (jumpUrlRouteData.Count > 0) ? jumpUrlRouteData[0] : null;
            if (route == null)
            {
                route = new JumpUrlRoute
                {
                    PC  = url,
                    WAP = url,
                    WX  = url
                };
            }
            return(route);
        }
Exemple #5
0
        public JumpUrlRoute GetRouteUrl(string controller, string action, string area, string url)
        {
            JumpUrlRoute item;
            string       lower  = controller;
            string       str    = action;
            string       lower1 = area;

            InitJumpUrlRoute();
            JumpUrlRoute jumpUrlRoute = null;

            url    = url.ToLower();
            lower  = lower.ToLower();
            str    = str.ToLower();
            lower1 = lower1.ToLower();
            List <JumpUrlRoute> jumpUrlRouteData = JumpUrlRouteData;

            if (!string.IsNullOrWhiteSpace(lower1))
            {
                jumpUrlRouteData = jumpUrlRouteData.FindAll((JumpUrlRoute d) => d.Area.ToLower() == lower1);
            }
            if (!string.IsNullOrWhiteSpace(lower))
            {
                jumpUrlRouteData = jumpUrlRouteData.FindAll((JumpUrlRoute d) => d.Controller.ToLower() == lower);
            }
            if (!string.IsNullOrWhiteSpace(str))
            {
                jumpUrlRouteData = jumpUrlRouteData.FindAll((JumpUrlRoute d) => d.Action.ToLower() == str);
            }
            if (jumpUrlRouteData.Count > 0)
            {
                item = jumpUrlRouteData[0];
            }
            else
            {
                item = null;
            }
            jumpUrlRoute = item;
            if (jumpUrlRoute == null)
            {
                JumpUrlRoute jumpUrlRoute1 = new JumpUrlRoute()
                {
                    PC  = url,
                    WAP = url,
                    WX  = url
                };
                jumpUrlRoute = jumpUrlRoute1;
            }
            return(jumpUrlRoute);
        }
        /// <summary>
        /// 跳转到手机URL
        /// </summary>
        /// <param name="JumpUrl">为空表示自动处理</param>
        //TODO:DZY[150730] 统一跳转

        /* zjt
         * Url请改为小写 【参数命名规范】
         */
        protected void JumpMobileUrl(ActionExecutingContext filterContext, string url = "")
        {
            string curUrl  = Request.Url.PathAndQuery;
            string jumpUrl = curUrl;
            var    route   = filterContext.RouteData;

            //无路由信息不跳转
            if (route == null)
            {
                return;
            }

            //路由处理
            string controller = route.Values["controller"].ToString().ToLower();
            string action     = route.Values["action"].ToString().ToLower();
            string area       = (route.DataTokens["area"] == null ? "" : route.DataTokens["area"].ToString().ToLower());

            if (area == "mobile" || area == "admin")
            {
                return;  //在移动端跳出
            }
            //Web区域跳转移动端
            if (area == "web")
            {
                IsAutoJumpMobile = true;
            }

            if (this.IsAutoJumpMobile && IsMobileTerminal)
            {
                if (Regex.Match(curUrl, @"\/m(\-.*)?").Length < 1)
                {
                    JumpUrlRoute jurdata = GetRouteUrl(controller, action, area, curUrl);
                    //非手机端跳转
                    switch (visitorTerminalInfo.Terminal)
                    {
                    case EnumVisitorTerminal.WeiXin:
                        if (jurdata != null)
                        {
                            jumpUrl = jurdata.WX;
                        }
                        jumpUrl = @"/m-WeiXin" + jumpUrl;
                        break;

                    case EnumVisitorTerminal.IOS:
                        if (jurdata != null)
                        {
                            jumpUrl = jurdata.WAP;
                        }
                        jumpUrl = @"/m-ios" + jumpUrl;
                        break;

                    default:
                        if (jurdata != null)
                        {
                            jumpUrl = jurdata.WAP;
                        }
                        jumpUrl = @"/m-wap" + jumpUrl;
                        break;
                    }

                    #region 参数特殊处理
                    if (jurdata.IsSpecial)
                    {
                        #region 店铺参数转换
                        if (jurdata.PC.ToLower() == @"/shop")
                        {
                            //商家首页参数处理
                            string strid   = route.Values["id"].ToString();
                            long   shopId  = 0;
                            long   vshopId = 0;
                            if (!long.TryParse(strid, out shopId))
                            {
                                shopId = 0;
                            }
                            if (shopId > 0)
                            {
                                var vshop = ServiceHelper.Create <IVShopService>().GetVShopByShopId(shopId);
                                if (vshop != null)
                                {
                                    vshopId = vshop.Id;
                                }
                            }
                            jumpUrl = jumpUrl + "/" + vshopId.ToString();
                        }
                        #endregion

                        //TODO:LRL 订单页面参数转换

                        /* zjt
                         * TODO可移除,保留注释即可
                         */
                        #region  单页面参数转换
                        if (jurdata.PC.ToLower() == @"/order/submit")
                        {
                            //商家首页参数处理
                            var strcartid = string.Empty;
                            var arg       = route.Values["cartitemids"];
                            if (arg == null)
                            {
                                strcartid = Request.QueryString["cartitemids"];
                            }
                            else
                            {
                                strcartid = arg.ToString();
                            }
                            jumpUrl = jumpUrl + "/?cartItemIds=" + strcartid;
                        }
                        #endregion
                    }
                    #endregion

                    if (!string.IsNullOrWhiteSpace(url))
                    {
                        jumpUrl = url;
                    }
                    string testurl = jumpUrl;
                    testurl = Request.Url.Scheme + "://" + Request.Url.Authority + testurl;
                    //页面不存在
                    if (!IsExistPage(testurl))
                    {
                        if (visitorTerminalInfo.Terminal == EnumVisitorTerminal.WeiXin)
                        {
                            jumpUrl = @"/m-WeiXin/";
                        }
                        else
                        {
                            jumpUrl = @"/m-wap/";
                        }
                    }

                    filterContext.Result = Redirect(jumpUrl);
                }
            }
        }
Exemple #7
0
        protected void JumpMobileUrl(System.Web.Routing.RouteData route, string url = "")
        {
            string pathAndQuery = base.Request.Url.PathAndQuery;
            string wX           = pathAndQuery;

            if (route == null)
            {
                return;
            }
            string lower = route.Values["controller"].ToString().ToLower();
            string str   = route.Values["action"].ToString().ToLower();
            string str1  = (route.DataTokens["area"] == null ? "" : route.DataTokens["area"].ToString().ToLower());

            if (str1 == "mobile")
            {
                return;
            }
            if (str1 == "web")
            {
                IsAutoJumpMobile = true;
            }

            if (IsAutoJumpMobile && IsMobileTerminal && Regex.Match(pathAndQuery, "\\/m(\\-.*)?").Length < 1)
            {
                JumpUrlRoute routeUrl = GetRouteUrl(lower, str, str1, pathAndQuery);
                switch (visitorTerminalInfo.Terminal)
                {
                case EnumVisitorTerminal.WeiXin:
                    {
                        if (routeUrl != null)
                        {
                            wX = routeUrl.WX;
                        }
                        wX = string.Concat("/m-weixin", wX);

                        break;
                    }

                case EnumVisitorTerminal.IOS:
                {
                    if (routeUrl != null)
                    {
                        wX = routeUrl.WAP;
                    }
                    wX = string.Concat("/m-ios", wX);
                    break;
                }

                default:
                {
                    if (routeUrl != null)
                    {
                        wX = routeUrl.WAP;
                    }
                    wX = string.Concat("/m-wap", wX);
                    break;
                }
                }
                if (routeUrl.IsSpecial)
                {
                    if (routeUrl.PC.ToLower() == "/shop")
                    {
                        string str2 = route.Values["id"].ToString();
                        long   num  = 0;
                        long   id   = 0;
                        if (!long.TryParse(str2, out num))
                        {
                            num = 0;
                        }
                        if (num > 0)
                        {
                            VShopInfo vShopByShopId = ServiceHelper.Create <IVShopService>().GetVShopByShopId(num);
                            if (vShopByShopId != null)
                            {
                                id = vShopByShopId.Id;
                            }
                        }
                        wX = string.Concat(wX, "/", id.ToString());
                    }
                    if (routeUrl.PC.ToLower() == "/order/submit")
                    {
                        string empty = string.Empty;
                        object item  = route.Values["cartitemids"];
                        empty = (item != null ? item.ToString() : base.Request.QueryString["cartitemids"]);
                        wX    = string.Concat(wX, "/?cartItemIds=", empty);
                    }
                }
                if (!string.IsNullOrWhiteSpace(url))
                {
                    wX = url;
                }
                if (!IsExistPage(string.Concat(base.Request.Url.Scheme, "://", base.Request.Url.Authority, wX)))
                {
                    wX = (visitorTerminalInfo.Terminal != EnumVisitorTerminal.WeiXin ? "/m-wap/" : "/m-weixin/");
                }
                base.Response.Redirect(wX);
            }
        }