private static InstancePersistenceCommand GetCreateOwnerCommand(WorkflowIdentity definitionIdentity) { // Technically, we only need to pass the owner identity when doing LoadRunnable. // However, if we create an instance with identity on a store that doesn't recognize // it, the identity metadata might be stored in a way which makes it unqueryable if // the store is later upgraded to support identity (e.g. SWIS 4.0 -> 4.5 upgrade). // So to be on the safe side, if we're using identity, we require the store to // explicitly support it. if (definitionIdentity != null) { var result = new CreateWorkflowOwnerWithIdentityCommand(); if (!object.ReferenceEquals(definitionIdentity, WorkflowApplication.unknownIdentity)) { result.InstanceOwnerMetadata.Add(Workflow45Namespace.DefinitionIdentities, new InstanceValue(new Collection <WorkflowIdentity> { definitionIdentity })); } return(result); } else { return(new CreateWorkflowOwnerCommand()); } }
private static InstanceOwner CreateWorkflowInstanceOwner(InstanceStore store, InstanceHandle handle) { var command = new CreateWorkflowOwnerWithIdentityCommand { InstanceOwnerMetadata = { { WorkflowHostTypePropertyName, new InstanceValue(WorkflowHostType) }, { DefinitionIdentityFilterPropertyName, new InstanceValue(WorkflowIdentityFilter.Any) }, { DefinitionIdentitiesPropertyName, new InstanceValue(new Collection <WorkflowIdentity>()) }, }, }; var owner = store.Execute(handle, command, TimeSpan.FromMinutes(1.0)).InstanceOwner; return(owner); }
private bool CreateWorkflowOwnerWithIdentity(InstancePersistenceContext context, CreateWorkflowOwnerWithIdentityCommand command) { Guid instanceOwnerId = Guid.NewGuid(); context.BindInstanceOwner(instanceOwnerId, instanceOwnerId); context.BindEvent(HasRunnableWorkflowEvent.Value); return(true); }