Пример #1
0
        public static void TestJournal()
        {
            foreach (string s in Enum.GetNames(typeof(JournalTypeEnum)))
            //string s = "EDDItemSet";
            {
                string json = "{ \"timestamp\":\"2017-04-05T11:16:19Z\", \"event\":\"" + s + "\" }";

                System.Diagnostics.Debug.WriteLine("Event " + s + ":");

                JournalEntry j = JournalEntry.CreateJournalEntry(json);

                Debug.Assert(j.Icon != null);

                string summary, info, detailed;
                j.FillInformation(out summary, out info, out detailed);

                Conditions.ConditionVariables vars = new Conditions.ConditionVariables();
                vars.AddPropertiesFieldsOfClass(j, "EventClass_", new Type[] { typeof(System.Drawing.Bitmap), typeof(Newtonsoft.Json.Linq.JObject) }, 5);      //depth seems good enough

                int n = 0;
                foreach (string cv in vars.NameList)
                {
                    if (n++ >= 1)
                    {
                        System.Diagnostics.Debug.Write(",");
                    }

                    System.Diagnostics.Debug.Write(cv);
                }

                System.Diagnostics.Debug.WriteLine("");
            }
        }
Пример #2
0
 private void writeEventInfoToLogDebugToolStripMenuItem_Click(object sender, EventArgs e)        //DEBUG ONLY
 {
     Conditions.ConditionVariables cv = new Conditions.ConditionVariables();
     cv.AddPropertiesFieldsOfClass(rightclicksystem.journalEntry, "", new Type[] { typeof(System.Drawing.Bitmap), typeof(Newtonsoft.Json.Linq.JObject) }, 5);
     discoveryform.LogLine(cv.ToString(separ: Environment.NewLine));
     if (rightclicksystem.ShipInformation != null)
     {
         discoveryform.LogLine(rightclicksystem.ShipInformation.ToString());
     }
 }
Пример #3
0
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            string res;

            if (ap.functions.ExpandString(UserData, out res) != Conditions.ConditionFunctions.ExpandResult.Failed)
            {
                StringParser sp = new StringParser(res);

                string prefix  = "ST_";
                string cmdname = sp.NextQuotedWord();

                if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase))
                {
                    prefix = sp.NextWord();

                    if (prefix == null)
                    {
                        ap.ReportError("Missing name after Prefix in Star");
                        return(true);
                    }

                    cmdname = sp.NextQuotedWord();
                }

                if (cmdname != null)
                {
                    ISystem sc = SystemClassDB.GetSystem(cmdname);
                    ap[prefix + "Found"] = sc != null ? "1" : "0";

                    if (sc != null)
                    {
                        Conditions.ConditionVariables vars = new Conditions.ConditionVariables();
                        ActionVars.SystemVars(vars, sc, prefix);
                        ap.Add(vars);
                        ActionVars.SystemVarsFurtherInfo(ap, (ap.actioncontroller as ActionController).HistoryList, sc, prefix);
                    }
                }
                else
                {
                    ap.ReportError("Missing starname in Star");
                }
            }
            else
            {
                ap.ReportError(res);
            }

            return(true);
        }
Пример #4
0
        static public List <HistoryEntry> MarkHistory(List <HistoryEntry> he, Conditions.ConditionLists cond, Conditions.ConditionVariables othervars, out int count)       // Used for debugging it..
        {
            count = 0;

            if (cond.Count == 0)       // no filters, all in
            {
                return(he);
            }
            else
            {
                List <HistoryEntry> ret = new List <HistoryEntry>();

                foreach (HistoryEntry s in he)
                {
                    List <Conditions.Condition> list = new List <Conditions.Condition>();    // don't want it

                    int mrk = s.EventDescription.IndexOf(":::");
                    if (mrk >= 0)
                    {
                        s.EventDescription = s.EventDescription.Substring(mrk + 3);
                    }

                    string er;

                    if (!cond.CheckFilterFalse(s.journalEntry, s.journalEntry.EventTypeStr, new Conditions.ConditionVariables[] { othervars, new Conditions.ConditionVariables("Note", s.snc?.Note ?? "") }, out er, list))
                    {
                        //System.Diagnostics.Debug.WriteLine("Filter out " + s.Journalid + " " + s.EntryType + " " + s.EventDescription);
                        s.EventDescription = "!" + list[0].eventname + ":::" + s.EventDescription;
                        count++;
                    }

                    ret.Add(s);
                }

                return(ret);
            }
        }
Пример #5
0
        static public List <HistoryEntry> FilterHistory(List <HistoryEntry> he, Conditions.ConditionLists cond, Conditions.ConditionVariables othervars, out int count)    // filter in all entries
        {
            count = 0;
            if (cond.Count == 0)       // no filters, all in
            {
                return(he);
            }
            else
            {
                string er;
                List <HistoryEntry> ret = (from s in he where cond.CheckFilterFalse(s.journalEntry, s.journalEntry.EventTypeStr,
                                                                                    new Conditions.ConditionVariables[] { othervars, new Conditions.ConditionVariables("Note", s.snc?.Note ?? "") },
                                                                                    out er, null) select s).ToList();

                count = he.Count - ret.Count;
                return(ret);
            }
        }
Пример #6
0
        static public bool FilterHistory(HistoryEntry he, Conditions.ConditionLists cond, Conditions.ConditionVariables othervars)                // true if it should be included
        {
            string er;

            return(cond.CheckFilterFalse(he.journalEntry, he.journalEntry.EventTypeStr,
                                         new Conditions.ConditionVariables[] { othervars, new Conditions.ConditionVariables("Note", he.snc?.Note ?? "") }, out er, null)); // true it should be included
        }
Пример #7
0
 static public List <HistoryEntry> CheckFilterTrue(List <HistoryEntry> he, Conditions.ConditionLists cond, Conditions.ConditionVariables othervars) // conditions match for item to stay
 {
     if (cond.Count == 0)                                                                                                                           // no filters, all in
     {
         return(he);
     }
     else
     {
         string er;
         List <HistoryEntry> ret = (from s in he where cond.CheckFilterTrue(s.journalEntry, new Conditions.ConditionVariables[] { othervars, new Conditions.ConditionVariables("Note", s.snc?.Note ?? "") }, out er, null) select s).ToList();
         return(ret);
     }
 }