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);
                    }
                }
            }

  • 相关阅读:
    Unity5和WebGL移植指南的一些总结
    Unite洛杉矶峰会精彩回顾:从图形、平台再到VR
    比代码更重要的是团队管理
    初期游戏编程的9大法则
    关于Unity3D手机网游开发一些小看法
    守住真我
    学习要讲方法
    学习笔记|编程风格
    随便记
    微信方法
  • 原文地址:https://www.cnblogs.com/AeroJin/p/2009170.html
Copyright © 2011-2022 走看看