// ================================================== // Methods /// <summary> /// Initializes repository with all local GPX files /// </summary> public void Init(string uri) { lock (_init) // TODO: use internal init for basic cache { if (Convert.ToBoolean(_init)) { return; } _trails = new BasicCacheService <TopoTrailInfo>(); var root = new DirectoryInfo(uri); _rootUri = root.FullName; foreach (var dir in root.EnumerateDirectories()) { var country = GeoCountryInfo.ByName(dir.Name); if (country != null) { foreach (var file in dir.EnumerateFiles("*.gpx")) { var trail = LoadTrail(file); _trails.Add(trail); } } } _init = true; } }
/// <summary> /// Removes all current track edits from session /// </summary> public List <TrackEditData> RemoveAll() { var all = _tracks.All; _tracks = new BasicCacheService <TrackEditData>(); return(all); }
public void Reload() { _cached = false; _dirty = false; _cache = new BasicCacheService <CartoPlaceInfo>(); Init(_uri); }
// ================================================== // Methods /// <summary> /// Initializes repository with all local GPX files /// </summary> public void Init(string uri) { lock (_init) // TODO: use internal init for basic cache { if (Convert.ToBoolean(_init)) { return; } _polar = new BasicCacheService <PolarTrainingInfo>(); var root = new DirectoryInfo(uri); _rootUri = root.FullName; foreach (var year in root.EnumerateDirectories()) { foreach (var file in year.EnumerateFiles("*.zip")) { var filename = Path.GetFileNameWithoutExtension(file.Name); // cache file list for later var training = new PolarTrainingInfo(); training.Uri = file.FullName; training.Key = filename.ToUpperInvariant(); // parse out datetime var index = filename.Length - 19; var parts = filename.Substring(index).Split('_'); var time = parts[1].Replace("-", ":"); // + "Z"; training.Timestamp = DateTime.Parse(parts[0] + " " + time); // add to partial cache _polar.Add(training); } } _init = true; } }
/// <summary> /// Clears the GPX file cache /// </summary> public void ResetCache() { _trails = null; _init = false; }
/// <summary> /// Clears the GPX file cache /// </summary> public void ResetCache() { _polar = null; _init = false; }