Exemplo n.º 1
0
        public ActionResult PoiGroup(string id, string exitId, string poiTypeString)
        {
            long          osmId;
            RouteJunction routeJunction = null;

            StopByStop.Route route = GetRouteFromRoutePathId(id);

            if (route != null)
            {
                routeJunction = GetJunctionFromExitId(exitId, out osmId);
            }

            if (routeJunction == null)
            {
                if (route != null)
                {
                    routeJunction = route.RouteSegments
                                    .SelectMany(rs => rs.RouteJunctions)
                                    .SingleOrDefault(rj => rj.Junction.SBSID.Equals(exitId, StringComparison.OrdinalIgnoreCase));

                    if (routeJunction != null)
                    {
                        telemetryClient.TrackEvent("PoiGroupToOSMFormatRedirect");
                        string requestFullUrl = HttpContext.Request.Url.ToString();
                        string redirectUrl    = requestFullUrl
                                                .Substring(0, requestFullUrl.IndexOf("route")) +
                                                string.Format("route/{0}/exit/osm-{1}/{2}", id, routeJunction.Junction.OSMID, poiTypeString);

                        return(RedirectPermanent(redirectUrl));
                    }
                }
                else
                {
                    telemetryClient.TrackEvent("RouteNotFound",
                                               new Dictionary <string, string>()
                    {
                        { "MissingRoute", id }
                    });
                    telemetryClient.TrackException(
                        new InvalidOperationException(string.Format("PoiGroup Action - Cannot find route. id={0}, exitId={1}", id, exitId)));

                    return(RedirectToAction("Index", "Home"));
                }
            }


            PoiType poiType = PoiType.General;
            var     model   = new MainModel(this.Url)
            {
                Page    = ClientPage.Route,
                RouteId = id,
                Route   = route,
                ExitId  = exitId,
            };

            if (routeJunction != null)
            {
                switch (poiTypeString.ToLowerInvariant())
                {
                case "gas":
                    poiType = PoiType.Gas;
                    break;

                case "food":
                    poiType = PoiType.Food;
                    break;
                }

                model.Page    = ClientPage.Exit;
                model.ExitId  = exitId;
                model.PoiType = poiType;
            }
            else
            {
                if (route != null)
                {
                    telemetryClient.TrackEvent("ExitNotFound",
                                               new Dictionary <string, string>()
                    {
                        { "MissingExit", id + "/" + exitId }
                    });
                    telemetryClient.TrackException(
                        new InvalidOperationException(string.Format("PoiGroup Action - Cannot find exit. id={0}, exitId={1}", id, exitId)));
                    model.Page = ClientPage.Route;
                }
                else
                {
                    telemetryClient.TrackEvent("RouteNotFound",
                                               new Dictionary <string, string>()
                    {
                        { "MissingRoute", id }
                    });
                    telemetryClient.TrackException(
                        new InvalidOperationException(string.Format("PoiGroup Action - Cannot find route. id={0}, exitId={1}", id, exitId)));
                    model.Page = ClientPage.Home;
                }
            }

            return(View("~/client/Views/Main.cshtml", new MainModel(this.Url)
            {
                Page = ClientPage.Exit,
                RouteId = id,
                Route = route,
                ExitId = exitId,
                PoiType = poiType
            }));
        }
Exemplo n.º 2
0
 public JsonResult RouteJsonData(string id)
 {
     StopByStop.Route route = GetRouteFromRoutePathId(id);
     return(Json(route, JsonRequestBehavior.AllowGet));
 }