Пример #1
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            Log4Net.LogInfo("RegisterRoutes Start");

            routes.Ignore("{resource}.axd");
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            // fixes issues regarding Web Service call from javascript (scripts -> library -> kendo.js)
            routes.Add(new Route("API/{resource}.asmx/{*pathInfo}", new StopRoutingHandler()));

            RouteConfig.RegisterRoutes(RouteTable.Routes);

            // 1-1 mapping of home pages for each .net application
            routes.MapPageRoute("PMTHomeRoute",
                                "PMT/PMT/Home",
                                "~/BM/PMO/Default.aspx",
                                true);

            routes.MapPageRoute("TEHomeRoute",
                                "TE/TE/Home",
                                "~/BM/Scheduling/Default.aspx",
                                true);

            routes.MapPageRoute("PDTMGMDEVTHomeRoute",
                                "PDTMGMDEVT/PDTMGMDEVT/Home",
                                "~/BM/RequirementAnalysis/Default.aspx",
                                true);

            routes.MapPageRoute("PrototypeHomeRoute",
                                "Prototype/Prototype/Home",
                                "~/Prototype/Default.aspx",
                                true);

            routes.MapPageRoute("SAHomeRoute",
                                "SA/SA/Home",
                                "~/Shared/SA/Default.aspx",
                                true);

            //routes.MapPageRoute("LegalHomeRoute",
            //	"Legal/Home",
            //	"~/BM/Legal/Default.aspx",
            //	true);

            var systemRequestProfile = GetStartupProfile();

            var dtRoutes     = ApplicationRouteDataManager.GetList(systemRequestProfile);
            var dtParameters = ApplicationRouteParameterDataManager.GetList(systemRequestProfile);

            // add routes which maps default pages to search first
            var searchRouteRows = dtRoutes.Select("RouteName LIKE '%EntityRouteSearch'");

            if (searchRouteRows.Length > 0)
            {
                foreach (DataRow dr in searchRouteRows)
                {
                    var proposedRoute = "{applicationCode}/{applicationModule}/" + Convert.ToString(dr[ApplicationRouteDataModel.DataColumns.ProposedRoute]);
                    var relativeRoute = Convert.ToString(dr[ApplicationRouteDataModel.DataColumns.RelativeRoute]);
                    var routeName     = Convert.ToString(dr[ApplicationRouteDataModel.DataColumns.RouteName]);

                    // MapPageRoute provides a way to define routes for Web Forms applications.
                    routes.MapPageRoute(routeName, proposedRoute, relativeRoute, true);
                }
            }

            // add other routes
            searchRouteRows = dtRoutes.Select("RouteName NOT LIKE '%EntityRouteSearch'");
            if (searchRouteRows.Length > 0)
            {
                foreach (DataRow dr in searchRouteRows)
                {
                    var proposedRoute = "{applicationCode}/{applicationModule}/" + Convert.ToString(dr[ApplicationRouteDataModel.DataColumns.ProposedRoute]);
                    var relativeRoute = Convert.ToString(dr[ApplicationRouteDataModel.DataColumns.RelativeRoute]);
                    var appRouteId    = Convert.ToInt32(dr[ApplicationRouteDataModel.DataColumns.ApplicationRouteId]);
                    var routeName     = Convert.ToString(dr[ApplicationRouteDataModel.DataColumns.RouteName]);

                    var routeParamList  = new RouteValueDictionary();
                    var routeParameters = dtParameters.Select(ApplicationRouteParameterDataModel.DataColumns.ApplicationRouteId + " = " + appRouteId);

                    if (routeParameters.Length > 0)
                    {
                        foreach (DataRow drParam in routeParameters)
                        {
                            var key   = drParam[ApplicationRouteParameterDataModel.DataColumns.ParameterName];
                            var value = drParam[ApplicationRouteParameterDataModel.DataColumns.ParameterValue];

                            routeParamList.Add(key.ToString(), value.ToString());
                        }

                        routeParamList.Add("applicationCode", "PMT");
                        //routeParamList.Add("applicationModule", "AA");
                    }

                    // MapPageRoute provides a way to define routes for Web Forms applications.
                    routes.MapPageRoute(routeName, proposedRoute, relativeRoute, true, routeParamList);
                }
            }

            //routes.MapRoute(
            //	name: "Default",
            //	url: "{controller}/{action}/{id}",
            //	defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
            //	namespaces: new[] { "Areas.Controllers" }
            //);

            //// Single Page Routing Example of a test page
            //routes.MapPageRoute("testRoute",
            //	"Test/TestPaging",
            //	"~/Shared/ApplicationManagement/Development/TestPaging/Test.aspx",
            //	true);

            //routes.MapPageRoute("testAng",
            //	"Test/Home",
            //	"~/Test/Home/Index.cshtml",
            //	false);

            //routes.MapPageRoute("TestPage1",
            //	"Page1",
            //	"~/Areas/AngularTest/app/app.js",
            //	false);

            //routes.MapPageRoute("d", "abcd", "~/Areas/AngularTest/app/core/views/nav.html", false);

            Log4Net.LogInfo("RegisterRoutes End");
        }