public void StartRotorsWorkFlow(List<string> sourceFileList) { lock (workFlowLock) { if (running) { throw new RotorsException("already one workflow is executing."); } else { RotorsWorkFlowDefinition workFlow = new RotorsWorkFlowDefinition(); running = true; IDictionary<string, object> variables = new Dictionary<string, object>(); if (sourceFileList != null) { variables = new Dictionary<string, object>(); variables.Add(Singleton<Constants>.UniqueInstance.FileVariableName, sourceFileList.ToArray()); } WorkflowApplication wfa = new WorkflowApplication(workFlow, variables); wfa.OnUnhandledException += new Func<WorkflowApplicationUnhandledExceptionEventArgs, UnhandledExceptionAction>((e) => { running = false; Singleton<ReportMediator>.UniqueInstance.ReportStatus(e.UnhandledException.ToString()); if (WorkFlowEnded != null) { WorkFlowEnded(this, null); } return UnhandledExceptionAction.Terminate; }); wfa.Completed += new Action<WorkflowApplicationCompletedEventArgs>((e) => { running = false; if (WorkFlowEnded != null) { WorkFlowEnded(this, null); } Singleton<ReportMediator>.UniqueInstance.ReportStatus("Completed!"); }); wfa.Idle += new Action<WorkflowApplicationIdleEventArgs>((e) => { Console.WriteLine("Idle" + e.ToString()); }); wfa.Run(); } } }
public void StartRotorsWorkFlow(List <string> sourceFileList) { lock (workFlowLock) { if (running) { throw new RotorsException("already one workflow is executing."); } else { RotorsWorkFlowDefinition workFlow = new RotorsWorkFlowDefinition(); running = true; IDictionary <string, object> variables = new Dictionary <string, object>(); if (sourceFileList != null) { variables = new Dictionary <string, object>(); variables.Add(Singleton <Constants> .UniqueInstance.FileVariableName, sourceFileList.ToArray()); } WorkflowApplication wfa = new WorkflowApplication(workFlow, variables); wfa.OnUnhandledException += new Func <WorkflowApplicationUnhandledExceptionEventArgs, UnhandledExceptionAction>((e) => { running = false; Singleton <ReportMediator> .UniqueInstance.ReportStatus(e.UnhandledException.ToString()); if (WorkFlowEnded != null) { WorkFlowEnded(this, null); } return(UnhandledExceptionAction.Terminate); }); wfa.Completed += new Action <WorkflowApplicationCompletedEventArgs>((e) => { running = false; if (WorkFlowEnded != null) { WorkFlowEnded(this, null); } Singleton <ReportMediator> .UniqueInstance.ReportStatus("Completed!"); }); wfa.Idle += new Action <WorkflowApplicationIdleEventArgs>((e) => { Console.WriteLine("Idle" + e.ToString()); }); wfa.Run(); } } }