Beispiel #1
0
 private static string ReturnHandler(bool boolean, IfXML script, IfXML parentIf, XML.DocXML parentDoc)
 {
     if (boolean)
     {
         if (script.If != null)
         {
             return(RunScript(script.If, script, null));
         }
         else if (Guid.TryParse(script.Return, out Guid next))
         {
             return(next.ToString());
         }
         else
         {
             return("error:\"Work\" is not a valid GUID");
         }
     }
     else
     {
         if (parentIf != null)
         {
             if (parentIf.Return != "")
             {
                 return(parentIf.Return);
             }
         }
         return(parentDoc.DefaultNextGuid);
     }
 }
Beispiel #2
0
        public static string RunScript(IfXML script, IfXML parentIf, XML.DocXML parentDoc)
        {
            var type = script.LeftHand.Split(':')[0];

            if (type == script.RightHand.Split(':')[0])
            {
                switch (type)
                {
                case "int":
                    try
                    {
                        int int1 = Convert.ToInt32(script.LeftHand.Split(':')[1]);
                        int int2 = Convert.ToInt32(script.RightHand.Split(':')[1]);
                        return(ReturnHandler(PerformOperation(int1, int2, script.Comparator),
                                             script, parentIf, parentDoc));
                    }
                    catch (Exception ex)
                    {
                        return("error:" + ex.Message);
                    }

                case "bool":
                    try
                    {
                        Boolean.TryParse(script.LeftHand.Split(':')[1], out bool b1);
                        Boolean.TryParse(script.RightHand.Split(':')[1], out bool b2);
                        return(ReturnHandler(PerformOperation(b1, b2, script.Comparator),
                                             script, parentIf, parentDoc));
                    }
                    catch (Exception ex)
                    {
                        return("error:" + ex.Message);
                    }

                case "date":
                    try
                    {
                        string ds1 = script.LeftHand.Split(':')[1];
                        string ds2 = script.RightHand.Split(':')[1];

                        if (ds1 == "today" && !ds2.Contains("/"))
                        {
                            return(ReturnHandler(PerformOperation(ds1, ds2, script.Comparator, true),
                                                 script, parentIf, parentDoc));
                        }
                        else
                        {
                            return(ReturnHandler(PerformOperation(ds1, ds2, script.Comparator, false),
                                                 script, parentIf, parentDoc));
                        }
                    }
                    catch (Exception ex)
                    {
                        return("error:" + ex.Message);
                    }

                default:
                    return("error:Type not recognized");
                }
            }
            else
            {
                return("error:Types are different");
            }
        }
Beispiel #3
0
 public static string RunScript(string xml, XML.DocXML parentDoc)
 {
     return(RunScript(IfXML.FromString(xml), null, parentDoc));
 }