WorkflowApplication app = new WorkflowApplication(new InsuredMemberWorkFlow.CreatePatient());
AutoResetEvent instanceUnloaded = new AutoResetEvent(false);
//setup persistence
// InstanceStore store = new SqlWorkflowInstanceStore(@"Data Source=.;Initial Catalog=workflowDB;User ID=sa;Password=$a");
InstanceStore store =
new SqlWorkflowInstanceStore(ConfigurationManager.ConnectionStrings["workflowDB"].ConnectionString);
InstanceHandle handle = store.CreateInstanceHandle();
var deleteOwnerCmd = new DeleteWorkflowOwnerCommand();
handle.Free();
app.InstanceStore = store;
app.PersistableIdle = (e) =>
{
return PersistableIdleAction.Unload;
};
app.Idle = (e) =>
{
instanceUnloaded.Set();
};
app.Unloaded = (e) =>
{
instanceUnloaded.Set();
};
app.Completed = (e) =>
{
// ShowHideButtons();
};
//Tracking Code
var fileTrackingProfile = new TrackingProfile();
fileTrackingProfile.Queries.Add(new WorkflowInstanceQuery
{
States = { "*" }
});
fileTrackingProfile.Queries.Add(new ActivityStateQuery()
{
ActivityName = "*",
States = { "*" },
Variables = { "*" }
});
fileTrackingProfile.Queries.Add(new CustomTrackingQuery()
{
ActivityName = "*",
Name = "*"
});
var fileTrackingParticipant = new FileTrackingParticipant { TrackingProfile = fileTrackingProfile };
app.Extensions.Add(fileTrackingParticipant);
//---End Tracking code
if (objPatient.WorkFlowId == Guid.Empty)
{
id = app.Id;
// Run the workflow.
app.Run();
objPatient.WorkFlowId = app.Id;
app.ResumeBookmark("SubmitClaimBookmark", objPatient);
Session["Action"] = "SC";
}
else if (objPatient.WorkFlowId != null)
{
app.Load(objPatient.WorkFlowId);
if (objPatient.NextAction == "Submit Claim")
{
app.ResumeBookmark("SubmitClaimBookmark", objPatient);
Session["Action"] = "SC";
}
else if (objPatient.NextAction == "Verify Claim")
{
app.ResumeBookmark("VerifyClaimBookmark", objPatient);
Session["Action"] = "VC";
}