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);
}
}
}
------解决方案--------------------
防止回发做了吗?
------解决方案--------------------
多用户审批一个项目。
可否点击一次后 禁用掉按钮 一直到审批过后 才启用。