public static Dictionary <string, DateTime> LoadLastFetchTimes(Station station) { var result = new Dictionary <string, DateTime>(); string filePath = StationsDatabase.GetStationDir(station) + sourcesFilename; lock (GetIoLock(filePath)) { if (File.Exists(filePath)) { try { var doc = XDocument.Load(filePath); foreach (var source in doc.Root.Element(xmlLastFetch).Elements()) { result.Add(source.Name.LocalName, DateTime.Parse(source.Value).ToUniversalTime()); } } catch (Exception e) { Trace.TraceError("Loading {0}: {1}", filePath, e.Message); } } } return(result); }
public static void SaveLastFetchTimes(IEnumerable <IAbstractDataSource> sources, IEnumerable <Station> stations) { foreach (var station in stations) { var doc = CreateXSourceTimes(sources, station). ToXDocument("sources", new XAttribute[] { new XAttribute(xmlStation, station.Id) }); string filePath = StationsDatabase.GetStationDir(station) + sourcesFilename; try { doc.Save(filePath); } catch (Exception e) { Trace.TraceError("Saving {0}: {1}", filePath, e.Message); } } }
private static void CreateDataDirIfNeed(Station station) { Directory.CreateDirectory(StationsDatabase.GetStationDir(station)); }
private static string GetSourceFilename(IAbstractDataSource source, Station station) { return(StationsDatabase.GetStationDir(station) + source.Id + filesExtension); }