private void OnWorkflowCompleted(WorkflowApplicationCompletedEventArgs wc) { if(wc.Outputs.ContainsKey("OutMovieRental")) { var createdRental = wc.Outputs["OutMovieRental"] as CustomerRental; MessageBox.Show(string.Format("New rental for {0} {1} has been created!", createdRental.PaymentCard.FirstName, createdRental.PaymentCard.LastName)); } }
private void workflow_OnWfCompleted(WorkflowApplicationCompletedEventArgs e) { var output = string.Empty; var dto = e.Outputs["Result"] as FlowStatusDto; if (dto != null) { foreach (var item in dto.Steps) { output += "Status: " + item.Status + ", Successful: " + item.Successful.ToString() + ", Message: " + item.Message + "<br/>"; } } }
/// <summary> /// Initializes a new instance of the <see cref="WorkflowCompletedEpisodeResult"/> class. /// </summary> /// <param name="args"> /// The event args. /// </param> /// <param name="instanceId"> /// The instance Id. /// </param> public WorkflowCompletedEpisodeResult(WorkflowApplicationCompletedEventArgs args, Guid instanceId) { this.State = args.CompletionState; this.InstanceId = instanceId; switch (this.State) { case ActivityInstanceState.Closed: this.Outputs = args.Outputs; break; case ActivityInstanceState.Faulted: this.TerminationException = args.TerminationException; break; } }
public static void OnCompleted(WorkflowApplicationCompletedEventArgs e) { idleEvent.Set(); }
private void OnCompleted(WorkflowApplicationCompletedEventArgs args) { _result = args.GetInstanceExtensions<IDSFDataObject>().ToList().First(); IDictionary<string, object> outputs = args.Outputs; try { if(!_isDebug) { // Travis.Frisinger : 19.10.2012 - Duplicated Recordset Data Bug 6038 object parentId; outputs.TryGetValue("ParentWorkflowInstanceId", out parentId); parentId = _result.ParentWorkflowInstanceId; object parentServiceName; outputs.TryGetValue("ParentServiceName", out parentServiceName); var parentServiceNameStr = string.IsNullOrEmpty(_result.ParentServiceName) ? string.Empty : _result.ParentServiceName; if(!string.IsNullOrEmpty(parentServiceNameStr) && Guid.TryParse(parentId.ToString(), out _parentWorkflowInstanceID)) { if(_parentWorkflowInstanceID != _currentInstanceID) { // BUG 7850 - TWR - 2013.03.11 - ResourceCatalog refactor var services = ResourceCatalog.Instance.GetDynamicObjects<DynamicServiceObjectBase>(_workspace.ID, parentServiceNameStr); if(services != null && services.Count > 0) { var service = services[0] as DynamicService; if(service != null) { _currentInstanceID = _parentWorkflowInstanceID; var actionSet = service.Actions; if(_result.WorkflowResumeable) { var serviceAction = actionSet.First(); PooledServiceActivity wfActivity = serviceAction.PopActivity(); try { ErrorResultTO invokeErrors; _result = _owner.InvokeWorkflow(wfActivity.Value, _result, _executionExtensions, _parentWorkflowInstanceID, _workspace, "dsfResumption", out invokeErrors); // attach any execution errors if(AllErrors != null) { AllErrors.MergeErrors(invokeErrors); } } finally { serviceAction.PushActivity(wfActivity); } } } } } } } } catch(Exception ex) { Dev2Logger.Log.Error(ex); ExecutionStatusCallbackDispatcher.Instance.Post(_result.ExecutionCallbackID, ExecutionStatusCallbackMessageType.ErrorCallback); } finally { try { if(_waitHandle != null) _waitHandle.Set(); ExecutableServiceRepository.Instance.Remove(this); if(DataTransferObject != null) { DataTransferObject.NumberOfSteps = _previousNumberOfSteps; } } catch(Exception e) { // Best effort ;) Dev2Logger.Log.Error(e); } } // force a throw to kill the engine ;) if(args.TerminationException != null) { _instance.Terminate("Force Terminate", new TimeSpan(0, 0, 1, 0)); } // Not compatable with run.Dispose() }
static void OnCompleted(WorkflowApplicationCompletedEventArgs e) { syncEvent.Set(); }
private void OnWorkflowCompleted(WorkflowApplicationCompletedEventArgs e) { OnExecutingStateChanged(new WorkflowExecutingStateEventArgs(false)); }
private void WorkflowCompletedCallback(WorkflowApplicationCompletedEventArgs cArgs) { var output = cArgs.GetInstanceExtensions<List<string>>(); var enumerable = output as List<string>[] ?? output.ToArray(); if (enumerable.First() != null) { txbOutput.Dispatcher.Invoke(() => { foreach (string item in enumerable.First()) { txbOutput.Text += item + "\r\n"; } }); } }
private static void Completed(WorkflowApplicationCompletedEventArgs e) { Program.syncEvent.Set(); }
private static void OnCompleted(WorkflowApplicationCompletedEventArgs workflowApplicationCompletedEventArgs) { }
void SubDivideWorkflowCompleted(WorkflowApplicationCompletedEventArgs e) { //流程结束,将流程实例移除 MyWorkflowInstance.removeDecomposeWorkflowApplication(e.InstanceId.ToString()); CrowdTaskService crowdTaskService = new CrowdTaskService(); //将当前流程的分解解决方案写入数据库 int result = crowdTaskService.saveDecomposeResult(e.InstanceId.ToString(),(ArrayList)e.Outputs["out_arraylist_task"]); //得到当前分解任务的内容 CrowdTask crowdTask = new CrowdTask(); crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(e.InstanceId.ToString()); //通过当前分解任务的父工作流ID ,获得该父工作流的所有子工作流,如果都完成了则开启分解判断过程 ArrayList allSonCrowdTask = crowdTaskService.findAllSonCrowdTaskByParentWorkflowIdAndTaskName(crowdTask.taskParentWorkflowId, crowdTask.taskName,crowdTask.mainTaskId); Dictionary<string, ArrayList> solutionTasks = new Dictionary<string, ArrayList>(); int count = 0; //遍历看看这个任务的同一级的分解任务是否都结束了 foreach (CrowdTask ct in allSonCrowdTask) { WorkflowApplication wa = MyWorkflowInstance.getDecomposeWorkflowApplication(ct.taskWorkflowId); if (wa != null) { break; } else { count++; } } //如果都结束了 if (count == ConstantDefine.divideNumber) { //获得每一个分解任务给出的解决方案 foreach (CrowdTask ct in allSonCrowdTask) { ArrayList solutions = crowdTaskService.findDecomposeResultByWorkflowId(ct.taskWorkflowId,ct.mainTaskId); if (solutions.Count != 0) { //表示当前工作流Id给出了分解方案 solutionTasks.Add(ct.taskWorkflowId, solutions); } } //表示至少有一个分解任务给出了解决方案 if (solutionTasks.Count != 0) { //开启5个投票流程 工作流实例 for (int i = 0; i < ConstantDefine.decomposeVotingNumber; i++) { StartSubProcess ssp = new StartSubProcess(); ssp.startDevideVotingProcess(solutionTasks); } } //表示所有的当前这几个分解任务都认为这个任务是简单任务,设置简单标记 else { //当前一个任务判定为简单,是要等这一层级的所有任务都判定完了在根据情况,把这一层是简单的任务抛出去 foreach (CrowdTask ct in allSonCrowdTask) { int h = crowdTaskService.updateDecomposeResultByWokflowIdAndTaskName(ct.taskParentWorkflowId, ct.taskName,ct.mainTaskId); } } /* //等待这一层的所有任务都分解完成了,把这一层的简单任务选出来,分发出去 ArrayList ThisLayerAllSonCrowdTask = crowdTaskService.findCrowdTaskByParentWorkflowIdAndTaskType(crowdTask.taskParentWorkflowId, TaskType.decomposeTask); int count1 = 0; //遍历这一层的任务,看看是否都完成了 foreach (CrowdTask ct in ThisLayerAllSonCrowdTask) { WorkflowApplication wa = MyWorkflowInstance.getDecomposeWorkflowApplication(ct.taskWorkflowId); if (wa != null) { break; } else { count1++; } } //这一层的所有任务都完成了 if (ThisLayerAllSonCrowdTask.Count == count1) { ArrayList al_simple = crowdTaskService.getAllThisLayerNeedSolvedCrowTaskInDecomposeResult(crowdTask.taskParentWorkflowId); //可以得到这一层一共有多少个简单任务 //将每一个简单任务分发出去启动解决流程 foreach (DecomposeResult al in al_simple) { for (int k = 0; k < ConstantDefine.solvingNumber; k++) { //将这个任务分发出去 CrowdTask ct = new CrowdTask(); ct.taskName = al.taskName; ct.taskDescription = al.taskDescription; ct.taskType = TaskType.solveTask; StartSubProcess ssp = new StartSubProcess(); ssp.startSolveProcess(ct); } } } * */ } //如果分解的工作流为空。 if (MyWorkflowInstance.getdecomposeWorkflowApplications().Count == 0 && MyWorkflowInstance.getdecomposeVotingWorkflowApplications().Count==0) { //加载所有的需要解决的任务,作为解决任务发放出去 ArrayList li = crowdTaskService.getAllNeedSolvedCrowTaskInDecomposeResult1(crowdTask.mainTaskId); foreach (DecomposeResult dr in li) { for (int k = 0; k < ConstantDefine.solvingNumber; k++) { //将这个任务分发出去 CrowdTask ct = new CrowdTask(); ct.taskName = dr.taskName; ct.taskDescription = dr.taskDescription; ct.taskType = TaskType.solveTask; ct.taskParentWorkflowId = dr.parent_workflow_id; StartSubProcess ssp = new StartSubProcess(); ssp.startSolveProcess(ct); } } MyWorkflowInstance.getWorkflowApplication(crowdTask.mainTaskId).ResumeBookmark(BookmarkName.Decomposing,null); ; } }
private void solveVotingWorkflowCompleted(WorkflowApplicationCompletedEventArgs e) { //保存到解决投票表里面 MyWorkflowInstance.removeSolveVotingWorkflowApplication(e.InstanceId.ToString()); CrowdTask crowdTask = new CrowdTask(); CrowdTaskService crowdTaskService = new CrowdTaskService(); crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(e.InstanceId.ToString()); //将当前流程的投票的分解的工作流ID写入数据库 int result = crowdTaskService.saveSolveVoteResult1(e.InstanceId.ToString(), (string)e.Outputs["out_bestSolutionWorkflowId"]); //如果所有的解决投票任务完成了。开启投票 if (MyWorkflowInstance.getSolveVotingWorkflowApplications().Count == 0) { //更新得到最佳答案; ArrayList allSolveCompeletedCrowdTask = crowdTaskService.findAllSolveCompeletedCrowdTaskByMainTaskId(crowdTask.mainTaskId); //得到每一个解决任务的名字,然后根据名字和描述再去加载解决任务的ID,得到ID之后再去判断是不是最佳答案 foreach (SolveResult sr in allSolveCompeletedCrowdTask) { ArrayList al = crowdTaskService.finSolveResultByMainTaskIdAndTaskName(crowdTask.mainTaskId,sr.taskName); int[] supportedNumber = new int[ConstantDefine.solvingNumber]; string[] supportedWorkflowId = new string[ConstantDefine.solvingNumber]; int i = 0; foreach (SolveResult item in al) { //拿到每一个ID 当做supportedId,去数据库里面比对 supportedNumber[i]= crowdTaskService.getSolveVoteResultBySupportedId(item.taskWorkflowId); supportedWorkflowId[i] = item.taskWorkflowId; i++; } int maxNumber = supportedNumber[0]; string maxWorkflowId = supportedWorkflowId[0]; for (int j = 0; j < al.Count; j++) { if (supportedNumber[j] > maxNumber) { maxNumber = supportedNumber[j]; maxWorkflowId = supportedWorkflowId[j]; } } //找到了最佳答案,更新。 crowdTaskService.updateSolveResultBestAnswer(maxWorkflowId); } //更新书签 MyWorkflowInstance.getWorkflowApplication(crowdTask.mainTaskId).ResumeBookmark(BookmarkName.SolveVoting, null); //生成分解树。 crowdTaskService.writeDecomposeTree(crowdTask.mainTaskId); } }
void solveWorkflowCompleted(WorkflowApplicationCompletedEventArgs e) { MyWorkflowInstance.removeSolveWorkflowApplication(e.InstanceId.ToString()); CrowdTask crowdTask = new CrowdTask(); CrowdTaskService crowdTaskService = new CrowdTaskService(); crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(e.InstanceId.ToString()); //将当前流程的解决结果写入数据库 int result = crowdTaskService.saveSolveResult(crowdTask, (string)e.Outputs["out_solution"]); /* //通过当前解决任务的工作流ID ,获得该工作流的所有同一任务的不同工作流,如果都完成了则开启解决判断过程; int count = 0; ArrayList allSonCrowdTask = crowdTaskService.findAllSonCrowdTaskByParentTaskNameAndTaskDescriptionAndTaskType(crowdTask.taskName, crowdTask.taskDescription,crowdTask.taskType); foreach (CrowdTask ct in allSonCrowdTask) { WorkflowApplication wa = MyWorkflowInstance.getSolveWorkflowApplication(ct.taskWorkflowId); if (wa != null) { break; } else { count++; } } if (count == ConstantDefine.solvingNumber) { //都已经解决完成,可以开始投票了 //通过当前获得到的workflowId ,加载解决方案,然后保存在一个list里面,开启投票流程 Dictionary<string,SolveResult> solveResutDic = new Dictionary<string,SolveResult>(); //得到所有的解决结果 foreach (CrowdTask ct in allSonCrowdTask) { SolveResult sr = crowdTaskService.findSolveResultByWorkflowId(ct.taskWorkflowId); solveResutDic.Add(ct.taskWorkflowId,sr); } if(solveResutDic.Count!=0) { //开启5个解决投票流程 工作流实例 for (int i = 0; i < ConstantDefine.solveVotingNumber; i++) { StartSubProcess ssp = new StartSubProcess(); ssp.startSolveVoteProcess(solveResutDic); } } } */ //如果所有的解决任务完成了。开启投票 if (MyWorkflowInstance.getSolveWorkflowApplications().Count == 0) { ArrayList allSolveCompeletedCrowdTask = crowdTaskService.findAllSolveCompeletedCrowdTaskByMainTaskId(crowdTask.mainTaskId); //得到所有的解决结果 foreach (SolveResult sr in allSolveCompeletedCrowdTask) { //开启投票过程 Dictionary<string, SolveResult> solveResutDic = new Dictionary<string, SolveResult>(); ArrayList abc = crowdTaskService.finSolveResultByMainTaskIdAndTaskName(crowdTask.mainTaskId, sr.taskName); foreach (SolveResult sdr in abc) { solveResutDic.Add(sdr.taskWorkflowId, sdr); } if (solveResutDic.Count != 0) { //开启5个解决投票流程 工作流实例 for (int i = 0; i < ConstantDefine.solveVotingNumber; i++) { StartSubProcess ssp = new StartSubProcess(); ssp.startSolveVoteProcess(solveResutDic); } } } MyWorkflowInstance.getWorkflowApplication(crowdTask.mainTaskId).ResumeBookmark(BookmarkName.Solving,null); } }
void DevideVotingWorkflowCompleted(WorkflowApplicationCompletedEventArgs e) { MyWorkflowInstance.removeVotingDecomposeWorkflowApplication(e.InstanceId.ToString()); CrowdTask crowdTask = new CrowdTask(); CrowdTaskService crowdTaskService = new CrowdTaskService(); //将当前流程的投票的分解的工作流ID写入数据库 int result = crowdTaskService.saveDecomposeVoteResult(e.InstanceId.ToString(), (string)e.Outputs["out_bestSolutionWorkflowId"]); crowdTask = crowdTaskService.findCrowdTaskByWorkflowId(e.InstanceId.ToString()); //通过当前任务的父工作流ID ,获得该父工作流的所有子工作流,如果都完成了则开启分解判断过程 int count = 0; ArrayList allSonCrowdTask = crowdTaskService.findCrowdTaskByParentWorkflowIdAndTaskTypeAndTaskName(crowdTask.taskParentWorkflowId, crowdTask.taskName,TaskType.decomposeVotingTask,crowdTask.mainTaskId); // Dictionary<string, ArrayList> solutionTasks = new Dictionary<string, ArrayList>(); // Dictionary<string, int> dic=null; foreach (CrowdTask ct in allSonCrowdTask) { WorkflowApplication wa = MyWorkflowInstance.getDecomposeVotingWorkflowApplication(ct.taskWorkflowId); if (wa != null) { //有一个不为空就表示改父工作流的所有子工作流没有都完成 break; } else { //表示完成了 count++; } } if (count == ConstantDefine.decomposeVotingNumber) { //得到这个投票任务的结果 ArrayList arraylist1= crowdTaskService.findCrowdTaskByParentWorkflowIdAndTaskTypeAndTaskName(crowdTask.taskParentWorkflowId,crowdTask.taskName,TaskType.decomposeTask,crowdTask.mainTaskId); //将arrayList1里面的每个任务取出来,将其ID获得,然后根据ID去decomposeResult 里面取值 int[] nums = new int[ConstantDefine.divideNumber]; string[] votedId = new string[ConstantDefine.divideNumber]; int i=0; foreach ( CrowdTask ct in arraylist1) { //在这里将去检索数据库 Dictionary<string,int> dict = crowdTaskService.findSupportThisIdNumber(ct.taskWorkflowId); if(dict.Count!=0){ nums[i] = dict.First().Value; votedId[i] =dict.First().Key; } else { nums[i] = 0; votedId[i] = ""; } i++; } string bestSolutionWorkflowId = votedId[0]; int max = nums[0]; for (int t = 0; t < nums.Length; t++) { if (nums[t] > max) { max = nums[t]; bestSolutionWorkflowId = votedId[t]; } } ArrayList bestSolutionArrayList = crowdTaskService.findDecomposeResultByWorkflowId(bestSolutionWorkflowId,crowdTask.mainTaskId); //设置投票标记 crowdTaskService.updateDecomposeResultVotedByWorkflowId(bestSolutionWorkflowId); foreach(DecomposeResult dr in bestSolutionArrayList){ //开启5个投票流程 工作流实例 for (int m = 0; m < ConstantDefine.divideNumber; m++) { CrowdTask task = new CrowdTask(); task.taskName=dr.taskName; task.taskDescription=dr.taskDescription; task.taskParentWorkflowId=bestSolutionWorkflowId; task.taskType=TaskType.decomposeTask; StartSubProcess ssp = new StartSubProcess(); ssp.startSubDivideProcess(new Guid(bestSolutionWorkflowId),task); } } } }
/// <summary> /// Retrieve Workflow Execution Logs and Workflow Execution Outputs /// </summary> private void WfExecutionCompleted(WorkflowApplicationCompletedEventArgs ev) { try { //retrieve & display execution log consoleExecutionLog.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action( delegate() { consoleExecutionLog.Text = _executionLog.TrackData; } )); //retrieve & display execution output foreach (var item in ev.Outputs) { consoleOutput.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Normal, new Action( delegate() { consoleOutput.Text += String.Format("[{0}] {1}" + Environment.NewLine, item.Key, item.Value); } )); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
// <summary> // This method gets called when the workflow completes or gets terminated // </summary> private void _workflowInstance_WorkflowCompleted(WorkflowApplicationCompletedEventArgs e) { _synchronizationContext.Post( state => { // If we are just cleaning up the workflow, no need to do anything // except enable the appropriate buttons (we might be heading to the // previous page) if (_onWorkflowCleanup) { Wizard.EnableButton(ButtonType.Previous, false); Wizard.EnableButton(ButtonType.Next, true); Wizard.EnableButton(ButtonType.Finish, false); Wizard.EnableButton(ButtonType.Cancel, true); _onWorkflowCleanup = false; return; } // If there was an exception, then the UnhandledException handler should have // already handled it. if (e.TerminationException == null) { // The workflow has completed successfully // Hide the status message on the DDL tab HideStatus(); SummaryTabs.Enabled = true; txtSaveDdlAs.Enabled = true; // Immediately enable the Finish button if we've gotten a hold of the WorkflowInstance // We also enable going back to the connection page and cancelling out of the wizard completely Wizard.EnableButton(ButtonType.Previous, true); Wizard.EnableButton(ButtonType.Next, false); Wizard.EnableButton(ButtonType.Finish, true); Wizard.EnableButton(ButtonType.Cancel, true); // Examine the SSDL output. Display an error if we can't find it. object ssdlOutputObj; var ssdlOutput = String.Empty; if (e.Outputs.TryGetValue(EdmConstants.ssdlOutputName, out ssdlOutputObj) && ssdlOutputObj != null && !String.IsNullOrEmpty(ssdlOutput = ssdlOutputObj as string)) { Wizard.ModelBuilderSettings.SsdlStringReader = new StringReader(ssdlOutput); } // Examine the MSL output. Display an error if we can't find it. object mslOutputObj; var mslOutput = String.Empty; if (e.Outputs.TryGetValue(EdmConstants.mslOutputName, out mslOutputObj) && mslOutputObj != null && !String.IsNullOrEmpty(mslOutput = mslOutputObj as string)) { Wizard.ModelBuilderSettings.MslStringReader = new StringReader(mslOutput); } // Examine the DDL output. Display an error if we can't find it. object ddlOutputObj; var ddlOutput = String.Empty; if (e.Outputs.TryGetValue(EdmConstants.ddlOutputName, out ddlOutputObj) && ddlOutputObj != null && !String.IsNullOrEmpty(ddlOutput = ddlOutputObj as string)) { Wizard.ModelBuilderSettings.DdlStringReader = new StringReader(ddlOutput); } // Display the DDL in the textbox if (!String.IsNullOrEmpty(ddlOutput)) { InferTablesAndDisplayDDL(ddlOutput); } } }, null); }
private static void OnCompleteInstanceExecution(object sender, WorkflowApplicationCompletedEventArgs e) { if (e.TerminationException != null) { Console.WriteLine("Workflow completed with {0}: {1}.", e.TerminationException.GetType().FullName, e.TerminationException.Message); } else { Console.WriteLine("Workflow completed successfully."); } }
// executed when instance is persisted public void OnWorkflowCompleted(WorkflowApplicationCompletedEventArgs e) { }
/// <summary> /// The on completed. /// </summary> /// <param name="completedEventArgs"> /// The completed event args. /// </param> private void OnCompleted(WorkflowApplicationCompletedEventArgs completedEventArgs) { // If the workflow completed while awaiting a response, set the event RemoveFromCache(completedEventArgs.InstanceId); if (completedEventArgs.TerminationException != null) { this.terminationException = completedEventArgs.TerminationException; } this.responseEvent.Set(); }
private void WorkflowCompleted(WorkflowApplicationCompletedEventArgs e) { this.running = false; StatusViewModel.SetStatusText(string.Format(Resources.CompletedStatus, e.CompletionState.ToString()), this.workflowName); }
static void OnCompleted(WorkflowApplicationCompletedEventArgs completedArgs) { completeEvent.Set(); }
void IWorkflowApplicationHandler.OnCompleted(WorkflowApplicationCompletedEventArgs e) { lock (managerStateLock) { if (this.state == ManagerState.Opened) { this.hostView.Dispatch(() => CompleteInstance(e.InstanceId, "Completed in the " + e.CompletionState.ToString() + " state")); } } }
private void HandleWorkflowApplicationCompleted(WorkflowApplicationCompletedEventArgs e) { if (Disposed) return; _structuredTracer.Correlate(); if (e.CompletionState == ActivityInstanceState.Closed) { if (System.Threading.Interlocked.CompareExchange(ref terminalStateHandled, Handled, NotHandled) == Handled) return; try { Tracer.WriteMessage("Workflow Application is completed and is in closed state."); Tracer.WriteMessage("Flatting out the PSDataCollection returned outputs."); foreach (KeyValuePair<string, object> outvariable in e.Outputs) { if (outvariable.Value != null) { if (outvariable.Value is PSDataCollection<PSObject>) { PSDataCollection<PSObject> outCollection = outvariable.Value as PSDataCollection<PSObject>; Dbg.Assert(outCollection != null, "outCollection should not be NULL"); foreach (PSObject obj in outCollection) { Streams.OutputStream.Add(obj); } outCollection.Clear(); } else if (outvariable.Value is PSDataCollection<ErrorRecord>) { PSDataCollection<ErrorRecord> errorCollection = outvariable.Value as PSDataCollection<ErrorRecord>; Dbg.Assert(errorCollection != null, "errorCollection should not be NULL"); foreach (ErrorRecord obj in errorCollection) { Streams.OutputStream.Add(PSObject.AsPSObject(obj)); } errorCollection.Clear(); } else if (outvariable.Value is PSDataCollection<WarningRecord>) { PSDataCollection<WarningRecord> warningCollection = outvariable.Value as PSDataCollection<WarningRecord>; Dbg.Assert(warningCollection != null, "warningCollection should not be NULL"); foreach (WarningRecord obj in warningCollection) { Streams.OutputStream.Add(PSObject.AsPSObject(obj)); } warningCollection.Clear(); } else if (outvariable.Value is PSDataCollection<ProgressRecord>) { PSDataCollection<ProgressRecord> progressCollection = outvariable.Value as PSDataCollection<ProgressRecord>; Dbg.Assert(progressCollection != null, "progressCollection should not be NULL"); foreach (ProgressRecord obj in progressCollection) { Streams.OutputStream.Add(PSObject.AsPSObject(obj)); } progressCollection.Clear(); } else if (outvariable.Value is PSDataCollection<VerboseRecord>) { PSDataCollection<VerboseRecord> verboseCollection = outvariable.Value as PSDataCollection<VerboseRecord>; Dbg.Assert(verboseCollection != null, "verboseCollection should not be NULL"); foreach (VerboseRecord obj in verboseCollection) { Streams.OutputStream.Add(PSObject.AsPSObject(obj)); } verboseCollection.Clear(); } else if (outvariable.Value is PSDataCollection<DebugRecord>) { PSDataCollection<DebugRecord> debugCollection = outvariable.Value as PSDataCollection<DebugRecord>; Dbg.Assert(debugCollection != null, "debugCollection should not be NULL"); foreach (DebugRecord obj in debugCollection) { Streams.OutputStream.Add(PSObject.AsPSObject(obj)); } debugCollection.Clear(); } else if (outvariable.Value is PSDataCollection<InformationRecord>) { PSDataCollection<InformationRecord> informationCollection = outvariable.Value as PSDataCollection<InformationRecord>; Dbg.Assert(informationCollection != null, "informationCollection should not be NULL"); foreach (InformationRecord obj in informationCollection) { Streams.OutputStream.Add(PSObject.AsPSObject(obj)); } informationCollection.Clear(); } else { // pass the object as is to the output stream this.Streams.OutputStream.Add(PSObject.AsPSObject(outvariable.Value)); } } } } catch (Exception exception) { Dbg.Assert(false, "An exception is raised after a workflow completed successfully. This is most likely a case of exception eating, check the exception details"); Tracer.TraceException(exception); } State = JobState.Completed; this.PerformTaskAtTerminalState(); // do all cleanups here to save memory PerformCleanupAtTerminalState(); if (this.OnCompleted != null) this.OnCompleted(this); } if (e.CompletionState == ActivityInstanceState.Faulted) { HandleWorkflowApplicationFaultedState(e.TerminationException); } if (e.CompletionState == ActivityInstanceState.Canceled) { this.HandleWorkflowApplicationCanceled(); } }
private void HandleWorkflowApplicationCompleted(WorkflowApplicationCompletedEventArgs e) { if (!base.Disposed) { PSWorkflowApplicationInstance._structuredTracer.Correlate(); if (e.CompletionState == ActivityInstanceState.Closed) { if (Interlocked.CompareExchange(ref this.terminalStateHandled, 1, 0) != 1) { try { this.Tracer.WriteMessage("Workflow Application is completed and is in closed state."); this.Tracer.WriteMessage("Flatting out the PSDataCollection returned outputs."); foreach (KeyValuePair<string, object> output in e.Outputs) { if (output.Value == null) { continue; } if (output.Value as PSDataCollection<PSObject> == null) { if (output.Value as PSDataCollection<ErrorRecord> == null) { if (output.Value as PSDataCollection<WarningRecord> == null) { if (output.Value as PSDataCollection<ProgressRecord> == null) { if (output.Value as PSDataCollection<VerboseRecord> == null) { if (output.Value as PSDataCollection<DebugRecord> == null) { this.Streams.OutputStream.Add(PSObject.AsPSObject(output.Value)); } else { PSDataCollection<DebugRecord> value = output.Value as PSDataCollection<DebugRecord>; foreach (DebugRecord debugRecord in value) { this.Streams.OutputStream.Add(PSObject.AsPSObject(debugRecord)); } value.Clear(); } } else { PSDataCollection<VerboseRecord> verboseRecords = output.Value as PSDataCollection<VerboseRecord>; foreach (VerboseRecord verboseRecord in verboseRecords) { this.Streams.OutputStream.Add(PSObject.AsPSObject(verboseRecord)); } verboseRecords.Clear(); } } else { PSDataCollection<ProgressRecord> progressRecords = output.Value as PSDataCollection<ProgressRecord>; foreach (ProgressRecord progressRecord in progressRecords) { this.Streams.OutputStream.Add(PSObject.AsPSObject(progressRecord)); } progressRecords.Clear(); } } else { PSDataCollection<WarningRecord> warningRecords = output.Value as PSDataCollection<WarningRecord>; foreach (WarningRecord warningRecord in warningRecords) { this.Streams.OutputStream.Add(PSObject.AsPSObject(warningRecord)); } warningRecords.Clear(); } } else { PSDataCollection<ErrorRecord> errorRecords = output.Value as PSDataCollection<ErrorRecord>; foreach (ErrorRecord errorRecord in errorRecords) { this.Streams.OutputStream.Add(PSObject.AsPSObject(errorRecord)); } errorRecords.Clear(); } } else { PSDataCollection<PSObject> pSObjects = output.Value as PSDataCollection<PSObject>; foreach (PSObject pSObject in pSObjects) { this.Streams.OutputStream.Add(pSObject); } pSObjects.Clear(); } } } catch (Exception exception1) { Exception exception = exception1; this.Tracer.TraceException(exception); } this.State = JobState.Completed; this.PerformTaskAtTerminalState(); this.PerformCleanupAtTerminalState(); if (base.OnCompleted != null) { base.OnCompleted(this); } } else { return; } } if (e.CompletionState == ActivityInstanceState.Faulted) { this.HandleWorkflowApplicationFaultedState(e.TerminationException); } if (e.CompletionState == ActivityInstanceState.Canceled) { this.HandleWorkflowApplicationCanceled(); } return; } else { return; } }
private void wfapp_WorkflowCompleted(WorkflowApplicationCompletedEventArgs e) { }
/// <summary> /// Executes when a workflow completed either successfully, either failing. /// </summary> /// <param name="e"></param> private void wfapp_WorkflowCompleted(WorkflowApplicationCompletedEventArgs e) { WorkflowDetails workflow; lock (syncRoot) { workflow = workflows[e.InstanceId]; } if (WorkflowEvent != null) { switch (e.CompletionState) { case ActivityInstanceState.Closed: // Completed successfully WorkflowEvent(this, new HostEventArgs(WorkflowEventType.Completed, e.InstanceId)); break; case ActivityInstanceState.Canceled: if (workflow.LastException == null) { WorkflowEvent(this, new HostEventArgs(WorkflowEventType.Cancelled, e.InstanceId)); } else { WorkflowEvent(this, new HostEventArgs(WorkflowEventType.Failed, e.InstanceId, workflow.LastException.Message)); } break; case ActivityInstanceState.Faulted: // This should not happen, workflows are forced to cancel case ActivityInstanceState.Executing: default: throw new NotImplementedException(); } } }
/// <summary> /// Initializes a new instance of the <see cref="NinjectWorkflowApplicationCompletedEventArgs"/> class. /// </summary> /// <param name="workflowApplicationCompletedEventArgs">The <see cref="System.Activities.WorkflowApplicationCompletedEventArgs"/> instance containing the event data.</param> public NinjectWorkflowApplicationCompletedEventArgs(WorkflowApplicationCompletedEventArgs workflowApplicationCompletedEventArgs) : base(workflowApplicationCompletedEventArgs) { this.CompletionState = this.Arguments.CompletionState; this.Outputs = this.Arguments.Outputs; this.TerminationException = this.Arguments.TerminationException; }
/// <summary> /// Executes when a workflow completed either successfully, either failing. /// </summary> /// <param name="e"></param> private void wfapp_WorkflowCompleted(WorkflowApplicationCompletedEventArgs e) { WorkflowDetails workflow; lock (syncRoot) { workflow = workflows[e.InstanceId]; } // This is the point to save output parameters SaveWorkflowParameters(workflow.Job, e.Outputs); if (WorkflowEvent != null) { switch (e.CompletionState) { case ActivityInstanceState.Closed: // Completed successfully WorkflowEvent(this, new HostEventArgs(WorkflowEventType.Completed, e.InstanceId)); break; case ActivityInstanceState.Canceled: switch (workflow.Job.Status) { case JobStatus.Cancelled: WorkflowEvent(this, new HostEventArgs(WorkflowEventType.Cancelled, e.InstanceId)); break; case JobStatus.TimedOut: WorkflowEvent(this, new HostEventArgs(WorkflowEventType.TimedOut, e.InstanceId)); break; case JobStatus.Failed: WorkflowEvent(this, new HostEventArgs(WorkflowEventType.Failed, e.InstanceId, workflow.LastException.Message)); break; default: throw new NotImplementedException(); } break; case ActivityInstanceState.Faulted: // This should not happen, workflows are forced to cancel case ActivityInstanceState.Executing: default: throw new NotImplementedException(); } } }
static void completed(WorkflowApplicationCompletedEventArgs e) { writeRunInfo(e.InstanceId, "completed", e.CompletionState.ToString()); }
/// <summary> /// Internal Completed Handler /// </summary> /// <param name="args"> /// The args. /// </param> private void InternalCompleted(WorkflowApplicationCompletedEventArgs args) { if (this.Completed != null) { var action = this.innerCompleted; if (action != null) { action(args); } this.Completed(args); } }