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 WorkflowCreationContext OnGetCreationContext(object[] inputs, OperationContext operationContext, Guid instanceId, WorkflowHostingResponseContext responseContext) { if(!operationContext.IncomingMessageHeaders.Action.EndsWith("Ask")) { throw new InvalidOperationException(); } EnterpriseWorkflowCreationContext workflowCreationContext = new EnterpriseWorkflowCreationContext(); string question = inputs[0] as string; string email = inputs[1] as string; workflowCreationContext.WorkflowArguments.Add("Question", question); workflowCreationContext.Email = email; responseContext.SendResponse(instanceId, null); return workflowCreationContext; }
/// <summary> /// Override to create a new<see cref="T:System.ServiceModel.Activities.WorkflowCreationContext" /> instance. /// </summary> /// <param name="inputs">The inputs to the service operation.</param> /// <param name="operationContext">Provides the execution context of the service operation invoked.</param> /// <param name="instanceId">The instance ID of the workflow instance being created.</param> /// <param name="responseContext">The <see cref="T:System.ServiceModel.Activities.WorkflowHostingEndpointResponseContext" /> object that can be used to send replies back to the message source for a request/reply contract.</param> /// <returns>A workflow creation context object.</returns> /// <exception cref="InvalidOperationException">Invalid Action: + operationContext.IncomingMessageHeaders.Action</exception> protected override WorkflowCreationContext OnGetCreationContext(object[] inputs, OperationContext operationContext, Guid instanceId, WorkflowHostingResponseContext responseContext) { var creationContext = new WorkflowCreationContext(); var action = operationContext.IncomingMessageHeaders.Action; if (action.EndsWith("Create")) { PopulateContextArguments(inputs, creationContext); responseContext.SendResponse(instanceId, null); } else if (action.EndsWith("CreateWithInstanceId")) { PopulateContextArguments(inputs, creationContext); } else { throw new InvalidOperationException("Invalid Action: " + action); } return creationContext; }