internal string GetNewSystems(SQLiteDBClass db)
        {
            string json;
            string date = "2010-01-01 00:00:00";
            string lstsyst = db.GetSettingString("EDSMLastSystems", "2010-01-01 00:00:00");

            string retstr = "";

            Application.DoEvents();

            json = RequestSystems(lstsyst);

            db.GetAllSystems();

            List<SystemClass> listNewSystems = SystemClass.ParseEDSM(json, ref date);

            retstr = listNewSystems.Count.ToString() + " new systems from EDSM." + Environment.NewLine;
            Application.DoEvents();
            SystemClass.Store(listNewSystems);
            db.PutSettingString("EDSMLastSystems", date);

            return retstr;
        }
        private void textBoxCmdrName_Leave(object sender, EventArgs e)
        {
            if (!EDDiscoveryForm.CommanderName.Equals(textBoxCmdrName.Text))
            {
                SQLiteDBClass db = new SQLiteDBClass();

                db.PutSettingString("CommanderName", textBoxCmdrName.Text);
                //EDDiscoveryForm.CommanderName = textBoxCmdrName.Text;
            }
        }
        public static bool CheckED()
        {
            Process[] processes = Process.GetProcessesByName("EliteDangerous32");

            if (processes == null)
            {
                EDRunning = false;
            }
            else if (processes.Length == 0)
            {
                EDRunning = false;

                SQLiteDBClass db = new SQLiteDBClass();

                if (EDDirectory==null || EDDirectory.Equals(""))
                    EDDirectory = db.GetSettingString("EDDirectory", "");
            }
            else
            {
                string processFilename = null;
                try
                {
                    processFilename = processes[0].MainModule.FileName;
                }
                catch (Win32Exception)
                {
                }

                if (processFilename != null && (EDFileName==null || !EDFileName.Equals(processes[0].MainModule.FileName)))
                {
                    EDFileName = processes[0].MainModule.FileName;
                    EDDirectory = Path.GetDirectoryName(EDFileName);

                    SQLiteDBClass db = new SQLiteDBClass();

                    if (EDDirectory.Contains("PUBLIC_TEST_SERVER")) // BETA
                    {
                        db.PutSettingString("EDDirectoryBeta", EDDirectory);
                        Beta = true;
                    }
                    else
                    {
                        Beta = false;
                        db.PutSettingString("EDDirectory", EDDirectory);
                    }

                }

                try
                {
                    EDVersion = processes[0].MainModule.FileVersionInfo.ProductVersion;
                }
                catch (Win32Exception)
                {
                }

                EDRunning = true;

            }

            //processes = Process.GetProcessesByName("EDLaunch");

            //if (processes == null)
            //{
            //    EDLaunchRunning = false;
            //}
            //else if (processes.Length == 0)
            //{
            //    EDLaunchRunning = false;
            //}
            //else
            //{

            //    EDLaunchFileName = ProcessExecutablePath(processes[0]);
            //    EDLaunchRunning = true;

            //}

            return EDRunning;
        }
        private void GetEDSCDistances()
        {
            try
            {
                SQLiteDBClass db = new SQLiteDBClass();
                EDSCClass edsc = new EDSCClass();
                string lstdist = db.GetSettingString("EDSCLastDist", "2010-01-01 00:00:00");
                string json;

                // Get distances
                string rwdisttime = db.GetSettingString("RWLastDist", "2000-01-01 00:00:00"); // Latest time from RW file.
                string rwdistfiletime = "";
                lstdist = db.GetSettingString("EDSCLastDist", "2010-01-01 00:00:00");
                List<DistanceClass> dists = new List<DistanceClass>();

                json = LoadJsonArray(fileTgcDistances);
                dists = DistanceClass.ParseEDSC(json, ref rwdistfiletime);

                if (!rwdisttime.Equals(rwdistfiletime))  // New distance file from Redwizzard
                {
                    DistanceClass.Delete(DistancsEnum.EDSC); // Remove all EDSC distances.
                    lstdist = "2010-01-01 00:00:00";
                    db.PutSettingString("RWLastDist", rwdistfiletime);
                }

                if (lstdist.Equals("2010-01-01 00:00:00"))
                {
                    LogText("Adding data from tgcdistances.json " + Environment.NewLine);

                    lstdist = rwdistfiletime;

                    if (json == null)
                        LogText("Couldn't read file." + Environment.NewLine);

                    else
                    {
                        LogText("Found " + dists.Count.ToString() + " new distances." + Environment.NewLine);

                        DistanceClass.Store(dists);
                        db.PutSettingString("EDSCLastDist", lstdist);
                    }

                }

                LogText("Checking for new distances from EDSC. ");

                Application.DoEvents();
                json = edsc.RequestDistances(lstdist);

                dists = new List<DistanceClass>();
                dists = DistanceClass.ParseEDSC(json, ref lstdist);

                if (json == null)
                    LogText("No response from server." + Environment.NewLine);

                else
                    LogText("Found " + dists.Count.ToString() + " new distances." + Environment.NewLine);

                Application.DoEvents();
                DistanceClass.Store(dists);
                db.PutSettingString("EDSCLastDist", lstdist);
                db.GetAllDistances();
                OnDistancesLoaded();

                // Check for a new installer
                CheckForNewInstaller();

            }
            catch (Exception ex)
            {
                LogText("GetEDSCDistances exception:" + ex.Message + Environment.NewLine);

            }
        }
        private void GetEDSCSystems()
        {
            try
            {
                SQLiteDBClass db = new SQLiteDBClass();
                EDSMClass edsm = new EDSMClass();

                string json;

                string rwsystime = db.GetSettingString("RWLastSystems", "2000-01-01 00:00:00"); // Latest time from RW file.
                string rwsysfiletime = "";

                CommanderName = db.GetSettingString("CommanderName", "");
                Invoke((MethodInvoker) delegate {
                    travelHistoryControl1.textBoxCmdrName.Text = CommanderName;
                });

                json = LoadJsonArray(fileTgcSystems);
                List<SystemClass> systems = SystemClass.ParseEDSC(json, ref rwsysfiletime);

                if (!rwsystime.Equals(rwsysfiletime))  // New distance file from Redwizzard
                {
                    SystemClass.Delete(SystemStatusEnum.EDSC); // Remove all EDSC systems.

                    db.PutSettingString("RWLastSystems", rwsysfiletime);
                    db.PutSettingString("EDSMLastSystems", rwsysfiletime);
                    Invoke((MethodInvoker) delegate {
                        TravelHistoryControl.LogText("Adding data from tgcsystems.json " + Environment.NewLine);
                    });
                    SystemClass.Store(systems);
                    EDDBClass eddb = new EDDBClass();
                    DBUpdateEDDB(eddb);
                }

                string retstr = edsm.GetNewSystems(db);
                Invoke((MethodInvoker)delegate
                {
                    TravelHistoryControl.LogText(retstr);
                });

                db.GetAllSystemNotes();
                db.GetAllSystems();

                SystemNames.Clear();
                foreach (SystemClass system in SystemData.SystemList)
                {
                    SystemNames.Add(system.name);
                }

            }
            catch (Exception ex)
            {
                Invoke((MethodInvoker) delegate {
                    TravelHistoryControl.LogText("GetEDSCSystems exception:" + ex.Message + Environment.NewLine);
                });
            }
        }
        private void GetEDDBUpdate()
        {
            try
            {
                EDDBClass eddb = new EDDBClass();
                string timestr;
                DateTime time;

                Thread.Sleep(1000);

                SQLiteDBClass db = new SQLiteDBClass();
                timestr = db.GetSettingString("EDDBSystemsTime", "0");
                time = new DateTime(Convert.ToInt64(timestr), DateTimeKind.Utc);
                bool updatedb = false;

                if (DateTime.UtcNow.Subtract(time).TotalDays > 0.5)
                {
                    LogText("Get systems from EDDB. ");

                    if (eddb.GetSystems())
                    {
                        LogText("OK." + Environment.NewLine);

                        db.PutSettingString("EDDBSystemsTime", DateTime.UtcNow.Ticks.ToString());
                        updatedb = true;
                    }
                    else
                        LogText("Failed." + Environment.NewLine, Color.Red);

                    eddb.GetCommodities();
                }

                timestr = db.GetSettingString("EDDBStationsLiteTime", "0");
                time = new DateTime(Convert.ToInt64(timestr), DateTimeKind.Utc);

                if (DateTime.UtcNow.Subtract(time).TotalDays > 0.5)
                {

                    LogText("Get stations from EDDB. ");
                    if (eddb.GetStationsLite())
                    {
                        LogText("OK." + Environment.NewLine);
                        db.PutSettingString("EDDBStationsLiteTime", DateTime.UtcNow.Ticks.ToString());
                        updatedb = true;
                    }
                    else
                        LogText("Failed." + Environment.NewLine, Color.Red);

                }

                if (updatedb)
                {
                    DBUpdateEDDB(eddb);
                }

                return;

            }
            catch (Exception ex)
            {
                Invoke((MethodInvoker)delegate
                {
                    TravelHistoryControl.LogText("GetEDSCSystems exception:" + ex.Message + Environment.NewLine);
                });
            }
        }
Beispiel #7
0
        internal string GetNewSystems(SQLiteDBClass db)
        {
            string json;
            string date = "2010-01-01 00:00:00";
            string lstsyst;

            string retstr = "";

            Application.DoEvents();

            db.GetAllSystems();

            //if (lstsys)

            DateTime NewSystemTime;

            if (SQLiteDBClass.globalSystems == null || SQLiteDBClass.globalSystems.Count ==0)
            {
                lstsyst = "2010-01-01 00:00:00";
            }
            else
            {
                NewSystemTime = SQLiteDBClass.globalSystems.Max(x => x.UpdateDate);
                lstsyst = NewSystemTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
                lstsyst = db.GetSettingString("EDSMLastSystems", lstsyst);

                if (lstsyst.Equals("2010-01-01 00:00:00"))
                    lstsyst = NewSystemTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);

            }
            json = RequestSystems(lstsyst);

            List<SystemClass> listNewSystems = SystemClass.ParseEDSM(json, ref date);

            List<SystemClass> systems2Store = new List<SystemClass>();

            foreach (SystemClass system in listNewSystems)
            {
                // Check if sys exists first
                SystemClass sys = SystemData.GetSystem(system.name);
                if (sys == null)
                    systems2Store.Add(system);
                else if (!sys.name.Equals(system.name) || sys.x != system.x || sys.y != system.y || sys.z != system.z)  // Case or position changed
                    systems2Store.Add(system);
            }
            SystemClass.Store(systems2Store);

            retstr = systems2Store.Count.ToString() + " new systems from EDSM." + Environment.NewLine;
            Application.DoEvents();

            db.PutSettingString("EDSMLastSystems", date);

            return retstr;
        }
Beispiel #8
0
        public static bool CheckED()
        {
            Process[] processes32 = Process.GetProcessesByName("EliteDangerous32");
            Process[] processes64 = Process.GetProcessesByName("EliteDangerous64");

            Process[] processes = processes32;

            if (processes == null || processes32.Length == 0)
                processes = processes64;

            if (processes == null)
            {
                EDRunning = false;
            }
            else if (processes.Length == 0 )
            {
                EDRunning = false;

                SQLiteDBClass db = new SQLiteDBClass();

                if (EDDirectory==null || EDDirectory.Equals(""))
                    EDDirectory = db.GetSettingString("EDDirectory", "");
            }
            else
            {
                string processFilename = null;
                try
                {
                    int id = processes[0].Id;
                    processFilename = GetMainModuleFilepath(id);
                    EDFileName = processFilename;
                    //processFilename = processes[0].MainModule.FileName;
                }
                catch (Win32Exception)
                {
                }

                EDDirectory = Path.GetDirectoryName(EDFileName);
                if (EDDirectory != null)
                {
                    SQLiteDBClass db = new SQLiteDBClass();
                    if (EDDirectory.Contains("PUBLIC_TEST_SERVER")) // BETA
                    {
                        db.PutSettingString("EDDirectoryBeta", EDDirectory);
                        Beta = true;
                    }
                    else
                    {
                        Beta = false;
                        db.PutSettingString("EDDirectory", EDDirectory);
                    }
                }

                EDRunning = true;

            }

            //processes = Process.GetProcessesByName("EDLaunch");

            //if (processes == null)
            //{
            //    EDLaunchRunning = false;
            //}
            //else if (processes.Length == 0)
            //{
            //    EDLaunchRunning = false;
            //}
            //else
            //{

            //    EDLaunchFileName = ProcessExecutablePath(processes[0]);
            //    EDLaunchRunning = true;

            //}

            return EDRunning;
        }
        internal string GetNewSystems(SQLiteDBClass db)
        {
            string json;
            string date = "2010-01-01 00:00:00";
            string lstsyst;

            string retstr = "";


            Application.DoEvents();

            db.GetAllSystems();

            //if (lstsys)


            DateTime NewSystemTime;

            if (SQLiteDBClass.globalSystems == null || SQLiteDBClass.globalSystems.Count ==0)
            {
                lstsyst = "2010-01-01 00:00:00";
            }
            else
            {
                NewSystemTime = SQLiteDBClass.globalSystems.Max(x => x.UpdateDate);
                lstsyst = NewSystemTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
                lstsyst = db.GetSettingString("EDSMLastSystems", lstsyst);

                if (lstsyst.Equals("2010-01-01 00:00:00"))
                    lstsyst = NewSystemTime.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);


            }
            json = RequestSystems(lstsyst);


            List<SystemClass> listNewSystems = SystemClass.ParseEDSM(json, ref date);

            retstr = listNewSystems.Count.ToString() + " new systems from EDSM." + Environment.NewLine;
            Application.DoEvents();
            SystemClass.Store(listNewSystems);
            db.PutSettingString("EDSMLastSystems", date);

            return retstr;
        }
Beispiel #10
0
        private void SaveSettings()
        {
            SQLiteDBClass db = new SQLiteDBClass();

            db.PutSettingBool("NetlogDirAutoMode", radioButton_Auto.Checked);
            db.PutSettingString("Netlogdir", textBoxNetLogDir.Text);
        }