Example #1
0
        public void Update(bool write = true, SQLiteConnectionUser conn = null)     // call at start to populate above
        {
            try
            {
                useNotifyIcon           = SQLiteConnectionUser.GetSettingBool("UseNotifyIcon", false, conn);
                orderrowsinverted       = SQLiteConnectionUser.GetSettingBool("OrderRowsInverted", false, conn);
                minimizeToNotifyIcon    = SQLiteConnectionUser.GetSettingBool("MinimizeToNotifyIcon", false, conn);
                keepOnTop               = SQLiteConnectionUser.GetSettingBool("KeepOnTop", false, conn);
                displayUTC              = SQLiteConnectionUser.GetSettingBool("DisplayUTC", false, conn);
                defaultvoicedevice      = SQLiteConnectionUser.GetSettingString("VoiceAudioDevice", "Default", conn);
                defaultwavedevice       = SQLiteConnectionUser.GetSettingString("WaveAudioDevice", "Default", conn);
                showuievents            = SQLiteConnectionUser.GetSettingBool("ShowUIEvents", false, conn);
                clickthrukey            = (System.Windows.Forms.Keys)SQLiteConnectionUser.GetSettingInt("ClickThruKey", (int)System.Windows.Forms.Keys.ShiftKey, conn);
                edsmeddbdownload        = SQLiteConnectionUser.GetSettingBool("EDSMEDDBDownloadData", true, conn); // this goes with the USER on purpose, so its kept over a system db delete
                edsmgridids             = SQLiteConnectionSystem.GetSettingString("EDSMGridIDs", "Not Set");       // from system database, not user, to keep setting with system data
                fullhistoryloaddaylimit = SQLiteConnectionUser.GetSettingInt("FullHistoryLoadDayLimit", 0);
                language           = SQLiteConnectionUser.GetSettingString("DefaultLanguage", "Auto");
                drawduringresize   = SQLiteConnectionUser.GetSettingBool("DrawDuringResizeWindow", true);
                sortpanelsalpha    = SQLiteConnectionUser.GetSettingBool("PanelsSortedByName", false);
                essentialeventtype = SQLiteConnectionUser.GetSettingString("EssentialEventType", "Default");
                coriolisURL        = SQLiteConnectionUser.GetSettingString("CorolisURL", Properties.Resources.URLCoriolis);
                eddshipyardURL     = SQLiteConnectionUser.GetSettingString("EDDShipyardURL", Properties.Resources.URLEDShipyard);
                edsmfullsystemsurl = SQLiteConnectionUser.GetSettingString("EDSMFullSystemsURL", "Default");
                eddbsystemsurl     = SQLiteConnectionUser.GetSettingString("EDDBSystemsURL", "Default");

                EliteDangerousCore.EDCommander.Load(write, conn);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("EDDConfig.Update()" + ":" + ex.Message);
                System.Diagnostics.Trace.WriteLine(ex.StackTrace);
            }
        }
Example #2
0
        public void Update(bool write = true, SQLiteConnectionUser conn = null)     // call at start to populate above
        {
            try
            {
                _useNotifyIcon        = SQLiteConnectionUser.GetSettingBool("UseNotifyIcon", false, conn);
                _EDSMLog              = SQLiteConnectionUser.GetSettingBool("EDSMLog", false, conn);
                _orderrowsinverted    = SQLiteConnectionUser.GetSettingBool("OrderRowsInverted", false, conn);
                _minimizeToNotifyIcon = SQLiteConnectionUser.GetSettingBool("MinimizeToNotifyIcon", false, conn);
                _keepOnTop            = SQLiteConnectionUser.GetSettingBool("KeepOnTop", false, conn);
                _displayUTC           = SQLiteConnectionUser.GetSettingBool("DisplayUTC", false, conn);
                _clearCommodities     = SQLiteConnectionUser.GetSettingBool("ClearCommodities", false, conn);
                _clearMaterials       = SQLiteConnectionUser.GetSettingBool("ClearMaterials", false, conn);
                _autoLoadPopouts      = SQLiteConnectionUser.GetSettingBool("AutoLoadPopouts", false, conn);
                _autoSavePopouts      = SQLiteConnectionUser.GetSettingBool("AutoSavePopouts", false, conn);
                _defaultvoicedevice   = SQLiteConnectionUser.GetSettingString("VoiceAudioDevice", "Default", conn);
                _defaultwavedevice    = SQLiteConnectionUser.GetSettingString("WaveAudioDevice", "Default", conn);
                _showuievents         = SQLiteConnectionUser.GetSettingBool("ShowUIEvents", false, conn);
                _clickthrukey         = (System.Windows.Forms.Keys)SQLiteConnectionUser.GetSettingInt("ClickThruKey", (int)System.Windows.Forms.Keys.ShiftKey, conn);
                _EDSMEDDBDownload     = SQLiteConnectionUser.GetSettingBool("EDSMEDDBDownloadData", true, conn); // this goes with the USER on purpose, so its kept over a system db delete
                _EDSMGridIDs          = SQLiteConnectionSystem.GetSettingString("EDSMGridIDs", "All");           // from system database, not user, to keep setting with system data

                EliteDangerousCore.EDCommander.Load(write, conn);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("EDDConfig.Update()" + ":" + ex.Message);
                System.Diagnostics.Trace.WriteLine(ex.StackTrace);
            }
        }
Example #3
0
        static public DateTime GetLastEDSMRecordTimeUTC()
        {
            string   rwsystime = SQLiteConnectionSystem.GetSettingString("EDSMLastSystems", "2000-01-01 00:00:00"); // Latest time from RW file.
            DateTime edsmdate;

            if (!DateTime.TryParse(rwsystime, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal, out edsmdate))
            {
                edsmdate = new DateTime(2000, 1, 1);
            }

            return(edsmdate);
        }
Example #4
0
        private void CheckSystems(Func <bool> cancelRequested, Action <int, string> reportProgress)  // ASYNC process, done via start up, must not be too slow.
        {
            reportProgress(-1, "");

            string   rwsystime = SQLiteConnectionSystem.GetSettingString("EDSMLastSystems", "2000-01-01 00:00:00"); // Latest time from RW file.
            DateTime edsmdate;

            if (!DateTime.TryParse(rwsystime, CultureInfo.InvariantCulture, DateTimeStyles.None, out edsmdate))
            {
                edsmdate = new DateTime(2000, 1, 1);
            }

            if (DateTime.Now.Subtract(edsmdate).TotalDays > 7)  // Over 7 days do a sync from EDSM
            {
                // Also update galactic mapping from EDSM
                LogLine("Get galactic mapping from EDSM.");
                galacticMapping.DownloadFromEDSM();

                // Skip EDSM full update if update has been performed in last 4 days
                bool     outoforder = SQLiteConnectionSystem.GetSettingBool("EDSMSystemsOutOfOrder", true);
                DateTime lastmod    = outoforder ? SystemClass.GetLastSystemModifiedTime() : SystemClass.GetLastSystemModifiedTimeFast();

                if (DateTime.UtcNow.Subtract(lastmod).TotalDays > 4 ||
                    DateTime.UtcNow.Subtract(edsmdate).TotalDays > 28)
                {
                    syncstate.performedsmsync = true;
                }
                else
                {
                    SQLiteConnectionSystem.PutSettingString("EDSMLastSystems", DateTime.Now.ToString(CultureInfo.InvariantCulture));
                }
            }

            if (!cancelRequested())
            {
                SQLiteConnectionUser.TranferVisitedSystemstoJournalTableIfRequired();
                SQLiteConnectionSystem.CreateSystemsTableIndexes();
                SystemNoteClass.GetAllSystemNotes();                    // fill up memory with notes, bookmarks, galactic mapping
                BookmarkClass.GetAllBookmarks();
                galacticMapping.ParseData();                            // at this point, EDSM data is loaded..
                SystemClass.AddToAutoComplete(galacticMapping.GetGMONames());
                EDDiscovery.EliteDangerous.MaterialCommodityDB.SetUpInitialTable();

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

                string   timestr = SQLiteConnectionSystem.GetSettingString("EDDBSystemsTime", "0");
                DateTime time    = new DateTime(Convert.ToInt64(timestr), DateTimeKind.Utc);
                if (DateTime.UtcNow.Subtract(time).TotalDays > 6.5)     // Get EDDB data once every week.
                {
                    syncstate.performeddbsync = true;
                }
            }
        }
Example #5
0
        // Called from Background Thread Worker at Init()

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

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

            Debug.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Check systems");
            ReportSyncProgress(-1, "");

            bool checkGithub = EDDOptions.Instance.CheckGithubFiles;

            if (checkGithub)      // not normall in debug, due to git hub chokeing
            {
                // Async load of maps in another thread
                DownloadMaps(() => PendingClose);

                // and Expedition data
                DownloadExpeditions(() => PendingClose);

                // and Exploration data
                DownloadExploration(() => PendingClose);
            }

            if (!EDDOptions.Instance.NoSystemsLoad)
            {
                // 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.".Tx(this, "EDSM"));
                    galacticMapping.DownloadFromEDSM();
                    SQLiteConnectionSystem.PutSettingString("EDSMGalMapLast", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"));
                }

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

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

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

            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!".Tx(this, "EDMC"));
                }
            }

            if (!EDDOptions.Instance.NoLoad)        // here in this thread, we do a refresh of history.
            {
                LogLine("Reading travel history".Tx(this, "RTH"));
                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(string.Format("Full synchronisation to the {0} 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.".Tx(this, "SyncEDSM"), databases));
                }
            }
            else
            {
                LogLine("Synchronisation to EDSM and EDDB disabled. Use Settings panel to reenable".Tx(this, "SyncOff"));
            }
        }
Example #6
0
        static public DateTime GetLastEDDBDownloadTime()
        {
            string timestr = SQLiteConnectionSystem.GetSettingString("EDDBSystemsTime", "0");

            return(new DateTime(Convert.ToInt64(timestr), DateTimeKind.Utc));
        }
Example #7
0
        public static bool PerformEDSMFullSync(Func <bool> cancelRequested, Action <int, string> reportProgress, Action <string> logLine, Action <string> logError)
        {
            string   rwsystime = SQLiteConnectionSystem.GetSettingString("EDSMLastSystems", "2000-01-01 00:00:00"); // Latest time from RW file.
            DateTime edsmdate;

            if (!DateTime.TryParse(rwsystime, CultureInfo.InvariantCulture, DateTimeStyles.None, out edsmdate))
            {
                edsmdate = new DateTime(2000, 1, 1);
            }

            long updates = 0;

            // Delete all old systems
            SQLiteConnectionSystem.PutSettingString("EDSMLastSystems", "2010-01-01 00:00:00");
            SQLiteConnectionSystem.PutSettingString("EDDBSystemsTime", "0");

            EDSMClass edsm = new EDSMClass();

            logLine("Get hidden systems from EDSM and remove from database");

            RemoveHiddenSystems();

            if (cancelRequested())
            {
                return(false);
            }

            logLine("Download systems file from EDSM.");

            string edsmsystems = Path.Combine(EliteConfigInstance.InstanceOptions.AppDataDirectory, "edsmsystems.json");

            logLine("Resyncing all downloaded EDSM systems with local database." + Environment.NewLine + "This will take a while.");

            bool newfile;
            bool success = BaseUtils.DownloadFileHandler.DownloadFile(EDSMClass.ServerAddress + "dump/systemsWithCoordinates.json", edsmsystems, out newfile, (n, s) =>
            {
                SQLiteConnectionSystem.CreateTempSystemsTable();

                string rwsysfiletime = "2014-01-01 00:00:00";
                bool outoforder      = false;
                using (var reader = new StreamReader(s))
                    updates = ParseEDSMUpdateSystemsStream(reader, ref rwsysfiletime, ref outoforder, true, cancelRequested, reportProgress, useCache: false, useTempSystems: true);
                if (!cancelRequested())       // abort, without saving time, to make it do it again
                {
                    SQLiteConnectionSystem.PutSettingString("EDSMLastSystems", rwsysfiletime);
                    logLine("Replacing old systems table with new systems table and re-indexing - please wait");
                    reportProgress(-1, "Replacing old systems table with new systems table and re-indexing - please wait");
                    SQLiteConnectionSystem.ReplaceSystemsTable();
                    SQLiteConnectionSystem.PutSettingBool("EDSMSystemsOutOfOrder", outoforder);
                    reportProgress(-1, "");
                }
                else
                {
                    throw new OperationCanceledException();
                }
            });

            if (!success)
            {
                logLine("Failed to download EDSM system file from server, will check next time");
                return(false);
            }

            // Stop if requested
            if (cancelRequested())
            {
                return(false);
            }

            logLine("Local database updated with EDSM data, " + updates + " systems updated.");

            GC.Collect();

            return(updates > 0);
        }