protected int _Compare(ProcessVariablesContainer variables) { object left = _GetLeft(variables); object right = _GetRight(variables); return(_Compare(left, right, variables)); }
protected sealed override object _Invoke(ProcessVariablesContainer variables) { Log.Debug("Attempting to compile script to execute for script element {0}", new object[] { id }); string errors; if (!_CompileAssembly(out errors)) { throw new Exception(errors); } Log.Debug("Creating new instance of compiled script class for script element {0}", new object[] { id }); object o = _assembly.CreateInstance(_className); Log.Debug("Accesing method from new instance of compiled script class for script element {0}", new object[] { id }); MethodInfo mi = o.GetType().GetMethod(_functionName); object[] args = new object[] { variables }; Log.Debug("Executing method from new instance of compiled script class for script element {0}", new object[] { id }); object ret = mi.Invoke(o, args); if (mi.ReturnType == typeof(void)) { Log.Debug("Collecting the returned value from new instance of compiled script class for script element {0}", new object[] { id }); ret = args[0]; } return(ret); }
protected int _Compare(object left, object right, ProcessVariablesContainer variables) { if (left == null && right != null) { return(-1); } else if (left != null && right == null) { return(1); } else { if (left is string && right is string) { return(((string)left).CompareTo(right)); } else { if (left is string && !(right is string)) { left = _ConvertToType((string)left, right.GetType(), variables); } else if (!(left is string) && right is string) { right = _ConvertToType((string)right, left.GetType(), variables); } else { return(left.ToString().CompareTo(right.ToString())); } return(((IComparable)left).CompareTo(right)); } } }
protected override object _Invoke(ProcessVariablesContainer variables) { Log.Info("Attempting to invoke Javascript script {0}", new object[] { id }); if (_engineType == null) { throw new Exception("Unable to process Javascript because the Jint.dll was not located in the Assembly path."); } Log.Debug("Creating new Javascript Engine for script element {0}", new object[] { id }); object engine = _engineType.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); object[] pars = new object[] { "variables", variables }; Log.Debug("Invoking Javascript Engine for script element {0}", new object[] { id }); _setValue.Invoke(engine, pars); object ret = null; if (_Code.Contains("return ")) { ret = _getCompletionValue.Invoke(_execute.Invoke(engine, new object[] { string.Format(_codeExecReturnFormat, _Code) }), new object[] { }); } else { ret = _getCompletionValue.Invoke(_execute.Invoke(engine, new object[] { _Code }), new object[] {}); } if (_IsCondition) { return(bool.Parse(_toObject.Invoke(ret, new object[] { }).ToString())); } else if (_IsTimerEvent) { return(DateTime.Parse(_toObject.Invoke(ret, new object[] { }).ToString())); } return(pars[1]); }
protected object _GetRight(ProcessVariablesContainer variables) { object right = null; if (this["rightVariable"] != null) { right = _extractVariable(variables, this["rightVariable"]); } else { if (SubNodes != null) { foreach (XmlNode n in SubNodes) { if (n.NodeType == XmlNodeType.Element) { if (_map.isMatch("exts", "right", n.Name) || n.Name == "right") { right = n.InnerText; break; } } } } } return(right); }
public TimeSpan? GetTimeout(ProcessVariablesContainer variables) { foreach (IElement ie in Children) { if (ie is TimerEventDefinition) return ((TimerEventDefinition)ie).GetTimeout(variables); } return null; }
public DateTime GetTime(ProcessVariablesContainer variables) { if (_Code == "") { throw new Exception("Invalid Date String Specified"); } DateString ds = new BpmEngine.DateString(_Code); return(ds.GetTime(variables)); }
public object Invoke(ProcessVariablesContainer variables) { Log.Info("Attempting to process script {0}", new object[] { id }); try { return(_Invoke(variables)); } catch (Exception e) { Log.Exception(e); throw e; } }
protected override bool _Evaluate(ProcessVariablesContainer variables) { bool ret = false; if (_Conditions != null) { foreach (ACondition cond in _Conditions) { ret = ret || cond.Evaluate(variables); } } return(ret); }
protected override bool _Evaluate(ProcessVariablesContainer variables) { object right = _GetRight(variables); object left = _GetLeft(variables); if (left == null && right != null) { return(false); } else if (left != null && right == null) { return(false); } else { if (left is Array) { foreach (object ol in (Array)left) { if (_Compare(ol, right, variables) == 0) { return(true); } } } else if (left is Hashtable) { foreach (object ol in ((Hashtable)left).Keys) { if (_Compare(ol, right, variables) == 0) { return(true); } } foreach (object ol in ((Hashtable)left).Values) { if (_Compare(ol, right, variables) == 0) { return(true); } } } else if (left.ToString().Contains(right.ToString())) { return(true); } } return(false); }
private object _ConvertToType(string value, Type type, ProcessVariablesContainer variables) { object ret = value; switch (type.FullName) { case "System.Boolean": ret = bool.Parse(value); break; case "System.Byte[]": ret = Convert.FromBase64String(value); break; case "System.Char": ret = value[0]; break; case "System.DateTime": ret = new DateString(value).GetTime(variables); break; case "System.Decimal": ret = decimal.Parse(value); break; case "System.Double": ret = double.Parse(value); break; case "System.Single": ret = float.Parse(value); break; case "System.Int32": ret = int.Parse(value); break; case "System.Int64": ret = long.Parse(value); break; case "System.Int16": ret = short.Parse(value); break; } return(ret); }
public bool IsFlowValid(IsFlowValid isFlowValid, ProcessVariablesContainer variables) { Log.Debug("Checking if Sequence Flow[{0}] is valid", new object[] { id }); bool ret = isFlowValid(this, variables); if (ExtensionElement != null) { ExtensionElements ee = (ExtensionElements)ExtensionElement; if (ee.Children != null) { foreach (IElement ie in ee.Children) { if (ie is ConditionSet) { ret = ret & ((ConditionSet)ie).Evaluate(variables); } } } } return(ret); }
public bool IsStartValid(ProcessVariablesContainer variables, IsProcessStartValid isProcessStartValid) { if (ExtensionElement != null) { ExtensionElements ee = (ExtensionElements)ExtensionElement; if (ee.Children != null) { foreach (IElement ie in ee.Children) { if (ie is ConditionSet) { if (!((ConditionSet)ie).Evaluate(variables)) { return(false); } } } } } return(isProcessStartValid(this, variables)); }
internal void ProcessTask(ref ProcessVariablesContainer variables, ProcessScriptTask processScriptTask) { if (ExtensionElement != null) { ExtensionElements ee = (ExtensionElements)ExtensionElement; if (ee.Children != null) { foreach (IElement ie in ee.Children) { if (ie is AScript) { variables = (ProcessVariablesContainer)((AScript)ie).Invoke(variables); break; } } } } if (processScriptTask != null) { processScriptTask(this, ref variables); } }
public TimeSpan?GetTimeout(ProcessVariablesContainer variables) { DateTime now = DateTime.Now; DateTime?end = null; foreach (IElement ie in Children) { if (ie is XDateString) { end = ((XDateString)ie).GetTime(variables); break; } else if (ie is AScript) { end = (DateTime)((AScript)ie).Invoke(variables); break; } } if (!end.HasValue && this.ExtensionElement != null) { foreach (IElement ie in ((ExtensionElements)this.ExtensionElement).Children) { if (ie is XDateString) { end = ((XDateString)ie).GetTime(variables); break; } else if (ie is AScript) { end = (DateTime)((AScript)ie).Invoke(variables); break; } } } return(end.HasValue ? end.Value.Subtract(now) : (TimeSpan?)null); }
protected abstract bool _Evaluate(ProcessVariablesContainer variables);
protected override bool _Evaluate(ProcessVariablesContainer variables) { return(variables[this["variable"]] == null); }
public abstract string[] EvaulateOutgoingPaths(Definition definition, IsFlowValid isFlowValid, ProcessVariablesContainer variables);
public abstract bool Evaluate(ProcessVariablesContainer variables);
public override string[] EvaulateOutgoingPaths(Definition definition, IsFlowValid isFlowValid, ProcessVariablesContainer variables) { List <string> ret = new List <string>(); foreach (string str in Outgoing) { if ((Default == null ? "" : Default) != str) { SequenceFlow sf = (SequenceFlow)definition.LocateElement(str); if (sf.IsFlowValid(isFlowValid, variables)) { ret.Add(sf.id); } } } if (ret.Count == 0) { if (Default != null) { ret.Add(Default); } } return(ret.Count == 0 ? null : ret.ToArray()); }
protected abstract object _Invoke(ProcessVariablesContainer variables);
protected override bool _Evaluate(ProcessVariablesContainer variables) { return(_Compare(variables) >= 0); }
public override string[] EvaulateOutgoingPaths(Definition definition, IsFlowValid isFlowValid, ProcessVariablesContainer variables) { string ret = null; foreach (string str in Outgoing) { if ((Default == null ? "" : Default) != str) { SequenceFlow sf = (SequenceFlow)definition.LocateElement(str); if (sf.IsFlowValid(isFlowValid, variables)) { ret = sf.id; break; } } } return(ret == null ? (this.Default == null ? null : new string[] { Default }) : new string[] { ret }); }
public sealed override bool Evaluate(ProcessVariablesContainer variables) { bool ret = _Evaluate(variables); return(_negated ? !ret : ret); }
public override string[] EvaulateOutgoingPaths(Definition definition, IsFlowValid isFlowValid, ProcessVariablesContainer variables) { return(Outgoing); }
public override bool Evaluate(ProcessVariablesContainer variables) { return((bool)_script.Invoke(variables)); }
public override bool Evaluate(ProcessVariablesContainer variables) { return(_Conditions[0].Evaluate(variables)); }