本文介绍了卸载和加载工作流实例后无法调用事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我是工作流程的新手.我创建了一个新的工作流程,并在单击按钮事件后将其卸载,并在触发另一个按钮后加载了该事件.但是在这里,我无法从一种状态转移到另一种状态.这是我的代码:
Hi Everybody,
I am new to workflows. I am created a new workflow and i unloaded it after a button click event and I am loading the event after firing another button. But here I am not able to move from one state to other state. Here my code is:
protected void SendData_Click(object sender, EventArgs e)
{
Guid state_ID = Guid.NewGuid();
Dictionary<string,> Params = new Dictionary<string,>();
WorkflowInstance instance = null;
StateMachineWorkflowInstance ins = null;
SqlWorkflowPersistenceService sqlPersistenceService = new SqlWorkflowPersistenceService(ConfigurationManager.ConnectionStrings["PersistenceConnectionString"].ToString());
WorkFlowDemo.states.state state = new WorkFlowDemo.states.state();
ExternalDataExchangeService ExDateExchService = new ExternalDataExchangeService();
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
workflowRuntime.AddService(sqlPersistenceService);
workflowRuntime.AddService(ExDateExchService);
//workflowRuntime.InstanceStore = store;
ExDateExchService.AddService(state);
instance =
workflowRuntime.CreateWorkflow(typeof(Workflow1), Params, state_ID);
Session["state_ID"] = state_ID;
instance.Start();
ins = new StateMachineWorkflowInstance(workflowRuntime, state_ID);
state.SubmitContent(state_ID);
if (ins.CurrentStateName == "Submitted")
{
SendData.Visible = false;
Approve.Visible = true;
Reject.Visible = true;
Incomplete.Visible = true;
Cancel.Visible = true;
}
instance.Unload();
}
protected void Approve_Click(object sender, EventArgs e)
{
Guid state_ID = Guid.NewGuid();
Dictionary<string,> Params = new Dictionary<string,>();
WorkflowInstance instance = null;
StateMachineWorkflowInstance ins = null;
SqlWorkflowPersistenceService sqlPersistenceService = new SqlWorkflowPersistenceService(ConfigurationManager.ConnectionStrings["PersistenceConnectionString"].ToString());
//WorkFlowDemo.states.state state = new WorkFlowDemo.states.state();
//ExternalDataExchangeService ExDateExchService = new ExternalDataExchangeService();
//WorkflowRuntime workflowRuntime = new WorkflowRuntime();
//workflowRuntime.AddService(sqlPersistenceService);
//workflowRuntime.AddService(ExDateExchService);
////workflowRuntime.InstanceStore = store;
//ExDateExchService.AddService(state);
//instance =
// workflowRuntime.CreateWorkflow(typeof(Workflow1), Params, state_ID);
WorkFlowDemo.states.state state = new WorkFlowDemo.states.state();
ExternalDataExchangeService ExDateExchService = new ExternalDataExchangeService();
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
workflowRuntime.AddService(sqlPersistenceService);
workflowRuntime.AddService(ExDateExchService);
Guid workflowId = new Guid(Session["state_ID"].ToString());
//workflowRuntime.CurrentWorkflowInstanceID = workflowId;
workflowRuntime.StartRuntime();
if (workflowRuntime.IsStarted)
{
instance = workflowRuntime.GetWorkflow(workflowId);
}
instance.Load();
//instance.ReloadTrackingProfiles();
//workflowRuntime.AddService(ExDateExchService);
state.Approved(state_ID);
ins = new StateMachineWorkflowInstance(workflowRuntime, state_ID);
if (ins.CurrentStateName == "Complete")
{
Data.Visible = true;
Data.InnerText = "Approved";
ContentTextBox.Visible = false;
SendData.Visible = false;
Approve.Visible = false;
Reject.Visible = false;
Incomplete.Visible = false;
Cancel.Visible = false;
if (workflowRuntime != null)
{
workflowRuntime.StopRuntime();
workflowRuntime.Dispose();
}
}
}
这里的事件是
Here events are
namespace WorkFlowDemo
{
public class states
{
[Serializable]
public class state: Istates,ISendDataService
{
private string getassigneddata;
public event EventHandler<System.Workflow.Activities.ExternalDataEventArgs> submitted;
public event EventHandler<System.Workflow.Activities.ExternalDataEventArgs> approved;
public event EventHandler<System.Workflow.Activities.ExternalDataEventArgs> rejected;
public event EventHandler<System.Workflow.Activities.ExternalDataEventArgs> completed;
public event EventHandler<ReceivedDataEventArgs> ReceivedDataEvent;
public void SubmitContent(Guid instanceID)
{
if (this.submitted != null)
{
this.submitted(this, new System.Workflow.Activities.ExternalDataEventArgs(instanceID));
}
}
public void Rejected(Guid instanceID)
{
if (this.rejected != null)
{
this.rejected(this, new System.Workflow.Activities.ExternalDataEventArgs(instanceID));
}
}
public void Approved(Guid instanceID)
{
if (this.approved != null)
this.approved(this, new System.Workflow.Activities.ExternalDataEventArgs(instanceID));
}
}
}
}
加载工作流程后,任何人都可以告诉我如何从一种状态转换为另一种状态吗?
Can any body tell how can i move from one state to other state after loading the work flow
推荐答案
这篇关于卸载和加载工作流实例后无法调用事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!