internal Route(string path) { RouteFolder = FolderStructure.Route(path); string trkFilePath = RouteFolder.TrackFileName; try { RouteFile trkFile = new RouteFile(trkFilePath); Name = trkFile.Route.Name; RouteID = trkFile.Route.RouteID; Description = trkFile.Route.Description; } #pragma warning disable CA1031 // Do not catch general exception types catch #pragma warning restore CA1031 // Do not catch general exception types { Name = $"<{catalog.GetString("load error:")} {System.IO.Path.GetFileName(path)}>"; } if (string.IsNullOrEmpty(Name)) { Name = $"<{catalog.GetString("unnamed:")} {System.IO.Path.GetFileNameWithoutExtension(path)}>"; } if (string.IsNullOrEmpty(Description)) { Description = null; } Path = path; }
internal Route(string path) { RouteFolder = FolderStructure.Route(path); string trkFilePath = RouteFolder.TrackFileName; try { var trkFile = new RouteFile(trkFilePath); Name = trkFile.Route.Name; RouteID = trkFile.Route.RouteID; Description = trkFile.Route.Description; } catch { Name = $"<{catalog.GetString("load error:")} {System.IO.Path.GetFileName(path)}>"; } if (string.IsNullOrEmpty(Name)) { Name = $"<{catalog.GetString("unnamed:")} {System.IO.Path.GetFileNameWithoutExtension(path)}>"; } if (string.IsNullOrEmpty(Description)) { Description = null; } Path = path; }
internal async Task LoadTrackData(bool?useMetricUnits, CancellationToken cancellationToken) { List <Task> loadTasks = new List <Task>(); FolderStructure.ContentFolder.RouteFolder routeFolder = FolderStructure.Route(routePath); RouteFile routeFile = new RouteFile(routeFolder.TrackFileName); RouteName = routeFile.Route.Name; UseMetricUnits = useMetricUnits.GetValueOrDefault(routeFile.Route.MilepostUnitsMetric); loadTasks.Add(Task.Run(() => { string tdbFile = routeFolder.TrackDatabaseFile(routeFile); if (!File.Exists(tdbFile)) { Trace.TraceError($"Track Database File not found in {tdbFile}"); return; } TrackDB = new TrackDatabaseFile(tdbFile).TrackDB; }, cancellationToken)); loadTasks.Add(Task.Run(() => { TrackSections = new TrackSectionsFile(routeFolder.TrackSectionFile); if (File.Exists(routeFolder.RouteTrackSectionFile)) { TrackSections.AddRouteTSectionDatFile(routeFolder.RouteTrackSectionFile); } }, cancellationToken)); loadTasks.Add(Task.Run(() => { string rdbFile = routeFolder.RoadTrackDatabaseFile(routeFile); if (!File.Exists(rdbFile)) { Trace.TraceError($"Road Database File not found in {rdbFile}"); return; } RoadTrackDB = new RoadDatabaseFile(rdbFile).RoadTrackDB; }, cancellationToken)); loadTasks.Add(Task.Run(() => SignalConfig = new SignalConfigurationFile(routeFolder.SignalConfigurationFile, routeFolder.ORSignalConfigFile), cancellationToken)); await Task.WhenAll(loadTasks).ConfigureAwait(false); }