internal static List <Activity> GetChildren(ActivityUtilities.ChildActivity root, ActivityUtilities.ActivityCallStack parentChain, ProcessActivityTreeOptions options) { ActivityUtilities.FinishCachingSubtree(root, parentChain, options); List <Activity> listOfChildren = new List <Activity>(); foreach (Activity activity in WorkflowInspectionServices.GetActivities(root.Activity)) { listOfChildren.Add(activity); } int toProcessIndex = 0; while (toProcessIndex < listOfChildren.Count) { foreach (Activity activity in WorkflowInspectionServices.GetActivities(listOfChildren[toProcessIndex])) { listOfChildren.Add(activity); } toProcessIndex++; } return(listOfChildren); }
public static void printActivityTreeA(Activity activity) { if (tag == null) { tag = new activityStruct(); tag.parent = null; tag.currentActivity = activity; tag.displayName = activity.DisplayName; } System.Collections.Generic.IEnumerator<Activity> list = WorkflowInspectionServices.GetActivities(activity).GetEnumerator(); while (list.MoveNext()) { activityStruct temp = new activityStruct(); temp.parent = tag; temp.currentActivity = list.Current; temp.displayName = list.Current.DisplayName; printActivityTreeA(list.Current); } }
public List <Array> printActivityTree(Activity activity, string _parallel = "") { string[] myIntArray = new string[3]; List <Array> allSteps = new List <Array>(); if ((activity is CodeActivity) && (activity.DisplayName.IndexOf(keyForStep) > 0)) { myIntArray.SetValue(activity.DisplayName.Replace(keyForStep, ""), 0); myIntArray.SetValue(activity.Id, 1); myIntArray.SetValue(_parallel, 2); allSteps.Add(myIntArray); } if ((activity is Parallel)) { _parallel = activity.Id; } IEnumerator <Activity> list = WorkflowInspectionServices.GetActivities(activity).GetEnumerator(); while (list.MoveNext()) { var allStepsBuf = allSteps.Concat(printActivityTree(list.Current, _parallel)); allSteps = allStepsBuf.ToList(); } if ((activity is Parallel) && (activity.Id == _parallel)) { _parallel = ""; } return(allSteps); }
public void GetChildrenModifyChildrenExecute() { TestSequence sequence = new TestSequence("Test Sequence") { Activities = { new TestWriteLine("WriteLine A") { Message = "message a", }, }, }; WorkflowInspectionServices.GetActivities(sequence.ProductActivity); sequence.Activities.Add( new TestWriteLine("WriteLine B") { Message = "message b", } ); // Now that we've changed the tree we explicitly recache WorkflowInspectionServices.CacheMetadata(sequence.ProductActivity); TestRuntime.RunAndValidateWorkflow(sequence); }
private void InspectActivity(Activity root) { IEnumerator <Activity> activities = WorkflowInspectionServices.GetActivities(root).GetEnumerator(); while (activities.MoveNext()) { PropertyInfo propVars = activities.Current.GetType().GetProperties().FirstOrDefault(p => p.Name == "Variables" && p.PropertyType == typeof(Collection <Variable>)); if (propVars != null) { try { Collection <Variable> variables = (Collection <Variable>)propVars.GetValue(activities.Current, null); variables.ToList().ForEach(v => { Variables.Add(v.Name); }); } catch { } } InspectActivity(activities.Current); } }
public IDev2Activity Parse(DynamicActivity dynamicActivity, List <IDev2Activity> seenActivities) { try { var chart = WorkflowInspectionServices.GetActivities(dynamicActivity).FirstOrDefault() as Flowchart; if (chart != null) { if (chart.StartNode == null) { return(null); } var start = chart.StartNode as FlowStep; if (start != null) { var tool = ParseTools(start, seenActivities); return(tool.FirstOrDefault()); } var flowstart = chart.StartNode as FlowSwitch <string>; if (flowstart != null) { return(ParseSwitch(flowstart, seenActivities).FirstOrDefault()); } var flowdec = chart.StartNode as FlowDecision; return(ParseDecision(flowdec, seenActivities).FirstOrDefault()); } return(null); } catch (InvalidWorkflowException e) { Dev2Logger.Log.Error(e); throw; } }
protected override Activity GetDebuggableActivity(Activity root) { WorkflowInspectionServices.CacheMetadata(root); var enumerator = WorkflowInspectionServices.GetActivities(root).GetEnumerator(); enumerator.MoveNext(); return(enumerator.Current); }
Dictionary <object, SourceLocation> GetErrorInformation(Activity activity) { Dictionary <object, SourceLocation> sourceLocations = null; Activity implementationRoot = null; IEnumerable <Activity> children = WorkflowInspectionServices.GetActivities(activity); foreach (Activity child in children) { // Check if the child is the root of the activity's implementation // When an activity is an implementation child of another activity, the IDSpace for // the implementation child is different than it's parent activity and parent's public // children. The IDs for activities in the root activity's IDSpace are 1, 2 // etc and for the root implementation child it is 1.1 and for its implementation // child it is 1.1.1 and so on. // As the activity can have just one implementation root, we just check // for '.' to identify the root of the implementation. if (child.Id.Contains(".")) { implementationRoot = child; break; } } if (implementationRoot == null) { return(sourceLocations); } // We use the workflow debug symbol to get the line and column number information for a // erroneous activity. // We do not rely on the workflow debug symbol to get the file name. This is to enable cases // where the xaml was hand written outside of the workflow designer. The hand written xaml // file will not have the workflow debug symbol unless it was saved in the workflow designer. string symbolString = DebugSymbol.GetSymbol(implementationRoot) as String; if (!string.IsNullOrEmpty(symbolString)) { try { WorkflowSymbol wfSymbol = WorkflowSymbol.Decode(symbolString); if (wfSymbol != null) { sourceLocations = SourceLocationProvider.GetSourceLocations(activity, wfSymbol); } } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } // Ignore invalid symbol. } } return(sourceLocations); }
}//end public static Activity getRuntimeActivityByDynamicActivity(DynamicActivity dynamicActivity) { IEnumerator <Activity> list = WorkflowInspectionServices.GetActivities(dynamicActivity).GetEnumerator(); list.MoveNext(); Activity runtimeActivity = list.Current; return(runtimeActivity); }
public void GetChildrenModifyChildrenExecute() { Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); TestIf testIf = new TestIf("If", HintThenOrElse.Then, HintThenOrElse.Else) { ConditionExpression = ((env) => ((int)counter.Get(env)) < 1), ThenActivity = new TestWriteLine("WriteLine Then") { Message = "Executing activity in Then branch", }, ElseActivity = new TestWriteLine("WriteLine Else") { Message = "Executing activity in Else branch", }, }; TestSequence outerSequence = new TestSequence("Outer sequence") { Variables = { counter }, Activities = { new TestDoWhile("DoWhile") { ConditionExpression = ((env) => counter.Get(env) < 2), Body = new TestSequence("Inner sequence") { Activities = { testIf, new TestAssign <int>("Increment Counter") { ValueExpression = (env) => counter.Get(env) + 1, ToVariable = counter, }, } }, HintIterationCount = 2, } }, }; WorkflowInspectionServices.GetActivities(testIf.ProductActivity); testIf.ThenActivity = new TestWriteLine("Then") { Message = "In Then branch", }; testIf.ElseActivity = new TestWriteLine("Else") { Message = "In Else branch", }; TestRuntime.RunAndValidateWorkflow(outerSequence); }
protected override Activity GetRootRuntimeWorkflowElement(Activity root) { WorkflowInspectionServices.CacheMetadata(root); IEnumerator <Activity> enumerator1 = WorkflowInspectionServices.GetActivities(root).GetEnumerator(); // Get the first child enumerator1.MoveNext(); root = enumerator1.Current; return(root); }
static void printActivityTree(Activity activity, string tag) { Console.WriteLine("{0} DisplayName:{1},type:{2}", tag, activity.DisplayName, activity.GetType()); IEnumerator <Activity> list = WorkflowInspectionServices.GetActivities(activity).GetEnumerator(); while (list.MoveNext()) { printActivityTree(list.Current, " " + tag); } }
private static ActivityInfo[] GetActivityChildren(Activity activity) { var children = new List <ActivityInfo>(); foreach (var child in WorkflowInspectionServices.GetActivities(activity).Where(a => a != null)) { children.Add(new ActivityInfo(child, activity, string.Empty)); } return(children.ToArray()); }
public void GetChildrenModifyChildrenExecute() { Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); TestDoWhile doWhile = new TestDoWhile("dowhile act") { ConditionExpression = ((env) => ((int)counter.Get(env)) < 10), Body = new TestSequence("test sequence act") { Activities = { new TestWriteLine("wrong activity", "Its a big world after all"), new TestAssign <int>("Increment Counter") { ToVariable = counter, ValueExpression = ((env) => (((int)counter.Get(env))) + 1), }, }, }, HintIterationCount = 5, }; TestSequence outerSequence = new TestSequence("sequence1") { Variables = { counter }, Activities = { doWhile, } }; WorkflowInspectionServices.GetActivities(doWhile.ProductActivity); doWhile.ConditionExpression = (env) => ((int)counter.Get(env)) < 5; doWhile.Body = new TestSequence("test sequence act") { Activities = { new TestWriteLine("write hello", "Its a small world after all"), new TestAssign <int>("Increment Counter") { ToVariable = counter, ValueExpression = ((env) => (((int)counter.Get(env))) + 1), }, }, }; // We need to recache the metadata now that we've changed the tree WorkflowInspectionServices.CacheMetadata(outerSequence.ProductActivity); TestRuntime.RunAndValidateWorkflow(outerSequence); }
public static void InspectActivity(Activity root, int indent) { // Inspect the activity tree using WorkflowInspectionServices. IEnumerator <Activity> activities = WorkflowInspectionServices.GetActivities(root).GetEnumerator(); Debug.WriteLine("{0}{1}", new string(' ', indent), root.DisplayName); while (activities.MoveNext()) { InspectActivity(activities.Current, indent + 2); } }
public void Instrument(Activity rootActivity, Dictionary <object, SourceLocation> sourceLocations, string typeNamePrefix) { Queue <KeyValuePair <Activity, string> > queue = new Queue <KeyValuePair <Activity, string> >(); Activity key = rootActivity; KeyValuePair <Activity, string> item = new KeyValuePair <Activity, string>(key, string.Empty); queue.Enqueue(item); HashSet <string> set = new HashSet <string>(); HashSet <Activity> set2 = new HashSet <Activity>(); while (queue.Count > 0) { string str; SourceLocation location; item = queue.Dequeue(); key = item.Key; string str2 = item.Value; string displayName = key.DisplayName; if (string.IsNullOrEmpty(displayName)) { displayName = key.GetType().Name; } if (str2 == string.Empty) { str = displayName; } else { str = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", new object[] { str2, displayName }); } int num = 0; while (set.Contains(str)) { num++; str = string.Format(CultureInfo.InvariantCulture, "{0}.{1}{2}", new object[] { str2, displayName, num.ToString(CultureInfo.InvariantCulture) }); } set.Add(str); set2.Add(key); if (sourceLocations.TryGetValue(key, out location)) { this.Instrument(key, location, str); } foreach (Activity activity2 in WorkflowInspectionServices.GetActivities(key)) { if (!set2.Contains(activity2)) { queue.Enqueue(new KeyValuePair <Activity, string>(activity2, str)); } } } this.stateManager.Bake(typeNamePrefix); }
protected override void Execute(NativeActivityContext context) { var activities = WorkflowInspectionServices.GetActivities(this); string name = MessageName; if (string.IsNullOrWhiteSpace(name)) { Debug.WriteLine("Bookmark name is empty"); return; } context.CreateBookmark(name, OnResumeBookmark); }
void FixAndCompileExpressions(Activity dynamicActivity, Guid resourceID) { // NOTE: DO NOT set properties or variables! SetNamespaces(dynamicActivity); // MS Memory Leak ;( var chart = WorkflowInspectionServices.GetActivities(dynamicActivity).FirstOrDefault() as Flowchart; if (chart != null) { FixExpressions(chart, true); } Dev2Logger.Log.Info("Fix Expressions"); CompileExpressionsImpl(dynamicActivity,resourceID); }
Activity GetRootRuntimeWorkflowElement() { Activity root = XamlHelper.GetActivity(_designer.Text); WorkflowInspectionServices.CacheMetadata(root); IEnumerator <Activity> enumerator1 = WorkflowInspectionServices.GetActivities(root).GetEnumerator(); //Get the first child of the x:class enumerator1.MoveNext(); root = enumerator1.Current; return(root); }
public static Activity GetRootRuntimeWorkflowElement(Activity workflowInstance) { Activity root = workflowInstance; WorkflowInspectionServices.CacheMetadata(root); IEnumerator <Activity> enumerator1 = WorkflowInspectionServices.GetActivities(root).GetEnumerator(); //Get the first child of the x:class enumerator1.MoveNext(); root = enumerator1.Current; return(root); }
static void InternalGetParentChildRelationships(Activity activity, Activity parent, IDictionary <Activity, Activity> parentChildMappings) { if (!parentChildMappings.ContainsKey(activity)) { // the very first parent declaring the child activity // and the rest are parent to reference child relationships parentChildMappings.Add(activity, parent); } foreach (Activity child in WorkflowInspectionServices.GetActivities(activity)) { InternalGetParentChildRelationships(child, activity, parentChildMappings); } }
private Activity GetRuntimeActivity() { _workflowDesigner.Flush(); var stringReader = new StringReader(_workflowDesigner.Text); var root = ActivityXamlServices.Load(stringReader); WorkflowInspectionServices.CacheMetadata(root); var list = WorkflowInspectionServices.GetActivities(root).GetEnumerator(); list.MoveNext(); var runtimeActivity = list.Current; return(runtimeActivity); }
private void MapInstrumentationStates(Activity rootActivity1, Activity rootActivity2) { Queue <KeyValuePair <Activity, Activity> > queue = new Queue <KeyValuePair <Activity, Activity> >(); queue.Enqueue(new KeyValuePair <Activity, Activity>(rootActivity1, rootActivity2)); HashSet <Activity> set = new HashSet <Activity>(); while (queue.Count > 0) { System.Activities.Debugger.State state; KeyValuePair <Activity, Activity> pair = queue.Dequeue(); Activity key = pair.Key; Activity activity2 = pair.Value; if (this.states.TryGetValue(key, out state)) { if (this.states.ContainsKey(activity2)) { Debugger.Log(1, "Workflow", System.Activities.SR.DuplicateInstrumentation(activity2.DisplayName)); } else { this.states.Add(activity2, state); } } set.Add(key); IEnumerator <Activity> enumerator = WorkflowInspectionServices.GetActivities(key).GetEnumerator(); IEnumerator <Activity> enumerator2 = WorkflowInspectionServices.GetActivities(activity2).GetEnumerator(); bool flag = enumerator.MoveNext(); bool flag2 = enumerator2.MoveNext(); while (flag && flag2) { if (!set.Contains(enumerator.Current)) { if (enumerator.Current.GetType() != enumerator2.Current.GetType()) { Debugger.Log(2, "Workflow", "Unmatched type: " + enumerator.Current.GetType().FullName + " vs " + enumerator2.Current.GetType().FullName + "\n"); } queue.Enqueue(new KeyValuePair <Activity, Activity>(enumerator.Current, enumerator2.Current)); } flag = enumerator.MoveNext(); flag2 = enumerator2.MoveNext(); } if (flag || flag2) { Debugger.Log(2, "Workflow", "Unmatched number of children\n"); } } }
private void InitializeUninstrumentedSubRoots() { this.uninstrumentedSubRoots = new Dictionary <Activity, string>(); Queue <Activity> queue = new Queue <Activity>(); this.CollectSubRoot(this.root); queue.Enqueue(this.root); while (queue.Count > 0) { foreach (Activity activity2 in WorkflowInspectionServices.GetActivities(queue.Dequeue())) { this.CollectSubRoot(activity2); queue.Enqueue(activity2); } } }
internal static List <Activity> GetChildren(ActivityUtilities.ChildActivity root, ActivityUtilities.ActivityCallStack parentChain, ProcessActivityTreeOptions options) { ActivityUtilities.FinishCachingSubtree(root, parentChain, options); List <Activity> list = new List <Activity>(); foreach (Activity activity in WorkflowInspectionServices.GetActivities(root.Activity)) { list.Add(activity); } for (int i = 0; i < list.Count; i++) { foreach (Activity activity2 in WorkflowInspectionServices.GetActivities(list[i])) { list.Add(activity2); } } return(list); }
Activity GetRootRuntimeWorkflowElement(Activity root) { try { //Activity root = ActivityXamlServices.Load(_currentWorkflowFile); WorkflowInspectionServices.CacheMetadata(root); IEnumerator <Activity> enumerator1 = WorkflowInspectionServices.GetActivities(root).GetEnumerator(); //Get the first child of the x:class enumerator1.MoveNext(); root = enumerator1.Current; } catch (Exception ex) { Log.Logger.LogData(ex.Message, LogLevel.Error); } return(root); }
public static void AddWorkflow(RigOapChecklist rigOapChecklist, ILog log, IIrmaOapDbContext context) { var workflowActivity = new Genericlist() { DisplayName = $"Genericlist_{rigOapChecklist.Id}" }; var activities = new List <Activity>(WorkflowInspectionServices.GetActivities(workflowActivity)); var indent = 0; activities.ForEach((act) => Console.WriteLine("{0}{1}", new string(' ', indent), act.DisplayName)); string serializedAB = ToXaml(activities[0]); var version = new Version(1, 0); var wfr = new WorkflowRepository(context, log); var workflow = wfr.GetActiveWorkflow(8); //var workflow = new Irma.Models.Domain.Workflow.Workflow(); //workflow.Name = "BarrierAuthorityOIM"; //workflow.Major = version.Major; //workflow.Minor = version.Minor; //workflow.Active = true; //workflow.ActivityXaml = ToXaml(workflowActivity); //var workflowType = workflowActivity.GetType(); //workflow.Assembly = workflowType.Assembly.GetName().Name; //workflow.Type = workflowType.FullName; var workflowinstance = new RigOapChecklistWorkflow(rigOapChecklist) { Name = $"{workflow.Name} Instance", Workflow = workflow }; var wfs = new WorkflowEngineService(log); var wfir = new RigOapChecklistWorkflowRepository(context, log); wfs.Start(workflowActivity, version, workflowinstance); wfir.Add(workflowinstance); }
private void BuildUpChildActivities(Activity root) { var activities = WorkflowInspectionServices.GetActivities(root); foreach (var activity in activities) { var type = activity.GetType(); var systemActivities = type.Namespace != null && (type.Namespace.StartsWith("System.") || type.Namespace.StartsWith("Microsoft.")); if (!systemActivities) { _container.BuildUp(type, activity); } BuildUpChildActivities(activity); } }
public void GetChildrenModifyChildrenExecute() { Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); TestWhile whileAct = new TestWhile("while act") { ConditionExpression = ((env) => false), Body = new TestSequence("Seq"), }; TestSequence outerSequence = new TestSequence("sequence1") { Variables = { counter }, Activities = { whileAct, }, }; WorkflowInspectionServices.GetActivities(whileAct.ProductActivity); whileAct.ConditionExpression = (env) => ((int)counter.Get(env)) < 1; whileAct.Body = new TestSequence("Inner Seq") { Activities = { new TestWriteLine("write hello") { Message = "Its a small world after all", }, new TestAssign <int>("Increment Counter") { ValueExpression = ((env) => (((int)counter.Get(env))) + 1), ToVariable = counter, }, }, }; whileAct.HintIterationCount = 1; // Now that we've changed the tree we need to recache WorkflowInspectionServices.CacheMetadata(outerSequence.ProductActivity); TestRuntime.RunAndValidateWorkflow(outerSequence); }
public void GetChildrenModifyChildrenExecute() { TestFlowchart flowchart = new TestFlowchart("Flow1"); TestWriteLine writeLine1 = new TestWriteLine("hello1", "Hello1"); TestWriteLine writeLine2 = new TestWriteLine("hello2", "Hello2"); TestWriteLine writeLine3 = new TestWriteLine("hello3", "Hello3"); TestWriteLine writeLine4 = new TestWriteLine("hello4", "Hello4"); flowchart.AddLink(writeLine1, writeLine2); flowchart.AddLink(writeLine2, writeLine3); WorkflowInspectionServices.GetActivities(flowchart.ProductActivity); flowchart.AddLink(writeLine3, writeLine4); // Now that we've change the tree we need to explicitly recache WorkflowInspectionServices.CacheMetadata(flowchart.ProductActivity); TestRuntime.RunAndValidateWorkflow(flowchart); }