Beispiel #1
0
        private void loadFlows()
        {
            var afls = GetActionFlows(Settings.Settings.Default.ActionBuilderFlowsXml);

            foreach (var af in afls)
            {
                ActionFlows.Add(af);
            }
        }
Beispiel #2
0
 public void Save()
 {
     try
     {
         XmlDocument          doc = createFlowXml(ActionFlows.ToList());
         StringBuilder        sb  = new StringBuilder();
         System.IO.TextWriter tr  = new System.IO.StringWriter(sb);
         XmlTextWriter        wr  = new XmlTextWriter(tr);
         wr.Formatting = Formatting.None;
         doc.Save(wr);
         wr.Close();
         Settings.Settings.Default.ActionBuilderFlowsXml = sb.ToString();
     }
     catch
     {
     }
 }
Beispiel #3
0
 public void Save()
 {
     try
     {
         XmlDocument          doc = createFlowXml(ActionFlows.ToList());
         StringBuilder        sb  = new StringBuilder();
         System.IO.TextWriter tr  = new System.IO.StringWriter(sb);
         XmlTextWriter        wr  = new XmlTextWriter(tr);
         wr.Formatting = Formatting.None;
         doc.Save(wr);
         wr.Close();
         Core.Settings.Default.ActionBuilderFlowsXml = sb.ToString();
     }
     catch (Exception e)
     {
         Core.ApplicationData.Instance.Logger.AddLog(this, e);
     }
 }
Beispiel #4
0
        private void getActionFlowsFromXml(XmlDocument doc)
        {
            List <ActionImplementation> allActionImpl = new List <ActionImplementation>();

            XmlNodeList nl = doc.SelectNodes("/flows/flow");

            foreach (XmlNode n in nl)
            {
                ActionFlow af = new ActionFlow();
                af.Name    = n.Attributes["name"].Value;
                af.ID      = n.Attributes["id"].Value;
                af.Actions = new List <ActionImplementation>();

                XmlNodeList al = n.SelectNodes("action");
                foreach (XmlNode a in al)
                {
                    Type                 t           = Type.GetType(a.Attributes["type"].Value);
                    ConstructorInfo      constructor = t.GetConstructor(Type.EmptyTypes);
                    ActionImplementation obj         = (ActionImplementation)constructor.Invoke(null);
                    obj.ID       = a.Attributes["id"].Value;
                    obj.Location = new System.Windows.Point((double)int.Parse(a.Attributes["x"].Value), (double)int.Parse(a.Attributes["y"].Value));

                    af.Actions.Add(obj);
                    allActionImpl.Add(obj);

                    XmlNodeList vl = a.SelectNodes("values/value");
                    foreach (XmlNode v in vl)
                    {
                        obj.Values.Add(v.InnerText);
                    }
                }

                ActionFlows.Add(af);
            }

            //all actions are created, now we can match the ID's for the connections.
            nl = doc.SelectNodes("/flows/flow/action");
            foreach (XmlNode n in nl)
            {
                ActionImplementation          ai = (from ac in allActionImpl where ac.ID == n.Attributes["id"].Value select ac).FirstOrDefault();
                XmlNodeList                   conl;
                ActionImplementation.Operator op = ai.AllowOperators;
                if ((op & ActionImplementation.Operator.Equal) != 0)
                {
                    conl = n.SelectNodes("Equal/ID");
                    foreach (XmlNode con in conl)
                    {
                        ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.Equal);
                    }
                }
                if ((op & ActionImplementation.Operator.Larger) != 0)
                {
                    conl = n.SelectNodes("Larger/ID");
                    foreach (XmlNode con in conl)
                    {
                        ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.Larger);
                    }
                }
                if ((op & ActionImplementation.Operator.LargerOrEqual) != 0)
                {
                    conl = n.SelectNodes("LargerOrEqual/ID");
                    foreach (XmlNode con in conl)
                    {
                        ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.LargerOrEqual);
                    }
                }
                if ((op & ActionImplementation.Operator.Less) != 0)
                {
                    conl = n.SelectNodes("Less/ID");
                    foreach (XmlNode con in conl)
                    {
                        ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.Less);
                    }
                }
                if ((op & ActionImplementation.Operator.LessOrEqual) != 0)
                {
                    conl = n.SelectNodes("LessOrEqual/ID");
                    foreach (XmlNode con in conl)
                    {
                        ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.LessOrEqual);
                    }
                }
                if ((op & ActionImplementation.Operator.NotEqual) != 0)
                {
                    conl = n.SelectNodes("NotEqual/ID");
                    foreach (XmlNode con in conl)
                    {
                        ai.ConnectToOutput((from ac in allActionImpl where ac.ID == con.InnerText select ac).FirstOrDefault(), ActionImplementation.Operator.NotEqual);
                    }
                }
            }
        }