Example #1
0
        public async override void Initialize()
        {
            // use app data path to asteroids data (downloaded by user)
            string file = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Astrarium", "OrbitalElements", "Asteroids.dat");

            // use default path to asteroids data
            if (!File.Exists(file))
            {
                file = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Data", "Asteroids.dat");
            }

            if (File.Exists(file))
            {
                asteroids.Clear();
                asteroids.AddRange(reader.Read(file));
            }
            else
            {
                Log.Error("Asteroids orbital elements data file not found.");
            }

            if (settings.Get <bool>("AsteroidsAutoUpdateOrbitalElements") &&
                DateTime.Now.Subtract(settings.Get <DateTime>("AsteroidsDownloadOrbitalElementsTimestamp")).TotalDays >= (int)settings.Get <decimal>("AsteroidsAutoUpdateOrbitalElementsPeriod"))
            {
                Log.Info("Obital elements of asteroids needs to be updated, updating...");
                await Task.Run(() => UpdateOrbitalElements(silent : true));
            }
        }
Example #2
0
 public override void Initialize()
 {
     asteroids.AddRange(reader.Read());
 }