コード例 #1
0
        /// <summary>
        /// Synchronously executes the task using the specified <see cref="RuntimeTaskExecutionContext"/> execution context object.
        /// </summary>
        /// <param name="context">The execution context.</param>
        public override void Run(RuntimeTaskExecutionContext context)
        {
            var callToken = TraceManager.CustomComponent.TraceIn();

            base.Run(context);

            if (CurrentActivity != null)
            {
                using (IActivityTrackingEventStream eventStream = ActivityTrackingEventStreamFactory.CreateEventStream(context.PipelineContext))
                {
                    eventStream.CompleteActivity(CurrentActivity);
                }
            }

            TraceManager.CustomComponent.TraceOut(callToken);
        }
コード例 #2
0
        /// <summary>
        /// Executes the custom runtime task component to process the input message and returns the result message.
        /// </summary>
        /// <param name="pContext">A reference to <see cref="Microsoft.BizTalk.Component.Interop.IPipelineContext"/> object that contains the current pipeline context.</param>
        /// <param name="pInMsg">A reference to <see cref="Microsoft.BizTalk.Message.Interop.IBaseMessage"/> object that contains the message to process.</param>
        /// <returns>A reference to the returned <see cref="Microsoft.BizTalk.Message.Interop.IBaseMessage"/> object which will contain the output message.</returns>
        public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            Guard.ArgumentNotNull(pContext, "pContext");
            Guard.ArgumentNotNull(pInMsg, "pInMsg");

            var callToken = TraceManager.PipelineComponent.TraceIn();

            if (pInMsg.BodyPart != null)
            {
                Stream messageDataStream = BizTalkUtility.EnsureSeekableStream(pInMsg, pContext);

                if (messageDataStream != null)
                {
                    try
                    {
                        XmlReaderSettings readerSettings = new XmlReaderSettings()
                        {
                            CloseInput = false, CheckCharacters = false, IgnoreComments = true, IgnoreProcessingInstructions = true, IgnoreWhitespace = true, ValidationType = ValidationType.None
                        };

                        using (XmlReader messageDataReader = XmlReader.Create(messageDataStream, readerSettings))
                        {
                            ActivityBase genericActivity = ActivityBase.Create(messageDataReader);

                            if (genericActivity != null)
                            {
                                using (IActivityTrackingEventStream eventStream = ActivityTrackingEventStreamFactory.CreateEventStream(pContext))
                                {
                                    string methodName = pInMsg.Context.Read(SoapMethodProperty.Name.Name, SoapMethodProperty.Name.Namespace) as string;

                                    if (!String.IsNullOrEmpty(methodName))
                                    {
                                        if (methodName.EndsWith(Resources.BeginActivityMethodName))
                                        {
                                            eventStream.BeginActivity(genericActivity);
                                        }
                                        else if (methodName.EndsWith(Resources.UpdateActivityMethodName))
                                        {
                                            eventStream.UpdateActivity(genericActivity);
                                        }
                                        else if (methodName.EndsWith(Resources.CompleteActivityMethodName))
                                        {
                                            eventStream.CompleteActivity(genericActivity);
                                        }
                                    }
                                    else
                                    {
                                        TraceManager.PipelineComponent.TraceWarning(TraceLogMessages.CannotDetermineSoapAction, this.GetType().Name, SoapMethodProperty.Name.Name, SoapMethodProperty.Name.Namespace);
                                    }
                                }
                            }
                            else
                            {
                                TraceManager.PipelineComponent.TraceWarning(TraceLogMessages.CannotDeserializeActivityMessage, this.GetType().Name, typeof(ActivityBase).FullName);
                            }
                        }
                    }
                    finally
                    {
                        if (messageDataStream.CanSeek)
                        {
                            messageDataStream.Seek(0, SeekOrigin.Begin);
                        }
                    }
                }
            }

            TraceManager.PipelineComponent.TraceOut(callToken);
            return(pInMsg);
        }