Пример #1
0
 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());
     }
 }
Пример #2
0
            WorkflowIdentity Parse()
            {
                if (!ExtractName())
                {
                    return(null);
                }
                if (!ExtractVersion())
                {
                    return(null);
                }
                if (!ExtractPackage())
                {
                    return(null);
                }

                Fx.Assert(!this.name.Contains(";"), "Regex should not have matched semi-colon");
                Fx.Assert(!HasLeadingOrTrailingWhitespace(this.name), "Whitespace should have been stripped");
                Fx.Assert(this.package == null || !HasLeadingOrTrailingWhitespace(this.package), "Whitespace should have been stripped");

                WorkflowIdentity result = new WorkflowIdentity();

                result.name    = this.name;
                result.version = this.version;
                result.package = this.package;
                return(result);
            }
Пример #3
0
            public void Initialize(WorkflowIdentity definitionIdentity, TimeSpan timeout)
            {
                Fx.Assert(this.handle == null, "We are already initialized by now");

                using (new TransactionScope(TransactionScopeOption.Suppress))
                {
                    try
                    {
                        this.CreateTemporaryHandle(null);
                        this.owner           = this.store.Execute(this.temporaryHandle, GetCreateOwnerCommand(definitionIdentity), timeout).InstanceOwner;
                        this.ownerWasCreated = true;
                    }
                    finally
                    {
                        this.FreeTemporaryHandle();
                    }

                    this.handle = this.isTryLoad ? this.store.CreateInstanceHandle(this.owner) : this.store.CreateInstanceHandle(this.owner, this.InstanceId);

                    Thread.MemoryBarrier();
                    if (this.aborted)
                    {
                        this.handle.Free();
                    }
                }
            }
 internal WorkflowApplicationInstance(
     WorkflowApplication.PersistenceManagerBase persistenceManager,
     IDictionary <XName, InstanceValue> values,
     WorkflowIdentity definitionIdentity)
 {
     this.PersistenceManager = persistenceManager;
     this.Values             = values;
     this.DefinitionIdentity = definitionIdentity;
     this.state = (int)State.Initialized;
 }
Пример #5
0
 private static string GetMessage(WorkflowIdentity expectedVersion, WorkflowIdentity actualVersion)
 {
     if (actualVersion == null && expectedVersion != null)
     {
         return(SR.WorkflowIdentityNullStateId(expectedVersion));
     }
     else if (actualVersion != null && expectedVersion == null)
     {
         return(SR.WorkflowIdentityNullHostId(actualVersion));
     }
     else if (!object.Equals(expectedVersion, actualVersion))
     {
         return(SR.WorkflowIdentityStateIdHostIdMismatch(actualVersion, expectedVersion));
     }
     else
     {
         return(null);
     }
 }
Пример #6
0
            public IAsyncResult BeginInitialize(WorkflowIdentity definitionIdentity, TimeSpan timeout, AsyncCallback callback, object state)
            {
                Fx.Assert(this.handle == null, "We are already initialized by now");

                using (new TransactionScope(TransactionScopeOption.Suppress))
                {
                    IAsyncResult result = null;

                    try
                    {
                        this.CreateTemporaryHandle(null);
                        result = this.store.BeginExecute(this.temporaryHandle, GetCreateOwnerCommand(definitionIdentity), timeout, callback, state);
                    }
                    finally
                    {
                        // We've encountered an exception
                        if (result == null)
                        {
                            this.FreeTemporaryHandle();
                        }
                    }
                    return(result);
                }
            }
Пример #7
0
 public VersionMismatchException(string message, WorkflowIdentity expectedVersion, WorkflowIdentity actualVersion, Exception innerException)
     : base(message, innerException)
 {
     this.ExpectedVersion = expectedVersion;
     this.ActualVersion   = actualVersion;
 }
Пример #8
0
 public VersionMismatchException(WorkflowIdentity expectedVersion, WorkflowIdentity actualVersion)
     : base(GetMessage(expectedVersion, actualVersion))
 {
     this.ExpectedVersion = expectedVersion;
     this.ActualVersion   = actualVersion;
 }