protected override IAsyncResult BeginTryCommand(InstancePersistenceContext context, InstancePersistenceCommand command, TimeSpan timeout, AsyncCallback callback, object state)
        {
            if(context == null) throw new ArgumentNullException("context");
            if(command == null) throw new ArgumentNullException("command");

            // Log which commands we are receiving
            Debug.WriteLine("InstanceStore::BeginTryCommand::{0} received", command.GetType().Name);

            IAsyncResult result = null;  
            
            // validate the store lock
                      
            if (command is CreateWorkflowOwnerCommand)
            {
                result = CreateWorkflowOwner(context, (CreateWorkflowOwnerCommand) command, timeout, callback, state);
            }
                        
            if (result == null)
            {
                // Log which commands we are not handling
                Debug.WriteLine("InstanceStore::BeginTryCommand::{0} was not implemented", command.GetType().Name);

                // The base.BeginTryCommand will return a false (unhandled) return value
                return base.BeginTryCommand(context, command, timeout, callback, state);
            }
            return result;
        }
예제 #2
0
        protected override IAsyncResult BeginTryCommand(
            InstancePersistenceContext context,
            InstancePersistenceCommand command,
            TimeSpan timeout, AsyncCallback callback, object state)
        {

            switch(command.GetType().Name)
            {
                case "CreateWorkflowOwnerCommand":

                    Func<Exception> createFunc = () => ProcessCreateWorkflowOwner(context,
                                                                                  command as CreateWorkflowOwnerCommand);

                    return createFunc.BeginInvoke(ar =>
                        {
                            Exception ex = createFunc.EndInvoke(ar);
                            callback(new InstanceStoreAsyncResult(ar, ex));
                        }, state);

                case "LoadWorkflowCommand":
                    Func<Exception> loadFunc = () => ProcessLoadWorkflow(context,
                                                                         command as LoadWorkflowCommand);

                    return loadFunc.BeginInvoke(ar =>
                        {
                            Exception ex = loadFunc.EndInvoke(ar);
                            callback(new InstanceStoreAsyncResult(ar, ex));
                        }, state);

                case "LoadWorkflowByInstanceKeyCommand":
                    Func<Exception> loadByKeyFunc = () => ProcessLoadWorkflowByInstanceKey(context,
                                                                                           command as LoadWorkflowByInstanceKeyCommand);

                    return loadByKeyFunc.BeginInvoke(ar =>
                        {
                            Exception ex = loadByKeyFunc.EndInvoke(ar);
                            callback(new InstanceStoreAsyncResult(ar, ex));
                        }, state);

                case "SaveWorkflowCommand":
                    Func<Exception> saveFunc = () => ProcessSaveWorkflow(context,
                                                                         command as SaveWorkflowCommand);

                    return saveFunc.BeginInvoke(ar =>
                        {
                            Exception ex = saveFunc.EndInvoke(ar);
                            callback(new InstanceStoreAsyncResult(ar, ex));
                        }, state);

                default:
                    return base.BeginTryCommand(
                        context, command, timeout, callback, state);
            }


        }