static void UpdateKeyData(InstancePersistenceContext context, SaveWorkflowCommand saveWorkflowCommand) { InstanceView instanceView = context.InstanceView; foreach (KeyValuePair<Guid, IDictionary<XName, InstanceValue>> keyEntry in saveWorkflowCommand.InstanceKeysToAssociate) { if (!instanceView.InstanceKeys.ContainsKey(keyEntry.Key)) { context.AssociatedInstanceKey(keyEntry.Key); if (keyEntry.Value != null) { foreach (KeyValuePair<XName, InstanceValue> property in keyEntry.Value) { context.WroteInstanceKeyMetadataValue(keyEntry.Key, property.Key, property.Value); } } } } foreach (Guid key in saveWorkflowCommand.InstanceKeysToComplete) { InstanceKeyView existingKeyView; if (instanceView.InstanceKeys.TryGetValue(key, out existingKeyView)) { if (existingKeyView.InstanceKeyState != InstanceKeyState.Completed) { context.CompletedInstanceKey(key); } } } foreach (Guid key in saveWorkflowCommand.InstanceKeysToFree) { InstanceKeyView existingKeyView; if (instanceView.InstanceKeys.TryGetValue(key, out existingKeyView)) { context.UnassociatedInstanceKey(key); } } foreach (KeyValuePair<Guid, IDictionary<XName, InstanceValue>> keyEntry in saveWorkflowCommand.InstanceKeyMetadataChanges) { if (keyEntry.Value != null) { foreach (KeyValuePair<XName, InstanceValue> property in keyEntry.Value) { context.WroteInstanceKeyMetadataValue(keyEntry.Key, property.Key, property.Value); } } } if (saveWorkflowCommand.CompleteInstance) { foreach (KeyValuePair<Guid, InstanceKeyView> instanceKeys in instanceView.InstanceKeys) { if (instanceKeys.Value != null) { if (instanceKeys.Value.InstanceKeyState == InstanceKeyState.Associated) { context.CompletedInstanceKey(instanceKeys.Key); } } } } }
private static void UpdateKeyData(InstancePersistenceContext context, SaveWorkflowCommand saveWorkflowCommand) { InstanceView instanceView = context.InstanceView; foreach (KeyValuePair<Guid, IDictionary<XName, InstanceValue>> pair in saveWorkflowCommand.InstanceKeysToAssociate) { if (!instanceView.InstanceKeys.ContainsKey(pair.Key)) { context.AssociatedInstanceKey(pair.Key); if (pair.Value != null) { foreach (KeyValuePair<XName, InstanceValue> pair2 in pair.Value) { context.WroteInstanceKeyMetadataValue(pair.Key, pair2.Key, pair2.Value); } } } } foreach (Guid guid in saveWorkflowCommand.InstanceKeysToComplete) { InstanceKeyView view2; if (instanceView.InstanceKeys.TryGetValue(guid, out view2) && (view2.InstanceKeyState != InstanceKeyState.Completed)) { context.CompletedInstanceKey(guid); } } foreach (Guid guid2 in saveWorkflowCommand.InstanceKeysToFree) { InstanceKeyView view3; if (instanceView.InstanceKeys.TryGetValue(guid2, out view3)) { context.UnassociatedInstanceKey(guid2); } } foreach (KeyValuePair<Guid, IDictionary<XName, InstanceValue>> pair3 in saveWorkflowCommand.InstanceKeyMetadataChanges) { if (pair3.Value != null) { foreach (KeyValuePair<XName, InstanceValue> pair4 in pair3.Value) { context.WroteInstanceKeyMetadataValue(pair3.Key, pair4.Key, pair4.Value); } } } if (saveWorkflowCommand.CompleteInstance) { foreach (KeyValuePair<Guid, InstanceKeyView> pair5 in instanceView.InstanceKeys) { if ((pair5.Value != null) && (pair5.Value.InstanceKeyState == InstanceKeyState.Associated)) { context.CompletedInstanceKey(pair5.Key); } } } }