public void Test___Method_Reset___Status_Stopped() { var duration = new AnyVariable <int>() { Value = 1000 }; var testee = new ParallelActivity() { Activities = new List <IActivity>() { new DelayActivity() { Duration = duration }, new DelayActivity() { Duration = duration } } }; testee.Stop(); Assert.AreEqual(ActivityStatus.Stopped, testee.Status); testee.Reset(); Assert.AreEqual(ActivityStatus.Created, testee.Status); }
public async Task Test___Method_Start___Status_Created_to_Suspended() { var duration = new AnyVariable <int>() { Value = 1000 }; var testee = new ParallelActivity() { Activities = new List <IActivity>() { new DelayActivity() { Duration = duration }, new SuspendActivity() { Until = new FalseCondition() } } }; await testee.Start(); Assert.AreEqual(ActivityStatus.Suspended, testee.Status); }
public async Task Test___Method_Stop___Status_Executing() { var duration = new AnyVariable <int>() { Value = 1000 }; var testee = new ParallelActivity() { Activities = new List <IActivity>() { new DelayActivity() { Duration = duration }, new DelayActivity() { Duration = duration } } }; var task = testee.Start(); Assert.AreEqual(ActivityStatus.Executing, testee.Status); testee.Stop(); await task; Assert.AreEqual(ActivityStatus.Stopped, testee.Status); }
private void ProcessActivitySelection(ActionTypes actionType) { if (actionType == ActionTypes.None) { return; } ParallelActivity parallelActivity = null; // Check for multi activity selection if (actionType != ActionTypes.SendAutoReply & actionType != ActionTypes.CreateNote & actionType != ActionTypes.CreateTask) { parallelActivity = new ParallelActivity(); } // Process each selected activity if ((actionType & ActionTypes.SendAutoReply) == ActionTypes.SendAutoReply) { ProcessAutoReplyEmailActivity(parallelActivity); } if ((actionType & ActionTypes.CreateNote) == ActionTypes.CreateNote) { ProcessOutlookNoteActivity(parallelActivity); } if ((actionType & ActionTypes.CreateTask) == ActionTypes.CreateTask) { ProcessOutlookTaskActivity(parallelActivity); } // Add ParallelActivity to the workflow if (parallelActivity != null) { workflowDesigner.SequentialWorkflow.Activities.Add(parallelActivity); workflowDesigner.Host.RootComponent.Site.Container.Add(parallelActivity); } }
void Container1() { System.Workflow.Activities.CodeCondition codecondition1 = new System.Workflow.Activities.CodeCondition(); // <snippet180> // <snippet181> // <snippet182> this.WhileLoop = new System.Workflow.Activities.WhileActivity(); this.Parallel = new System.Workflow.Activities.ParallelActivity(); this.Sequence1 = new System.Workflow.Activities.SequenceActivity(); this.Sequence2 = new System.Workflow.Activities.SequenceActivity(); this.ConsoleMessage1 = new System.Workflow.Activities.CodeActivity(); this.ConsoleMessage2 = new System.Workflow.Activities.CodeActivity(); // // WhileLoop // this.WhileLoop.Activities.Add(this.Parallel); codecondition1.Condition += new System.EventHandler <System.Workflow.Activities.ConditionalEventArgs>(this.WhileCondition); this.WhileLoop.Condition = codecondition1; this.WhileLoop.Name = "WhileLoop"; // </snippet182> // // Parallel // this.Parallel.Activities.Add(this.Sequence1); this.Parallel.Activities.Add(this.Sequence2); this.Parallel.Name = "Parallel"; // </snippet181> // // Sequence1 // this.Sequence1.Activities.Add(this.ConsoleMessage1); this.Sequence1.Name = "Sequence1"; // // Sequence2 // this.Sequence2.Activities.Add(this.ConsoleMessage2); this.Sequence2.Name = "Sequence2"; // </snippet180> }
public async Task Test___Method_Start___Status_Suspended_to_Completed() { var duration = new AnyVariable <int>() { Value = 1000 }; var value = new AnyVariable <bool>() { Value = false }; var testee = new ParallelActivity() { Activities = new List <IActivity>() { new DelayActivity() { Duration = duration }, new SuspendActivity() { Until = new TrueCondition() { Value = value } } } }; await testee.Start(); Assert.AreEqual(ActivityStatus.Suspended, testee.Status); value.SetValue <bool>(true); await testee.Start(); Assert.AreEqual(ActivityStatus.Completed, testee.Status); }
private void ProcessAutoReplyEmailActivity(ParallelActivity activityList) { AutoReplyEmail emailActivity = new AutoReplyEmail(); emailActivity.Name = "AutoReplyEmail"; SequenceActivity branch = new SequenceActivity(); branch.Name = "branch1"; branch.Activities.Add(emailActivity); if (activityList != null) { activityList.Activities.Add(branch); } else { workflowDesigner.SequentialWorkflow.Activities.Add(branch); } workflowDesigner.Host.RootComponent.Site.Container.Add(emailActivity); workflowDesigner.Host.RootComponent.Site.Container.Add(branch); }
private void ProcessOutlookNoteActivity(ParallelActivity activityList) { OutlookNote outlookNoteActivity = new OutlookNote(); outlookNoteActivity.Name = "CreateOutlookNote"; SequenceActivity branch = new SequenceActivity(); branch.Name = "branch2"; branch.Activities.Add(outlookNoteActivity); if (activityList != null) { activityList.Activities.Add(branch); } else { workflowDesigner.SequentialWorkflow.Activities.Add(branch); } workflowDesigner.Host.RootComponent.Site.Container.Add(outlookNoteActivity); workflowDesigner.Host.RootComponent.Site.Container.Add(branch); }
private void InitializeComponent() { Console.WriteLine("1"); CanModifyActivities = true; CodeCondition codecondition1 = new CodeCondition(); CodeCloseMailProgram2 = new CodeActivity(); CodeCloseMailProgram3 = new CodeActivity(); DelayWaitForSentMail2 = new DelayActivity(); DelayWaitForSentMail3 = new DelayActivity(); PrepareMail2 = new CodeActivity(); PrepareMail3 = new CodeActivity(); CodeCloseMailProgram1 = new CodeActivity(); DelayWaitForSentMail1 = new DelayActivity(); CodePrepareMail1 = new CodeActivity(); SeqSendMail2 = new SequenceActivity(); SeqSendMail1 = new SequenceActivity(); SeqSendMail3 = new SequenceActivity(); TerminateFinishNoNeedToReadMail = new TerminateActivity(); Parallel = new ParallelActivity(); IfElseBranchActivityNoNeed = new IfElseBranchActivity(); IfElseBranchActivityNeedToSendMail = new IfElseBranchActivity(); NeedToSendMail = new IfElseActivity(); PrepareMail3.Name = "PrepareMail3"; PrepareMail3.ExecuteCode += new EventHandler(PrepareMail3_ExecuteCode); CodeCloseMailProgram3.Name = "CodeCloseMailProgram3"; CodeCloseMailProgram3.ExecuteCode += new EventHandler(CodeCloseMailProgram3_ExecuteCode); DelayWaitForSentMail3.Name = "DelayWaitForSentMail3"; DelayWaitForSentMail3.TimeoutDuration = TimeSpan.Parse("00:00:03"); CodeCloseMailProgram2.Name = "CodeCloseMailProgram2"; CodeCloseMailProgram2.ExecuteCode += new EventHandler(CodeCloseMailProgram2_ExecuteCode); DelayWaitForSentMail2.Name = "DelayWaitForSentMail2"; DelayWaitForSentMail2.TimeoutDuration = TimeSpan.Parse("00:00:02"); PrepareMail2.Name = "PrepareMail2"; PrepareMail2.ExecuteCode += new EventHandler(PrepareMail2_ExecuteCode); CodeCloseMailProgram1.Name = "CodeCloseMailProgram1"; CodeCloseMailProgram1.ExecuteCode += new EventHandler(CodeCloseMailProgram_ExecuteCode); DelayWaitForSentMail1.Name = "DelayWaitForSentMail1"; DelayWaitForSentMail1.TimeoutDuration = TimeSpan.Parse("00:00:05"); CodePrepareMail1.Name = "CodePrepareMail1"; CodePrepareMail1.ExecuteCode += new EventHandler(CodeActivity1_ExecuteCode); SeqSendMail2.Activities.Add(PrepareMail2); SeqSendMail2.Activities.Add(DelayWaitForSentMail2); SeqSendMail2.Activities.Add(CodeCloseMailProgram2); SeqSendMail2.Name = "SeqSendMail2"; SeqSendMail3.Activities.Add(PrepareMail3); SeqSendMail3.Activities.Add(DelayWaitForSentMail3); SeqSendMail3.Activities.Add(CodeCloseMailProgram3); SeqSendMail3.Name = "SeqSendMail3"; SeqSendMail1.Activities.Add(CodePrepareMail1); SeqSendMail1.Activities.Add(DelayWaitForSentMail1); SeqSendMail1.Activities.Add(CodeCloseMailProgram1); SeqSendMail1.Name = "SeqSendMail1"; TerminateFinishNoNeedToReadMail.Name = "TerminateFinishNoNeedToReadMail"; Parallel.Activities.Add(SeqSendMail1); Parallel.Activities.Add(SeqSendMail2); Parallel.Activities.Add(SeqSendMail3); Parallel.Name = "Parallel"; IfElseBranchActivityNoNeed.Activities.Add(TerminateFinishNoNeedToReadMail); IfElseBranchActivityNoNeed.Name = "IfElseBranchActivityNoNeed"; IfElseBranchActivityNeedToSendMail.Activities.Add(Parallel); codecondition1.Condition += new EventHandler <ConditionalEventArgs>(IfElseCondition); IfElseBranchActivityNeedToSendMail.Condition = codecondition1; IfElseBranchActivityNeedToSendMail.Name = "IfElseBranchActivityNeedToSendMail"; NeedToSendMail.Activities.Add(IfElseBranchActivityNeedToSendMail); NeedToSendMail.Activities.Add(IfElseBranchActivityNoNeed); NeedToSendMail.Name = "NeedToSendMail"; Activities.Add(NeedToSendMail); Name = "IfElseParalellWorkFlow"; CanModifyActivities = false; }
private void InitializeComponent() { parallel1 = new ParallelActivity(); sequence1 = new SequenceActivity(); sequence2 = new SequenceActivity(); begin = new CodeActivity(); end = new CodeActivity(); increment1 = new CodeActivity(); increment2 = new CodeActivity(); decrement1 = new CodeActivity(); decrement2 = new CodeActivity(); SynchronizedDecrement = new SynchronizationScopeActivity(); SynchronizedIncrement = new SynchronizationScopeActivity(); System.Collections.Generic.List <string> stringCollection1 = new System.Collections.Generic.List <string>(); System.Collections.Generic.List <string> stringCollection2 = new System.Collections.Generic.List <string>(); this.CanModifyActivities = true; // parallel this.parallel1.Activities.Add(sequence1); this.parallel1.Activities.Add(sequence2); this.parallel1.Name = "parallel1"; // sequences this.sequence1.Activities.Add(SynchronizedIncrement); this.sequence1.Name = "sequence1"; this.sequence2.Activities.Add(SynchronizedDecrement); this.sequence2.Name = "sequence2"; // both synchronization activities are set to the same syncMutex string // in order for the parallel activity to provide synchronization guarantees for shared data access to count variable this.SynchronizedIncrement.Name = "SynchronizedIncrement"; stringCollection1.Add("syncMutex"); this.SynchronizedIncrement.SynchronizationHandles = stringCollection1; this.SynchronizedIncrement.Activities.Add(increment1); this.SynchronizedIncrement.Activities.Add(increment2); this.SynchronizedDecrement.Name = "SynchronizedDecrement"; stringCollection2.Add("syncMutex"); this.SynchronizedDecrement.SynchronizationHandles = stringCollection2; this.SynchronizedDecrement.Activities.Add(decrement1); this.SynchronizedDecrement.Activities.Add(decrement2); // code activities begin.Name = "begin"; begin.ExecuteCode += new EventHandler(Begin_ExecuteCode); end.Name = "end"; end.ExecuteCode += new EventHandler(End_ExecuteCode); increment1.Name = "increment1"; increment1.ExecuteCode += new EventHandler(Increment1_ExecuteCode); increment2.Name = "increment2"; increment2.ExecuteCode += new EventHandler(Increment2_ExecuteCode); decrement1.Name = "decrement1"; decrement1.ExecuteCode += new EventHandler(Decrement1_ExecuteCode); decrement2.Name = "decrement2"; decrement2.ExecuteCode += new EventHandler(Decrement2_ExecuteCode); // workflow activities this.Activities.Add(begin); this.Activities.Add(parallel1); this.Activities.Add(end); this.Name = "SynchronizedActivityWorkflow"; this.CanModifyActivities = false; }