Esempio n. 1
0
        public static 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;
        }
Esempio n. 2
0
        private void SendPricestoEDDN(HistoryEntry he)
        {
            try
            {
                EDDN.EDDNClass eddn = new EDDN.EDDNClass();

                eddn.commanderName = he.Commander.EdsmName;
                if (string.IsNullOrEmpty(eddn.commanderName))
                {
                    eddn.commanderName = Capi.Credentials.Commander;
                }


                JObject msg = eddn.CreateEDDNCommodityMessage(Capi.Profile.StarPort.commodities, Capi.Profile.CurrentStarSystem.name, Capi.Profile.StarPort.name, DateTime.UtcNow);

                if (msg != null)
                {
                    LogLine("EDDN: Send commodities prices");
                    if (eddn.PostMessage(msg))
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                LogLineHighlight("EDDN: Send commodities prices failed: " + ex.Message);
            }
        }
Esempio n. 3
0
        static public bool SendToEDDN(HistoryEntry he)
        {
            EDDNClass eddn = new EDDNClass();

            if (he.Commander != null)
            {
                eddn.commanderName = he.Commander.EdsmName;
                if (string.IsNullOrEmpty(eddn.commanderName))
                {
                    eddn.commanderName = he.Commander.Name;
                }
            }

            JournalEntry je = he.journalEntry;

            if (je == null)
            {
                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))
                {
                    he.SetEddnSync();
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        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);
            }
        }