コード例 #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();

            IBaseMessageFactory msgFactory     = context.PipelineContext.GetMessageFactory();
            IBaseMessage        responseMsg    = msgFactory.CreateMessage();
            IBaseMessageContext responseMsgCtx = msgFactory.CreateMessageContext();
            IBaseMessageContext requestMsgCtx  = context.Message.Context;

            responseMsg.Context = responseMsgCtx;

            if (BizTalkUtility.ContainsResponsePart(context.Message))
            {
                IBaseMessagePart responsePart = BizTalkUtility.GetResponsePart(context.Message);
                responseMsg.AddPart(context.Message.BodyPartName, responsePart, true);
            }
            else
            {
                responseMsg.AddPart(context.Message.BodyPartName, context.Message.BodyPart, true);
            }

            responseMsgCtx.Promote(EpmRRCorrelationToken.Name.Name, EpmRRCorrelationToken.Name.Namespace, requestMsgCtx.Read(EpmRRCorrelationToken.Name.Name, EpmRRCorrelationToken.Name.Namespace));
            responseMsgCtx.Promote(RouteDirectToTP.Name.Name, RouteDirectToTP.Name.Namespace, true);
            responseMsgCtx.Promote(CorrelationToken.Name.Name, CorrelationToken.Name.Namespace, requestMsgCtx.Read(CorrelationToken.Name.Name, CorrelationToken.Name.Namespace));
            responseMsgCtx.Promote(ReqRespTransmitPipelineID.Name.Name, ReqRespTransmitPipelineID.Name.Namespace, requestMsgCtx.Read(ReqRespTransmitPipelineID.Name.Name, ReqRespTransmitPipelineID.Name.Namespace));
            responseMsgCtx.Write(ReceivePipelineResponseConfig.Name.Name, ReceivePipelineResponseConfig.Name.Namespace, requestMsgCtx.Read(ReceivePipelineResponseConfig.Name.Name, ReceivePipelineResponseConfig.Name.Namespace));

            context.Message = responseMsg;

            TraceManager.CustomComponent.TraceOut(callToken);
        }
コード例 #2
0
ファイル: Manipulator.cs プロジェクト: radtek/DevOps
        /// <summary>
        /// Writes to message context
        /// </summary>
        /// <param name="value"></param>
        /// <param name="propertyName"></param>
        /// <param name="messageContext"></param>
        /// <returns></returns>
        private IBaseMessageContext WriteToMessageContextAndPromote(string value, string serializedContextProperty, IBaseMessageContext messageContext, bool promoteProperty)
        {
            MessageContextDescription msgContextDes = (MessageContextDescription)SerializeToObject(typeof(MessageContextDescription), serializedContextProperty);

            if (!string.IsNullOrEmpty(value))
            {
                if (!string.IsNullOrEmpty(msgContextDes.PropertyName) && !string.IsNullOrEmpty(msgContextDes.PropertyNamespace))
                {
                    //Check whether writng to OutboundTransportLocation
                    if (msgContextDes.PropertyName.Equals(BtsProperties.OutboundTransportLocation.Name, StringComparison.InvariantCultureIgnoreCase) &&
                        msgContextDes.PropertyNamespace.Equals(BtsProperties.OutboundTransportLocation.Namespace, StringComparison.InvariantCultureIgnoreCase))
                    {
                        FileInfo fileInfo = new FileInfo(value);

                        if (!Directory.Exists(fileInfo.DirectoryName))
                        {
                            Directory.CreateDirectory(fileInfo.DirectoryName);
                        }
                    }

                    if (promoteProperty)
                    {
                        messageContext.Promote(msgContextDes.PropertyName, msgContextDes.PropertyNamespace, value);
                    }
                    else
                    {
                        messageContext.Write(msgContextDes.PropertyName, msgContextDes.PropertyNamespace, value);
                    }
                }
            }

            return(messageContext);
        }
 public override void Execute(IBaseMessageContext messageContext)
 {
     if (messageContext == null)
     {
         throw new ArgumentNullException(nameof(messageContext));
     }
     if (ExtractionMode == ExtractionMode.Write)
     {
         if (_logger.IsDebugEnabled)
         {
             _logger.DebugFormat("Writing property {0} with value {1} to context.", PropertyName, Value);
         }
         messageContext.Write(PropertyName.Name, PropertyName.Namespace, Value);
     }
     else if (ExtractionMode == ExtractionMode.Promote)
     {
         if (_logger.IsDebugEnabled)
         {
             _logger.DebugFormat("Promoting property {0} with value {1} to context.", PropertyName, Value);
         }
         messageContext.Promote(PropertyName.Name, PropertyName.Namespace, Value);
     }
     else
     {
         base.Execute(messageContext);
     }
 }
 public virtual void Execute(IBaseMessageContext messageContext)
 {
     if (messageContext == null)
     {
         throw new ArgumentNullException(nameof(messageContext));
     }
     if (ExtractionMode == ExtractionMode.Clear)
     {
         if (_logger.IsDebugEnabled)
         {
             _logger.DebugFormat("Clearing property {0} from context.", PropertyName);
         }
         if (messageContext.IsPromoted(PropertyName.Name, PropertyName.Namespace))
         {
             messageContext.Promote(PropertyName.Name, PropertyName.Namespace, null);
         }
         messageContext.Write(PropertyName.Name, PropertyName.Namespace, null);
     }
     else if (ExtractionMode == ExtractionMode.Ignore)
     {
         if (_logger.IsDebugEnabled)
         {
             _logger.DebugFormat("Ignoring property {0} from context.", PropertyName);
         }
     }
     else
     {
         throw new InvalidOperationException($"Unexpected ExtractionMode '{ExtractionMode}'.");
     }
 }
コード例 #5
0
        /// <summary>
        /// Implements IComponent.Execute method.
        /// </summary>
        /// <param name="pc">Pipeline context</param>
        /// <param name="inmsg">Input message</param>
        /// <returns>Original input message</returns>
        /// <remarks>
        /// IComponent.Execute method is used to initiate
        /// the processing of the message in this pipeline component.
        /// </remarks>
        public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
        {
            //
            // TODO: implement component logic
            //
            // this way, it's a passthrough pipeline component
            IBaseMessageContext context = inmsg.Context;
            Stream            inStream  = inmsg.BodyPart.Data;
            XslTransmitHelper transmit  = new XslTransmitHelper(this.XslPath, this.XPathSourceFileName, this.EnableValidateNamespace, this.AllowPassThruTransmit);

            if (!string.IsNullOrEmpty(this.XPathSourceFileName))
            {
                string sourceFileName = transmit.GetSourceFileName(XmlReader.Create(inStream), this.XPathSourceFileName);
                if (!string.IsNullOrEmpty(sourceFileName))
                {
                    context.Write("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", sourceFileName);
                    context.Promote("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", sourceFileName);
                }
                inStream.Seek(0, SeekOrigin.Begin);
            }
            var outStream = transmit.Transmit(inStream);

            inmsg.BodyPart.Data = outStream;
            pc.ResourceTracker.AddResource(outStream);



            return(inmsg);
        }
        protected override void SetContextProperties(IBaseMessageContext pipelineContext, System.Collections.Generic.Dictionary <string, string> ResolverDictionary)
        {
            var _transportLocation = ResolverDictionary["Resolver.TransportLocation"];
            var _endpointConfig    = ResolverDictionary["Resolver.EndpointConfig"];
            var _operation         = ResolverDictionary["Resolver.Action"];

            EventLogger.Write(string.Format("Resolver retorna la accion de {0}.", _operation));
            pipelineContext.Write(BtsProperties.OutboundTransportLocation.Name, BtsProperties.OutboundTransportLocation.Namespace, _transportLocation);
            pipelineContext.Write(BtsProperties.OutboundTransportType.Name, BtsProperties.OutboundTransportType.Namespace, AdapterName);

            var customProps = new Dictionary <string, string>();

            customProps = _endpointConfig.ParseKeyValuePairs(true);
            EventLogger.Write("Custom properties");



            pipelineContext.Promote(WebHttpOptions.Operation.Name, WebHttpOptions.Operation.Namespace, _operation);

            pipelineContext.Write(WebHttpOptions.Action.Name, WebHttpOptions.Action.Namespace, _operation);
            pipelineContext.Write(WebHttpOptions.HttpMethodAndUrl.Name, WebHttpOptions.HttpMethodAndUrl.Namespace, customProps.GetValue("HttpMethodAndUrl"));
            pipelineContext.Write(WebHttpOptions.HttpHeaders.Name, WebHttpOptions.HttpHeaders.Namespace, customProps.GetValue("HttpHeaders"));
            pipelineContext.Write(WebHttpOptions.VariablePropertyMapping.Name, WebHttpOptions.VariablePropertyMapping.Namespace, customProps.GetValue("VariablePropertyMapping"));
            pipelineContext.Write(WebHttpOptions.SuppressMessageBodyForHttpVerbs.Name, WebHttpOptions.SuppressMessageBodyForHttpVerbs.Namespace, customProps.GetValue("SuppressMessageBodyForHttpVerbs"));
            pipelineContext.Write(WebHttpOptions.SecurityMode.Name, WebHttpOptions.SecurityMode.Namespace, customProps.GetValue("SecurityMode"));
            pipelineContext.Write(WebHttpOptions.TransportClientCredentialType.Name, WebHttpOptions.TransportClientCredentialType.Namespace, customProps.GetValue("TransportClientCredentialType"));
            pipelineContext.Write(WebHttpOptions.UserName.Name, WebHttpOptions.UserName.Namespace, customProps.GetValue("UserName"));
            pipelineContext.Write(WebHttpOptions.Password.Name, WebHttpOptions.Password.Namespace, customProps.GetValue("Password"));
            pipelineContext.Write(WebHttpOptions.SendTimeout.Name, WebHttpOptions.SendTimeout.Namespace, customProps.GetValue("SendTimeout"));
            pipelineContext.Write(WebHttpOptions.OpenTimeout.Name, WebHttpOptions.OpenTimeout.Namespace, customProps.GetValue("OpenTimeout"));
            pipelineContext.Write(WebHttpOptions.CloseTimeout.Name, WebHttpOptions.CloseTimeout.Namespace, customProps.GetValue("CloseTimeout"));
            pipelineContext.Write(WebHttpOptions.ProxyToUse.Name, WebHttpOptions.ProxyToUse.Namespace, customProps.GetValue("ProxyToUse"));
            pipelineContext.Write(WebHttpOptions.ProxyAddress.Name, WebHttpOptions.ProxyAddress.Namespace, customProps.GetValue("ProxyAddress"));
        }
コード例 #7
0
 public static void Promote <T>(this IBaseMessageContext context, MessageContextProperty <T, string> property, string value)
     where T : MessageContextPropertyBase, new()
 {
     if (value != null)
     {
         context.Promote(property.Name, property.Namespace, value);
     }
 }
コード例 #8
0
        public void Promote(string name, string ns, object value)
        {
            if (value == null || String.IsNullOrEmpty(name) || String.IsNullOrEmpty(ns))
            {
                return;
            }

            context.Promote(name, ns, value);
        }
コード例 #9
0
 internal IBaseMessage AddContextValue(string name, string nspace, bool isPromoted, object value)
 {
     if (isPromoted)
     {
         _context.Promote(name, nspace, value);
     }
     else
     {
         _context.Write(name, nspace, value);
     }
     return(this);
 }
コード例 #10
0
        public static void Promote(this IBaseMessageContext ctx, ContextProperty property, object val)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            if (val == null)
            {
                throw new ArgumentNullException("val");
            }

            ctx.Promote(property.PropertyName, property.PropertyNamespace, val);
        }
コード例 #11
0
        public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            try
            {
                IBaseMessageContext msgContext = pInMsg.Context;
                msgContext.Write(customPromotedPropertyName, customPromotedPropertyNameSpace, customPromotedPropertyValue);
                msgContext.Promote(customPromotedPropertyName, customPromotedPropertyNameSpace, customPromotedPropertyValue);
            }
            catch (Exception ex)
            {
                if (pInMsg != null)
                {
                    pInMsg.SetErrorInfo(ex);
                }
                throw ex;
            }

            return(pInMsg);
        }
コード例 #12
0
        public static void Copy(this IBaseMessageContext ctx, ContextProperty source, ContextProperty destination)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            if (destination == null)
            {
                throw new ArgumentNullException("destination");
            }

            object sourceValue;

            if (!ctx.TryRead(source, out sourceValue))
            {
                throw new InvalidOperationException("Could not find the specified source property in BizTalk context.");
            }

            ctx.Promote(destination, sourceValue);
        }
コード例 #13
0
 public virtual void Execute(IBaseMessageContext messageContext, string originalValue, ref string newValue)
 {
     if (messageContext == null)
     {
         throw new ArgumentNullException(nameof(messageContext));
     }
     if (ExtractionMode == ExtractionMode.Write)
     {
         if (_logger.IsDebugEnabled)
         {
             _logger.DebugFormat("Writing property {0} with value {1} to context.", PropertyName, originalValue);
         }
         messageContext.Write(PropertyName.Name, PropertyName.Namespace, originalValue);
     }
     else if (ExtractionMode == ExtractionMode.Promote)
     {
         if (_logger.IsDebugEnabled)
         {
             _logger.DebugFormat("Promoting property {0} with value {1} to context.", PropertyName, originalValue);
         }
         messageContext.Promote(PropertyName.Name, PropertyName.Namespace, originalValue);
     }
     else if (ExtractionMode == ExtractionMode.Demote)
     {
         var @object = messageContext.Read(PropertyName.Name, PropertyName.Namespace);
         var value   = @object.IfNotNull(o => o.ToString());
         if (!value.IsNullOrEmpty())
         {
             newValue = value;
             if (_logger.IsDebugEnabled)
             {
                 _logger.DebugFormat("Demoting property {0} with value {1} from context.", PropertyName, newValue);
             }
         }
     }
     else
     {
         base.Execute(messageContext);
     }
 }
コード例 #14
0
        public static IBaseMessageContext GetMininalContext(IPipelineContext pipelineContext, IBaseMessage message)
        {
            IBaseMessageContext outputContext = pipelineContext.GetMessageFactory().CreateMessageContext();

            foreach (var context in minMessageContext)
            {
                var value = message.Context.Read(context.Item1, context.Item2);
                if (value != null)
                {
                    var isPromoted = message.Context.IsPromoted(context.Item1, context.Item2);
                    if (isPromoted || context.Item3)
                    {
                        outputContext.Promote(context.Item1, context.Item2, value);
                    }
                    else
                    {
                        outputContext.Write(context.Item1, context.Item2, value);
                    }
                }
            }
            return(outputContext);
        }
コード例 #15
0
        private static IBaseMessageContext CloneMessageContext(IBaseMessageContext context)
        {
            IBaseMessageContext clonedContext = MessageFactory.CreateMessageContext();

            for (int i = 0; i < context.CountProperties; i++)
            {
                string propertyNamespace = String.Empty;
                string propertyName      = String.Empty;

                object value = context.ReadAt(i, out propertyName, out propertyNamespace);

                if (context.IsPromoted(propertyName, propertyNamespace))
                {
                    clonedContext.Promote(propertyName, propertyNamespace, value);
                }
                else
                {
                    clonedContext.Write(propertyName, propertyNamespace, value);
                }
            }

            return(clonedContext);
        }
コード例 #16
0
        public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            if (!Enabled)
            {
                return(pInMsg);
            }
            string errorMessage;

            if (!Validate(out errorMessage))
            {
                throw new ArgumentException(errorMessage);
            }
            IBaseMessageContext messageContext = pInMsg.Context;
            var m = Regex.Match(PropertyValuePairArray, @"{(?<contextProperty>.+?#.+?),(?<value>.+?)}");

            while (m.Success)
            {
                string contextProperty = m.Groups["contextProperty"].Value, valueToPromote = m.Groups["value"].Value;
                messageContext.Promote(new ContextProperty(contextProperty), valueToPromote);
                m = m.NextMatch();
            }
            return(pInMsg);
        }
コード例 #17
0
        public static IBaseMessageContext CloneAndExcludeESBProperties(IPipelineContext pipelineContext, IBaseMessage message)
        {
            IBaseMessageContext outputContext = pipelineContext.GetMessageFactory().CreateMessageContext();

            for (int i = 0; i < message.Context.CountProperties; i++)
            {
                var name      = string.Empty;
                var nameSpace = string.Empty;
                var value     = message.Context.ReadAt(i, out name, out nameSpace);
                if (!nameSpace.Equals(itineraryNamespace, StringComparison.InvariantCultureIgnoreCase) && value != null)
                {
                    var isPromoted = message.Context.IsPromoted(name, nameSpace);
                    if (isPromoted)
                    {
                        outputContext.Promote(name, nameSpace, value);
                    }
                    else
                    {
                        outputContext.Write(name, nameSpace, value);
                    }
                }
            }
            return(outputContext);
        }
 public static IBaseMessageContext PromoteSenderName(this IBaseMessageContext context, string senderName)
 {
     context.Promote(BizTalkFactoryProperties.SenderName, senderName);
     return(context);
 }
 public static IBaseMessageContext PromoteCorrelationToken(this IBaseMessageContext context, string correlationToken)
 {
     context.Promote(BizTalkFactoryProperties.CorrelationToken, correlationToken);
     return(context);
 }
コード例 #20
0
 public void UpdateMessageTypeContext(IBaseMessageContext context, string newNamespace, string name)
 {
     context.Promote(MessageTypeContextName, MessageTypeContextNs, string.Concat(newNamespace, "#", name));
 }
 public static IBaseMessageContext PromoteEnvironmentTag(this IBaseMessageContext context, string environmentTag)
 {
     context.Promote(BizTalkFactoryProperties.EnvironmentTag, environmentTag);
     return(context);
 }
 public static IBaseMessageContext PromoteCorrelationId(this IBaseMessageContext context, string correlationId)
 {
     context.Promote(Subscribable.BizTalkFactoryProperties.CorrelationId, correlationId);
     return(context);
 }
コード例 #23
0
        /// <summary>
        /// Updates the BizTalk BaseMessage and Message Context with any new or modified values from the executed BRE Policies.
        /// </summary>
        /// <param name="msgCtxt">BizTalk BaseMessage Context value collection to update</param>
        /// <param name="bre">BRE Descriptor with possible values to read for updating the Message context</param>
        /// <param name="pCtxt">PipelineContext</param>
        /// <param name="baseMsg">BizTalk BaseMessage to update</param>
        private static void UpdateContextProperties(MessageContextFactRetriever msgCtxt, BRE bre, IPipelineContext pCtxt, ref IBaseMessage baseMsg)
        {
            try
            {
                if (pCtxt == null || baseMsg == null)
                {
                    return;
                }
                IBaseMessageContext baseMsgCtxt = baseMsg.Context;
                foreach (var updatedCtxt in msgCtxt.GetDictionaryCollection())
                {
                    string[] NameNameSpaceValues = updatedCtxt.Key.Split('#');

                    // no need to check for old values just overwrite and add
                    // Check to see if we need to promote it
                    string name            = NameNameSpaceValues[1];
                    bool   shouldPromote   = name.Contains("!");
                    bool   isDistinguished = name.Contains("/");

                    string namesp = NameNameSpaceValues[0];

                    // check to determine if we should promote and not distinguished
                    if (shouldPromote && !isDistinguished)
                    {
                        string correctName = name;

                        // remove ! char from key name before promoting
                        if (shouldPromote)
                        {
                            correctName = name.Substring(0, name.Length - 1);
                        }

                        // however check to see if already promoted or not
                        bool isAlreadyPromoted = false;
                        var  ovalue            = baseMsgCtxt.Read(correctName, namesp);
                        if (ovalue != null)
                        {
                            isAlreadyPromoted = baseMsgCtxt.IsPromoted(correctName, namesp);
                        }

                        if (ovalue != null && isAlreadyPromoted)
                        {
                            // we need to remove and re - promote
                            baseMsgCtxt.Write(correctName, namesp, null);
                            baseMsgCtxt.Promote(correctName, namesp, null);
                            baseMsgCtxt.Promote(correctName, namesp, updatedCtxt.Value);
                        }
                        else
                        {
                            // it's not already promoted and we should promote if we can,
                            // this assumes there is a valid property schema, name, and data type associated with it for promotion validation...
                            // dangerous operation which could cause cyclic loop by re-promoting a property that was slated to be demoted *wasPromote*...
                            if (bre.useRepromotionSpecified)
                            {
                                if (bre.useRepromotion)
                                {
                                    try
                                    {
                                        baseMsgCtxt.Write(correctName, namesp, null);
                                        baseMsgCtxt.Promote(correctName, namesp, null);
                                        baseMsgCtxt.Promote(correctName, namesp, updatedCtxt.Value);
                                    }
                                    catch (Exception ex)
                                    {
                                        EventLogger.LogMessage(
                                            string.Format(
                                                "Namespace: {0}\nName: {1}\n caused an exception:\n{2}\nThis item was not promoted.",
                                                namesp, correctName, ex.Message), EventLogEntryType.Error, 1000);
                                    }
                                }
                            }
                        }
                    }
                    else if (shouldPromote && isDistinguished)
                    {
                        // can't promote a distinguished field that contains a "/" in it's name, there's no way for BizTalk to validate it using normal BizTalk Property Schemas...
                        // do nothing.
                    }
                    else if (isDistinguished)
                    {
                        // We don't need to promote it, only write it (Distinguished)
                        // we need to remove and re-write it
                        baseMsgCtxt.Write(name, namesp, null);
                        baseMsgCtxt.Write(name, namesp, updatedCtxt.Value);
                    }
                    //else niether promote nore write so do nothing...
                }
                pCtxt.ResourceTracker.AddResource(baseMsgCtxt);
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry("BRE_ResolverProvider::UpdateContextProperties", ex.ToString(),
                                    EventLogEntryType.Error, 10000);
                throw;
            }
        }
 public static IBaseMessageContext PromoteReceiverName(this IBaseMessageContext context, string receiverName)
 {
     context.Promote(BizTalkFactoryProperties.ReceiverName, receiverName);
     return(context);
 }
コード例 #25
0
 public void UpdateMessageTypeContext(IBaseMessageContext context, string newNamespace, string name)
 {
     context.Promote(MessageTypeContextName, MessageTypeContextNs, string.Concat(newNamespace, "#", name));
 }
コード例 #26
0
 public static void Promote(this IBaseMessageContext ctx, ContextProperty property, object val)
 {
     ctx.Promote(property.Name, property.Namespace, val);
 }
コード例 #27
0
 public static void Promote <T, TV>(this IBaseMessageContext context, MessageContextProperty <T, TV> property, TV value)
     where T : MessageContextPropertyBase, new()
     where TV : struct
 {
     context.Promote(property.Name, property.Namespace, value);
 }
コード例 #28
0
 public static void SetPrimaryCorrelationId(this IBaseMessageContext source, Guid primaryCorrelationId)
 {
     source.Promote(PrimaryCorrelationId_propertyName, PrimaryCorrelationId_propertyNs, primaryCorrelationId.ToString());
 }