Пример #1
0
        public JObject CreateEDDNMessage(JournalScan journal, string starSystem, double x, double y, double z, long?systemAddress = null)
        {
            JObject msg = new JObject();

            msg["header"]     = Header();
            msg["$schemaRef"] = GetEDDNJournalSchemaRef();

            JObject message = journal.GetJson();

            message["StarSystem"] = starSystem;
            message["StarPos"]    = new JArray(new float[] { (float)x, (float)y, (float)z });

            if (systemAddress != null)
            {
                message["SystemAddress"] = systemAddress;
            }

            string bodydesig = journal.BodyDesignation ?? journal.BodyName;

            if (!bodydesig.StartsWith(starSystem, StringComparison.InvariantCultureIgnoreCase))  // For now test if its a different name ( a few exception for like sol system with named planets)  To catch a rare out of sync bug in historylist.
            {
                return(null);
            }


            message        = RemoveCommonKeys(message);
            msg["message"] = message;
            return(msg);
        }
Пример #2
0
        public JObject CreateEDDNMessage(JournalScan journal, ISystem system)
        {
            if (system.SystemAddress == null)
            {
                return(null);
            }

            // Reject scan if system doesn't match scan system
            if (journal.SystemAddress != null && journal.StarSystem != null && (journal.SystemAddress != system.SystemAddress || journal.StarSystem != system.Name))
            {
                return(null);
            }

            JObject msg = new JObject();

            msg["header"]     = Header();
            msg["$schemaRef"] = GetEDDNJournalSchemaRef();

            JObject message = journal.GetJson();

            if (message == null)
            {
                return(null);
            }

            message["StarSystem"] = system.Name;
            message["StarPos"]    = new JArray(new float[] { (float)system.X, (float)system.Y, (float)system.Z });

            message["SystemAddress"] = system.SystemAddress;

            if (message["Materials"] != null && message["Materials"] is JArray)
            {
                foreach (JObject mmat in message["Materials"])
                {
                    mmat.Remove("Name_Localised");
                }
            }

            string bodydesig = journal.BodyDesignation ?? journal.BodyName;

            if (!bodydesig.StartsWith(system.Name, StringComparison.InvariantCultureIgnoreCase))  // For now test if its a different name ( a few exception for like sol system with named planets)  To catch a rare out of sync bug in historylist.
            {
                if (journal.BodyDesignation != null || System.Text.RegularExpressions.Regex.IsMatch(journal.BodyName, " [A-Z][A-Z]-[A-Z] [a-h][0-9]", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
                {
                    return(null);
                }

                msg["IsUnknownBody"] = true;
                msg["$schemaRef"]    = GetEDDNJournalSchemaRef(true);
            }


            message = RemoveCommonKeys(message);

            message = FilterJournalEvent(message, AllowedFieldsScan);

            msg["message"] = message;
            return(msg);
        }
Пример #3
0
        public JObject CreateEGOMessage(JournalScan journal, string starSystem, double x, double y, double z)
        {
            JObject detail = new JObject();

            detail["input_1"] = ego_username;
            detail["input_2"] = ego_apikey;
            detail["input_3"] = application_id;
            detail["input_4"] = auth_code;
            detail["input_5"] = journal.GetJson().ToString().Replace("\"", "\\\"");
            detail["input_6"] = starSystem;
            detail["input_7"] = x;
            detail["input_8"] = y;
            detail["input_9"] = z;
            JObject msg = new JObject();

            msg["input_values"] = detail;
            return(msg);
        }
Пример #4
0
        public JObject CreateEDDNMessage(JournalScan journal, ISystem system)
        {
            JObject msg = new JObject();

            msg["header"]     = Header();
            msg["$schemaRef"] = GetEDDNJournalSchemaRef();

            JObject message = journal.GetJson();

            message["StarSystem"] = system.Name;
            message["StarPos"]    = new JArray(new float[] { (float)system.X, (float)system.Y, (float)system.Z });

            if (system.SystemAddress != null)
            {
                message["SystemAddress"] = system.SystemAddress;
            }

            if (message["Materials"] != null && message["Materials"] is JArray)
            {
                foreach (JObject mmat in message["Materials"])
                {
                    mmat.Remove("Name_Localised");
                }
            }

            string bodydesig = journal.BodyDesignation ?? journal.BodyName;

            if (!bodydesig.StartsWith(system.Name, StringComparison.InvariantCultureIgnoreCase))  // For now test if its a different name ( a few exception for like sol system with named planets)  To catch a rare out of sync bug in historylist.
            {
                return(null);
            }


            message        = RemoveCommonKeys(message);
            msg["message"] = message;
            return(msg);
        }