示例#1
0
        static CorrelationQuery CreateCorrelationQueryCore(MessageQuerySet select, Collection <CorrelationInitializer> correlationInitializers)
        {
            CorrelationQuery correlationQuery = null;

            if (select != null)
            {
                Fx.Assert(select.Count != 0, "Empty MessageQuerySet is not allowed!");

                correlationQuery = new CorrelationQuery
                {
                    Select = select
                };
            }

            if (correlationInitializers != null && correlationInitializers.Count > 0)
            {
                foreach (CorrelationInitializer correlation in correlationInitializers)
                {
                    QueryCorrelationInitializer queryCorrelation = correlation as QueryCorrelationInitializer;
                    if (queryCorrelation != null)
                    {
                        Fx.Assert(queryCorrelation.MessageQuerySet.Count != 0, "Empty MessageQuerySet is not allowed!");

                        correlationQuery = correlationQuery ?? new CorrelationQuery();
                        correlationQuery.SelectAdditional.Add(queryCorrelation.MessageQuerySet);
                    }
                }
            }

            return(correlationQuery);
        }
示例#2
0
        // Wrapper code that encapsulates creating a simple message query for the purposes of the sample
        static MessageQuerySet CreateMessageQuerySet(string query)
        {
            XPathMessageQuery xpathQuery = new XPathMessageQuery(query);

            MessageQuerySet mqs = new MessageQuerySet();

            mqs.Add("accountQuery", xpathQuery);

            return(mqs);
        }
        public static CorrelationQuery CreateServerCorrelationQuery(MessageQuerySet select, Collection <CorrelationInitializer> correlationInitializers, OperationDescription operation, bool isResponse)
        {
            CorrelationQuery query = CreateCorrelationQueryCore(select, correlationInitializers);

            if (query != null)
            {
                string str = !isResponse ? operation.Messages[0].Action : operation.Messages[1].Action;
                CorrelationActionMessageFilter filter = new CorrelationActionMessageFilter {
                    Action = str
                };
                query.Where = filter;
            }
            return(query);
        }
示例#4
0
        public static CorrelationQuery CreateServerCorrelationQuery(MessageQuerySet select, Collection <CorrelationInitializer> correlationInitializers,
                                                                    OperationDescription operation, bool isResponse)
        {
            Fx.Assert(operation != null, "Argument cannot be null!");

            CorrelationQuery correlationQuery = CreateCorrelationQueryCore(select, correlationInitializers);

            if (correlationQuery != null)
            {
                string action = !isResponse ? operation.Messages[0].Action : operation.Messages[1].Action;
                correlationQuery.Where = new CorrelationActionMessageFilter {
                    Action = action
                };
            }

            return(correlationQuery);
        }
示例#5
0
        /// <summary>
        /// Generate the correlation hash
        /// </summary>
        /// <returns>MessageQuerySet</returns>
        private MessageQuerySet CreateCorrelationQuery()
        {
            var xpath = new XPathMessageQuery
            {
                Namespaces = new XmlNamespaceManager(new NameTable()),
                Expression = "//sample:WorkflowId"
            };

            xpath.Namespaces.AddNamespace("sample", MessageNamespace);

            var messageQuerySet = new MessageQuerySet
            {
                Name = "RequestCorrelation"
            };

            messageQuerySet.Add("WorkflowId", xpath);

            return(messageQuerySet);
        }
示例#6
0
        private static CorrelationQuery CreateDefaultCorrelationQuery(CorrelationQuery query, string action, CorrelationDataDescription data, ref bool shouldPreserveMessage)
        {
            XPathMessageQuery query5 = new XPathMessageQuery {
                Expression = string.Format(CultureInfo.InvariantCulture, "sm:correlation-data('{0}')", new object[] { data.Name }),
                Namespaces = new XPathMessageContext()
            };
            MessageQuery query2 = query5;

            if (data.IsOptional)
            {
                OptionalMessageQuery query3 = new OptionalMessageQuery {
                    Query = query2
                };
                query2 = query3;
            }
            if (query == null)
            {
                MessageFilter filter;
                bool          flag = data.Name == "wsc-instanceId";
                if (!shouldPreserveMessage && !flag)
                {
                    shouldPreserveMessage = true;
                }
                if (action == "*")
                {
                    filter = new MatchAllMessageFilter();
                }
                else
                {
                    filter = new ActionMessageFilter(new string[] { action });
                }
                CorrelationQuery query4 = new CorrelationQuery {
                    Where = filter,
                    IsDefaultContextQuery = flag
                };
                MessageQuerySet set = new MessageQuerySet();
                set.Add(data.Name, query2);
                query4.Select = set;
                return(query4);
            }
            query.Select[data.Name] = query2;
            return(query);
        }
示例#7
0
        // this method generates the correlationQuery for client side send and receiveReply
        public static Collection <CorrelationQuery> CreateClientCorrelationQueries(MessageQuerySet select, Collection <CorrelationInitializer> correlationInitializers,
                                                                                   string overridingAction, XName serviceContractName, string operationName, bool isResponse)
        {
            Fx.Assert(serviceContractName != null && operationName != null, "Argument cannot be null!");

            Collection <CorrelationQuery> queryCollection = new Collection <CorrelationQuery>();
            CorrelationQuery correlationQuery             = CreateCorrelationQueryCore(select, correlationInitializers);

            if (correlationQuery != null)
            {
                if (overridingAction != null)
                {
                    correlationQuery.Where = new CorrelationActionMessageFilter {
                        Action = overridingAction
                    };
                }
                else
                {
                    ProvideDefaultNamespace(ref serviceContractName);
                    string defaultAction = NamingHelper.GetMessageAction(new XmlQualifiedName(serviceContractName.LocalName, serviceContractName.NamespaceName),
                                                                         operationName, null, isResponse);

                    correlationQuery.Where = new CorrelationActionMessageFilter {
                        Action = defaultAction
                    };
                }

                queryCollection.Add(correlationQuery);

                if (isResponse)
                {
                    // we need an additional query with empty action to support soap1.1 reply cases
                    CorrelationQuery noActionQuery = correlationQuery.Clone();
                    noActionQuery.Where = new CorrelationActionMessageFilter {
                        Action = String.Empty
                    };
                    queryCollection.Add(noActionQuery);
                }
            }

            return(queryCollection);
        }
        public static Collection <CorrelationQuery> CreateClientCorrelationQueries(MessageQuerySet select, Collection <CorrelationInitializer> correlationInitializers, string overridingAction, XName serviceContractName, string operationName, bool isResponse)
        {
            Collection <CorrelationQuery> collection = new Collection <CorrelationQuery>();
            CorrelationQuery item = CreateCorrelationQueryCore(select, correlationInitializers);

            if (item != null)
            {
                if (overridingAction != null)
                {
                    CorrelationActionMessageFilter filter = new CorrelationActionMessageFilter {
                        Action = overridingAction
                    };
                    item.Where = filter;
                }
                else
                {
                    ProvideDefaultNamespace(ref serviceContractName);
                    string str = NamingHelper.GetMessageAction(new XmlQualifiedName(serviceContractName.LocalName, serviceContractName.NamespaceName), operationName, null, isResponse);
                    CorrelationActionMessageFilter filter2 = new CorrelationActionMessageFilter {
                        Action = str
                    };
                    item.Where = filter2;
                }
                collection.Add(item);
                if (isResponse)
                {
                    CorrelationQuery query2 = item.Clone();
                    CorrelationActionMessageFilter filter3 = new CorrelationActionMessageFilter {
                        Action = string.Empty
                    };
                    query2.Where = filter3;
                    collection.Add(query2);
                }
            }
            return(collection);
        }
        private static CorrelationQuery CreateCorrelationQueryCore(MessageQuerySet select, Collection <CorrelationInitializer> correlationInitializers)
        {
            CorrelationQuery query = null;

            if (select != null)
            {
                query = new CorrelationQuery {
                    Select = select
                };
            }
            if ((correlationInitializers != null) && (correlationInitializers.Count > 0))
            {
                foreach (CorrelationInitializer initializer in correlationInitializers)
                {
                    QueryCorrelationInitializer initializer2 = initializer as QueryCorrelationInitializer;
                    if (initializer2 != null)
                    {
                        query = query ?? new CorrelationQuery();
                        query.SelectAdditional.Add(initializer2.MessageQuerySet);
                    }
                }
            }
            return(query);
        }
示例#10
0
        //Define the Workflow
        static Activity ServerWorkflow()
        {
            Variable <string> correlationValue = new Variable <string>()
            {
                Name = "correlationID"
            };
            MessageQuerySet mqs = new MessageQuerySet()
            {
                { "ch", new XPathMessageQuery("//ser:string", new XPathMessageContext()) },
            };

            Receive requestOne = new Receive
            {
                OperationName       = "ScenarioOne",
                ServiceContractName = Constants.ServiceContractName,
                CanCreateInstance   = true,
                CorrelatesOn        = mqs,
            };

            Receive requestTwo = new Receive
            {
                OperationName       = "ScenarioTwo",
                ServiceContractName = Constants.ServiceContractName,
                CanCreateInstance   = false,
                CorrelatesOn        = mqs,
            };

            return(new Sequence
            {
                Variables = { correlationValue },
                Activities =
                {
                    new WriteLine                         {
                        Text = "Begin Server Workflow. Begin Scenario One."
                    },

                    new TransactedReceiveScope
                    {
                        // Flow in transaction
                        Request = requestOne,
                        Body = new Sequence
                        {
                            Activities =
                            {
                                new WriteLine             {
                                    Text = "Begin Scenario One TransactedReceiveScope Body"
                                },

                                new SendReply             {
                                    Request = requestOne
                                },

                                new PrintTxInfo(),

                                // Inner TransactionScope scope joins the existing transaction
                                new TransactionScope
                                {
                                    Body = new Sequence
                                    {
                                        Activities =
                                        {
                                            new WriteLine {
                                                Text = "Begin Scenario One Inner TransactionScope Body"
                                            },

                                            new PrintTxInfo(),

                                            new WriteLine {
                                                Text = "End Scenario One Inner TransactionScope Body"
                                            },
                                        },
                                    },
                                },

                                new PrintTxInfo(),

                                new WriteLine             {
                                    Text = "End Scenario One TransactedReceiveScope Body"
                                },
                            }
                        }
                    },

                    new WriteLine                         {
                        Text = "End Scenario One. Begin Scenario Two."
                    },

                    new TransactedReceiveScope
                    {
                        // Flow in transaction
                        Request = requestTwo,
                        Body = new Sequence
                        {
                            Activities =
                            {
                                new WriteLine             {
                                    Text = "Begin Scenario Two TransactedReceiveScope Body"
                                },

                                new SendReply             {
                                    Request = requestTwo
                                },

                                new PrintTxInfo(),

                                // Inner TransactionScope joins the existing transaction, but it sets a timeout for the work in its scope.
                                // If the timeout expires the entire transaction will be aborted.
                                new TransactionScope
                                {
                                    Timeout = TimeSpan.FromSeconds(2),
                                    Body = new Sequence
                                    {
                                        Activities =
                                        {
                                            new WriteLine {
                                                Text = "Begin Scenario Two Inner TransactionScope Body"
                                            },

                                            new Delay     {
                                                Duration = TimeSpan.FromSeconds(5)
                                            },

                                            new PrintTxInfo(),

                                            new WriteLine {
                                                Text = "End Scenario Two Inner TransactionScope Body"
                                            },
                                        },
                                    }
                                },

                                new PrintTxInfo(),

                                new WriteLine             {
                                    Text = "End Scenario Two TransactedReceiveScope Body"
                                },
                            },
                        },
                    },

                    new WriteLine                         {
                        Text = "End Scenario Two. End Server Workflow\n"
                    },
                },
            });
        }
示例#11
0
        private static Activity GetPropertyWorkflow()
        {
            // Correlation handle used to link operations together
            Variable <CorrelationHandle> operationHandle = new Variable <CorrelationHandle>();

            // The generated property Id
            Variable <Guid> propertyId = new Variable <Guid>();

            // Variable used to indicate that the workflow should finish
            Variable <bool> finished = new Variable <bool>("Finished", false);

            Variable <string> address     = new Variable <string>();
            Variable <string> owner       = new Variable <string>();
            Variable <double> askingPrice = new Variable <double>();

            // Initial receive - this kicks off the workflow
            Receive receive = new Receive
            {
                CanCreateInstance   = true,
                OperationName       = "UploadPropertyInformation",
                ServiceContractName = XName.Get("IProperty", ns),
                Content             = new ReceiveParametersContent
                {
                    Parameters =
                    {
                        { "address",     new OutArgument <string>(address)     },
                        { "owner",       new OutArgument <string>(owner)       },
                        { "askingPrice", new OutArgument <double>(askingPrice) }
                    }
                }
            };

            // Define the local namespace
            XPathMessageContext messageContext = new XPathMessageContext();

            messageContext.AddNamespace("local", ns);

            // Extracts the guid sent back to the client on the initial response
            MessageQuerySet extractGuid = new MessageQuerySet
            {
                { "PropertyId", new XPathMessageQuery("sm:body()/ser:guid", messageContext) }
            };

            // Extracts the guid sent up with the property image
            MessageQuerySet extractGuidFromUploadRoomInformation = new MessageQuerySet
            {
                { "PropertyId", new XPathMessageQuery(@"sm:body()/local:UploadRoomInformation/local:propertyId", messageContext) }
            };

            // Receive used to indicate that the upload is complete
            Receive receiveDetailsComplete = new Receive
            {
                OperationName       = "DetailsComplete",
                ServiceContractName = XName.Get("IProperty", ns),
                CorrelatesWith      = operationHandle,
                CorrelatesOn        = extractGuid,
                Content             = ReceiveContent.Create(new OutArgument <Guid>(propertyId))
            };

            Variable <string> roomName = new Variable <string>();
            Variable <double> width    = new Variable <double>();
            Variable <double> depth    = new Variable <double>();

            // Receive room information
            Receive receiveRoomInfo = new Receive
            {
                OperationName       = "UploadRoomInformation",
                ServiceContractName = XName.Get("IProperty", ns),
                CorrelatesWith      = operationHandle,
                CorrelatesOn        = extractGuidFromUploadRoomInformation,
                Content             = new ReceiveParametersContent
                {
                    Parameters =
                    {
                        { "propertyId", new OutArgument <Guid>()           },
                        { "roomName",   new OutArgument <string>(roomName) },
                        { "width",      new OutArgument <double>(width)    },
                        { "depth",      new OutArgument <double>(depth)    },
                    }
                }
            };

            return(new Sequence
            {
                Variables = { propertyId, operationHandle, finished, address, owner, askingPrice },
                Activities =
                {
                    receive,
                    new WriteLine {
                        Text = "Assigning a unique ID"
                    },
                    new Assign <Guid>
                    {
                        To = new OutArgument <Guid> (propertyId),
                        Value = new InArgument <Guid> (Guid.NewGuid())
                    },
                    new WriteLine  {
                        Text = new InArgument <string> (env => string.Format("{0} is selling {1} for {2}.\r\nAssigned unique id {3}.",owner.Get(env),                                                                                                            address.Get(env), askingPrice.Get(env), propertyId.Get(env)))
                    },
                    new SendReply
                    {
                        Request = receive,
                        Content = SendContent.Create(new InArgument <Guid> (env => propertyId.Get(env))),
                        CorrelationInitializers =
                        {
                            new QueryCorrelationInitializer
                            {
                                CorrelationHandle = operationHandle,
                                MessageQuerySet = extractGuid
                            }
                        }
                    },
                    new While
                    {
                        Condition = ExpressionServices.Convert <bool>(env => !finished.Get(env)),
                        Body = new Pick
                        {
                            Branches =
                            {
                                new PickBranch
                                {
                                    Variables =           { roomName,                 width,depth                                                                                                                     },
                                    Trigger = receiveRoomInfo,
                                    Action = new WriteLine{
                                        Text = new InArgument <string> (env => string.Format("Room '{0}' uploaded, dimensions {1}W x {2}D",roomName.Get(env),                                                                                                         width.Get(env),   depth.Get(env)))
                                    },
                                },
                                new PickBranch
                                {
                                    Trigger = receiveDetailsComplete,
                                    Action = new Sequence
                                    {
                                        Activities =
                                        {
                                            new Assign <bool>
                                            {
                                                To = new OutArgument <bool>(finished),
                                                Value = new InArgument <bool>(true)
                                            },
                                            new WriteLine {
                                                Text = "Property Details Complete"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    new WriteLine {
                        Text = "Finished!"
                    }
                }
            });
        }
 public static Collection<CorrelationQuery> CreateClientCorrelationQueries(MessageQuerySet select, Collection<CorrelationInitializer> correlationInitializers, string overridingAction, XName serviceContractName, string operationName, bool isResponse)
 {
     Collection<CorrelationQuery> collection = new Collection<CorrelationQuery>();
     CorrelationQuery item = CreateCorrelationQueryCore(select, correlationInitializers);
     if (item != null)
     {
         if (overridingAction != null)
         {
             CorrelationActionMessageFilter filter = new CorrelationActionMessageFilter {
                 Action = overridingAction
             };
             item.Where = filter;
         }
         else
         {
             ProvideDefaultNamespace(ref serviceContractName);
             string str = NamingHelper.GetMessageAction(new XmlQualifiedName(serviceContractName.LocalName, serviceContractName.NamespaceName), operationName, null, isResponse);
             CorrelationActionMessageFilter filter2 = new CorrelationActionMessageFilter {
                 Action = str
             };
             item.Where = filter2;
         }
         collection.Add(item);
         if (isResponse)
         {
             CorrelationQuery query2 = item.Clone();
             CorrelationActionMessageFilter filter3 = new CorrelationActionMessageFilter {
                 Action = string.Empty
             };
             query2.Where = filter3;
             collection.Add(query2);
         }
     }
     return collection;
 }
示例#13
0
        static WorkflowService GetService()
        {
            Variable <Customer>          customer     = new Variable <Customer>();
            Variable <Order>             order        = new Variable <Order>();
            Variable <string>            drug         = new Variable <string>();
            Variable <double>            adjustedCost = new Variable <double>();
            Variable <int>               percentagePaidByInsurance = new Variable <int>();
            Variable <CorrelationHandle> customerHandle            = new Variable <CorrelationHandle>();
            Variable <CorrelationHandle> orderHandle = new Variable <CorrelationHandle>();

            XPathMessageContext pathContext = new XPathMessageContext();

            pathContext.AddNamespace("psns", Constants.PharmacyServiceNamespace);

            // <Snippet2>
            MessageQuerySet GetOrderQuerySet = new MessageQuerySet
            {
                {
                    "OrderID",
                    new XPathMessageQuery("//psns:Order/psns:OrderID", pathContext)
                }
            };
            // </Snippet2>
            MessageQuerySet GetOrderIDQuerySet = new MessageQuerySet
            {
                {
                    "OrderID",
                    new XPathMessageQuery("//ser:guid", pathContext)
                }
            };

            MessageQuerySet customerQuerySet = new MessageQuerySet
            {
                {
                    "CustomerID",
                    new XPathMessageQuery("//psns:GetBaseCost/psns:Customer/psns:CustomerID", pathContext)
                }
            };

            MessageQuerySet customerIDQuerySet = new MessageQuerySet
            {
                {
                    "CustomerID",
                    new XPathMessageQuery("//ser:guid", pathContext)
                }
            };

            // This will use implicit correlation within the workflow using the WorkflowServiceHost's default CorrelationHandle
            // <Snippet3>
            Receive prescriptionRequest = new Receive
            {
                DisplayName         = "Request Perscription",
                OperationName       = "GetBaseCost",
                ServiceContractName = Constants.PharmacyServiceContractName,
                CanCreateInstance   = true,
                //CorrelatesWith = customerHandle,  -- add this line for explicit correlation
                CorrelatesOn = customerQuerySet,
                Content      = new ReceiveParametersContent
                {
                    Parameters =
                    {
                        { "Customer", new OutArgument <Customer>(customer) },
                        { "Drug",     new OutArgument <string>(drug)       },
                    }
                }
            };
            // </Snippet3>

            // This will use implicit correlation within the workflow using the WorkflowServiceHost's default CorrelationHandle
            Receive GetInsurancePaymentPercentageRequest = new Receive
            {
                DisplayName         = "Get Insurance Coverage",
                ServiceContractName = Constants.PharmacyServiceContractName,
                OperationName       = "GetInsurancePaymentPercentage",
                CanCreateInstance   = true,
                //CorrelatesWith = customerHandle,  -- add this line for explicit correlation
                CorrelatesOn = customerIDQuerySet,
                Content      = ReceiveContent.Create(new OutArgument <Guid>())
            };

            // This will explicitly correlate with the SendReply action after the prescriptionRequest using the OrderID (stored in the orderHandle)
            Receive GetAdjustedCostRequest = new Receive
            {
                DisplayName         = "Get Adjusted Cost",
                OperationName       = "GetAdjustedCost",
                ServiceContractName = Constants.PharmacyServiceContractName,
                CanCreateInstance   = true,
                CorrelatesOn        = GetOrderIDQuerySet,
                CorrelatesWith      = orderHandle,
                Content             = ReceiveContent.Create(new OutArgument <Guid>())
            };

            Activity PrescriptonWorkflow = new Sequence()
            {
                Variables  = { customer, order, drug, percentagePaidByInsurance, adjustedCost, customerHandle, orderHandle },
                Activities =
                {
                    new WriteLine
                    {
                        Text = "Beginning Workflow"
                    },

                    new Parallel
                    {
                        Branches =
                        {
                            new Sequence
                            {
                                Activities =
                                {
                                    GetInsurancePaymentPercentageRequest,
                                    new Assign <int>
                                    {
                                        To    = new OutArgument <int>((e) => percentagePaidByInsurance.Get(e)),
                                        Value = new InArgument <int>((e) => new Random().Next(0, 100))
                                    },
                                    new SendReply
                                    {
                                        DisplayName = "Return Percentage",
                                        Request     = GetInsurancePaymentPercentageRequest,
                                        Content     = SendContent.Create(new InArgument <int>((e) => percentagePaidByInsurance.Get(e)))
                                    }
                                }
                            },

                            new Sequence
                            {
                                Activities =
                                {
                                    prescriptionRequest,
                                    new WriteLine
                                    {
                                        Text = new InArgument <string>(env => (string.Format("{0}, {1}\t{2}",customer.Get(env).LastName,                                                       customer.Get(env).FirstName, customer.Get(env).CustomerID.ToString())))
                                    },
                                    new Assign <Order>
                                    {
                                        To    = new OutArgument <Order>(order),
                                        Value = new InArgument <Order>((e) => new Order()
                                        {
                                            CustomerID = customer.Get(e).CustomerID,Drug = drug.Get(e),                                                               OrderID = Guid.NewGuid()
                                        })
                                    },
                                    new WriteLine
                                    {
                                        Text = new InArgument <string>(env => (string.Format("OrderID: {0}",order.Get(env).OrderID.ToString())))
                                    },
                                    new Assign <int>
                                    {
                                        To    = new OutArgument <int>((e) => order.Get(e).Cost),
                                        Value = new InArgument <int>((e) => new Random().Next(20,                   50))
                                    },
                                    // <Snippet0>
                                    new SendReply
                                    {
                                        DisplayName = "Send Adjusted Cost",
                                        Request     = prescriptionRequest,
                                        // Initialize the orderHandle using the MessageQuerySet to correlate with the final GetAdjustedCost request
                                        CorrelationInitializers =
                                        {
                                            // <Snippet1>
                                            new QueryCorrelationInitializer
                                            {
                                                CorrelationHandle = orderHandle,
                                                MessageQuerySet   = GetOrderQuerySet
                                            }
                                            // </Snippet1>
                                        },
                                        Content = SendContent.Create(new InArgument <Order>((e) => order.Get(e)))
                                    }
                                    // </Snippet0>
                                }
                            }
                        }
                    },

                    new Assign <double>
                    {
                        To    = new OutArgument <double>((e) => adjustedCost.Get(e)),
                        Value = new InArgument <double>((e) => order.Get(e).Cost *(100 - percentagePaidByInsurance.Get(e)) * .01)
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>(env => (string.Format("Base Cost: ${0}", order.Get(env).Cost.ToString())))
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>(env => (string.Format("Insurance Coverage: {0}%", percentagePaidByInsurance.Get(env).ToString())))
                    },
                    new WriteLine
                    {
                        Text = new InArgument <string>(env => (string.Format("Adjusted Cost: ${0}", decimal.Round(Convert.ToDecimal(adjustedCost.Get(env)), 2))))
                    },
                    GetAdjustedCostRequest,
                    new SendReply
                    {
                        Request = GetAdjustedCostRequest,
                        Content = SendContent.Create(new InArgument <double>((e) => adjustedCost.Get(e)))
                    },
                    new WriteLine
                    {
                        Text = "Workflow Completed"
                    }
                }
            };

            WorkflowService service = new WorkflowService
            {
                Name = "PharmacyService",
                Body = PrescriptonWorkflow,
                ConfigurationName = "PharmacyService"
            };

            return(service);
        }
示例#14
0
        // Wrapper code that encapsulates creating a simple message query for the purposes of the sample
        static MessageQuerySet CreateMessageQuerySet(string query)
        {
            XPathMessageQuery xpathQuery = new XPathMessageQuery(query);

            MessageQuerySet mqs = new MessageQuerySet();
            mqs.Add("accountQuery", xpathQuery);

            return mqs;
        }
示例#15
0
        //Define the Workflow
        static Activity ServerWorkflow()
        {
            Variable<string> correlationValue = new Variable<string>() { Name = "correlationID" };
            MessageQuerySet mqs = new MessageQuerySet()
            {
                { "ch", new XPathMessageQuery("//ser:string", new XPathMessageContext()) },
            };

            Receive requestOne = new Receive
            {
                OperationName = "ScenarioOne",
                ServiceContractName = Constants.ServiceContractName,
                CanCreateInstance = true,
                CorrelatesOn = mqs,
            };

            Receive requestTwo = new Receive
            {
                OperationName = "ScenarioTwo",
                ServiceContractName = Constants.ServiceContractName,
                CanCreateInstance = false,
                CorrelatesOn = mqs,
            };

            return new Sequence
            {
                Variables = { correlationValue },
                Activities =
                {
                    new WriteLine { Text = "Begin Server Workflow. Begin Scenario One." },

                    new TransactedReceiveScope
                    {
                        // Flow in transaction
                        Request = requestOne,
                        Body = new Sequence
                        {
                            Activities =
                            {
                                new WriteLine { Text = "Begin Scenario One TransactedReceiveScope Body" },

                                new SendReply { Request = requestOne },

                                new PrintTxInfo(),

                                // Inner TransactionScope scope joins the existing transaction
                                new TransactionScope
                                {
                                    Body = new Sequence
                                    {
                                        Activities =
                                        {
                                            new WriteLine { Text = "Begin Scenario One Inner TransactionScope Body" },

                                            new PrintTxInfo(),

                                            new WriteLine { Text = "End Scenario One Inner TransactionScope Body" },
                                        },
                                    },

                                },

                                new PrintTxInfo(),

                                new WriteLine { Text = "End Scenario One TransactedReceiveScope Body" },

                            }
                        }
                    },

                    new WriteLine { Text = "End Scenario One. Begin Scenario Two." },

                    new TransactedReceiveScope
                    {
                        // Flow in transaction
                        Request = requestTwo,
                        Body = new Sequence
                        {
                            Activities =
                            {
                                new WriteLine { Text = "Begin Scenario Two TransactedReceiveScope Body" },

                                new SendReply { Request = requestTwo },

                                new PrintTxInfo(),

                                // Inner TransactionScope joins the existing transaction, but it sets a timeout for the work in its scope.
                                // If the timeout expires the entire transaction will be aborted.
                                new TransactionScope
                                {
                                    Timeout = TimeSpan.FromSeconds(2),
                                    Body = new Sequence
                                    {
                                        Activities =
                                        {
                                            new WriteLine { Text = "Begin Scenario Two Inner TransactionScope Body" },

                                            new Delay { Duration = TimeSpan.FromSeconds(5) },

                                            new PrintTxInfo(),

                                            new WriteLine { Text = "End Scenario Two Inner TransactionScope Body" },
                                        },
                                    }
                                },

                                new PrintTxInfo(),

                                new WriteLine { Text = "End Scenario Two TransactedReceiveScope Body" },
                            },
                        },
                    },

                    new WriteLine { Text = "End Scenario Two. End Server Workflow\n" },
                },
            };
        }
 private static CorrelationQuery CreateCorrelationQueryCore(MessageQuerySet select, Collection<CorrelationInitializer> correlationInitializers)
 {
     CorrelationQuery query = null;
     if (select != null)
     {
         query = new CorrelationQuery {
             Select = select
         };
     }
     if ((correlationInitializers != null) && (correlationInitializers.Count > 0))
     {
         foreach (CorrelationInitializer initializer in correlationInitializers)
         {
             QueryCorrelationInitializer initializer2 = initializer as QueryCorrelationInitializer;
             if (initializer2 != null)
             {
                 query = query ?? new CorrelationQuery();
                 query.SelectAdditional.Add(initializer2.MessageQuerySet);
             }
         }
     }
     return query;
 }
        // this method generates the correlationQuery for client side send and receiveReply
        public static Collection<CorrelationQuery> CreateClientCorrelationQueries(MessageQuerySet select, Collection<CorrelationInitializer> correlationInitializers,
            string overridingAction, XName serviceContractName, string operationName, bool isResponse)
        {
            Fx.Assert(serviceContractName != null && operationName != null, "Argument cannot be null!");

            Collection<CorrelationQuery> queryCollection = new Collection<CorrelationQuery>();
            CorrelationQuery correlationQuery = CreateCorrelationQueryCore(select, correlationInitializers);

            if (correlationQuery != null)
            {
                if (overridingAction != null)
                {
                    correlationQuery.Where = new CorrelationActionMessageFilter { Action = overridingAction };
                }
                else
                {
                    ProvideDefaultNamespace(ref serviceContractName);
                    string defaultAction = NamingHelper.GetMessageAction(new XmlQualifiedName(serviceContractName.LocalName, serviceContractName.NamespaceName),
                        operationName, null, isResponse);

                    correlationQuery.Where = new CorrelationActionMessageFilter { Action = defaultAction };
                }

                queryCollection.Add(correlationQuery);

                if (isResponse)
                {
                    // we need an additional query with empty action to support soap1.1 reply cases
                    CorrelationQuery noActionQuery = correlationQuery.Clone();
                    noActionQuery.Where = new CorrelationActionMessageFilter { Action = String.Empty };
                    queryCollection.Add(noActionQuery);
                }
            }

            return queryCollection;
        }
示例#18
0
        public ClientRequestApprovalWorkflow()
        {
            Variable <CorrelationHandle> corr          = new Variable <CorrelationHandle>();
            Variable <ApprovalResponse>  response      = new Variable <ApprovalResponse>();
            Variable <ApprovalRequest>   cancelRequest = new Variable <ApprovalRequest> {
                Name = "CancelRequest"
            };
            Variable <StartApprovalParams> startParams        = new Variable <StartApprovalParams>();
            Variable <CorrelationHandle>   requestReplyHandle = new Variable <CorrelationHandle> {
                Name = "RequestReplyHandle"
            };

            // For correlating between approval requests and responses
            MessageQuerySet approvalMQS = new MessageQuerySet
            {
                {
                    "ApprovalProcessId",
                    new XPathMessageQuery("local-name()='Id'", new XPathMessageContext())
                }
            };

            this.Implementation = () =>
                                  new Sequence
            {
                Variables  = { corr, response, startParams, requestReplyHandle, cancelRequest },
                Activities =
                {
                    // Called by a local client proxy to trigger the creation of a new approval request
                    new Receive
                    {
                        OperationName       = "StartGetApproval",
                        ServiceContractName = "IApprovalResults",
                        Content             = new ReceiveMessageContent(new OutArgument <StartApprovalParams>(startParams)),
                        CanCreateInstance   = true,
                    },
                    // Ask the approval manager to start the approval process
                    new Send
                    {
                        OperationName       = "RequestApprovalOf",
                        ServiceContractName = "IApprovalProcess",
                        EndpointAddress     = new InArgument <Uri>(env => startParams.Get(env).ServiceAddress),
                        Endpoint            = new Endpoint
                        {
                            Binding = new BasicHttpBinding(),
                        },
                        Content = new SendMessageContent(new InArgument <ApprovalRequest>(env => startParams.Get(env).Request)),
                        CorrelationInitializers =
                        {
                            new QueryCorrelationInitializer
                            {
                                CorrelationHandle = corr,
                                MessageQuerySet   = approvalMQS,
                            },
                        }
                    },
                    // Get a response from the approval manager or a request to cancel the approval
                    //  from the local client proxy (user presses the cancel request button on the ui)
                    new Pick
                    {
                        Branches =
                        {
                            new PickBranch
                            {
                                Trigger = new Receive
                                {
                                    OperationName       = "ApprovalProcessResults",
                                    ServiceContractName = "IApprovalResults",
                                    CorrelatesWith      = corr,
                                    CorrelatesOn        = approvalMQS,
                                    Content             = new ReceiveMessageContent(new OutArgument <ApprovalResponse>(response)),
                                },
                            },
                            new PickBranch
                            {
                                Trigger = new Receive
                                {
                                    OperationName       = "CancelApprovalRequest",
                                    ServiceContractName = "IApprovalResults",
                                    CorrelatesWith      = corr,
                                    CorrelatesOn        = approvalMQS,
                                    Content             = new ReceiveMessageContent(new OutArgument <ApprovalRequest>(cancelRequest)),
                                },
                                // Send cancelation to the approval manager to pass on to clients approving document
                                Action = new Sequence
                                {
                                    Activities =
                                    {
                                        new Send
                                        {
                                            OperationName       = "CancelApprovalRequest",
                                            ServiceContractName = "IApprovalProcess",
                                            EndpointAddress     = new InArgument <Uri>(env => startParams.Get(env).ServiceAddress),
                                            Endpoint            = new Endpoint
                                            {
                                                Binding = new BasicHttpBinding(),
                                            },
                                            Content = new SendMessageContent(new InArgument <ApprovalRequest>(env => startParams.Get(env).Request)),
                                        },
                                        new TerminateWorkflow
                                        {
                                            Reason = "Approval Request Canceled",
                                        }
                                    }
                                }
                            }
                        }
                    },
                    new InvokeMethod
                    {
                        TargetType = typeof(ExternalToMainComm),
                        MethodName = "WriteStatusLine",
                        Parameters =
                        {
                            new InArgument <String>("Got an approval response..."),
                        },
                    },
                    // update ui with new response
                    new InvokeMethod
                    {
                        TargetType = typeof(ExternalToMainComm),
                        MethodName = "ApprovalRequestResponse",
                        Parameters =
                        {
                            new InArgument <ApprovalResponse>(response),
                        }
                    },
                }
            };
        }
 public static CorrelationQuery CreateServerCorrelationQuery(MessageQuerySet select, Collection<CorrelationInitializer> correlationInitializers, OperationDescription operation, bool isResponse)
 {
     CorrelationQuery query = CreateCorrelationQueryCore(select, correlationInitializers);
     if (query != null)
     {
         string str = !isResponse ? operation.Messages[0].Action : operation.Messages[1].Action;
         CorrelationActionMessageFilter filter = new CorrelationActionMessageFilter {
             Action = str
         };
         query.Where = filter;
     }
     return query;
 }
示例#20
0
        static WorkflowService GetService()
        {
            Variable<Customer> customer = new Variable<Customer>();
            Variable<Order> order = new Variable<Order>();
            Variable<string> drug = new Variable<string>();
            Variable<double> adjustedCost = new Variable<double>();
            Variable<int> percentagePaidByInsurance = new Variable<int>();
            Variable<CorrelationHandle> customerHandle = new Variable<CorrelationHandle>();
            Variable<CorrelationHandle> orderHandle = new Variable<CorrelationHandle>();

            XPathMessageContext pathContext = new XPathMessageContext();
            pathContext.AddNamespace("psns", Constants.PharmacyServiceNamespace);

            MessageQuerySet GetOrderQuerySet = new MessageQuerySet
            {
                {
                    "OrderID",
                    new XPathMessageQuery("//psns:Order/psns:OrderID",pathContext)
                }
            };

            MessageQuerySet GetOrderIDQuerySet = new MessageQuerySet
            {
                {
                    "OrderID",
                    new XPathMessageQuery("//ser:guid",pathContext)
                }
            };

            MessageQuerySet customerQuerySet = new MessageQuerySet
            {
                {
                    "CustomerID",
                    new XPathMessageQuery("//psns:GetBaseCost/psns:Customer/psns:CustomerID",pathContext)
                }
            };

            MessageQuerySet customerIDQuerySet = new MessageQuerySet
            {
                {
                    "CustomerID",
                    new XPathMessageQuery("//ser:guid",pathContext)
                }
            };

            // This will use implicit correlation within the workflow using the WorkflowServiceHost's default CorrelationHandle
            Receive prescriptionRequest = new Receive
            {
                DisplayName = "Request Perscription",
                OperationName = "GetBaseCost",
                ServiceContractName = Constants.PharmacyServiceContractName,
                CanCreateInstance = true,
                //CorrelatesWith = customerHandle,  -- add this line for explicit correlation
                CorrelatesOn = customerQuerySet,
                Content = new ReceiveParametersContent
                {
                    Parameters =
                    {
                        {"Customer",new OutArgument<Customer>(customer)},
                        {"Drug",new OutArgument<string>(drug)},
                    }
                }
            };

            // This will use implicit correlation within the workflow using the WorkflowServiceHost's default CorrelationHandle
            Receive GetInsurancePaymentPercentageRequest = new Receive
            {
                DisplayName = "Get Insurance Coverage",
                ServiceContractName = Constants.PharmacyServiceContractName,
                OperationName = "GetInsurancePaymentPercentage",
                CanCreateInstance = true,
                //CorrelatesWith = customerHandle,  -- add this line for explicit correlation
                CorrelatesOn = customerIDQuerySet,
                Content = ReceiveContent.Create(new OutArgument<Guid>())
            };

            // This will explicitly correlate with the SendReply action after the prescriptionRequest using the OrderID (stored in the orderHandle)
            Receive GetAdjustedCostRequest = new Receive
            {
                DisplayName = "Get Adjusted Cost",
                OperationName = "GetAdjustedCost",
                ServiceContractName = Constants.PharmacyServiceContractName,
                CanCreateInstance = true,
                CorrelatesOn = GetOrderIDQuerySet,
                CorrelatesWith = orderHandle,
                Content = ReceiveContent.Create(new OutArgument<Guid>())
            };

            Activity PrescriptonWorkflow = new Sequence()
            {
                Variables = { customer, order, drug, percentagePaidByInsurance, adjustedCost, customerHandle, orderHandle },
                Activities =
                {
                    new WriteLine
                    {
                        Text = "Beginning Workflow"
                    },

                    new Parallel
                    {
                        Branches =
                        {
                            new Sequence
                            {
                                Activities =
                                {
                                    GetInsurancePaymentPercentageRequest,
                                    new Assign<int>
                                    {
                                        To = new OutArgument<int>( (e) => percentagePaidByInsurance.Get(e) ),
                                        Value = new InArgument<int>( (e) => new Random().Next(0,100))
                                    },
                                    new SendReply
                                    {
                                        DisplayName = "Return Percentage",
                                        Request = GetInsurancePaymentPercentageRequest,
                                        Content = SendContent.Create(new InArgument<int>((e) => percentagePaidByInsurance.Get(e)))
                                    }

                                }
                            },

                            new Sequence
                            {
                                Activities =
                                {
                                    prescriptionRequest,
                                    new WriteLine
                                    {
                                        Text = new InArgument<string>(env => (string.Format("{0}, {1}\t{2}", customer.Get(env).LastName ,customer.Get(env).FirstName,customer.Get(env).CustomerID.ToString())))
                                    },
                                    new Assign<Order>
                                    {
                                        To = new OutArgument<Order>(order),
                                        Value = new InArgument<Order>( (e) => new Order() { CustomerID = customer.Get(e).CustomerID, Drug = drug.Get(e), OrderID = Guid.NewGuid() } )
                                    },
                                    new WriteLine
                                    {
                                        Text = new InArgument<string>(env => (string.Format("OrderID: {0}", order.Get(env).OrderID.ToString())))
                                    },
                                    new Assign<int>
                                    {
                                        To = new OutArgument<int>( (e) => order.Get(e).Cost ),
                                        Value = new InArgument<int>( (e) => new Random().Next(20,50))
                                    },
                                    new SendReply
                                    {
                                        DisplayName = "Send Adjusted Cost",
                                        Request = prescriptionRequest,
                                        // Initialize the orderHandle using the MessageQuerySet to correlate with the final GetAdjustedCost request
                                        CorrelationInitializers =
                                        {
                                            new QueryCorrelationInitializer
                                            {
                                                CorrelationHandle = orderHandle,
                                                MessageQuerySet = GetOrderQuerySet
                                            }
                                        },
                                        Content = SendContent.Create(new InArgument<Order>((e) => order.Get(e)))
                                    }
                                }
                            }
                        }
                    },

                    new Assign<double>
                    {
                        To = new OutArgument<double>( (e) => adjustedCost.Get(e) ),
                        Value = new InArgument<double>( (e) => order.Get(e).Cost *  (100-percentagePaidByInsurance.Get(e)) *.01)
                    },
                    new WriteLine
                    {
                        Text = new InArgument<string>(env => (string.Format("Base Cost: ${0}", order.Get(env).Cost.ToString())))
                    },
                    new WriteLine
                    {
                        Text = new InArgument<string>(env => (string.Format("Insurance Coverage: {0}%", percentagePaidByInsurance.Get(env).ToString())))
                    },
                    new WriteLine
                    {
                        Text = new InArgument<string>(env => (string.Format("Adjusted Cost: ${0}", decimal.Round(Convert.ToDecimal(adjustedCost.Get(env)),2))))
                    },
                    GetAdjustedCostRequest,
                    new SendReply
                    {
                        Request = GetAdjustedCostRequest,
                        Content = SendContent.Create(new InArgument<double>((e) => adjustedCost.Get(e)))
                    },
                    new WriteLine
                    {
                        Text = "Workflow Completed"
                    }

                }
            };

            WorkflowService service = new WorkflowService
            {
                Name = "PharmacyService",
                Body = PrescriptonWorkflow,
                ConfigurationName = "PharmacyService"
            };

            return service;
        }
        public static CorrelationQuery CreateServerCorrelationQuery(MessageQuerySet select, Collection<CorrelationInitializer> correlationInitializers,
            OperationDescription operation, bool isResponse)
        {
            Fx.Assert(operation != null, "Argument cannot be null!");

            CorrelationQuery correlationQuery = CreateCorrelationQueryCore(select, correlationInitializers);

            if (correlationQuery != null)
            {
                string action = !isResponse ? operation.Messages[0].Action : operation.Messages[1].Action;
                correlationQuery.Where = new CorrelationActionMessageFilter { Action = action };
            }

            return correlationQuery;
        }
        public ClientRequestApprovalWorkflow()
        {
            Variable<CorrelationHandle> corr = new Variable<CorrelationHandle>();
            Variable<ApprovalResponse> response = new Variable<ApprovalResponse>();
            Variable<ApprovalRequest> cancelRequest = new Variable<ApprovalRequest> { Name = "CancelRequest" };
            Variable<StartApprovalParams> startParams = new Variable<StartApprovalParams>();
            Variable<CorrelationHandle> requestReplyHandle = new Variable<CorrelationHandle> { Name = "RequestReplyHandle" };

            // For correlating between approval requests and responses
            MessageQuerySet approvalMQS = new MessageQuerySet
            {
                {
                    "ApprovalProcessId",
                    new XPathMessageQuery("local-name()='Id'", new XPathMessageContext())
                }
            };

            this.Implementation = () =>
                new Sequence
                {
                    Variables = { corr, response, startParams, requestReplyHandle, cancelRequest },
                    Activities =
                    {
                        // Called by a local client proxy to trigger the creation of a new approval request
                        new Receive
                        {
                            OperationName = "StartGetApproval",
                            ServiceContractName = "IApprovalResults",
                            Content = new ReceiveMessageContent(new OutArgument<StartApprovalParams>(startParams)),
                            CanCreateInstance = true,
                        },
                        // Ask the approval manager to start the approval process
                        new Send
                        {
                            OperationName = "RequestApprovalOf",
                            ServiceContractName = "IApprovalProcess",
                            EndpointAddress = new InArgument<Uri>(env => startParams.Get(env).ServiceAddress),
                            Endpoint = new Endpoint
                            {
                                 Binding = new BasicHttpBinding(),
                            },
                            Content = new SendMessageContent(new InArgument<ApprovalRequest>(env => startParams.Get(env).Request)),
                            CorrelationInitializers =
                            {
                                new QueryCorrelationInitializer
                                {
                                    CorrelationHandle = corr,
                                    MessageQuerySet = approvalMQS,
                                },
                            }
                        },
                        // Get a response from the approval manager or a request to cancel the approval
                        //  from the local client proxy (user presses the cancel request button on the ui)
                        new Pick
                        {
                            Branches =
                            {
                                new PickBranch
                                {
                                    Trigger = new Receive
                                    {
                                        OperationName = "ApprovalProcessResults",
                                        ServiceContractName = "IApprovalResults",
                                        CorrelatesWith = corr,
                                        CorrelatesOn = approvalMQS,
                                        Content = new ReceiveMessageContent(new OutArgument<ApprovalResponse>(response)),
                                    },
                                },
                                new PickBranch
                                {
                                    Trigger = new Receive
                                    {
                                        OperationName = "CancelApprovalRequest",
                                        ServiceContractName = "IApprovalResults",
                                        CorrelatesWith = corr,
                                        CorrelatesOn = approvalMQS,
                                        Content = new ReceiveMessageContent(new OutArgument<ApprovalRequest>(cancelRequest)),
                                    },
                                    // Send cancelation to the approval manager to pass on to clients approving document
                                    Action = new Sequence
                                    {
                                        Activities =
                                        {
                                            new Send
                                            {
                                                OperationName = "CancelApprovalRequest",
                                                ServiceContractName = "IApprovalProcess",
                                                EndpointAddress = new InArgument<Uri>(env => startParams.Get(env).ServiceAddress),
                                                Endpoint = new Endpoint
                                                {
                                                    Binding = new BasicHttpBinding(),
                                                },
                                                Content = new SendMessageContent(new InArgument<ApprovalRequest>(env => startParams.Get(env).Request)),
                                            },
                                            new TerminateWorkflow
                                            {
                                                Reason = "Approval Request Canceled",
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        new InvokeMethod
                        {
                            TargetType = typeof(ExternalToMainComm),
                            MethodName = "WriteStatusLine",
                            Parameters =
                            {
                                new InArgument<String>("Got an approval response..."),
                            },
                        },
                        // update ui with new response
                        new InvokeMethod
                        {
                            TargetType = typeof(ExternalToMainComm),
                            MethodName = "ApprovalRequestResponse",
                            Parameters =
                            {
                                new InArgument<ApprovalResponse>(response),
                            }
                        },
                    }
                };
        }
        static CorrelationQuery CreateCorrelationQueryCore(MessageQuerySet select, Collection<CorrelationInitializer> correlationInitializers)
        {
            CorrelationQuery correlationQuery = null;

            if (select != null)
            {
                Fx.Assert(select.Count != 0, "Empty MessageQuerySet is not allowed!");

                correlationQuery = new CorrelationQuery
                {
                    Select = select
                };
            }

            if (correlationInitializers != null && correlationInitializers.Count > 0)
            {
                foreach (CorrelationInitializer correlation in correlationInitializers)
                {
                    QueryCorrelationInitializer queryCorrelation = correlation as QueryCorrelationInitializer;
                    if (queryCorrelation != null)
                    {
                        Fx.Assert(queryCorrelation.MessageQuerySet.Count != 0, "Empty MessageQuerySet is not allowed!");

                        correlationQuery = correlationQuery ?? new CorrelationQuery();
                        correlationQuery.SelectAdditional.Add(queryCorrelation.MessageQuerySet);
                    }
                }
            }

            return correlationQuery;
        }
示例#24
0
 internal IDictionary <XName, ContractDescription> GetContractDescriptions()
 {
     if (this.cachedInferredContracts == null)
     {
         this.WalkActivityTree();
         this.correlationQueryByContract = new Dictionary <XName, Collection <CorrelationQuery> >();
         IDictionary <XName, ContractDescription> dictionary = new Dictionary <XName, ContractDescription>();
         IDictionary <ContractAndOperationNameTuple, OperationInfo> dictionary2 = new Dictionary <ContractAndOperationNameTuple, OperationInfo>();
         foreach (Receive receive in this.knownServiceActivities)
         {
             OperationInfo info;
             XName         serviceContractXName = this.FixServiceContractName(receive.ServiceContractName);
             ContractAndOperationNameTuple key  = new ContractAndOperationNameTuple(serviceContractXName, receive.OperationName);
             if (dictionary2.TryGetValue(key, out info))
             {
                 ContractValidationHelper.ValidateReceiveWithReceive(receive, info.Receive);
             }
             else
             {
                 ContractDescription description;
                 if (!dictionary.TryGetValue(serviceContractXName, out description))
                 {
                     description = new ContractDescription(serviceContractXName.LocalName, serviceContractXName.NamespaceName)
                     {
                         ConfigurationName = serviceContractXName.LocalName
                     };
                     dictionary.Add(serviceContractXName, description);
                 }
                 OperationDescription item = ContractInferenceHelper.CreateOperationDescription(receive, description);
                 description.Operations.Add(item);
                 info = new OperationInfo(receive, item);
                 dictionary2.Add(key, info);
             }
             this.CorrectOutMessageForOperationWithFault(receive, info);
             ContractInferenceHelper.UpdateIsOneWayFlag(receive, info.OperationDescription);
             ContractInferenceHelper.AddFaultDescription(receive, info.OperationDescription);
             ContractInferenceHelper.AddKnownTypesToOperation(receive, info.OperationDescription);
             ContractInferenceHelper.AddReceiveToFormatterBehavior(receive, info.OperationDescription);
             Collection <CorrelationQuery> queries = null;
             if (receive.HasCorrelatesOn || receive.HasCorrelationInitializers)
             {
                 MessageQuerySet  select           = receive.HasCorrelatesOn ? receive.CorrelatesOn : null;
                 CorrelationQuery correlationQuery = ContractInferenceHelper.CreateServerCorrelationQuery(select, receive.CorrelationInitializers, info.OperationDescription, false);
                 this.CollectCorrelationQuery(ref queries, serviceContractXName, correlationQuery);
             }
             if (receive.HasReply)
             {
                 foreach (SendReply reply in receive.FollowingReplies)
                 {
                     ReceiveAndReplyTuple tuple2 = new ReceiveAndReplyTuple(receive, reply);
                     this.receiveAndReplyPairs.Remove(tuple2);
                     this.CollectCorrelationQueryFromReply(ref queries, serviceContractXName, reply, info.OperationDescription);
                     reply.SetContractName(serviceContractXName);
                 }
             }
             if (receive.HasFault)
             {
                 foreach (Activity activity in receive.FollowingFaults)
                 {
                     ReceiveAndReplyTuple tuple3 = new ReceiveAndReplyTuple(receive, activity);
                     this.receiveAndReplyPairs.Remove(tuple3);
                     this.CollectCorrelationQueryFromReply(ref queries, serviceContractXName, activity, info.OperationDescription);
                 }
             }
         }
         if (this.receiveAndReplyPairs.Count != 0)
         {
             throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new ValidationException(System.ServiceModel.Activities.SR.DanglingReceive));
         }
         if (System.ServiceModel.Activities.TD.InferredContractDescriptionIsEnabled())
         {
             foreach (ContractDescription description3 in dictionary.Values)
             {
                 System.ServiceModel.Activities.TD.InferredContractDescription(description3.Name, description3.Namespace);
                 if (System.ServiceModel.Activities.TD.InferredOperationDescriptionIsEnabled())
                 {
                     foreach (OperationDescription description4 in description3.Operations)
                     {
                         System.ServiceModel.Activities.TD.InferredOperationDescription(description4.Name, description3.Name, description4.IsOneWay.ToString());
                     }
                 }
             }
         }
         this.cachedInferredContracts = dictionary;
     }
     return(this.cachedInferredContracts);
 }