Ejemplo n.º 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);
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 3
0
 private static void CreateDataDirIfNeed(Station station)
 {
     Directory.CreateDirectory(StationsDatabase.GetStationDir(station));
 }
Ejemplo n.º 4
0
 private static string GetSourceFilename(IAbstractDataSource source, Station station)
 {
     return(StationsDatabase.GetStationDir(station) + source.Id + filesExtension);
 }