Beispiel #1
1
        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();
            }
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
        /////////////////////////////////////////////////////////////////////////////
        /////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////
        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
        }
Beispiel #4
0
        /// <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);
            }
        }
Beispiel #5
0
        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();
            }
        }
Beispiel #6
0
        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();
        }
Beispiel #7
0
        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();
            }
        }
		public void NoCorrelationParameter ()
		{
			SampleService1 sample = new SampleService1 ();
			WorkflowRuntime workflow = new WorkflowRuntime ();
			ExternalDataExchangeService data_change = new ExternalDataExchangeService ();
			workflow.AddService (data_change);
			data_change.AddService (sample);
		}
Beispiel #9
0
        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();
        }
Beispiel #10
0
 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");
		}
Beispiel #12
0
        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);
        }
Beispiel #13
0
        public void EventHandler(object sender, ExternalDataEventArgs eventArgs)
        {
            if (eventArgs == null)
            {
                throw new ArgumentNullException("eventArgs");
            }

            try
            {
                object         workItem;
                IPendingWork   workHandler;
                object[]       args = this.enqueueWrapper.PrepareEventArgsArray(sender, eventArgs, out workItem, out workHandler);
                EventQueueName key  = GetKey(args);

                String securityIdentifier = null;
                if (eventArgs.Identity == null)
                {
                    IIdentity       identity        = System.Threading.Thread.CurrentPrincipal.Identity;
                    WindowsIdentity windowsIdentity = identity as WindowsIdentity;
                    if (windowsIdentity != null && windowsIdentity.User != null)
                    {
                        securityIdentifier = windowsIdentity.User.Translate(typeof(NTAccount)).ToString();
                    }
                    else if (identity != null)
                    {
                        securityIdentifier = identity.Name;
                    }

                    eventArgs.Identity = securityIdentifier;
                }
                else
                {
                    securityIdentifier = eventArgs.Identity;
                }

                MethodMessage message = new MethodMessage(this.proxiedType, this.eventName, args, securityIdentifier);

                WorkflowActivityTrace.Activity.TraceEvent(TraceEventType.Information, 0, "Firing event {0} for instance {1}", this.eventName, eventArgs.InstanceId);

                this.enqueueWrapper.DeliverMessage(eventArgs, key, message, workItem, workHandler);
            }
            catch (Exception e)
            {
                if (ExternalDataExchangeService.IsIrrecoverableException(e))
                {
                    throw;
                }
                else
                {
                    throw new EventDeliveryFailedException(SR.GetString(SR.Error_EventDeliveryFailedException, this.proxiedType, this.eventName, eventArgs.InstanceId), e);
                }
            }
        }
Beispiel #14
0
		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);
		}
 public void EventHandler(object sender, ExternalDataEventArgs eventArgs)
 {
     if (eventArgs == null)
     {
         throw new ArgumentNullException("eventArgs");
     }
     try
     {
         object         obj2;
         IPendingWork   work;
         object[]       objArray = this.enqueueWrapper.PrepareEventArgsArray(sender, eventArgs, out obj2, out work);
         EventQueueName key      = this.GetKey(objArray);
         string         name     = null;
         if (eventArgs.Identity == null)
         {
             IIdentity       identity  = Thread.CurrentPrincipal.Identity;
             WindowsIdentity identity2 = identity as WindowsIdentity;
             if ((identity2 != null) && (identity2.User != null))
             {
                 name = identity2.User.Translate(typeof(NTAccount)).ToString();
             }
             else if (identity != null)
             {
                 name = identity.Name;
             }
             eventArgs.Identity = name;
         }
         else
         {
             name = eventArgs.Identity;
         }
         MethodMessage message = new MethodMessage(this.proxiedType, this.eventName, objArray, name);
         WorkflowActivityTrace.Activity.TraceEvent(TraceEventType.Information, 0, "Firing event {0} for instance {1}", new object[] { this.eventName, eventArgs.InstanceId });
         this.enqueueWrapper.DeliverMessage(eventArgs, key, message, obj2, work);
     }
     catch (Exception exception)
     {
         if (ExternalDataExchangeService.IsIrrecoverableException(exception))
         {
             throw;
         }
         throw new EventDeliveryFailedException(SR.GetString("Error_EventDeliveryFailedException", new object[] { this.proxiedType, this.eventName, eventArgs.InstanceId }), exception);
     }
 }
Beispiel #16
0
        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();
        }
Beispiel #17
0
        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");
                }
            }
        }
Beispiel #18
0
        public frmMain()
        {
            InitializeComponent();

            orderHistory = new Dictionary<string, List<string>>();

            //Inicia el Workflow
            this.workflowRuntime = new WorkflowRuntime();
            //Sirve para intercambio de dato entre el Workflow y el Host
            this.exchangeService = new ExternalDataExchangeService();


            this.workflowRuntime.AddService(this.exchangeService);
            this.exchangeService.AddService(this);
            this.workflowRuntime.StartRuntime();


            this.itemsList.SelectedIndex = 0;


        }
Beispiel #19
0
    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();
    }
Beispiel #20
0
        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();
            }
        }
Beispiel #21
0
        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);
        }
Beispiel #22
0
        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();
            }
        }
Beispiel #23
0
        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();
            }
        }
		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");
		}
Beispiel #25
0
        /// <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;
            }
        }
Beispiel #26
0
 public EnqueueMessageWrapper(ExternalDataExchangeService eds)
 {
     this.eds = eds;
 }
 public EnqueueMessageWrapper(ExternalDataExchangeService eds)
 {
     this.eds = eds;
 }
Beispiel #28
0
        protected virtual void AddServices()
        {
            ExternalDataExchangeService dataService = new ExternalDataExchangeService();
            Runtime.AddService(dataService);

            //OrderService orderService = OrderService.Instance;
            //dataService.AddService(orderService);

            //OrderTransactionService txnService = new OrderTransactionService();
            //Runtime.AddService(txnService);

            //ContextService = new HttpContextWrapper();
        }
Beispiel #29
0
        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();
        }
		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);
		}
Beispiel #31
0
        public void Flush()
        {
            _workflowRuntime = null;
            _externalDataExchangeService = null;
            _manualWorkflowSchedulerService = null;
            _fileWorkflowPersistenceService = null;
            _formsWorkflowEventService = null;

            _resourceLocker.ResetInitialization();
        }
Beispiel #32
0
        private WorkflowRuntime InitializeWorkflowRuntime()
        {
            WorkflowRuntime workflowRuntime;

            if (WorkflowRuntimeProviderPluginFacade.HasConfiguration)
            {
                string providerName = WorkflowRuntimeProviderRegistry.DefaultWorkflowRuntimeProviderName;

                workflowRuntime = WorkflowRuntimeProviderPluginFacade.GetWorkflowRuntime(providerName);
            }
            else
            {
                Log.LogVerbose(LogTitle, "Using default workflow runtime");
                workflowRuntime = new WorkflowRuntime();
            }


            _manualWorkflowSchedulerService = new ManualWorkflowSchedulerService(true);
            workflowRuntime.AddService(_manualWorkflowSchedulerService);

            _fileWorkflowPersistenceService = new FileWorkflowPersistenceService(SerializedWorkflowsDirectory);
            workflowRuntime.AddService(_fileWorkflowPersistenceService);

            _externalDataExchangeService = new ExternalDataExchangeService();
            workflowRuntime.AddService(_externalDataExchangeService);


            AddWorkflowLoggingEvents(workflowRuntime);


            workflowRuntime.WorkflowCompleted += (sender, args) =>
            {
                using (ThreadDataManager.EnsureInitialize())
                {
                    OnWorkflowInstanceTerminatedCleanup(args.WorkflowInstance.InstanceId);
                }
            };



            workflowRuntime.WorkflowAborted += (sender, args) =>
            {
                using (ThreadDataManager.EnsureInitialize())
                {
                    OnWorkflowInstanceTerminatedCleanup(args.WorkflowInstance.InstanceId);
                }
            };



            workflowRuntime.WorkflowTerminated += (sender, args) =>
            {
                using (ThreadDataManager.EnsureInitialize())
                {
                    OnWorkflowInstanceTerminatedCleanup(args.WorkflowInstance.InstanceId);
                }

                using (_resourceLocker.Locker)
                {
                    _resourceLocker.Resources.ExceptionFromWorkflow.Add(Thread.CurrentThread.ManagedThreadId, args.Exception);
                }
            };



            workflowRuntime.WorkflowCreated += (sender, args) =>
                SetWorkflowInstanceStatus(args.WorkflowInstance.InstanceId, WorkflowInstanceStatus.Idle, true);

            workflowRuntime.WorkflowIdled += (sender, args) =>
                SetWorkflowInstanceStatus(args.WorkflowInstance.InstanceId, WorkflowInstanceStatus.Idle, false);

            workflowRuntime.WorkflowLoaded += (sender, args) => 
                SetWorkflowInstanceStatus(args.WorkflowInstance.InstanceId, WorkflowInstanceStatus.Idle, true);

            return workflowRuntime;
        }
		public void RemoveNullService ()
		{
			WorkflowRuntime workflow = new WorkflowRuntime ();
			ExternalDataExchangeService data_change = new ExternalDataExchangeService ();
			workflow.AddService (data_change);
			data_change.RemoveService (null);
		}