static public bool SendToEDDN(HistoryEntry he) { EDDNClass eddn = new EDDNClass(); JournalEntry je = JournalEntry.Get(he.Journalid); JObject msg = null; if (je.EventTypeID == JournalTypeEnum.FSDJump) { msg = eddn.CreateEDDNMessage(je as JournalFSDJump); } else if (je.EventTypeID == JournalTypeEnum.Docked) { msg = eddn.CreateEDDNMessage(je as JournalDocked, he.System.x, he.System.y, he.System.z); } else if (je.EventTypeID == JournalTypeEnum.Scan) { msg = eddn.CreateEDDNMessage(je as JournalScan, he.System.name, he.System.x, he.System.y, he.System.z); } if (msg != null) { if (eddn.PostMessage(msg)) { return(true); } } return(false); }
private void sendUnsyncedScanToEDDNToolStripMenuItem_Click(object sender, EventArgs e) { if (rightclicksystem != null && EDDNClass.IsDelayableEDDNMessage(rightclicksystem.EntryType, rightclicksystem.EventTimeUTC) && !rightclicksystem.EDDNSync) { EDDNSync.SendEDDNEvent(discoveryform.LogLine, rightclicksystem); } }
private void SyncThread(object _eddn) { EDDNClass eddn = (EDDNClass)_eddn; running = true; Sync(eddn); running = false; }
// Called after HE removal/reorder, and after the UI's has had a chance to operate private void Controller_NewEntrySecond(HistoryEntry he, HistoryList hl) { BaseUtils.AppTicks.TickCountLapDelta("DFS", true); actioncontroller.ActionRunOnEntry(he, Actions.ActionEventEDList.NewEntry(he)); var t1 = BaseUtils.AppTicks.TickCountLapDelta("DFS"); if (t1.Item2 >= 80) { System.Diagnostics.Trace.WriteLine("NE Second Actions slow " + t1.Item1); } // all notes committed SystemNoteClass.CommitDirtyNotes((snc) => { if (EDCommander.Current.SyncToEdsm && snc.FSDEntry) { EDSMClass.SendComments(snc.SystemName, snc.Note, 0, he.Commander); } }); if (he.IsFSDCarrierJump) { int count = history.GetVisitsCount(he.System.Name); LogLine(string.Format("Arrived at system {0} Visit No. {1}".T(EDTx.EDDiscoveryForm_Arrived), he.System.Name, count)); System.Diagnostics.Trace.WriteLine("Arrived at system: " + he.System.Name + " " + count + ":th visit."); } if (EDCommander.Current.SyncToIGAU) { EliteDangerousCore.IGAU.IGAUSync.NewEvent(LogLine, he); } if (EDCommander.Current.SyncToEDAstro) { EliteDangerousCore.EDAstro.EDAstroSync.SendEDAstroEvents(new List <HistoryEntry>() { he }); } if (EDDNClass.IsEDDNMessage(he.EntryType) && he.AgeOfEntry() < TimeSpan.FromDays(1.0) && EDCommander.Current.SyncToEddn == true) { EDDNSync.SendEDDNEvents(LogLine, new List <HistoryEntry> { he }); } if (DLLManager.Count > 0) { DLLManager.NewJournalEntry(EliteDangerousCore.DLL.EDDDLLCallerHE.CreateFromHistoryEntry(history, he), false); } ScreenshotConverter.NewJournalEntry(he.journalEntry); // tell the screenshotter. CheckActionProfile(he); }
public bool StartSync(EDDNClass eddn, bool syncto) { if (running) // Only start once. { return(false); } _syncTo = syncto; ThreadEDDNSync = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(SyncThread)); ThreadEDDNSync.Name = "EDDN Sync"; ThreadEDDNSync.IsBackground = true; ThreadEDDNSync.Start(eddn); return(true); }
private void Sync(EDDNClass eddn) { try { mainForm.LogLine("EDDN sync begin"); List <HistoryEntry> hlfsdunsyncedlist = mainForm.history.FilterByScanNotEDDNSynced; // first entry is oldest if (_syncTo && hlfsdunsyncedlist.Count > 0) { mainForm.LogLine("EDDN: Sending " + hlfsdunsyncedlist.Count.ToString() + " events"); int edsmsystemssent = 0; foreach (var he in hlfsdunsyncedlist) { if (Exit) { running = false; return; } { if (EDDNSync.SendEDDNEvent(he)) { edsmsystemssent++; } Thread.Sleep(1000); // Throttling to 1 per second to not kill EDDN network } } mainForm.LogLine(string.Format("EDDN Events sent {0}", edsmsystemssent)); } mainForm.LogLine("EDDN sync Done"); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("Exception ex:" + ex.Message); mainForm.LogLineHighlight("EDDN sync Exception " + ex.Message); } }
private void historyContextMenu_Opening(object sender, CancelEventArgs e) { mapGotoStartoolStripMenuItem.Enabled = (rightclicksystem != null && rightclicksystem.System.HasCoordinate); viewOnEDSMToolStripMenuItem.Enabled = (rightclicksystem != null); sendUnsyncedScanToEDDNToolStripMenuItem.Enabled = (rightclicksystem != null && EDDNClass.IsDelayableEDDNMessage(rightclicksystem.EntryType, rightclicksystem.EventTimeUTC) && !rightclicksystem.EDDNSync); removeSortingOfColumnsToolStripMenuItem.Enabled = dataGridViewJournal.SortedColumn != null; jumpToEntryToolStripMenuItem.Enabled = dataGridViewJournal.Rows.Count > 0; }
private void Controller_NewEntrySecond(HistoryEntry he, HistoryList hl) // called after all UI's have had their chance { BaseUtils.AppTicks.TickCountLapDelta("DFS", true); actioncontroller.ActionRunOnEntry(he, Actions.ActionEventEDList.NewEntry(he)); var t1 = BaseUtils.AppTicks.TickCountLapDelta("DFS"); if (t1.Item2 >= 80) { System.Diagnostics.Trace.WriteLine("NE Second Actions slow " + t1.Item1); } // all notes committed SystemNoteClass.CommitDirtyNotes((snc) => { if (EDCommander.Current.SyncToEdsm && snc.FSDEntry) { EDSMClass.SendComments(snc.SystemName, snc.Note, 0, he.Commander); } }); var lastent = history.GetLast; if (!object.ReferenceEquals(he, lastent)) { LogLineHighlight(string.Format("Current history entry is not last in history - possible re-entrancy.\nAlert the EDDiscovery developers using either discord or Github (see help) and attach log file {0}", BaseUtils.TraceLog.LogFileName)); Trace.WriteLine($"Current history entry is not last in history"); Trace.WriteLine($"Current entry: {he.journalEntry?.GetJsonString()}"); Trace.WriteLine($"Last entry: {lastent.journalEntry?.GetJsonString()}"); Trace.WriteLine($"Stack Trace:"); Trace.WriteLine(new StackTrace(true).ToString()); } if (he.IsFSDCarrierJump) { int count = history.GetVisitsCount(he.System.Name); LogLine(string.Format("Arrived at system {0} Visit No. {1}".T(EDTx.EDDiscoveryForm_Arrived), he.System.Name, count)); System.Diagnostics.Trace.WriteLine("Arrived at system: " + he.System.Name + " " + count + ":th visit."); } if (EDCommander.Current.SyncToEdsm && EDSMJournalSync.OkayToSend(he)) // send this one, if allowed. { EDSMJournalSync.SendEDSMEvents(LogLine, new List <HistoryEntry>() { he }); // send, if bad credentials, EDSM will moan alerting the user } if (EDCommander.Current.SyncToInara) { EliteDangerousCore.Inara.InaraSync.NewEvent(LogLine, hl, he); } if (EDCommander.Current.SyncToIGAU) { EliteDangerousCore.IGAU.IGAUSync.NewEvent(LogLine, he); } if (EDCommander.Current.SyncToEDAstro) { EliteDangerousCore.EDAstro.EDAstroSync.SendEDAstroEvents(new List <HistoryEntry>() { he }); } if (EDDNClass.IsEDDNMessage(he.EntryType) && he.AgeOfEntry() < TimeSpan.FromDays(1.0) && EDCommander.Current.SyncToEddn == true) { EDDNSync.SendEDDNEvents(LogLine, he); } DLLManager.NewJournalEntry(EliteDangerousCore.DLL.EDDDLLCallerHE.CreateFromHistoryEntry(history, he), false); screenshotconverter.NewJournalEntry(he.journalEntry); // tell the screenshotter. CheckActionProfile(he); }
private void Controller_NewEntrySecond(HistoryEntry he, HistoryList hl) // called after all UI's have had their chance { BaseUtils.AppTicks.TickCountLapDelta("DFS", true); actioncontroller.ActionRunOnEntry(he, Actions.ActionEventEDList.NewEntry(he)); var t1 = BaseUtils.AppTicks.TickCountLapDelta("DFS"); if (t1.Item2 >= 80) { System.Diagnostics.Trace.WriteLine("NE Second Actions slow " + t1.Item1); } // all notes committed SystemNoteClass.CommitDirtyNotes((snc) => { if (EDCommander.Current.SyncToEdsm && snc.FSDEntry) { EDSMClass.SendComments(snc.SystemName, snc.Note, 0, he.Commander); } }); var lastent = history.GetLast; if (!object.ReferenceEquals(he, lastent)) { LogLineHighlight(string.Format("Current history entry is not last in history - possible re-entrancy.\nAlert the EDDiscovery developers using either discord or Github (see help) and attach log file {0}", BaseUtils.TraceLog.LogFileName)); Trace.WriteLine($"Current history entry is not last in history"); Trace.WriteLine($"Current entry: {he.journalEntry?.GetJsonString()}"); Trace.WriteLine($"Last entry: {lastent.journalEntry?.GetJsonString()}"); Trace.WriteLine($"Stack Trace:"); Trace.WriteLine(new StackTrace(true).ToString()); } if (he.IsFSDCarrierJump) { int count = history.GetVisitsCount(he.System.Name); LogLine(string.Format("Arrived at system {0} Visit No. {1}".T(EDTx.EDDiscoveryForm_Arrived), he.System.Name, count)); System.Diagnostics.Trace.WriteLine("Arrived at system: " + he.System.Name + " " + count + ":th visit."); } if (EDCommander.Current.SyncToEdsm && EDSMJournalSync.OkayToSend(he)) // send this one, if allowed. { EDSMJournalSync.SendEDSMEvents(LogLine, new List <HistoryEntry>() { he }); // send, if bad credentials, EDSM will moan alerting the user } if (EDCommander.Current.SyncToInara) { EliteDangerousCore.Inara.InaraSync.NewEvent(LogLine, he); } if (EDCommander.Current.SyncToIGAU) { EliteDangerousCore.IGAU.IGAUSync.NewEvent(LogLine, he); } if (EDDNClass.IsEDDNMessage(he.EntryType) && he.AgeOfEntry() < TimeSpan.FromDays(1.0) && EDCommander.Current.SyncToEddn == true) { EDDNSync.SendEDDNEvents(LogLine, he); } DLLManager.NewJournalEntry(EliteDangerousCore.DLL.EDDDLLCallerHE.CreateFromHistoryEntry(history, he), false); screenshotconverter.NewJournalEntry(he.journalEntry); // tell the screenshotter. CheckActionProfile(he); // finally, CAPI, if docked, try and get commodity data, and if so, create a new EDD record // placed here because it causes a new set of newentries to be called if (he.EntryType == JournalTypeEnum.Docked && FrontierCAPI.Active) { System.Threading.Tasks.Task.Run(() => // don't hold up the main thread, do it in a task, as its a HTTP operation { var dockevt = he.journalEntry as EliteDangerousCore.JournalEvents.JournalDocked; string marketjson = FrontierCAPI.Market(); CAPI.Market mk = new CAPI.Market(marketjson); if (mk.IsValid) { System.IO.File.WriteAllText(@"c:\code\market.json", marketjson); if (dockevt.StationName.Equals(mk.Name, StringComparison.InvariantCultureIgnoreCase)) { System.Diagnostics.Debug.WriteLine($"CAPI got market {mk.Name}"); var entry = new EliteDangerousCore.JournalEvents.JournalEDDCommodityPrices(he.EventTimeUTC.AddSeconds(1), mk.ID, mk.Name, he.System.Name, EDCommander.CurrentCmdrID, mk.Commodities); var jo = entry.ToJSON(); // get json of it, and add it to the db entry.Add(jo); BeginInvoke((System.Windows.Forms.MethodInvoker) delegate { Debug.Assert(System.Windows.Forms.Application.MessageLoop); System.Diagnostics.Debug.WriteLine("CAPI fire new entry"); NewEntry(entry); // then push it thru. this will cause another set of calls to NewEntry First/Second // EDDN handler will pick up EDDCommodityPrices and send it. }); } else { System.Diagnostics.Trace.WriteLine($"CAPI disagree on market {dockevt.StationName} vs {mk.Name}"); } } else { System.Diagnostics.Trace.WriteLine($"CAPI market invalid {marketjson}"); } }); } }