zoukankan      html  css  js  c++  java
  • WF 多次提交问题

    公司做了个审批的WF,现在遇到个问题,每当审批用户点击按钮两次那么工作流就被执行了两次,即使我们做了很多限制用户连续点击按钮,但是当多用户同时访问时,用户单击按钮N久后WF才提交,但是在等待的这个过程中,用户又一次打开当前这个链接,又单击了审批这个按钮,那么这种情况工作流就被重复执行了,网上看了好多资料都没提到这块,在此请教各位哪位大虾了.

    下面是我工作流执行代码:

    这段代码是写在Application里面的

    protected static string connectionString = ConfigurationManager.ConnectionStrings["CHAS.REPAIR"].ConnectionString;
            protected void Application_Start(object sender, EventArgs e)
            {
                WorkflowRuntime workflowRuntime = new WorkflowRuntime();
                SqlTrackingService sqlTs = new SqlTrackingService(connectionString);

                SqlWorkflowPersistenceService persistService = new SqlWorkflowPersistenceService(connectionString);

                workflowRuntime.AddService(sqlTs);
                workflowRuntime.AddService(persistService);

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

                dataServer.AddService(new CHAS.REPAIR.BLL.InterFace.RepairHandler());

                workflowRuntime.StartRuntime();
                Application.Add("WorkflowRuntime", workflowRuntime);
            }

    下面这段代码就是按钮单击所执行的代码了

    private void RunWorkFlow(RepairFlows rf)
            {
               
                WorkflowRuntime wr = this.Application["WorkflowRuntime"] as WorkflowRuntime;

                //關聯workflw業務類
                ExternalDataExchangeService dataService = wr.GetService(typeof(ExternalDataExchangeService)) as ExternalDataExchangeService;
                RepairHandler wfRepair = dataService.GetService(typeof(RepairHandler)) as RepairHandler;
                wfRepair.UpRepair += new EventHandler<UpRepairEventArgs>(UpRepairEventArgs);
                WorkflowInstance instance = wr.GetWorkflow(rf.WorkFlowGuid);
                instance.Load();
                wfRepair.RepairEvent(rf.WorkFlowGuid, rf);
                if (rf.ApprovalResults == 1)
                {
                    while (!instance.TryUnload())
                    {
                        System.Threading.Thread.Sleep(500);
                    }
                }
            }

  • 相关阅读:
    🍖名称空间与作用域
    🍖文件打开模式 "t"
    🍖函数参数
    【转】LINQ中的Aggregate语法
    【转】c#中string.trimstart() 和string.trimend() 的用法
    1094 和为k的连续区间(暴力)
    1095 Anigram单词
    1031 骨牌覆盖 (斐波拉契数列)
    最长公共子序列(模板 LCSL)
    1092 回文字符串(LCSL_DP)
  • 原文地址:https://www.cnblogs.com/AeroJin/p/2009170.html
Copyright © 2011-2022 走看看