예제 #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);
 }