当前位置:编程学习 > C#/ASP.NET >>

急,WF工作流问题三天没有找到问题

启动一新的流程使流程转到新的一个流程点(状态机工作流),再启动一个新的流程无法往下执行也是再开始处不动,但是我关了全部的ie启动新的流程就可以,但如果要启动新的流程还是不行。代码如下;

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Workflow.Activities;
using System.Workflow.ComponentModel;
using System.Workflow.Runtime;
using System.Collections.Generic;
using System.Workflow.Runtime.Hosting;
using System.Workflow;
using System.Data.SqlClient;

namespace webtest
{
    public partial class _Default : System.Web.UI.Page
    {
        /// <summary>
        /// 定义工作流引擎对象,加载各种服务类、工作流实例或者创建工作流实例
        /// </summary>
        private static WorkflowRuntime workflowRuntime =default(WorkflowRuntime);
        /// <summary>
        /// 定义Charge服务类,用来和工作流实例通讯
        /// </summary>
        ExtendServiceInstance.Charge chargeService =default( ExtendServiceInstance.Charge);

        /// <summary>
        /// 定义工作流实例
        /// </summary>
        private static WorkflowInstance instance = default(WorkflowInstance);
        /// <summary>
        /// 定义扩展服务对象用来加载Charge服务类,并被工作流引擎加载
        /// </summary>
        private static ExternalDataExchangeService dataExchangeService = default(ExternalDataExchangeService);
        /// <summary>
        /// 定义持久化服务

        private static WorkflowPersistenceService persistenceService = default(WorkflowPersistenceService);
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            if (workflowRuntime == null)
                workflowRuntime = new WorkflowRuntime();
            if (chargeService == null)
                chargeService = new ExtendServiceInstance.Charge();
            
                if (persistenceService == null)
                    // 实例化SqlWorkflowPersistenceService
                    persistenceService =
                                new SqlWorkflowPersistenceService(
                                "Data Source=localhost;Initial Catalog=gzl;Integrated Security=SSPI;",
                                false,
                                new TimeSpan(1, 0, 0),
                                new TimeSpan(0, 0, 5));

                if (workflowRuntime.GetService(persistenceService.GetType()) == null)

                    // 绑定服务
                    workflowRuntime.AddService(persistenceService);

                workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
                workflowRuntime.WorkflowIdled += OnWorkflowIdled;
                workflowRuntime.WorkflowPersisted += OnWorkflowPersisted;
                workflowRuntime.WorkflowUnloaded += OnWorkflowUnloaded;
                workflowRuntime.WorkflowLoaded += OnWorkflowLoaded;
                workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
                workflowRuntime.WorkflowAborted += OnWorkflowAborted;

                dataExchangeService = new ExternalDataExchangeService();
                if (workflowRuntime.GetService(dataExchangeService.GetType()) == null)
                {
                    workflowRuntime.AddService(dataExchangeService);
                    if (dataExchangeService.GetService(chargeService.GetType()) == null)
                        dataExchangeService.AddService(chargeService);
                }


                workflowRuntime.StartRuntime();
                Dictionary<string, object> parameters = new Dictionary<string, object>();

                parameters.Add("MoneyMax", TextBoxMax.Text.ToString());



                instance = workflowRuntime.CreateWorkflow(typeof(work.Workflow1), parameters);

                instance.Start();
                chargeService.RaiseOnInitStart(instance.InstanceId);
                Response.Write(instance.InstanceId.ToString());


         

        }
        private void OnWorkflowTerminated(object sender, WorkflowTerminatedEventArgs e)
        {

        }

        private void OnWorkflowLoaded(object sender, WorkflowEventArgs e)
        {

        }

        private void OnWorkflowUnloaded(object sender, WorkflowEventArgs e)
        {
        }

        private void OnWorkflowPersisted(object sender, WorkflowEventArgs e)
        {
        }

        private void OnWorkflowIdled(object sender, WorkflowEventArgs e)
        {
            // 调用SqlWorkflowPersistenceService进行持久化
            e.WorkflowInstance.TryUnload();
        }

        private void OnWorkflowCompleted(object sender, WorkflowCompletedEventArgs instance)
        {

        }

        private void OnWorkflowAborted(object sender, WorkflowEventArgs e)
        {
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            

            //instance = workflowRuntime.GetWorkflow(new Guid("00F391B9-6C8E-451E-BCAD-E60648ED38E2");
            //if (instance != null)
            //{
            //    instance.Load();
            //    HiddenWorkflowState.Value = (new StateMachineWorkflowInstance(workflowRuntime, instance.InstanceId)).CurrentStateName;
            //}
            //if (workflowRuntime == null)
            //    workflowRuntime = new WorkflowRuntime();
            //if (chargeService == null)
            //    chargeService = new ExtendServiceInstance.Charge();

            //chargeService.RaiseOnBossStart(id);
        }
    }
}

--------------------编程问答-------------------- up --------------------编程问答-------------------- 为十分顶一下吧 --------------------编程问答--------------------                             UPUPUPUPUP --------------------编程问答-------------------- 友情顶贴 --------------------编程问答-------------------- 我也刚接触!学习! --------------------编程问答-------------------- 2008年得帖子?? --------------------编程问答-------------------- 有难度,up
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,