Exemple #1
0
 // <Snippet0>
 protected override IAsyncResult OnBeginWorkflowCompleted(ActivityInstanceState completionState, IDictionary <string, object> workflowOutputs,
                                                          Exception faultedReason, TimeSpan timeout, AsyncCallback callback, object state)
 {
     if (completionState == ActivityInstanceState.Faulted)
     {
         Console.WriteLine("InstanceId :" + InstanceId + " OnBeginWorkflowTerminated");
     }
     else if (completionState == ActivityInstanceState.Canceled)
     {
         Console.WriteLine("InstanceId :" + InstanceId + " OnBeginWorkflowCanceled");
     }
     else
     {
         Console.WriteLine("InstanceId :" + InstanceId + " OnBeginWorkflowCompleted");
         WorkflowHostingResponseContext responseContext = UserState as WorkflowHostingResponseContext;
         if (responseContext != null)
         {
             foreach (object value in workflowOutputs.Values)
             {
                 responseContext.SendResponse(value, null);
                 break;
             }
         }
     }
     return(base.OnBeginWorkflowCompleted(completionState, workflowOutputs, faultedReason, timeout, callback, state));
 }
 public WorkflowServiceInstance GetInstance(WorkflowGetInstanceContext parameters)
 {
     if ((this.workflowInstance == null) && (parameters != null))
     {
         lock (base.ThisLock)
         {
             base.ThrowIfDisposedOrNotOpen();
             if (this.workflowInstance == null)
             {
                 try
                 {
                     WorkflowServiceInstance instance;
                     if (parameters.WorkflowHostingEndpoint != null)
                     {
                         WorkflowHostingResponseContext responseContext = new WorkflowHostingResponseContext();
                         WorkflowCreationContext        creationContext = parameters.WorkflowHostingEndpoint.OnGetCreationContext(parameters.Inputs, parameters.OperationContext, this.InstanceId, responseContext);
                         if (creationContext == null)
                         {
                             throw System.ServiceModel.Activities.FxTrace.Exception.AsError(WorkflowHostingEndpoint.CreateDispatchFaultException());
                         }
                         instance = this.directory.InitializeInstance(this.InstanceId, this, null, creationContext);
                         parameters.WorkflowCreationContext        = creationContext;
                         parameters.WorkflowHostingResponseContext = responseContext;
                     }
                     else
                     {
                         instance = this.directory.InitializeInstance(this.InstanceId, this, null, null);
                     }
                     this.workflowInstance = instance;
                 }
                 finally
                 {
                     if (this.workflowInstance == null)
                     {
                         base.Fault();
                     }
                 }
             }
         }
     }
     return(this.workflowInstance);
 }
Exemple #3
0
        protected override WorkflowCreationContext OnGetCreationContext(object[] inputs, OperationContext operationContext, Guid instanceId, WorkflowHostingResponseContext responseContext)
        {
            WorkflowCreationContext creationContext = new WorkflowCreationContext();

            if (operationContext.IncomingMessageHeaders.Action.EndsWith("Create"))
            {
                Dictionary <string, object> arguments = (Dictionary <string, object>)inputs[0];
                if (arguments != null && arguments.Count > 0)
                {
                    foreach (KeyValuePair <string, object> pair in arguments)
                    {
                        //arguments to pass to the workflow
                        creationContext.WorkflowArguments.Add(pair.Key, pair.Value);
                    }
                }
                //reply to client with instanceId
                responseContext.SendResponse(instanceId, null);
            }
            else if (operationContext.IncomingMessageHeaders.Action.EndsWith("CreateWithInstanceId"))
            {
                Dictionary <string, object> arguments = (Dictionary <string, object>)inputs[0];
                if (arguments != null && arguments.Count > 0)
                {
                    foreach (KeyValuePair <string, object> pair in arguments)
                    {
                        //arguments to pass to workflow
                        creationContext.WorkflowArguments.Add(pair.Key, pair.Value);
                    }
                }
            }
            else
            {
                throw new InvalidOperationException("Invalid Action: " + operationContext.IncomingMessageHeaders.Action);
            }
            return(creationContext);
        }
        protected override System.Activities.Bookmark OnResolveBookmark(object[] inputs, OperationContext operationContext, WorkflowHostingResponseContext responseContext, out object value)
        {
            Bookmark bookmark = null;

            value = null;
            if (operationContext.IncomingMessageHeaders.Action.EndsWith("ResumeBookmark"))
            {
                //bookmark name supplied by client as input to IWorkflowCreation.ResumeBookmark
                bookmark = new Bookmark((string)inputs[1]);
                //value supplied by client as argument to IWorkflowCreation.ResumeBookmark
                value = (string)inputs[2];

                responseContext.SendResponse(null, null);//Not OneWay anymore.
            }
            else
            {
                //  throw new NotImplementedException(operationContext.IncomingMessageHeaders.Action);
                responseContext.SendResponse(typeof(void), null);
            }
            return(bookmark);
        }
Exemple #5
0
        // <Snippet0>
        protected override Bookmark OnResolveBookmark(object[] inputs, OperationContext operationContext, WorkflowHostingResponseContext responseContext, out object value)
        {
            Bookmark bookmark = null;

            value = null;
            if (operationContext.IncomingMessageHeaders.Action.EndsWith("ResumeBookmark"))
            {
                //bookmark name supplied by client as input to IWorkflowCreation.ResumeBookmark
                bookmark = new Bookmark((string)inputs[1]);
                //value supplied by client as argument to IWorkflowCreation.ResumezBookmark
                value = (string)inputs[2];
            }
            else
            {
                throw new NotImplementedException(operationContext.IncomingMessageHeaders.Action);
            }
            return(bookmark);
        }
Exemple #6
0
        protected override Bookmark OnResolveBookmark(object[] inputs, OperationContext operationContext, WorkflowHostingResponseContext responseContext, out object value)
        {
            Fx.Assert(operationContext.IncomingMessageHeaders.Action == RaiseEventAction, "Message action is not RaiseEvent");

            Fx.Assert(inputs.Length >= 3, "Insufficient number of inputs");

            Fx.Assert(inputs[1] is IComparable, "The queue name from ExternalDataExchangeService is not an IComparable object");
            IComparable queueName = (IComparable)inputs[1];

            value = inputs[2];
            responseContext.SendResponse(null, null);
            return(new Bookmark(queueName.ToString()));
        }