Пример #1
0
        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);
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
 private static void CreateDataDirIfNeed(Station station)
 {
     Directory.CreateDirectory(StationsDatabase.GetStationDir(station));
 }
Пример #4
0
 private static string GetSourceFilename(IAbstractDataSource source, Station station)
 {
     return(StationsDatabase.GetStationDir(station) + source.Id + filesExtension);
 }