none
状态机工作流求助!斑竹、大虾帮帮忙! RRS feed

  • 问题

  • 无法为实例 ID“b005771a-806b-4d07-b7a3-68cfcd3d1cec”传递接口类型“WFL_Sign.IEventProcess”上的事件“SignThird”。

    状态机工作流运行到第二步,出现的问题。网上找了找,试了试都不能解决。

    斑竹帮忙解决一下!

    有会的大虾能否指点一二。

     

    2008年12月19日 7:29

答案

  • 需要确保SignThird的时候,是在第二级审批状态。我觉得还是你的工作流并没有跳转到正确的状态,不行你就把代码打个包发给我,我帮你看看,我的邮箱是guxiahui@gmail.com

    2008年12月30日 3:35

全部回复

  • 是不是在工作流外触发了SignThird事件?而这个事件注册到了ExternalDataExchangeService中。当运行到第二个节点的时候触发了这个事件,但是工作流中没有相应的HandleExternalEventActivity。就会产生这样的错误。

    2008年12月22日 7:21
  • 我在网上找了找资料,也这么说。但上一步好用呀。

     

    代码如下:

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    using System.Workflow;
    using System.Workflow.Runtime;
    using System.Workflow.Activities;


    namespace WFL_Sign
    {

        /// <summary>
        /// 事件传递的参数
        /// </summary>
        [Serializable]
        public class EventProcessArgs : ExternalDataEventArgs
        {

            #region 属性

            private bool firstSign;             //一级签字
            private bool secondSign;            //二级签字
            private bool thirdSign;             //三级签字
            private string message;             //消息

            public bool FirstSign               //一级签字属性访问器
            {
                set { firstSign = value; }
                get { return firstSign; }
            }
            public bool SecondSign              //二级签字属性访问器
            {
                set { secondSign = value; }
                get { return secondSign; }
            }
            public bool ThirdSign               //三级签字属性访问器
            {
                set { thirdSign = value; }
                get { return thirdSign; }
            }
            public string Message               //消息属性访问器
            {
                set { message = value; }
                get { return message; }
            }

            #endregion

            /// <summary>
            /// 初始化类对象
            /// </summary>
            public EventProcessArgs(Guid guid) : base(guid) { }
        }

        /// <summary>
        /// 审批接口
        /// </summary>
        [ExternalDataExchange]
        public interface IEventProcess
        {
            event EventHandler<EventProcessArgs> StartProcess;      //启动审批流程
            event EventHandler<EventProcessArgs> SignFirst;         //一级审批
            event EventHandler<EventProcessArgs> SignSecond;        //二级审批
            event EventHandler<EventProcessArgs> SignThird;         //三级审批
        }

        public class EventProcess : IEventProcess
        {

            #region IEventProcess 成员

            public event EventHandler<EventProcessArgs> StartProcess;      //启动审批流程
            public event EventHandler<EventProcessArgs> SignFirst;         //一级审批
            public event EventHandler<EventProcessArgs> SignSecond;        //二级审批
            public event EventHandler<EventProcessArgs> SignThird;         //三级审批

            #endregion

            /// <summary>
            /// 启动审批流程
            /// </summary>
            /// <param name="gid">唯一表识</param>
            /// <param name="pass">是否通过</param>
            /// <param name="firstSign">一级审批</param>
            /// <param name="secondSign">二级审批</param>
            /// <param name="thirdSign">三级审批</param>
            /// <param name="message">消息</param>
            public void RaiseStartProcess(string gid, bool firstSign, bool secondSign, bool thirdSign, string message)
            {
                Guid guid = new Guid(gid);
                EventProcessArgs args = new EventProcessArgs(guid);

                args.FirstSign = firstSign;         //一级审批
                args.SecondSign = secondSign;       //二级审批
                args.ThirdSign = thirdSign;         //三级审批
                args.Message = message;             //消息
                StartProcess(null, args);
            }


            /// <summary>
            /// 一级审批
            /// </summary>
            /// <param name="gid">唯一表识</param>
            /// <param name="firstSign">一级审批</param>
            /// <param name="secondSign">二级审批</param>
            /// <param name="thirdSign">三级审批</param>
            /// <param name="message">消息</param>
            public void RaiseSignFirst(string gid, bool firstSign, bool secondSign, bool thirdSign, string message)
            {
                Guid guid = new Guid(gid);
                EventProcessArgs args = new EventProcessArgs(guid);

                args.FirstSign = firstSign;         //一级审批
                args.SecondSign = secondSign;       //二级审批
                args.ThirdSign = thirdSign;         //三级审批
                args.Message = message;             //消息
                SignFirst(null, args);
            }

            /// <summary>
            /// 二级审批
            /// </summary>
            /// <param name="gid">唯一表识</param>
            /// <param name="firstSign">一级审批</param>
            /// <param name="secondSign">二级审批</param>
            /// <param name="thirdSign">三级审批</param>
            /// <param name="message">消息</param>
            public void RaiseSignSecond(string gid, bool firstSign, bool secondSign, bool thirdSign, string message)
            {
                Guid guid = new Guid(gid);
                EventProcessArgs args = new EventProcessArgs(guid);

                args.FirstSign = firstSign;         //一级审批
                args.SecondSign = secondSign;       //二级审批
                args.ThirdSign = thirdSign;         //三级审批
                args.Message = message;             //消息
                SignSecond(null, args);
            }

            /// <summary>
            /// 三级级审批
            /// </summary>
            /// <param name="gid">唯一表识</param>
            /// <param name="firstSign">一级审批</param>
            /// <param name="secondSign">二级审批</param>
            /// <param name="thirdSign">三级审批</param>
            /// <param name="message">消息</param>
            public void RaiseSignThird(string gid, bool firstSign, bool secondSign, bool thirdSign, string message)
            {
                Guid guid = new Guid(gid);
                EventProcessArgs args = new EventProcessArgs(guid);

                args.FirstSign = firstSign;         //一级审批
                args.SecondSign = secondSign;       //二级审批
                args.ThirdSign = thirdSign;         //三级审批
                args.Message = message;             //消息
                SignThird(null, args);
            }
        }
    }

     

    上几步都好使,调试时“SignThird(null, args);”报错。

    2008年12月23日 2:00
  • 调用代码如下:  

    runtime = new WorkflowRuntime();
                    runtime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(runtime_WorkflowCompleted);
                    runtime.WorkflowCreated += new EventHandler<WorkflowEventArgs>(runtime_WorkflowCreated);
                    runtime.WorkflowIdled += new EventHandler<WorkflowEventArgs>(runtime_WorkflowIdled);
                    runtime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(runtime_WorkflowTerminated);

                    ExternalDataExchangeService changeService = new ExternalDataExchangeService();
                    runtime.AddService(changeService);
                    process = new EventProcess();
                    changeService.AddService(process);
                    runtime.StartRuntime();

                    instance = runtime.CreateWorkflow(typeof(SginWorkFlow));
                    instance.Start();

                    process.RaiseStartProcess(instance.InstanceId.ToString(), false, false, false, "等待一级审批");
                    btn_First.Enabled = true;
                    btn_Second.Enabled = false;
                    btn_GoFirst.Enabled = false;
                    btn_Third.Enabled = false;
                    btn_UnThird.Enabled = false;
                    lbl_Message.Text = "等待一级审批";
                    lbl_Message.ForeColor = Color.Blue;
                    lbl_Message.Font.Size = FontUnit.Smaller;


            /// <summary>
            /// 一级签字
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void btn_First_Click(object sender, EventArgs e)
            {
                process.RaiseSignFirst(instance.InstanceId.ToString(), true, false, false, "等待二级审批");
                btn_First.Enabled = false;
                btn_Second.Enabled = true;
                btn_GoFirst.Enabled = true;
                btn_Third.Enabled = false;
                btn_UnThird.Enabled = false;
                lbl_Message.Text = "等待二级审批";
                lbl_Message.ForeColor = Color.Blue;
            }

            /// <summary>
            /// 二级签字通过
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void btn_Second_Click(object sender, EventArgs e)
            {
                swf.IsPass = true;
                process.RaiseSignSecond(instance.InstanceId.ToString(), true, true, false, "等待三级审批");
                btn_First.Enabled = false;
                btn_Second.Enabled = false;
                btn_GoFirst.Enabled = false;
                btn_Third.Enabled = true;
                btn_UnThird.Enabled = true;
                lbl_Message.Text = "等待三级审批";
                lbl_Message.ForeColor = Color.Blue;
            }

            /// <summary>
            /// 二级签字未通过
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void btn_GoFirst_Click(object sender, EventArgs e)
            {
                swf.IsPass = false;
                process.RaiseSignSecond(instance.InstanceId.ToString(), true, false, false, "二级审批未通过");
                btn_First.Enabled = true;
                btn_Second.Enabled = false;
                btn_GoFirst.Enabled = false;
                btn_Third.Enabled = false;
                btn_UnThird.Enabled = false;
                lbl_Message.Text = "二级审批未通过";
                lbl_Message.ForeColor = Color.Red;
            }

            /// <summary>
            /// 三级签字通过
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void btn_Third_Click(object sender, EventArgs e)
            {
                swf.IsPass = true;
                process.RaiseSignThird(instance.InstanceId.ToString(), true, true, true, "三级审批全部通过通过");
                btn_First.Enabled = false;
                btn_Second.Enabled = false;
                btn_GoFirst.Enabled = false;
                btn_Third.Enabled = false;
                btn_UnThird.Enabled = false;
                lbl_Message.Text = "三级审批全部通过通过";
                lbl_Message.ForeColor = Color.Blue;
            }

            /// <summary>
            /// 三级签字未通过
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void btn_UnThird_Click(object sender, EventArgs e)
            {
                swf.IsPass = false;
                process.RaiseSignThird(instance.InstanceId.ToString(), true, true, false, "三级审批未通过");
                btn_First.Enabled = false;
                btn_Second.Enabled = true;
                btn_GoFirst.Enabled = true;
                btn_Third.Enabled = false;
                btn_UnThird.Enabled = false;
                lbl_Message.Text = "三级审批未通过";
                lbl_Message.ForeColor = Color.Red;
            }

     

    2008年12月23日 2:11
  • 麻烦高人给指点一二。

     

    2008年12月23日 2:14
  • 需要确保SignThird的时候,是在第二级审批状态。我觉得还是你的工作流并没有跳转到正确的状态,不行你就把代码打个包发给我,我帮你看看,我的邮箱是guxiahui@gmail.com

    2008年12月30日 3:35
  • 試下把 類EventProcess 加入 [Serializable] 特性。

    lzsmi
    2009年3月11日 8:00
  • 真是热心啊,赞一个,我也在学WF
    http://www.chinesethnic.com http://www.thispictures.com
    2009年5月15日 12:07