static void Main() { CreateRoles(); using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { workflowRuntime.StartRuntime(); // Load the workflow type. Type type = typeof(PurchaseOrderWorkflow); ExternalDataExchangeService dataService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataService); poImpl = new StartPurchaseOrder(); dataService.AddService(poImpl); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; WorkflowInstance instance = workflowRuntime.CreateWorkflow(type); workflowInstanceId = instance.InstanceId; instance.Start(); SendPORequestMessage(); waitHandle.WaitOne(); workflowRuntime.StopRuntime(); } }
static void Main() { string connectionString = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;"; using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { ExternalDataExchangeService dataService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataService); dataService.AddService(expenseService); workflowRuntime.AddService(new SqlWorkflowPersistenceService(connectionString)); workflowRuntime.StartRuntime(); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.WorkflowIdled += OnWorkflowIdled; workflowRuntime.WorkflowAborted += OnWorkflowAborted; Type type = typeof(Microsoft.Samples.Workflow.CancelWorkflow.SampleWorkflow); WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type); workflowInstance.Start(); waitHandle.WaitOne(); workflowRuntime.StopRuntime(); } }
static void Main() { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { // Create our local service and add it to the workflow runtime's list of services ExternalDataExchangeService dataService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataService); VotingServiceImpl votingService = new VotingServiceImpl(); dataService.AddService(votingService); // Start up the runtime and hook the creation and completion events workflowRuntime.StartRuntime(); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.WorkflowStarted += OnWorkflowStarted; // Create the workflow's parameters collection Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("Alias", "Jim"); // Create and start the workflow Type type = typeof(HostCommunication.VotingServiceWorkflow); workflowRuntime.CreateWorkflow(type, parameters).Start(); waitHandle.WaitOne(); // Cleanly stop the runtime and all services workflowRuntime.StopRuntime(); } }
/// <summary> /// 创建工作流运行时 /// </summary> /// <param name="IsPer">是否使用持久化</param> /// <returns></returns> public static WorkflowRuntime CreateWorkFlowRuntime(bool IsPer) { try { WorkflowRuntime WfRuntime = new WorkflowRuntime(); if (IsPer) { ConnectionStringSettings defaultConnectionString = ConfigurationManager.ConnectionStrings["OracleConnection"]; WfRuntime.AddService(new AdoPersistenceService(defaultConnectionString, true, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0))); WfRuntime.AddService(new AdoTrackingService(defaultConnectionString)); WfRuntime.AddService(new AdoWorkBatchService()); } FlowEvent ExternalEvent = new FlowEvent(); ExternalDataExchangeService objService = new ExternalDataExchangeService(); WfRuntime.AddService(objService); objService.AddService(ExternalEvent); ManualWorkflowSchedulerService scheduleService = new ManualWorkflowSchedulerService(); WfRuntime.AddService(scheduleService); TypeProvider typeProvider = new TypeProvider(null); WfRuntime.AddService(typeProvider); WfRuntime.StartRuntime(); return WfRuntime; } catch (Exception ex) { LogHelper.WriteLog("CreateWorkFlowRuntime异常信息 :" + ex.ToString()); throw new Exception(ex.Message); } }
static void Main() { orderService = new OrderServiceImpl(); // Start the workflow runtime engine. using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { ExternalDataExchangeService dataService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataService); dataService.AddService(orderService); workflowRuntime.StartRuntime(); // Listen for the workflow events workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.WorkflowIdled += OnWorkflowIdled; // Start the workflow and wait for it to complete Type type = typeof(PurchaseOrderWorkflow); workflowRuntime.CreateWorkflow(type).Start(); waitHandle.WaitOne(); // Stop the workflow runtime engine. workflowRuntime.StopRuntime(); } }
public Mainform() { InitializeComponent(); this.runtime = new WorkflowRuntime(); runtime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(runtime_WorkflowCompleted); // Set up runtime to unload workflow instance from memory to file using FilePersistenceService FilePersistenceService filePersistence = new FilePersistenceService(true); runtime.AddService(filePersistence); // Add document approval service ExternalDataExchangeService dataService = new ExternalDataExchangeService(); runtime.AddService(dataService); documentService = new DocumentApprovalService(this); dataService.AddService(documentService); // Search for workflows that have previously been persisted to file, and load into the listview control. // These workflows will be reloaded by the runtime when events are raised against them. LoadWorkflowData(); // Start the runtime runtime.StartRuntime(); }
///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// public MainForm() { InitializeComponent(); #region UI define GenerateButtons(); GenerateAcctions(); #endregion #region Bankomats Init currentAccountCulture = CultureInfo.CurrentCulture; #endregion #region IniT Workflow workflowRuntime = new WorkflowRuntime(); ExternalDataExchangeService des = new ExternalDataExchangeService(); workflowRuntime.AddService(des); des.AddService(this); workflowRuntime.StartRuntime(); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(workflowRuntime_WorkflowTerminated); Type type = typeof(BankomatWorkflowLibrary.BankomatsWorkflow); workflowInstance = workflowRuntime.CreateWorkflow(type); workflowInstance.Start(); #endregion }
public void NoCorrelationParameter () { SampleService1 sample = new SampleService1 (); WorkflowRuntime workflow = new WorkflowRuntime (); ExternalDataExchangeService data_change = new ExternalDataExchangeService (); workflow.AddService (data_change); data_change.AddService (sample); }
static void Main(string[] args) { Console.WriteLine("Starting CRySTAL..."); Console.WriteLine("Linking Workflow Runtime Services..."); CRySTAL.WorkflowInterface.WorkflowInterface.CustomerWF = new CRySTAL.WorkflowInterface.CustomerWorkflowInterface(); WorkflowRuntime workflowRuntime = new WorkflowRuntime(); AppDomain.CurrentDomain.SetData("WorkflowRuntime", workflowRuntime); ManualWorkflowSchedulerService manualScheduler = new ManualWorkflowSchedulerService(true); AppDomain.CurrentDomain.SetData("ManualScheduler", manualScheduler); workflowRuntime.AddService(manualScheduler); ExternalDataExchangeService des = new ExternalDataExchangeService(); workflowRuntime.AddService(des); des.AddService(CRySTAL.WorkflowInterface.WorkflowInterface.CustomerWF); TimeSpan reloadIntevral = new TimeSpan(0, 0, 0, 20, 0); TimeSpan ownershipDuration = new TimeSpan(0, 0, 30, 0); string connectionString = @"Data Source=ETHIELE-LENOVO\SQLEXPRESS;Initial Catalog=WFTrackingAndPersistence;Integrated Security=True"; SqlWorkflowPersistenceService sqlPersistenceService = new SqlWorkflowPersistenceService(connectionString, true, ownershipDuration, reloadIntevral); workflowRuntime.AddService(sqlPersistenceService); SqlTrackingService sts = new SqlTrackingService(connectionString); workflowRuntime.AddService(sts); Console.WriteLine("Starting Workflow Runtime..."); workflowRuntime.StartRuntime(); //AppDomain.CurrentDomain.SetData("firstNamestr", "thisisatest"); List<ServiceHost> hosts = new List<ServiceHost>(); hosts.Add(new ServiceHost(typeof(CRySTAL.CookService))); hosts.Add(new ServiceHost(typeof(CRySTAL.BusBoyService))); hosts.Add(new ServiceHost(typeof(CRySTAL.HostService))); hosts.Add(new ServiceHost(typeof(CRySTAL.LoginService))); hosts.Add(new ServiceHost(typeof(CRySTAL.MenuService))); hosts.Add(new ServiceHost(typeof(CRySTAL.WaiterService))); foreach (ServiceHost host in hosts) { host.Open(); Console.WriteLine("CRySTAL: Service Running: " + host.BaseAddresses[0].ToString()); } Console.WriteLine("CRySTAL Ready"); Console.ReadLine(); Console.WriteLine("Shutting down CRySTAL..."); foreach (ServiceHost host in hosts) { host.Close(); Console.WriteLine("CRySTAL: Shutingdown Service :" + host.BaseAddresses[0].ToString()); } Console.WriteLine("Shutting down runtime..."); workflowRuntime.StopRuntime(); Console.WriteLine("CRySTAL shutdown complete"); Console.ReadLine(); }
private void RunUI() { _stateLabel.Text = _flow.InitialStateName; ExternalDataExchangeService externalDataSvc = new ExternalDataExchangeService(); _workflowRuntime.AddService(externalDataSvc); _eventService = Activator.CreateInstance(_flow.ServiceImplementation) as BaseServiceImplementation; externalDataSvc.AddService(_eventService); _instance.Start(); _flow.StartFlow(); }
public void AddGetRemoveTest () { SampleService2 sample = new SampleService2 (); WorkflowRuntime workflow = new WorkflowRuntime (); ExternalDataExchangeService data_change = new ExternalDataExchangeService (); workflow.AddService (data_change); data_change.AddService (sample); Assert.AreEqual (sample, data_change.GetService (sample.GetType ()), "C1#1"); data_change.RemoveService (sample); Assert.AreEqual (null, data_change.GetService (sample.GetType ()), "C1#2"); }
private void frmReclamo_Load(object sender, EventArgs e) { workflowRuntime = new WorkflowRuntime(); ExternalDataExchangeService dataExchange = new ExternalDataExchangeService(); workflowRuntime.AddService(dataExchange); dataExchange.AddService(this); workflowRuntime.StartRuntime(); workflowRuntime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(workflowRuntime_WorkflowCompleted); }
public Form1() { InitializeComponent(); this.workflowRuntime = new WorkflowRuntime(); exchangeService = new ExternalDataExchangeService(); //This starts the runtime but does not execute any //workflows until the application notifies it to start a workflow. this.workflowRuntime.StartRuntime(); //Enlace entre el workFlow y exchangeService workflowRuntime.AddService(exchangeService); //exchangeService es asociado para que iteractue con el formulario .. ya que implementa la interfaz "IExpenseReportService" que tiene el atributo [ExternalDataExchangeAttribute] exchangeService.AddService(this); workflowRuntime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(workflowRuntime_WorkflowCompleted); }
private void StartWorkflowRuntime() { // Create a new Workflow Runtime for this application runtime = new WorkflowRuntime(); // Create EventHandlers for the WorkflowRuntime runtime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(Runtime_WorkflowTerminated); runtime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(Runtime_WorkflowCompleted); runtime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(Runtime_WorkflowIdled); // Add the External Data Exchange Service ExternalDataExchangeService dataExchangeService = new ExternalDataExchangeService(); runtime.AddService(dataExchangeService); // Add a new instance of the OrderService to the External Data Exchange Service orderService = new OrderService(); dataExchangeService.AddService(orderService); // Start the Workflow services runtime.StartRuntime(); }
static void Main() { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { try { // Set up the runtime to unload the workflow instance from memory to file using FilePersistenceService workflowRuntime.AddService(new FilePersistenceService(true)); // Add document approval service ExternalDataExchangeService dataService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataService); dataService.AddService(documentApprover); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowIdled += OnWorkflowIdled; workflowRuntime.WorkflowTerminated += OnWorkflowTerminated; workflowRuntime.ServicesExceptionNotHandled += OnExceptionNotHandled; // Start the engine. workflowRuntime.StartRuntime(); // Load the workflow type. Type type = typeof(DocumentApprovalWorkflow); workflowRuntime.CreateWorkflow(type).Start(); // waitHandle blocks so that the program does not exit till workflow completes waitHandle.WaitOne(); } catch (Exception e) { Console.WriteLine("Exception \n\t Source: {0} \n\t Message: {1}", e.Source, e.Message); } finally { workflowRuntime.StopRuntime(); Console.WriteLine("Workflow runtime stopped, program exiting... \n"); } } }
public static void StartWorkflowRuntime() { // Create a new Workflow Runtime for this application runtime = new WorkflowRuntime(); // Create EventHandlers for the WorkflowRuntime //runtime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(Runtime_WorkflowTerminated); //runtime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(Runtime_WorkflowCompleted); //runtime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(Runtime_WorkflowIdled); // Add the External Data Exchange Service ExternalDataExchangeService dataExchangeService = new ExternalDataExchangeService(); runtime.AddService(dataExchangeService); // Add a new instance of the OrderService to the External Data Exchange Service ValuationEvents = new ValuationProcessEvents(); dataExchangeService.AddService(ValuationEvents); // Add Persistance service to the runtime SqlWorkflowPersistenceService sqlPersistenceService = new SqlWorkflowPersistenceService("Data Source=blrserver\\sql2005;Initial Catalog=IGRSS_EF;User ID=sa;Password=trans"); runtime.AddService(sqlPersistenceService); // Start the Workflow services runtime.StartRuntime(); }
static void Main(string[] args) { using(WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { AutoResetEvent waitHandle = new AutoResetEvent(false); ExternalDataExchangeService dataExchange = new ExternalDataExchangeService(); workflowRuntime.AddService(dataExchange); service = new EventService(); dataExchange.AddService(service); workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) { Console.WriteLine("Workflow completed."); waitHandle.Set(); }; workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { Console.WriteLine(e.Exception.Message); waitHandle.Set(); }; workflowRuntime.WorkflowIdled += delegate(object sender, WorkflowEventArgs e) { Console.WriteLine("Workflow idled."); Console.WriteLine("Sending event to workflow."); service.RaiseSetStateEvent(instanceId); }; WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(StateMachineCommunication.SimpleStateMachine)); instanceId = instance.InstanceId; Console.WriteLine("Starting workflow."); instance.Start(); waitHandle.WaitOne(); workflowRuntime.StopRuntime(); } }
private void StartWorkflowRuntime() { // Create a new Workflow Runtime for this application workflowRuntime = new WorkflowRuntime(); // Create EventHandlers for the WorkflowRuntime workflowRuntime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(WorkflowRuntime_WorkflowTerminated); workflowRuntime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(WorkflowRuntime_WorkflowCompleted); workflowRuntime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(workflowRuntime_WorkflowIdled); // Start the Workflow services workflowRuntime.StartRuntime(); // Add an instance of the External Data Exchange Service ExternalDataExchangeService externalDataExchangeService = new ExternalDataExchangeService(); workflowRuntime.AddService(externalDataExchangeService); // Add a new instance of the OrderService to the externalDataExchangeService speechService = new SpeechService(); externalDataExchangeService.AddService(speechService); // Subscribe to the menu text changed event speechService.PhoneTextChangedEventHandler += new SpeechService.UpdatePhoneTextEventHandler(UpdatePhoneTextEventHandler); }
static void Main() { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { ExternalDataExchangeService dataExchangeService = new ExternalDataExchangeService(); workflowRuntime.AddService(dataExchangeService); dataExchangeService.AddService(taskService); workflowRuntime.StartRuntime(); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { Console.WriteLine(e.Exception.Message); waitHandle.Set(); }; instance = workflowRuntime.CreateWorkflow(typeof(CorrelatedLocalServiceWorkflow)); instance.Start(); waitHandle.WaitOne(); workflowRuntime.StopRuntime(); } }
static void Main() { Activity workflow = CreateWorkflow(); using (System.ServiceModel.Activities.WorkflowServiceHost host = new System.ServiceModel.Activities.WorkflowServiceHost(workflow, new Uri(Program.baseAddress))) { ExternalDataExchangeService dataExchangeService = new ExternalDataExchangeService(); TaskService taskService = new TaskService(); dataExchangeService.AddService(taskService); WorkflowRuntimeEndpoint workflowRuntimeEndpoint = new WorkflowRuntimeEndpoint(); workflowRuntimeEndpoint.AddService(dataExchangeService); host.AddServiceEndpoint(workflowRuntimeEndpoint); host.AddDefaultEndpoints(); host.Open(); IWorkflow proxy = ChannelFactory<IWorkflow>.CreateChannel(new BasicHttpBinding(), new EndpointAddress(Program.baseAddress)); proxy.Start(); Console.WriteLine("Workflow starting, press enter when workflow completes.\n"); Console.ReadLine(); } }
/// <summary> /// 启动与工作流程相同类型流程,查询对应节点用户 /// </summary> /// <param name="CompanyID">公司ID</param> /// <param name="ModelCode">模块代码</param> /// <param name="FlowGUID">待审批流GUID,新增时为空或者为StartFlow</param> /// <returns></returns> public DataResult GetAppUser(OracleConnection con, string CompanyID, string ModelCode, string FlowGUID, string xml) { DataResult GetAppUserResult = new DataResult(); try { string StateName = null; if (FlowGUID == "" || FlowGUID == "StartFlow") { StateName = "StartFlow"; } else { //根据待审批流程GUID,检索待审批状态节点代码 List<FLOW_FLOWRECORDDETAIL_T> FlowRecord = FlowBLL2.GetFlowInfo(con, "", FlowGUID, "", "", "", "", "", null); if (FlowRecord == null) { GetAppUserResult.Err = "没有待处理的审核"; GetAppUserResult.UserInfo = null; return GetAppUserResult; } StateName = FlowRecord[0].STATECODE; } //根据公司ID,模块代码获取配置的流程 WorkflowInstance instance = null; LogHelper.WriteLog("根据公司ID,模块代码获取配置的流程FlowBLL2.GetFlowByModelName:OgrType='0'"); List<FLOW_MODELFLOWRELATION_T> MODELFLOWRELATION = FlowBLL2.GetFlowByModelName(con, CompanyID, "", ModelCode, "0"); if (MODELFLOWRELATION == null || MODELFLOWRELATION.Count == 0) { GetAppUserResult.Err = "没有可使用的流程"; GetAppUserResult.UserInfo = null; return GetAppUserResult; } FLOW_FLOWDEFINE_T Xoml = MODELFLOWRELATION[0].FLOW_FLOWDEFINE_T; XmlReader readerxoml, readerule; StringReader strXoml = new StringReader(Xoml.XOML); StringReader strRules = new StringReader(Xoml.RULES == null ? "" : Xoml.RULES); readerxoml = XmlReader.Create(strXoml); readerule = XmlReader.Create(strRules); WorkflowRuntime workflowRuntime = new WorkflowRuntime(); workflowRuntime.StartRuntime(); FlowEvent ExternalEvent = new FlowEvent(); ExternalDataExchangeService objService = new ExternalDataExchangeService(); workflowRuntime.AddService(objService); objService.AddService(ExternalEvent); TypeProvider typeProvider = new TypeProvider(null); workflowRuntime.AddService(typeProvider); //XmlReader readerxoml = XmlReader.Create(HttpContext.Current.Server.MapPath ("TestFlow.xml")); // instance = workflowRuntime.CreateWorkflow(readerxoml); if (Xoml.RULES == null) instance = workflowRuntime.CreateWorkflow(readerxoml); else instance = workflowRuntime.CreateWorkflow(readerxoml, readerule, null); // instance = workflowRuntime.CreateWorkflow(typeof(TestFlow)); instance.Start(); StateMachineWorkflowInstance workflowinstance = new StateMachineWorkflowInstance(workflowRuntime, instance.InstanceId); //从实例中获取定义 if (1 == 2) { System.Workflow.Activities.StateMachineWorkflowActivity smworkflow = new StateMachineWorkflowActivity(); smworkflow = workflowinstance.StateMachineWorkflow; RuleDefinitions ruleDefinitions = smworkflow.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions; WorkflowMarkupSerializer markupSerializer = new WorkflowMarkupSerializer(); StringBuilder xoml = new StringBuilder(); StringBuilder rule = new StringBuilder(); XmlWriter xmlWriter = XmlWriter.Create(xoml); XmlWriter ruleWriter = XmlWriter.Create(rule); markupSerializer.Serialize(xmlWriter, smworkflow); markupSerializer.Serialize(ruleWriter, ruleDefinitions); xmlWriter.Close(); ruleWriter.Close(); StringReader readxoml = new StringReader(xoml.ToString()); StringReader readrule = new StringReader(rule.ToString()); XmlReader readerxoml2 = XmlReader.Create(readxoml); XmlReader readerrule2 = XmlReader.Create(readrule); WorkflowInstance instance1 = workflowRuntime.CreateWorkflow(readerxoml2, readerrule2, null); instance1.Start(); StateMachineWorkflowInstance workflowinstance1 = new StateMachineWorkflowInstance(workflowRuntime, instance1.InstanceId); workflowinstance1.SetState(StateName); } //从实例中获取定义并启动新实例 //跳转到节点StateName workflowinstance.SetState(StateName); FlowDataType.FlowData FlowData = new FlowDataType.FlowData(); FlowData.xml = xml; // FlowData.Flow_FlowRecord_T = null; ExternalEvent.OnDoFlow(instance.InstanceId, FlowData);//激发流程引擎流转到下一状态 System.Threading.Thread.Sleep(1000); PermissionServiceClient WcfPermissionService = new PermissionServiceClient(); string CurrentStateName = workflowinstance.CurrentStateName == null ? "End" : workflowinstance.CurrentStateName; //取得当前状态 List<UserInfo> listUser = new List<UserInfo>(); if (CurrentStateName != "End") { if (CurrentStateName.Substring(0, 5) == "State") { CurrentStateName = CurrentStateName.Substring(5); } string WFCurrentStateName = new Guid(CurrentStateName).ToString("D"); T_SYS_USER[] User = WcfPermissionService.GetSysUserByRole(WFCurrentStateName); //检索本状态(角色)对应用户 if (User != null) for (int i = 0; i < User.Length; i++) { UserInfo tmp = new UserInfo(); tmp.UserID = User[i].EMPLOYEEID; tmp.UserName = User[i].EMPLOYEENAME; listUser.Add(tmp); } } else { //已经到流程结束状态 UserInfo tmp = new UserInfo(); tmp.UserID = "End"; tmp.UserName = "******"; listUser.Add(tmp); } GetAppUserResult.UserInfo = listUser.Count > 0 ? listUser : null; if (GetAppUserResult.UserInfo == null) GetAppUserResult.Err = "没有找到用户"; return GetAppUserResult; // return listUser; //return workflowinstance.CurrentStateName == null ? "End" : workflowinstance.CurrentStateName; } catch (Exception ex) { GetAppUserResult.Err = ex.Message; GetAppUserResult.UserInfo = null; return GetAppUserResult; } }
public void start() { wfRuntime = new WorkflowRuntime(); //--通信 exExchangeService = new ExternalDataExchangeService(); exEvent = new ExternalEvent(); wfRuntime.AddService(exExchangeService); exExchangeService.AddService(exEvent); //- lsWFInfo = new List<string>(); lsWFEvent = new List<string>(); wfRuntime.AddService(lsWFInfo); //事件 this.wfRuntime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(wfRuntime_WorkflowCompleted); this.wfRuntime.Started += new EventHandler<WorkflowRuntimeEventArgs>(wfRuntime_Started); this.wfRuntime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(wfRuntime_WorkflowIdled); this.wfRuntime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(wfRuntime_WorkflowTerminated); this.wfRuntime.WorkflowAborted += new EventHandler<WorkflowEventArgs>(wfRuntime_WorkflowAborted); //-启动引擎 wfRuntime.StartRuntime(); }
public void TestActivity () { WorkflowRuntime workflowRuntime = new WorkflowRuntime (); DocumentService DocumentService = new DocumentService (); Type type = typeof (WorkFlowCallExternal); workflowRuntime.WorkflowCompleted += OnWorkflowCompleted; ExternalDataExchangeService dataExchangeService = new ExternalDataExchangeService (); workflowRuntime.AddService (dataExchangeService); dataExchangeService.AddService (DocumentService); workflowRuntime.CreateWorkflow (type).Start (); waitHandle.WaitOne (); workflowRuntime.Dispose (); Assert.AreEqual ("Joan Martinez", text, "C1#1"); Assert.AreEqual ("First", document, "C1#2"); }
public void AddingServiceTwice () { SampleService2 sample = new SampleService2 (); WorkflowRuntime workflow = new WorkflowRuntime (); ExternalDataExchangeService data_change = new ExternalDataExchangeService (); workflow.AddService (data_change); data_change.AddService (sample); data_change.AddService (sample); }
private static void AddServices() { #region Basic Workflow Services // Add the SqlWorkflowPersistenceService to the runtime engine. SqlWorkflowPersistenceService PersistService = new SqlWorkflowPersistenceService(Settings.Default.AppConnectionString); Runtime.AddService(PersistService); //SqlTrackingService TrackingService = new SqlTrackingService(Settings.Default.AppConnectionString); //Runtime.AddService(TrackingService); // Add ExternalDataExchangeService to communicate with any running Workflow ExternalDataExchangeService DataExchangeService = new ExternalDataExchangeService(); Runtime.AddService(DataExchangeService); #endregion #region Igrss Business Services ComplainServices = new ComplainService(); DataExchangeService.AddService(ComplainServices); LicenseApplicationServices = new LicenseApplicationService(); DataExchangeService.AddService(LicenseApplicationServices); AppealServices = new AppealService(); DataExchangeService.AddService(AppealServices); RefundServices = new RefundService(); DataExchangeService.AddService(RefundServices); AdjudicationServices = new AdjudicationService(); DataExchangeService.AddService(AdjudicationServices); #endregion //ComplainService complainService = new ComplainService(); //DataService.AddService(complainService); //OrderService orderService = OrderService.Instance; //dataService.AddService(orderService); //OrderTransactionService txnService = new OrderTransactionService(); //Runtime.AddService(txnService); //ContextService = new HttpContextWrapper(); }
static void Main(string[] args) { using (WorkflowRuntime workflowRuntime = new WorkflowRuntime()) { AutoResetEvent waitHandle = new AutoResetEvent(false); workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) { waitHandle.Set(); }; workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { Console.WriteLine(e.Exception.Message); waitHandle.Set(); }; // Add Persistence and Tracking SqlWorkflowPersistenceService persistenceService; persistenceService = new SqlWorkflowPersistenceService( ConfigurationManager. ConnectionStrings["PersistentDataStore"]. ConnectionString, true, TimeSpan.MaxValue, TimeSpan.MinValue); workflowRuntime.AddService(persistenceService); SqlTrackingService trackingService; trackingService = new SqlTrackingService( ConfigurationManager. ConnectionStrings["PersistentDataStore"]. ConnectionString); trackingService.UseDefaultProfile = true; workflowRuntime.AddService(trackingService); // Set up the data exchange ExternalDataExchangeService dataExchange; dataExchange = new ExternalDataExchangeService(); workflowRuntime.AddService(dataExchange); // Instatiate the local communication service CustomerCallService customerCallService = new CustomerCallService(); dataExchange.AddService(customerCallService); // Create a new workflow instance WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(CustomerService)); instance.Start(); // Create a new Call Call newCall = new Call(); newCall.CallersFirstName = "Alex"; newCall.Product = "Widget Number Nine"; // Change the state using the service and events customerCallService.ReceiveCall(instance.InstanceId, newCall); customerCallService.SendCallToPhoneResolution(instance.InstanceId, newCall); customerCallService.AssignCallToSupportPerson(instance.InstanceId, newCall); //Get a look at where we have wound up PrintStateMachineState(workflowRuntime, instance.InstanceId); // Change the state one last time customerCallService.ResolveCall(instance.InstanceId, newCall); // Print the history of our instance PrintHistory(workflowRuntime, instance.InstanceId); waitHandle.WaitOne(); // Keep the console open until key strokes are entered so that you can see what we did... Console.ReadLine(); } }
public override void Initialize(string name, NameValueCollection config) { base.Initialize(name, config); if (!string.IsNullOrEmpty(config["applicationName"])) { this._applicationName = config["applicationName"]; config.Remove("applicationName"); } if (!string.IsNullOrEmpty(config["connectionStringName"])) { this._connectionStringName = config["connectionStringName"]; config.Remove("connectionStringName"); } if (!string.IsNullOrEmpty(config["synchronousExecution"])) { this._synchronousExecution = Convert.ToBoolean(config["synchronousExecution"]); config.Remove("synchronousExecution"); } if (!string.IsNullOrEmpty(config["defaultStartTime"])) { this._defaultEndTime = config["defaultStartTime"]; config.Remove("defaultStartTime"); } if (!string.IsNullOrEmpty(config["defaultEndTime"])) { this._defaultEndTime = config["defaultEndTime"]; config.Remove("defaultEndTime"); } if (!string.IsNullOrEmpty(config["timeToExpire"])) { this._timeToExpire = TimeSpan.Parse(config["timeToExpire"]); config.Remove("timeToExpire"); } if (!string.IsNullOrEmpty(config["includeWeekends"])) { this._includeWeekends = Convert.ToBoolean(config["includeWeekends"]); config.Remove("includeWeekends"); } if (!string.IsNullOrEmpty(config["requestSchemaPath"])) { this._requestSchemaPath = config["requestSchemaPath"]; config.Remove("requestSchemaPath"); } if (!string.IsNullOrEmpty(config["responseSchemaPath"])) { this._responseSchemaPath = config["responseSchemaPath"]; config.Remove("responseSchemaPath"); } if (config.Count > 0) throw new ProviderException(string.Format("Unknown config attribute '{0}'", config.GetKey(0))); #region Workflow Runtime Initialization if (theWorkflowRuntime == null) { lock (this) { if (theWorkflowRuntime == null) { theWorkflowRuntime = new WorkflowRuntime(); theWorkflowRuntime.WorkflowLoaded += new EventHandler<WorkflowEventArgs>(theWorkflowRuntime_WorkflowLoaded); theWorkflowRuntime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(theWorkflowRuntime_WorkflowIdled); theWorkflowRuntime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(theWorkflowRuntime_WorkflowCompleted); theWorkflowRuntime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(theWorkflowRuntime_WorkflowTerminated); theWorkflowRuntime.WorkflowSuspended += new EventHandler<WorkflowSuspendedEventArgs>(theWorkflowRuntime_WorkflowSuspended); // Used for synchronous execution of workflow instances. if (this.SynchronousExecution) theSchedulerService = theWorkflowRuntime.GetService<ManualWorkflowSchedulerService>(); // Add the external data service ExternalDataExchangeService dataService = new ExternalDataExchangeService(); theWorkflowRuntime.AddService(dataService); // Add custom wiki management service. theServiceProvider = new ServiceProviderHelper(); dataService.AddService(theServiceProvider); // Add system SQL state service. SqlWorkflowPersistenceService stateService = new SqlWorkflowPersistenceService( ConfigurationManager.ConnectionStrings[this.ConnectionStringName].ConnectionString); theWorkflowRuntime.AddService(stateService); try { Trace.TraceInformation("Starting workflow engine."); // Start theWorkflowRuntime.StartRuntime(); Trace.TraceInformation("Workflow engine was sucessfully started."); } catch (Exception ex) { Trace.TraceError(string.Format( "Error while starting the workflow engine. Description: {0}", ex.Message)); theWorkflowRuntime.Dispose(); throw; } } } } #endregion }