public static GpxParser GetGpxParser(string gpxPath) { gpxPath = gpxPath.ToLower().Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); GpxParser parser = HttpContext.Current.Cache[gpxPath] as GpxParser; if (parser == null) { if (!File.Exists(gpxPath)) { return(null); } parser = new GpxParser(); parser.Parse(gpxPath); HttpContext.Current.Cache.Add( gpxPath, parser, new CacheDependency(new string[] { gpxPath, HttpContext.Current.Server.MapPath("Map.aspx") }), Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); } return(parser); }
protected void Page_Load(object sender, EventArgs e) { try { string routeName = Request.QueryString["Route"]; if (!IsPostBack) { Route r = DBHelper.GetRoute(routeName); if (r != null) { string gpxFile = PathFunctions.GetGpxPathFromRouteName(routeName); parser = Helper.GetGpxParser(gpxFile); if (parser != null) { parser.LoadPhothos(); } Title = r.Title; } } bool editMode = Request.QueryString["EditMode"] == "true"; GenerateCustomOptions(editMode); ChooseRoute.Visible = editMode; if (editMode && FileUploadGpx.HasFile) { try { GpxParser p = new GpxParser(); p.Parse(FileUploadGpx.FileContent); if (p.Tracks.Count == 0) { return; } parser = p; } catch { } } if (parser == null) { parser = GpxParser.FromSession(routeName); } else { parser.ToSession(routeName); } } finally { MapContainer.Visible = parser != null; } }
public static async Task <Guid> RunOrchestrator( [OrchestrationTrigger] IDurableOrchestrationContext context) { (var userId, var rawGpxData) = context.GetInput <(Guid, string)>(); var parsedGpx = GpxParser.Parse(new StringReader(rawGpxData)); // todo - also upload the file to raw storage! // todo - and record the raw file location in the uploaded cache function below. var config = SettingsManager.GetCredentials(); // todo this doesn't work. probably just move these configs for Azure Fxn var cosmosWriter = new UploadHandler(config.EndPoint, config.AuthKey, config.CosmosDatabase, config.CosmosContainer, config.StaticDataCosmosContainer); var tripHandler = new TripProcessorHandler(cosmosWriter); var plusCodeRanges = TripProcessorHandler.GetPlusCodeRanges(parsedGpx); tripHandler = await context.CallActivityAsync <TripProcessorHandler>("GpxFileUpload_WarmCache", (parsedGpx, tripHandler)); // parallel tracks: upload raw while also computing overlaps. var overlapComputeParams = (parsedGpx, userId, plusCodeRanges, tripHandler); var overlappingNodesTask = context.CallActivityAsync <HashSet <UserNodeCoverage> >("GpxFileUpload_OverlappingNodes", overlapComputeParams); var uploadRawTask = context.CallActivityAsync("GpxFileUpload_UploadRawRun", (parsedGpx, userId, tripHandler)); Task.WaitAll(overlappingNodesTask, uploadRawTask); var overlappingNodes = overlappingNodesTask.Result; // upload overlapping nodes var uploadCacheTask = context.CallActivityAsync("GpxFileUpload_UploadCache", (overlappingNodes, tripHandler)); var updateUserWayCoverage = context.CallActivityAsync("GpxFileUpload_UpdateUserWayCoverage", (overlappingNodes, userId, plusCodeRanges, tripHandler)); Task.WaitAll(uploadCacheTask, updateUserWayCoverage); // upload summary await context.CallActivityAsync("GpxFileUpload_UpdateUserSummaryAsync", (userId, tripHandler)); return(userId); }