Ejemplo n.º 1
0
        private void BackgroundInit()
        {
            StarScan.LoadBodyDesignationMap();
            MaterialCommodityDB.SetUpInitialTable();

            if (!EDDOptions.Instance.NoSystemsLoad)
            {
                downloadMapsTask = FGEImage.DownloadMaps(this, () => PendingClose, LogLine, LogLineHighlight);
                CheckSystems(() => PendingClose, (p, s) => ReportProgress(p, s));
            }

            SystemNoteClass.GetAllSystemNotes();                                // fill up memory with notes, bookmarks, galactic mapping
            BookmarkClass.GetAllBookmarks();

            ReportProgress(-1, "");
            InvokeAsyncOnUiThread(() => OnInitialSyncComplete?.Invoke());

            if (PendingClose)
            {
                return;
            }

            if (EliteDangerousCore.EDDN.EDDNClass.CheckforEDMC()) // EDMC is running
            {
                if (EDCommander.Current.SyncToEddn)               // Both EDD and EDMC should not sync to EDDN.
                {
                    LogLineHighlight("EDDiscovery and EDMarketConnector should not both sync to EDDN. Stop EDMC or uncheck 'send to EDDN' in settings tab!");
                }
            }

            if (PendingClose)
            {
                return;
            }
            LogLine("Reading travel history");

            if (!EDDOptions.Instance.NoLoad)
            {
                DoRefreshHistory(new RefreshWorkerArgs {
                    CurrentCommander = EDCommander.CurrentCmdrID
                });
            }

            if (PendingClose)
            {
                return;
            }

            if (syncstate.performeddbsync || syncstate.performedsmsync)
            {
                string databases = (syncstate.performedsmsync && syncstate.performeddbsync) ? "EDSM and EDDB" : ((syncstate.performedsmsync) ? "EDSM" : "EDDB");

                LogLine("ED Discovery will now synchronise to the " + databases + " databases to obtain star information." + Environment.NewLine +
                        "This will take a while, up to 15 minutes, please be patient." + Environment.NewLine +
                        "Please continue running ED Discovery until refresh is complete.");
            }
            InvokeAsyncOnUiThread(() => OnInitialisationComplete?.Invoke());
        }
Ejemplo n.º 2
0
        // Called from Background Thread Worker at Init()

        private void BackgroundInit()
        {
            StarScan.LoadBodyDesignationMap();
            MaterialCommodityDB.SetUpInitialTable();

            SQLiteConnectionSystem.CreateSystemsTableIndexes();     // just make sure they are there..

            Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " Check systems");
            ReportProgress(-1, "");

            if (!EDDOptions.Instance.NoSystemsLoad)
            {
                // Async load of maps in another thread

                downloadMapsTask = DownloadMaps(this, () => PendingClose, LogLine, LogLineHighlight);

                // Former CheckSystems, reworked to accomodate new switches..
                // Check to see what sync refreshes we need

                // New Galmap load - it was not doing a refresh if EDSM sync kept on happening. Now has its own timer

                string   rwgalmaptime = SQLiteConnectionSystem.GetSettingString("EDSMGalMapLast", "2000-01-01 00:00:00"); // Latest time from RW file.
                DateTime galmaptime;
                if (!DateTime.TryParse(rwgalmaptime, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out galmaptime))
                {
                    galmaptime = new DateTime(2000, 1, 1);
                }

                if (DateTime.Now.Subtract(galmaptime).TotalDays > 14)  // Over 14 days do a sync from EDSM for galmap
                {
                    LogLine("Get galactic mapping from EDSM.");
                    galacticMapping.DownloadFromEDSM();
                    SQLiteConnectionSystem.PutSettingString("EDSMGalMapLast", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));
                }

                Debug.WriteLine(BaseUtils.AppTicks.TickCount100 + " Check systems complete");
            }

            galacticMapping.ParseData();                            // at this point, gal map data has been uploaded - get it into memory
            SystemClassDB.AddToAutoComplete(galacticMapping.GetGMONames());
            SystemNoteClass.GetAllSystemNotes();
            BookmarkClass.LoadBookmarks();

            LogLine("Loaded Notes, Bookmarks and Galactic mapping.");

            ReportProgress(-1, "");
            InvokeAsyncOnUiThread(() => OnInitialSyncComplete?.Invoke());

            if (PendingClose)
            {
                return;
            }

            if (EliteDangerousCore.EDDN.EDDNClass.CheckforEDMC()) // EDMC is running
            {
                if (EDCommander.Current.SyncToEddn)               // Both EDD and EDMC should not sync to EDDN.
                {
                    LogLineHighlight("EDDiscovery and EDMarketConnector should not both sync to EDDN. Stop EDMC or uncheck 'send to EDDN' in settings tab!");
                }
            }

            if (!EDDOptions.Instance.NoLoad)        // here in this thread, we do a refresh of history.
            {
                LogLine("Reading travel history");
                DoRefreshHistory(new RefreshWorkerArgs {
                    CurrentCommander = EDCommander.CurrentCmdrID
                });                                                                                             // kick the background refresh worker thread into action
            }

            if (PendingClose)
            {
                return;
            }

            if (!EDDOptions.Instance.NoSystemsLoad && EDDConfig.Instance.EDSMEDDBDownload)        // if enabled
            {
                SystemClassEDSM.DetermineIfFullEDSMSyncRequired(syncstate);                       // ask EDSM and EDDB if they want to do a Full sync..
                EliteDangerousCore.EDDB.SystemClassEDDB.DetermineIfEDDBSyncRequired(syncstate);

                if (syncstate.perform_eddb_sync || syncstate.perform_edsm_fullsync)
                {
                    string databases = (syncstate.perform_edsm_fullsync && syncstate.perform_eddb_sync) ? "EDSM and EDDB" : ((syncstate.perform_edsm_fullsync) ? "EDSM" : "EDDB");

                    LogLine("Full synchronisation to the " + databases + " databases required." + Environment.NewLine +
                            "This will take a while, up to 15 minutes, please be patient." + Environment.NewLine +
                            "Please continue running ED Discovery until refresh is complete.");
                }
            }
            else
            {
                LogLine("Synchronisation to EDSM and EDDB disabled. Use Settings panel to reenable");
            }

            InvokeAsyncOnUiThread(() => OnInitialisationComplete?.Invoke());
        }