Example #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));
 }
        protected override WorkflowCreationContext OnGetCreationContext(object[] inputs, OperationContext operationContext, Guid instanceId, WorkflowHostingResponseContext responseContext)
        {
            WorkflowCreationContext creationContext = new WorkflowCreationContext();

            creationContext.CreateOnly = true;
            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)
                    {
                        creationContext.WorkflowArguments.Add(pair.Key, pair.Value);
                    }
                }
                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)
                    {
                        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);
        }
Example #4
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()));
        }