Click here to Skip to main content
15,888,065 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Folks,

I am working in Windows Workflow Foundation 4.5.I need some pointers in Persistence and tracking concepts.

I can able to persist the Workflow Application by creating an Instance and saved in Persistence Store [Instances Table ] in SQL Server 2008.


And by passing the Exact GUID to unload the Workflow Instance and load it back to the Application memory.

For the Reference I have created a seperate GUID column in the user input Data Table and the same GUID got stored in the Instances table.So by unloading the particular Instance ID or GUID , the app got loaded back with the Data.

Now if I Switch off the machine with the SQL server with User Input Data table or suppose if the server got crashed , how can we retrieve the Data from the Persistence Store.

Is it possible ? Is the instances table or any table will hold those values in it by any method ? I am not clear with this..

Please help !

Thanks in Advance.
Posted
Updated 3-Oct-13 21:19pm
v5
Comments
Sunasara Imdadhusen 11-Jun-13 1:48am    
Where is your code snippet?
Prasyee 4-Oct-13 3:18am    
public void GenerateInstanceStore(WorkflowApplication WorkApp, Guid id)
{
WFInstStore = new SqlWorkflowInstanceStore(WFInstanceConnStr);
WFInstStore.InstanceCompletionAction = InstanceCompletionAction.DeleteNothing;
try
{
WorkApp.InstanceStore = WFInstStore;
id = WorkApp.Id;
WFHostTypeName = XName.Get("Version" + id.ToString(), typeof(Activity).FullName);
WFInstHandle = CreateInstanceStoreOwnerHandle(WFInstStore, WFHostTypeName);
Dictionary<xname, object=""> wfScope = new Dictionary<xname, object="">
{
{
WorkflowHostTypePropertyName, WFHostTypeName
}
};

WorkApp.AddInitialInstanceValues(wfScope);
WorkApp.Completed = (e) => { completed = true; };
WorkApp.PersistableIdle = (e) => { return PersistableIdleAction.Persist; };
WFapphandle.Set();
WorkApp.Persist();
}
catch (Exception ex)
{
Obj_LogException.MyLogFile(ex.ToString());
}
finally
{
ReleaseObject(Obj_LogException);
ReleaseObject(Obj_LogFile);
ReleaseObject(WFInstStore);
//ReleaseObject(WFHostTypeName);
}
}


for unloading


public void LoadWinAppInstance(WorkflowApplication WinWFApp, Guid Gid)
{
//SqlWorkflowInstanceStore WFLoadInstStore = new SqlWorkflowInstanceStore(ConfigurationManager.AppSettings["PersistenceWorkflow"].ToString());
WFInstStore = new SqlWorkflowInstanceStore(WFInstanceConnStr);
WFInstStore.InstanceCompletionAction = InstanceCompletionAction.DeleteNothing;
try
{
WFHostTypeName = XName.Get("Version" + Gid.ToString(), typeof(Activity).FullName);
WFInstHandle = CreateInstanceStoreOwnerHandle(WFInstStore, WFHostTypeName);
WinWFApp.Completed = (WorkflowCompletedEventArgs) =>
{
completed = true;
};
WinWFApp.Unload();
}
catch (Exception ex)
{
Obj_LogException.MyLogFile(ex.ToString());
}
finally
{
//ReleaseObject(WFHostTypeName);
ReleaseObject(WFInstStore);
//ReleaseObject(WinWFApp);
ReleaseObject(Obj_LogFile);
ReleaseObject(Obj_LogException);
//ReleaseObject(Gid);
}
}
Prasyee 4-Oct-13 3:18am    
public InstanceHandle CreateInstanceStoreOwnerHandle(InstanceStore store, XName WFHostTypeName)
{
InstanceHandle ownerHandle = store.CreateInstanceHandle();
CreateWorkflowOwnerCommand ownerCommand = new CreateWorkflowOwnerCommand()
{
InstanceOwnerMetadata =
{
{
WorkflowHostTypePropertyName, new InstanceValue(WFHostTypeName)
}
}
};
store.DefaultInstanceOwner = store.Execute(ownerHandle, ownerCommand, TimeSpan.FromSeconds(30)).InstanceOwner;
return ownerHandle;
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900