private void Controller_RefreshComplete() { travelHistoryControl1.RefreshButton(true); journalViewControl1.RefreshButton(true); actioncontroller.ActionRunOnRefresh(); if (!Capi.IsCommanderLoggedin(EDCommander.Current.Name)) { Capi.Logout(); if (CompanionAPI.CompanionCredentials.CredentialState(EDCommander.Current.Name) == CompanionAPI.CompanionCredentials.State.CONFIRMED) { try { Capi.LoginAs(EDCommander.Current.Name); LogLine("Logged into Companion API"); } catch (Exception ex) { LogLineHighlight("Companion API log in failed: " + ex.Message); if (!(ex is CompanionAPI.CompanionAppException)) { LogLineHighlight(ex.StackTrace); } } } } if (Capi.LoggedIn) { if (Controller.history != null && Controller.history.GetLast.ContainsRares()) { LogLine("Not performing Companion API get due to carrying rares"); } else { try { Capi.GetProfile(); OnNewCompanionAPIData?.Invoke(Capi, null); } catch (Exception ex) { LogLineHighlight("Companion API get failed: " + ex.Message); if (!(ex is CompanionAPI.CompanionAppException)) { LogLineHighlight(ex.StackTrace); } // what do we do TBD } } } }
private void Controller_NewEntrySecond(HistoryEntry he, HistoryList hl) // called after all UI's have had their chance { actioncontroller.ActionRunOnEntry(he, "NewEntry"); if (he.EntryType == JournalTypeEnum.Docked) { if (Capi.IsCommanderLoggedin(EDCommander.Current.Name)) { if (he.ContainsRares()) { LogLine("Not performing Companion API get due to carrying rares"); } else { System.Diagnostics.Debug.WriteLine("Commander " + EDCommander.Current.Name + " in CAPI"); try { Capi.GetProfile(); JournalEDDCommodityPrices entry = JournalEntry.AddEDDCommodityPrices(EDCommander.Current.Nr, he.journalEntry.EventTimeUTC.AddSeconds(1), Capi.Profile.StarPort.name, Capi.Profile.StarPort.faction, Capi.Profile.StarPort.jcommodities); if (entry != null) { Controller.NewEntry(entry); OnNewCompanionAPIData?.Invoke(Capi, he); if (EDCommander.Current.SyncToEddn) { SendPricestoEDDN(he); } } } catch (Exception ex) { LogLineHighlight("Companion API get failed: " + ex.Message); } } } } }