private Exception ProcessSaveWorkflow(
InstancePersistenceContext context,
SaveWorkflowCommand command)
{
try
{
if(command.CompleteInstance)
{
_dataStore.DeleteInstance(
context.InstanceView.InstanceId);
_dataStore.DeleteInstanceAssociation(
context.InstanceView.InstanceId);
return null;
}
if(command.InstanceData.Count > 0 ||
command.InstanceMetadataChanges.Count > 0)
{
if(!_dataStore.SaveAllInstanceData(
context.InstanceView.InstanceId, command))
{
_dataStore.SaveAllInstanceMetaData(
context.InstanceView.InstanceId, command);
}
}
if(command.InstanceKeysToAssociate.Count > 0)
{
foreach(var entry in command.InstanceKeysToAssociate)
{
_dataStore.SaveInstanceAssociation(
context.InstanceView.InstanceId, entry.Key, false);
}
}
return null;
}
catch(InstancePersistenceException exception)
{
Console.WriteLine(
// ReSharper disable LocalizableElement
"ProcessSaveWorkflow exception: {0}", exception.Message);
// ReSharper restore LocalizableElement
return exception;
}
}