public void InitControl(EDDiscoveryForm discoveryForm) { _discoveryForm = discoveryForm; db = new SQLiteDBClass(); string ScreenshotsDirdefault = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\Frontier Developments\\Elite Dangerous"; string OutputDirdefault = ScreenshotsDirdefault + "\\Converted"; try { comboBoxFormat.SelectedIndex = db.GetSettingInt("ImageHandlerFormatNr", 0); } catch { } try { comboBoxFileNameFormat.SelectedIndex = db.GetSettingInt("comboBoxFileNameFormat", 0); } catch {} textBoxFileNameExample.Text = CreateFileName("Sol", "Screenshot_0000.bmp"); checkBoxAutoConvert.Checked = db.GetSettingBool("ImageHandlerAutoconvert", false); checkBoxRemove.Checked = db.GetSettingBool("checkBoxRemove", false); textBoxOutputDir.Text = db.GetSettingString("ImageHandlerOutputDir", OutputDirdefault); textBoxScreenshotsDir.Text = db.GetSettingString("ImageHandlerScreenshotsDir", ScreenshotsDirdefault); StartWatcher(); }
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; }
public void Prepare() { var db = new SQLiteDBClass(); _homeSystem = db.GetSettingString("DefaultMapCenter", "Sol"); _defaultZoom = (float)db.GetSettingDouble("DefaultMapZoom", 1.0); bool selectionCentre = db.GetSettingBool("CentreMapOnSelection", true); CenterSystemName = selectionCentre ? HistorySelection : _homeSystem; OrientateMapAroundSystem(CenterSystem); ResetCamera(); toolStripShowAllStars.Renderer = new MyRenderer(); }
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; }
public void Sync() { try { SQLiteDBClass db = new SQLiteDBClass(); EDSMClass edsm = new EDSMClass(); edsm.apiKey = db.GetSettingString("EDSMApiKey", ""); edsm.commanderName = db.GetSettingString("CommanderName", ""); //string comments = edsm.GetComments(new DateTime(2015, 1, 1)); List<SystemPosition> log; int ret = edsm.GetLogs(new DateTime(2011, 1, 1), out log); if (log == null) log = new List<SystemPosition>(); // Send Unsynced system to EDSM. List<SystemPosition> systems = (from s in mainForm.VisitedSystems where s.vs !=null && s.vs.EDSM_sync == false select s).ToList<SystemPosition>(); mainForm.LogLine("EDSM: Sending " + systems.Count.ToString() + " flightlog entries", Color.Black); foreach (var system in systems) { string json = null; if (Exit) { running = false; return; } if (system.vs != null && system.vs.EDSM_sync == false) { // check if it exist in EDSM SystemPosition ps2 = (from c in log where c.Name == system.Name && c.time.Ticks == system.time.Ticks select c).FirstOrDefault<SystemPosition>(); if (ps2 != null) { system.vs.EDSM_sync = true; system.Update(); } else json = edsm.SetLog(system.Name, system.time); if (json != null) { JObject msg = (JObject)JObject.Parse(json); int msgnum = msg["msgnum"].Value<int>(); string msgstr = msg["msg"].Value<string>(); if (msgnum == 100 || msgnum == 401 || msgnum == 402 || msgnum == 403) { if (msgnum == 100) System.Diagnostics.Trace.WriteLine("New"); system.vs.EDSM_sync = true; system.Update(); } else { mainForm.LogLine("EDSM sync ERROR:" + msgnum.ToString() +":" + msgstr, Color.Red); System.Diagnostics.Trace.WriteLine("Error sync:" + msgnum.ToString() + " : " + system.Name); break; } } } } TravelLogUnit tlu = null; // Check for new systems from EDSM bool newsystem = false; int defaultColour = db.GetSettingInt("DefaultMap", Color.Red.ToArgb()); foreach (var system in log) { SystemPosition ps2 = (from c in mainForm.VisitedSystems where c.Name == system.Name && c.time.Ticks == system.time.Ticks select c).FirstOrDefault<SystemPosition>(); if (ps2 == null) // Add to local DB... { if (tlu == null) // If we dontt have a travellogunit yet then create it. { tlu = new TravelLogUnit(); tlu.type = 2; // EDSM tlu.Path = "http://www.edsm.net/api-logs-v1/get-logs"; tlu.Name = "EDSM-" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture); tlu.Size = 0; tlu.Add(); // Add to Database } VisitedSystemsClass vs = new VisitedSystemsClass(); vs.Source = tlu.id; vs.Unit = tlu.Name; vs.Name = system.Name; vs.Time = system.time; vs.MapColour = defaultColour; vs.EDSM_sync = true; vs.Add(); // Add to DB; System.Diagnostics.Trace.WriteLine("New from EDSM"); newsystem = true; } } mainForm.LogLine("EDSM sync Done", Color.Black); if (newsystem) OnNewEDSMTravelLog(this); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("Exception ex:" + ex.Message); mainForm.LogLine("EDSM sync Exception " + ex.Message, Color.Red); } }
private void buttonSync_Click(object sender, EventArgs e) { if (textBoxCmdrName.Text.Equals("")) { MessageBox.Show("Please enter commander name before sending distances/ travel history to EDSM!"); return; } var db = new SQLiteDBClass(); var dists = from p in SQLiteDBClass.dictDistances where p.Value.Status == DistancsEnum.EDDiscovery orderby p.Value.CreateTime select p.Value; EDSMClass edsm = new EDSMClass(); foreach (var dist in dists) { string json; if (dist.Dist > 0) { LogText("Add distance: " + dist.NameA + " => " + dist.NameB + " :" + dist.Dist.ToString("0.00") + "ly" + Environment.NewLine); json = edsm.SubmitDistances(textBoxCmdrName.Text, dist.NameA, dist.NameB, dist.Dist); } else { if (dist.Dist < 0) // Can removedistance by adding negative value dist.Delete(); else { dist.Status = DistancsEnum.EDDiscoverySubmitted; dist.Update(); } json = null; } if (json != null) { string str=""; bool trilok; if (edsm.ShowDistanceResponse(json, out str, out trilok)) { LogText(str); dist.Status = DistancsEnum.EDDiscoverySubmitted; dist.Update(); } else { LogText(str); } } } if (db.GetSettingString("EDSMApiKey", "").Equals("")) { MessageBox.Show("Please enter EDSM api key (In settings) before sending travel history to EDSM!"); return; } sync.StartSync(); }
private void StoreSystemNote() { string txt; try { EDSMClass edsm = new EDSMClass(); SQLiteDBClass db = new SQLiteDBClass(); edsm.apiKey = db.GetSettingString("EDSMApiKey", ""); edsm.commanderName = db.GetSettingString("CommanderName", ""); if (currentSysPos == null || currentSysPos.curSystem == null) return; //SystemPosition sp = (SystemPosition)dataGridView1.Rows[lastRowIndex].Cells[1].Tag; txt = richTextBoxNote.Text; if (currentSysPos.curSystem.Note == null) currentSysPos.curSystem.Note = ""; if (currentSysPos != null && !txt.Equals(currentSysPos.curSystem.Note)) { SystemNoteClass sn; List<SystemClass> systems = new List<SystemClass>(); if (SQLiteDBClass.globalSystemNotes.ContainsKey(currentSysPos.curSystem.SearchName)) { sn = SQLiteDBClass.globalSystemNotes[currentSysPos.curSystem.SearchName]; sn.Note = txt; sn.Time = DateTime.Now; sn.Update(); } else { sn = new SystemNoteClass(); sn.Name = currentSysPos.curSystem.name; sn.Note = txt; sn.Time = DateTime.Now; sn.Add(); } currentSysPos.curSystem.Note = txt; dataGridView1.Rows[lastRowIndex].Cells[3].Value = txt; if (edsm.commanderName == null || edsm.apiKey == null) return; if (edsm.commanderName.Length>1 && edsm.apiKey.Length>1) edsm.SetComment(sn); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("Exception : " + ex.Message); System.Diagnostics.Trace.WriteLine(ex.StackTrace); LogText("Exception : " + ex.Message, Color.Red); LogText(ex.StackTrace, Color.Red); } }
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 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 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); }); } }
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; }
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; }
private void Form1_Load(object sender, EventArgs e) { try { // Click once System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CurrentVersion var assemblyFullName = Assembly.GetExecutingAssembly().FullName; var version = assemblyFullName.Split(',')[1].Split('=')[1]; Text = string.Format("EDDiscovery v{0}", version); EliteDangerous.CheckED(); SQLiteDBClass db = new SQLiteDBClass(); labelPanelText.Text = "Loading. Please wait!"; panelInfo.Visible = true; panelInfo.BackColor = Color.Gold; SystemData sdata = new SystemData(); routeControl1.travelhistorycontrol1 = travelHistoryControl1; // Default directory string datapath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Frontier_Developments\\Products"); // \\FORC-FDEV-D-1001\\Logs\\"; bool auto = db.GetSettingBool("NetlogDirAutoMode", true); if (auto) { datapath = db.GetSettingString("Netlogdir", datapath); textBoxNetLogDir.Text = datapath; radioButton_Auto.Checked = true; } else { radioButton_Manual.Checked = true; textBoxNetLogDir.Text = datapath = db.GetSettingString("Netlogdir", datapath); ; } if (EliteDangerous.EDRunning) { TravelHistoryControl.LogText("EliteDangerous " + EliteDangerous.EDVersion + " is running." + Environment.NewLine); } else TravelHistoryControl.LogText("EliteDangerous is not running ." + Environment.NewLine); if (!EliteDangerous.CheckStationLogging()) { TravelHistoryControl.LogText("Elite Dangerous is not logging system names!!! ", Color.Red); TravelHistoryControl.LogText("Add "); TravelHistoryControl.LogText("VerboseLogging=\"1\" ", Color.Blue); TravelHistoryControl.LogText("to <Network section in File: " + Path.Combine(EliteDangerous.EDDirectory, "AppConfig.xml") + " or AppConfigLocal.xml Remeber to restart Elite!" + Environment.NewLine); labelPanelText.Text = "Elite Dangerous is not logging system names!"; panelInfo.BackColor = Color.Salmon; } if (File.Exists("test.txt")) button1.Visible = true; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Form1_Load exception: " + ex.Message); System.Windows.Forms.MessageBox.Show("Trace: " + ex.StackTrace); } }
public void InitControl(EDDiscoveryForm discoveryForm) { _discoveryForm = discoveryForm; FreezeTrilaterationUI(); edsm = new EDSMClass(); var db = new SQLiteDBClass(); edsm.apiKey = db.GetSettingString("EDSMApiKey", ""); edsm.commanderName = db.GetSettingString("CommanderName", ""); }