private void RoutedContent(object sender, RoutingEventArgs e) { var httpContext = _httpContextAccessor(); var routingContext = e.RoutingSegmentContext; var request = httpContext?.Request; if (request != null && request.AcceptTypes.Contains(RoutingConstants.JsonContentType)) { //make sure routed language is first in accept language header var language = routingContext.Language ?? routingContext.ContentLanguage ?? ContentLanguage.PreferredCulture.Name; var acceptLanguageHeader = request.Headers[RoutingConstants.AcceptLanguage]; request.Headers[RoutingConstants.AcceptLanguage] = string.IsNullOrEmpty(acceptLanguageHeader) ? language : $"{language}, { acceptLanguageHeader}"; var property = routingContext.GetCustomRouteData <string>(RoutingConstants.RoutedPropertyKey); var shouldGetChildren = routingContext.GetCustomRouteData <string>(RoutingConstants.ChildrenKey); var contentApiChildPath = $"/{EPiServer.ContentApi.RouteConstants.BaseContentApiRoute}content/{routingContext.RoutedContentLink}/children"; if (bool.TryParse(shouldGetChildren, out bool result) && result) { httpContext.RewritePath(contentApiChildPath); } else { httpContext.RewritePath(property != null ? $"/{EPiServer.ContentApi.RouteConstants.BaseContentApiRoute}content/{routingContext.RoutedContentLink}?{RoutingConstants.RoutedPropertyKey}={property}" : $"/{EPiServer.ContentApi.RouteConstants.BaseContentApiRoute}content/{routingContext.RoutedContentLink}"); } //Set RouteData to null to pass the request to next routes (WebApi route) e.RoutingSegmentContext.RouteData = null; } }
private void ContentRoute_RoutedContent(object sender, RoutingEventArgs e) { var experimentProjectIdentifier = ServiceLocator.Current.GetInstance <IExperimentProjectIdentifier>(); var d = experimentProjectIdentifier.GetProjectVersion(e.RoutingSegmentContext.RoutedContentLink, new HttpContextWrapper(HttpContext.Current)); e.RoutingSegmentContext.RoutedContentLink = d; }
private void OnRoutedContent(object sender, RoutingEventArgs e) { var httpContext = HttpContext.Current; if (httpContext == null) { return; } var shouldSerializeStrategy = ServiceLocator.Current.GetInstance <IShouldSerializeResponseStrategy>(); if (!shouldSerializeStrategy.Execute(httpContext.Request)) { return; } var contentLink = e.RoutingSegmentContext.RoutedContentLink; var contentLoader = ServiceLocator.Current.GetInstance <IContentLoader>(); contentLoader.TryGet <IContent>(contentLink, out var content); if (content == null) { return; } e.CancelFurtherRouting = true; var serializer = ServiceLocator.Current.GetInstance <IContentApiSerializer>(); var result = serializer.Serialize(content); httpContext.Response.ContentType = httpContext.Request.AcceptTypes?.First(); httpContext.Response.Write(result); httpContext.Response.Flush(); httpContext.Response.End(); }
private void RoutedContent(object sender, RoutingEventArgs e) { var httpContext = _httpContextAccessor(); var routingContext = e.RoutingSegmentContext; var request = httpContext?.Request; if (request != null && request.AcceptTypes.Contains(RoutingConstants.JsonContentType)) { //make sure routed language is first in accept language header var language = routingContext.Language ?? routingContext.ContentLanguage ?? ContentLanguage.PreferredCulture.Name; var acceptLanguageHeader = request.Headers[RoutingConstants.AcceptLanguage]; request.Headers[RoutingConstants.AcceptLanguage] = string.IsNullOrEmpty(acceptLanguageHeader) ? language : $"{language}, { acceptLanguageHeader}"; //we need to consider the application path of the request in case the app is hosted in a virtual directory in IIS var applicationPath = VirtualPathUtility.AppendTrailingSlash(request.ApplicationPath); var property = routingContext.GetCustomRouteData <string>(RoutingConstants.RoutedPropertyKey); httpContext.RewritePath(property != null ? $"{applicationPath}{RouteConstants.BaseContentApiRoute}content/{routingContext.RoutedContentLink}?{RoutingConstants.RoutedPropertyKey}={property}" : $"{applicationPath}{RouteConstants.BaseContentApiRoute}content/{routingContext.RoutedContentLink}"); //Set RouteData to null to pass the request to next routes (WebApi route) e.RoutingSegmentContext.RouteData = null; } }
private void OnRoutingContent(object sender, RoutingEventArgs e) { PartialViewsInAreasRegistrar.Register(new HttpContextWrapper(HttpContext.Current)); var contentRouteEvents = ServiceLocator.Current.GetInstance <IContentRouteEvents>(); contentRouteEvents.RoutingContent -= OnRoutingContent; }
private void output_ReceivedData(object sender, RoutingEventArgs e) { if (e.Index < 0 || e.Index > device.Buffers.Length) { throw new ArgumentOutOfRangeException("e", "Output index exceeds number of outputs on the Asio device"); } device.Buffers[e.Index] = e.Buffer; if (isAllDataReceived()) { processFrame(); } }
public void OnNavigating(RoutingEventArgs routingEvent) { var search = routingEvent.To.ViewModel as SearchViewModel; if (search == null) { return; } if (!String.IsNullOrEmpty(_ApplicationConfiguration.Token)) { return; } routingEvent.RedirectToroute("authentication"); var first = routingEvent.From.ViewModel == null; var confirmationMessage = BuildEmptyTokenMessage(first); _MessageBox.ShowInformation(confirmationMessage); }
public void OnNavigating(RoutingEventArgs routingEvent) { }
private void Router_OnNavigating(object sender, RoutingEventArgs e) { _ApplicationLifeCycle.OnNavigating(e); }
private void RouteCompleted(object sender, RoutingEventArgs e) { gisRouting.ResetFinishedEvent(RouteCompleted); // Present the results gisOperations.GetSelectLayer().ClearGraphics(); RoutingData routingData = e.RoutingResult; gisOperations.GetRoutingLayer().ClearGraphics(); gisOperations.GetRoutingLayer().Graphics.Add(routingData.RouteGraphic); gisOperations.ZoomTo(routingData.RouteGraphic.Geometry); int i = 0; foreach (var item in routingData.RouteDirections.Features) { System.Text.StringBuilder infoText = new System.Text.StringBuilder(); infoText.AppendFormat("{0}. {1}", ++i, item.Attributes["text"]); if (i > 0 && i < routingData.RouteDirections.Features.Count - 1) { string distance = FormatDistance(Convert.ToDouble(item.Attributes["length"]), "km"); string time = null; if (item.Attributes.ContainsKey("time")) { time = FormatTime(Convert.ToDouble(item.Attributes["time"])); } if (!string.IsNullOrEmpty(distance) || !string.IsNullOrEmpty(time)) infoText.Append(" ("); infoText.Append(distance); if (!string.IsNullOrEmpty(distance) && !string.IsNullOrEmpty(time)) infoText.Append(", "); infoText.Append(time); if (!string.IsNullOrEmpty(distance) || !string.IsNullOrEmpty(time)) infoText.Append(")"); } // Set rendering symbol at the location Polyline polyline = item.Geometry as Polyline; ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection> pointCollections = polyline.Paths; // Process all segments foreach (var path in pointCollections) { // Skip first point for every segment MapPoint point = path.LastOrDefault(); if (point != null && !IsStopPoint(point)) { point.SpatialReference = routingData.RouteGraphic.Geometry.SpatialReference; Graphic graphic = new Graphic() { Geometry = point, Symbol = gisRouting.GetWayPointRouteSymbol() }; gisOperations.GetRoutingLayer().Graphics.Add(graphic); } } if (locationInputViewModel != null) { locationInputViewModel.RouteDirections.Add(infoText.ToString()); } } foreach (var item in stopPoints) { Graphic graphic = new Graphic() { Geometry = new MapPoint(item.X, item.Y, item.SpatialReference), Symbol = gisRouting.GetStopRouteSymbol() }; gisOperations.GetRoutingLayer().Graphics.Add(graphic); } locationInputViewModel.RefreshRoute(); }
/// <summary> /// Event executed when the calculation is finished. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void Route_Complete(object sender, CalculateRouteCompletedEventArgs args) { try { gisOperations.EnableDrawMode(); RoutingEventArgs routeArgs = new RoutingEventArgs(); List<string> directions = new List<string>(); if (args.Error != null) { directions.Add(args.Error.Message); routeArgs.RoutingResult.Directions = directions; } else { ObservableCollection<RouteLeg> routeLegs = args.Result.Result.Legs; int numLegs = routeLegs.Count; int instructionCount = 0; for (int n = 0; n < numLegs; n++) { directions.Add(string.Format("--Leg #{0}--\n", n + 1)); foreach (ItineraryItem item in routeLegs[n].Itinerary) { instructionCount++; directions.Add(string.Format("{0}. {1}\n", instructionCount, item.Text)); } } Regex regex = new Regex("<[/a-zA-Z:]*>", RegexOptions.IgnoreCase | RegexOptions.Multiline); RoutePath routePath = args.Result.Result.RoutePath; Polyline line = new Polyline(); line.Paths.Add(new PointCollection()); foreach (Location location in routePath.Points) line.Paths[0].Add(mercator.FromGeographic(new MapPoint(location.Longitude, location.Latitude)) as MapPoint); Graphic graphic = new Graphic() { Geometry = line, Symbol = this.lineRouteSymbol as Symbol }; graphicsRouteLayer.Graphics.Add(graphic); routeArgs.RoutingResult.Directions = directions; routeArgs.RoutingResult.RouteLine = line; } gisOperations.DisableDrawMode(); OnRoutingCalcComplete(routeArgs); } catch (Exception ex) { messageBoxCustom.Show(String.Format("Route_Complete /{0}", ex.Message), GisTexts.SevereError, MessageBoxCustomEnum.MessageBoxButtonCustom.Ok); } }
private void RouteSolvedComplete(object sender, RouteEventArgs a) { try { routeTask.SolveCompleted -= RouteSolvedComplete; WebMercator webMercator = new WebMercator(); RoutingEventArgs routingEvent = new RoutingEventArgs(); ESRI.ArcGIS.Client.Tasks.RouteResult routeResult = a.RouteResults[0]; routeResult.Route.Symbol = lineRouteSymbol; routingEvent.RoutingResult.RouteGraphic = routeResult.Route; SpatialReference initialSpatialReference = routingEvent.RoutingResult.RouteGraphic.Geometry.SpatialReference; routingEvent.RoutingResult.RouteGraphic.Geometry = webMercator.FromGeographic(routeResult.Route.Geometry); routingEvent.RoutingResult.RouteName = a.UserState as string; routingEvent.RoutingResult.RouteDirections = routeResult.Directions; foreach (var item in routingEvent.RoutingResult.RouteDirections) { item.Geometry.SpatialReference = initialSpatialReference; item.Geometry = webMercator.FromGeographic(item.Geometry); } OnRoutingCalcComplete(routingEvent); } catch (Exception ex) { messageBoxCustom.Show(String.Format("RouteSolvedComplete /{0}", ex.Message), GisTexts.SevereError, MessageBoxCustomEnum.MessageBoxButtonCustom.Ok); } }
/// <summary> /// Callback for the routing calculation /// </summary> /// <param name="e"></param> protected virtual void OnRoutingCalcComplete(RoutingEventArgs e) { if (routingComplete != null) { routingComplete(this, e); } }