private void NetLogMain() { try { m_Watcher = new System.IO.FileSystemWatcher(); if (Directory.Exists(GetNetLogPath())) { m_Watcher.Path = GetNetLogPath() + "\\"; m_Watcher.Filter = "netLog*.log"; m_Watcher.IncludeSubdirectories = true; m_Watcher.NotifyFilter = NotifyFilters.FileName; // | NotifyFilters.Size; m_Watcher.Changed += new FileSystemEventHandler(OnChanged); m_Watcher.Created += new FileSystemEventHandler(OnChanged); m_Watcher.Deleted += new FileSystemEventHandler(OnChanged); m_Watcher.EnableRaisingEvents = true; } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Net log watcher exception : " + ex.Message, "EDDiscovery Error"); System.Diagnostics.Trace.WriteLine("NetlogMAin exception : " + ex.Message); System.Diagnostics.Trace.WriteLine(ex.StackTrace); } while (!Exit) { try { Thread.Sleep(2000); EliteDangerous.CheckED(); if (NoEvents == false) { if (lastnfi != null) { FileInfo fi = new FileInfo(lastnfi.FileName); if (fi.Length != lastnfi.fileSize) { ParseFile(fi, visitedSystems); } else { //System.Diagnostics.Trace.WriteLine("No change"); } } } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("NetlogMAin exception : " + ex.Message); System.Diagnostics.Trace.WriteLine(ex.StackTrace); } } }
private void button_RefreshHistory_Click(object sender, EventArgs e) { visitedSystems = null; TriggerEDSMRefresh(); RefreshHistory(); EliteDangerous.CheckED(); }
private void CheckIfVerboseLoggingIsTurnedOn() { if (!EliteDangerous.CheckStationLogging()) { TravelHistoryControl.LogTextHighlight("Elite Dangerous is not logging system names!!! "); TravelHistoryControl.LogText("Add "); TravelHistoryControl.LogText("VerboseLogging=\"1\" "); TravelHistoryControl.LogText("to <Network section in File: " + Path.Combine(EliteDangerous.EDDirectory, "AppConfig.xml") + " or AppConfigLocal.xml Remember to restart Elite!" + Environment.NewLine); labelPanelText.Text = "Elite Dangerous is not logging system names!"; panelInfo.BackColor = Color.Salmon; } }
public AssignTravelLogSystemForm(TravelHistoryControl travelHistory, EliteDangerous.JournalEvents.JournalLocOrJump vsc) { InitializeComponent(); this._travelLogEntry = vsc; SystemClass.GetSystemAndAlternatives(vsc, out _linkSystem, out _alternatives, out _namestatus); this.tbLogSystemName.Text = vsc.StarSystem; this.tbVisitedDate.Text = vsc.EventTimeLocal.ToString(); this.tbLogCoordX.Text = vsc.HasCoordinate ? vsc.StarPos[0].ToString("0.000") : "?"; this.tbLogCoordY.Text = vsc.HasCoordinate ? vsc.StarPos[1].ToString("0.000") : "?"; this.tbLogCoordZ.Text = vsc.HasCoordinate ? vsc.StarPos[2].ToString("0.000") : "?"; this.tbLogCoordX.TextAlign = vsc.HasCoordinate ? HorizontalAlignment.Right : HorizontalAlignment.Center; this.tbLogCoordY.TextAlign = vsc.HasCoordinate ? HorizontalAlignment.Right : HorizontalAlignment.Center; this.tbLogCoordZ.TextAlign = vsc.HasCoordinate ? HorizontalAlignment.Right : HorizontalAlignment.Center; UpdateLinkedSystemList(_linkSystem); tbManualSystemName.AutoCompleteMode = AutoCompleteMode.SuggestAppend; tbManualSystemName.AutoCompleteSource = AutoCompleteSource.CustomSource; tbManualSystemName.SetAutoCompletor(EDDiscovery.DB.SystemClass.ReturnSystemListForAutoComplete); }
private void EDDiscoveryForm_Load(object sender, EventArgs e) { try { EliteDangerous.CheckED(); EDDConfig.Update(); RepositionForm(); InitFormControls(); InitSettingsTab(); CheckIfEliteDangerousIsRunning(); CheckIfVerboseLoggingIsTurnedOn(); if (File.Exists("test.txt")) { button1.Visible = true; } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("EDDiscoveryForm_Load exception: " + ex.Message); System.Windows.Forms.MessageBox.Show("Trace: " + ex.StackTrace); } }
public StationClass(JObject jo, SystemInfoSource source) { if (source == SystemInfoSource.EDDB) { name = jo["name"].Value <string>(); SearchName = name.ToLower(); eddb_id = jo["id"].Value <int>(); system_id = jo["system_id"].Value <int>(); if (jo["max_landing_pad_size"].Type == JTokenType.String) { max_landing_pad_size = jo["max_landing_pad_size"].Value <string>(); } if (jo["distance_to_star"].Type == JTokenType.Integer) { distance_to_star = jo["distance_to_star"].Value <int>(); } faction = jo["faction"].Value <string>(); government = EliteDangerous.Government2ID(jo["government"]); allegiance = EliteDangerous.Allegiance2ID(jo["allegiance"]); state = EliteDangerous.EDState2ID(jo["state"]); stationtype = EliteDangerous.EDStationType2ID(jo["type"]); if (jo["has_blackmarket"].Type == JTokenType.Integer) { has_blackmarket = jo["has_blackmarket"].Value <int>(); } else { has_blackmarket = -1; } if (jo["has_commodities"].Type == JTokenType.Integer) { has_commodities = jo["has_commodities"].Value <int>(); } else { has_commodities = -1; } if (jo["has_refuel"].Type == JTokenType.Integer) { has_refuel = jo["has_refuel"].Value <int>(); } else { has_refuel = -1; } if (jo["has_repair"].Type == JTokenType.Integer) { has_repair = jo["has_repair"].Value <int>(); } else { has_repair = -1; } if (jo["has_rearm"].Type == JTokenType.Integer) { has_rearm = jo["has_rearm"].Value <int>(); } else { has_rearm = -1; } if (jo["has_outfitting"].Type == JTokenType.Integer) { has_outfitting = jo["has_outfitting"].Value <int>(); } else { has_outfitting = -1; } if (jo["has_shipyard"].Type == JTokenType.Integer) { has_shipyard = jo["has_shipyard"].Value <int>(); } else { has_shipyard = -1; } economies = EliteDangerous.EDEconomies2ID((JArray)jo["economies"]); import_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["import_commodities"]); export_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["export_commodities"]); prohibited_commodities = EliteDangerous.EDCommodities2ID((JArray)jo["prohibited_commodities"]); eddb_updated_at = jo["updated_at"].Value <int>(); } }
private void ScanTickWorker(object sender, System.ComponentModel.DoWorkEventArgs e) { var worker = sender as System.ComponentModel.BackgroundWorker; var entries = new List <VisitedSystemsClass>(); e.Result = entries; int netlogpos = 0; NetLogFileReader nfi = null; try { if (EDDConfig.Instance.NetLogDirAutoMode) { EliteDangerous.CheckED(); } string filename = null; if (m_netLogFileQueue.TryDequeue(out filename)) // if a new one queued, we swap to using it { nfi = OpenFileReader(new FileInfo(filename)); lastnfi = nfi; } else if (!File.Exists(lastnfi.FileName) || lastnfi.filePos >= new FileInfo(lastnfi.FileName).Length) { HashSet <string> tlunames = new HashSet <string>(TravelLogUnit.GetAllNames()); string[] filenames = Directory.EnumerateFiles(GetNetLogPath(), "netLog.*.log", SearchOption.AllDirectories) .Select(s => new { name = Path.GetFileName(s), fullname = s }) .Where(s => !tlunames.Contains(s.name)) .OrderBy(s => s.name) .Select(s => s.fullname) .ToArray(); foreach (var name in filenames) { nfi = OpenFileReader(new FileInfo(name)); lastnfi = nfi; break; } } else { nfi = lastnfi; } if (nfi != null) { if (nfi.TimeZone == null) { nfi.ReadHeader(); if (nfi.TravelLogUnit.id == 0) { nfi.TravelLogUnit.Add(); } } netlogpos = nfi.TravelLogUnit.Size; foreach (VisitedSystemsClass dbsys in nfi.ReadSystems()) { dbsys.EDSM_sync = false; dbsys.MapColour = EDDConfig.Instance.DefaultMapColour; dbsys.Commander = EDDConfig.Instance.CurrentCmdrID; dbsys.Add(); // here we need to make sure the cursystem is set up.. need to do it here because OnNewPosition expects all cursystems to be non null.. VisitedSystemsClass item2 = VisitedSystemsClass.GetLast(dbsys.Commander, dbsys.Time); VisitedSystemsClass.UpdateVisitedSystemsEntries(dbsys, item2, EDDiscoveryForm.EDDConfig.UseDistances); // ensure they have system classes behind them.. entries.Add(dbsys); if (worker.CancellationPending) { break; } } nfi.TravelLogUnit.Update(); } if (worker.CancellationPending) { e.Cancel = true; } } catch (Exception ex) { // Revert and re-read the failed entries if (nfi != null && nfi.TravelLogUnit != null) { nfi.TravelLogUnit.Size = netlogpos; } System.Diagnostics.Trace.WriteLine("Net tick exception : " + ex.Message); System.Diagnostics.Trace.WriteLine(ex.StackTrace); throw; } }
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); } }
private void EDDiscoveryForm_Shown(object sender, EventArgs e) { try { travelHistoryControl1.Enabled = false; var redWizzardThread = new Thread(GetRedWizzardFiles) { Name = "Downloading Red Wizzard Files" }; var edscThread = new Thread(GetEDSCSystems) { Name = "Downloading EDSC Systems" }; var downloadmapsThread = new Thread(DownloadMaps) { Name = "Downloading map Files" }; redWizzardThread.Start(); edscThread.Start(); downloadmapsThread.Start(); while (redWizzardThread.IsAlive || edscThread.IsAlive || downloadmapsThread.IsAlive) { Thread.Sleep(50); Application.DoEvents(); } redWizzardThread.Join(); edscThread.Join(); downloadmapsThread.Join(); OnDistancesLoaded += new DistancesLoaded(this.DistancesLoaded); GetEDSCDistancesAsync(); //Application.DoEvents(); GetEDDBAsync(); if (SystemData.SystemList.Count == 0) { //sdata.ReadData(); } routeControl1.textBox_From.AutoCompleteCustomSource = SystemNames; routeControl1.textBox_To.AutoCompleteCustomSource = SystemNames; Text += " Systems: " + SystemData.SystemList.Count; routeControl1.travelhistorycontrol1 = travelHistoryControl1; travelHistoryControl1.netlog.OnNewPosition += new NetLogEventHandler(routeControl1.NewPosition); travelHistoryControl1.netlog.OnNewPosition += new NetLogEventHandler(travelHistoryControl1.NewPosition); TravelHistoryControl.LogText("Reading travelhistory "); travelHistoryControl1.RefreshHistory(); travelHistoryControl1.netlog.StartMonitor(); travelHistoryControl1.Enabled = true; if (EliteDangerous.CheckStationLogging()) { panelInfo.Visible = false; } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Form1_Load exception: " + ex.Message); System.Windows.Forms.MessageBox.Show("Trace: " + ex.StackTrace); travelHistoryControl1.Enabled = true; } }
private void EDDiscoveryForm_Shown(object sender, EventArgs e) { try { travelHistoryControl1.Enabled = false; var edsmThread = new Thread(GetEDSMSystems) { Name = "Downloading EDSM Systems", IsBackground = true }; var downloadmapsThread = new Thread(DownloadMaps) { Name = "Downloading map Files", IsBackground = true }; edsmThread.Start(); downloadmapsThread.Start(); while (edsmThread.IsAlive || downloadmapsThread.IsAlive) { Thread.Sleep(50); Application.DoEvents(); } edsmThread.Join(); downloadmapsThread.Join(); OnDistancesLoaded += new DistancesLoaded(this.DistancesLoaded); GetEDSMDistancesAsync(); //Application.DoEvents(); GetEDDBAsync(false); routeControl1.textBox_From.AutoCompleteCustomSource = SystemNames; routeControl1.textBox_To.AutoCompleteCustomSource = SystemNames; imageHandler1.StartWatcher(); routeControl1.EnableRouteTab(); // now we have systems, we can update this.. routeControl1.travelhistorycontrol1 = travelHistoryControl1; travelHistoryControl1.netlog.OnNewPosition += new NetLogEventHandler(routeControl1.NewPosition); travelHistoryControl1.netlog.OnNewPosition += new NetLogEventHandler(travelHistoryControl1.NewPosition); travelHistoryControl1.sync.OnNewEDSMTravelLog += new EDSMNewSystemEventHandler(travelHistoryControl1.RefreshEDSMEvent); TravelHistoryControl.LogText("Reading travel history " + Environment.NewLine); travelHistoryControl1.RefreshHistory(); travelHistoryControl1.netlog.StartMonitor(this); travelHistoryControl1.Enabled = true; if (EliteDangerous.CheckStationLogging()) { panelInfo.Visible = false; } // Check for a new installer CheckForNewInstaller(); LogLine("Total number of systems " + SystemData.SystemList.Count().ToString() + Environment.NewLine); LogLineSuccess("Loading completed!" + Environment.NewLine); panel_close.Enabled = true; // now we can safely close tabControl1.Enabled = true; } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("EDDiscovery_Load exception: " + ex.Message); System.Windows.Forms.MessageBox.Show("Trace: " + ex.StackTrace); travelHistoryControl1.Enabled = true; } }
private void NetLogMain() { try { m_Watcher = new System.IO.FileSystemWatcher(); if (Directory.Exists(GetNetLogPath())) { m_Watcher.Path = GetNetLogPath() + "\\"; m_Watcher.Filter = "netLog*.log"; m_Watcher.IncludeSubdirectories = true; m_Watcher.NotifyFilter = NotifyFilters.FileName; // | NotifyFilters.Size; m_Watcher.Changed += new FileSystemEventHandler(OnChanged); m_Watcher.Created += new FileSystemEventHandler(OnChanged); m_Watcher.Deleted += new FileSystemEventHandler(OnChanged); m_Watcher.EnableRaisingEvents = true; } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Net log watcher exception : " + ex.Message, "EDDiscovery Error"); System.Diagnostics.Trace.WriteLine("NetlogMAin exception : " + ex.Message); System.Diagnostics.Trace.WriteLine(ex.StackTrace); } List <TravelLogUnit> travelogUnits; // Get TravelLogUnits; travelogUnits = null; TravelLogUnit tlUnit = null; SQLiteDBClass db = new SQLiteDBClass(); int ii = 0; while (!Exit) { try { ii++; Thread.Sleep(2000); EliteDangerous.CheckED(); if (NoEvents == false) { if (lastnfi != null) { FileInfo fi = new FileInfo(lastnfi.FileName); if (fi.Length != lastnfi.fileSize || ii % 5 == 0) { if (tlUnit == null || !tlUnit.Name.Equals(Path.GetFileName(lastnfi.FileName))) // Create / find new travellog unit { travelogUnits = TravelLogUnit.GetAll(); // Check if we alreade have parse the file and stored in DB. if (tlUnit == null) { tlUnit = (from c in travelogUnits where c.Name == fi.Name select c).FirstOrDefault <TravelLogUnit>(); } if (tlUnit == null) { tlUnit = new TravelLogUnit(); tlUnit.Name = fi.Name; tlUnit.Path = Path.GetDirectoryName(fi.FullName); tlUnit.Size = 0; // Add real size after data is in DB //;(int)fi.Length; tlUnit.type = 1; tlUnit.Add(); travelogUnits.Add(tlUnit); } } int nrsystems = visitedSystems.Count; ParseFile(fi, visitedSystems); if (nrsystems < visitedSystems.Count) // Om vi har fler system { System.Diagnostics.Trace.WriteLine("New systems " + nrsystems.ToString() + ":" + visitedSystems.Count.ToString()); for (int nr = nrsystems; nr < visitedSystems.Count; nr++) // Lägg till nya i locala databaslogen { VisitedSystemsClass dbsys = new VisitedSystemsClass(); dbsys.Name = visitedSystems[nr].Name; dbsys.Time = visitedSystems[nr].time; dbsys.Source = tlUnit.id; dbsys.EDSM_sync = false; dbsys.Unit = fi.Name; dbsys.MapColour = db.GetSettingInt("DefaultMap", Color.Red.ToArgb()); dbsys.Unit = fi.Name; dbsys.Commander = 0; if (!tlUnit.Beta) // dont store history in DB for beta (YET) { dbsys.Add(); } visitedSystems[nr].vs = dbsys; } } else { //System.Diagnostics.Trace.WriteLine("No change"); } } } } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("NetlogMAin exception : " + ex.Message); System.Diagnostics.Trace.WriteLine(ex.StackTrace); } } }
public SystemClass(JObject jo, SystemInfoSource source) { if (source == SystemInfoSource.RW) { try { x = jo["x"].Value <double>(); y = jo["y"].Value <double>(); z = jo["z"].Value <double>(); name = jo["name"].Value <string>(); SearchName = name.ToLower(); cr = 1; status = SystemStatusEnum.RedWizzard; } catch { } } else if (source == SystemInfoSource.EDSC) { JArray ja = (JArray)jo["coord"]; name = jo["name"].Value <string>(); SearchName = name.ToLower(); cr = jo["cr"].Value <int>(); if (ja[0].Type == JTokenType.Float || ja[0].Type == JTokenType.Integer) { x = ja[0].Value <double>(); y = ja[1].Value <double>(); z = ja[2].Value <double>(); } else { x = double.NaN; y = double.NaN; z = double.NaN; } CommanderCreate = jo["commandercreate"].Value <string>(); CreateDate = jo["createdate"].Value <DateTime>(); CommanderUpdate = jo["commanderupdate"].Value <string>(); UpdateDate = jo["updatedate"].Value <DateTime>(); status = SystemStatusEnum.EDSC; } else if (source == SystemInfoSource.EDSM) { JObject coords = (JObject)jo["coords"]; name = jo["name"].Value <string>(); SearchName = name.ToLower(); //cr = jo["cr"].Value<int>(); x = double.NaN; y = double.NaN; z = double.NaN; if (coords != null && (coords["x"].Type == JTokenType.Float || coords["x"].Type == JTokenType.Integer)) { x = coords["x"].Value <double>(); y = coords["y"].Value <double>(); z = coords["z"].Value <double>(); } JArray submitted = (JArray)jo["submitted"]; if (submitted != null && submitted.Count > 0) { if (submitted[0]["cmdrname"] != null) { CommanderCreate = submitted[0]["cmdrname"].Value <string>(); } CreateDate = submitted[0]["date"].Value <DateTime>(); if (submitted[submitted.Count - 1]["cmdrname"] != null) { CommanderUpdate = submitted[submitted.Count - 1]["cmdrname"].Value <string>(); } UpdateDate = submitted[submitted.Count - 1]["date"].Value <DateTime>(); } UpdateDate = jo["date"].Value <DateTime>(); if (CreateDate.Year <= 1) { CreateDate = UpdateDate; } status = SystemStatusEnum.EDSC; } else if (source == SystemInfoSource.EDDB) { name = jo["name"].Value <string>(); SearchName = name.ToLower(); cr = 1; x = jo["x"].Value <double>(); y = jo["y"].Value <double>(); z = jo["z"].Value <double>(); id_eddb = jo["id"].Value <int>(); /*CommanderCreate = jo["commandercreate"].Value<string>(); * CreateDate = jo["createdate"].Value<DateTime>(); * CommanderUpdate = jo["commanderupdate"].Value<string>(); * UpdateDate = jo["updatedate"].Value<DateTime>();*/ faction = jo["faction"].Value <string>(); if (jo["population"].Type == JTokenType.Integer) { population = jo["population"].Value <long>(); } government = EliteDangerous.Government2ID(jo["government"]); allegiance = EliteDangerous.Allegiance2ID(jo["allegiance"]); state = EliteDangerous.EDState2ID(jo["state"]); security = EliteDangerous.EDSecurity2ID(jo["security"]); primary_economy = EliteDangerous.EDEconomy2ID(jo["primary_economy"]); if (jo["needs_permit"].Type == JTokenType.Integer) { needs_permit = jo["needs_permit"].Value <int>(); } eddb_updated_at = jo["updated_at"].Value <int>(); status = SystemStatusEnum.EDDB; } }