コード例 #1
0
 public void Execute(IBaseMessageContext context)
 {
     if (context.GetProperty(TrackingProperties.ProcessName).IsNullOrEmpty())
     {
         context.SetProcessName(Default.Processes.Failed);
     }
 }
        public XPathStream(XmlReader reader, Encoding encoding, SchemaMetaData schemaMetaData,IBaseMessageContext context)
        {
            m_context = context;

            m_schemaMetaData = schemaMetaData;

            xPathCollection = new XPathCollection();

            foreach (var item in m_schemaMetaData.Properties)
            {
                xPathCollection.Add(item.Key);
            }
           

            m_bodyPath = new LinkedList<string>();

            m_outputStream = new MemoryStream();

            this.m_reader = new XPathReader(reader, xPathCollection);
            

            this.m_writer = XmlWriter.Create(this.m_outputStream);

          
        }
コード例 #3
0
        /// <summary>
        /// Creates IBaseMessage object from string
        /// </summary>
        /// <param name="mf">Reference to BizTalk message factory object</param>
        /// <param name="url">Address of receive location where this message will be submitted</param>
        /// <param name="data">Payload of the message</param>
        /// <returns>BizTalk message object</returns>
        public static IBaseMessage CreateMessage(IBaseMessageFactory mf, string url, string data)
        {
            IBaseMessagePart     part = null;
            IBaseMessageContext  ctx  = null;
            IBaseMessage         msg  = null;
            SystemMessageContext smc  = null;

            // Write the data to a new stream...
            StreamWriter sw = new StreamWriter(new MemoryStream());

            sw.Write(data);
            sw.Flush();
            sw.BaseStream.Seek(0, SeekOrigin.Begin);

            // Create a new message
            msg       = mf.CreateMessage();
            part      = mf.CreateMessagePart();
            part.Data = sw.BaseStream;
            ctx       = msg.Context;
            msg.AddPart("body", part, true);

            // Set the system context properties
            smc = new SystemMessageContext(ctx);
            if (null != url)
            {
                smc.InboundTransportLocation = url;
            }

            return(msg);
        }
        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"));
        }
コード例 #5
0
        /// <summary>
        /// Creates an array of IBaseMessage objects from array of strings
        /// </summary>
        /// <param name="mf">Reference to BizTalk message factory object</param>
        /// <param name="url">Address of receive location where this message will be submitted to</param>
        /// <param name="data">Payloads for each message</param>
        /// <returns>Array of BizTalk message objects</returns>
        public static IBaseMessage[] CreateMessages(IBaseMessageFactory mf, string url, string[] data)
        {
            IBaseMessagePart    part = null;
            IBaseMessageContext ctx  = null;

            IBaseMessage[]       msgs = null;
            SystemMessageContext smc  = null;

            msgs = new IBaseMessage[data.Length];

            for (int c = 0; c < data.Length; c++)
            {
                // Write the data to a new stream...
                StreamWriter sw = new StreamWriter(new MemoryStream());
                sw.Write(data[c]);
                sw.Flush();
                sw.BaseStream.Seek(0, SeekOrigin.Begin);

                // Create a new message
                msgs[c]   = mf.CreateMessage();
                part      = mf.CreateMessagePart();
                part.Data = sw.BaseStream;
                ctx       = msgs[c].Context;
                msgs[c].AddPart("body", part, true);

                // Set the system context properties
                smc = new SystemMessageContext(ctx);
                if (null != url)
                {
                    smc.InboundTransportLocation = url;
                }
            }

            return(msgs);
        }
コード例 #6
0
        /// <summary>
        /// Creates IBaseMessage objects from array of streams
        /// </summary>
        /// <param name="mf">Reference to BizTalk message factory object</param>
        /// <param name="url">Address of receive location where this message will be submitted to</param>
        /// <param name="data">Payloads for each message</param>
        /// <returns>Array of BizTalk message objects</returns>
        public static IBaseMessage[] CreateMessages(IBaseMessageFactory mf, string url, Stream[] data)
        {
            IBaseMessagePart    part = null;
            IBaseMessageContext ctx  = null;

            IBaseMessage[]       msgs = null;
            SystemMessageContext smc  = null;

            msgs = new IBaseMessage[data.Length];

            for (int c = 0; c < data.Length; c++)
            {
                // Create a new message
                msgs[c]   = mf.CreateMessage();
                part      = mf.CreateMessagePart();
                part.Data = data[c];
                ctx       = msgs[c].Context;
                msgs[c].AddPart("body", part, true);

                // Set the system context properties
                smc = new SystemMessageContext(ctx);
                if (null != url)
                {
                    smc.InboundTransportLocation = url;
                }
            }

            return(msgs);
        }
 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);
     }
 }
コード例 #8
0
        public static string GetContextValue(IBaseMessageContext context, string property, string propertyNamespace)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (string.IsNullOrEmpty(property))
            {
                throw new ArgumentNullException("property");
            }
            if (string.IsNullOrEmpty(propertyNamespace))
            {
                throw new ArgumentNullException("propertyNamespace");
            }
            string str = string.Empty;

            try
            {
                object obj = context.Read(property, propertyNamespace);
                if (obj != null)
                {
                    str = obj.ToString();
                }
                return(str);
            }
            catch (Exception ex)
            {
                DECore.TraceProvider.Logger.TraceError(ex);
                return(string.Empty);
            }
        }
コード例 #9
0
        protected override void SetEndpointContextProperties(IBaseMessageContext pipelineContext, string endpointConfig)
        {
            //base.SetEndpointContextProperties(pipelineContext, endpointConfig);

            //string[] properties = endpointConfig.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries);

            //foreach (string property in properties)
            //{
            //    string[] data = property.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
            //    string key = data[0];
            //    string value = data.Length < 2 ? "" : data[1];

            //    pipelineContext.Write(key, this.AdapterContextPropertyNamespace, value);
            //}

            if (!string.IsNullOrEmpty(endpointConfig))
            {
                AdapterMgr.SetContextProperties(pipelineContext, endpointConfig, this.AdapterName, this.AdapterContextPropertyNamespace);
            }
            else
            {
                string defaultEC = this.GetDefaultEndpointConfig();
                if (!string.IsNullOrEmpty(defaultEC))
                {
                    AdapterMgr.SetContextProperties(pipelineContext, defaultEC, this.AdapterName, this.AdapterContextPropertyNamespace);
                }
            }
        }
コード例 #10
0
        private IBaseMessage BuildBTSMessage(IPipelineContext pContext, IBaseMessageContext sourceContext, List <Part> partList)
        {
            IBaseMessage     newMessage = pContext.GetMessageFactory().CreateMessage();
            IBaseMessagePart msgPart    = pContext.GetMessageFactory().CreateMessagePart();

            newMessage.Context = sourceContext;
            foreach (Part part in partList)
            {
                if (part.Data != null)
                {
                    msgPart.Charset     = "utf-8";
                    msgPart.ContentType = part.ContentType;
                    msgPart.Data        = GetPartStream(part.Data);
                    newMessage.AddPart(part.PartName, msgPart, part.IsBodyPart);
                }
                else
                {
                    System.IO.MemoryStream memStrm = new MemoryStream();
                    StreamWriter           sw      = new StreamWriter(memStrm);
                    sw.Write(part.RawData);
                    sw.Flush();
                    memStrm.Position = 0;

                    msgPart.ContentType = part.ContentType;
                    msgPart.Data        = memStrm;
                    newMessage.AddPart(part.PartName, msgPart, part.IsBodyPart);
                }
            }
            return(newMessage);
        }
        public void Execute(IBaseMessageContext context)
        {
            context.EnsureFileOutboundTransport();

            var outboundTransportLocation = context.GetProperty(BtsProperties.OutboundTransportLocation);
            var rootPath = Path.GetDirectoryName(outboundTransportLocation);

            if (rootPath.IsNullOrEmpty() && IO.Path.IsNetworkPath(outboundTransportLocation))
            {
                var fileName = Path.GetFileName(outboundTransportLocation);
                if (!fileName.IsNullOrEmpty())
                {
                    rootPath = outboundTransportLocation.Remove(outboundTransportLocation.Length - fileName.Length);
                }
            }
            if (rootPath.IsNullOrEmpty())
            {
                throw new InvalidOperationException("Root path was expected to be found in BtsProperties.OutboundTransportLocation context property.");
            }

            var subPathAndFile = context.GetProperty(BizTalkFactoryProperties.OutboundTransportLocation);

            if (subPathAndFile.IsNullOrEmpty())
            {
                throw new InvalidOperationException(
                          "Target sub path and file name were expected to be found in BizTalkFactoryProperties.OutboundTransportLocation context property.");
            }
            context.SetProperty(BtsProperties.OutboundTransportLocation, Path.Combine(rootPath !, subPathAndFile));
        }
コード例 #12
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);
        }
 public void Execute(IBaseMessageContext context)
 {
     if (context.GetProperty(TrackingProperties.ProcessName).IsNullOrEmpty())
     {
         context.SetProcessName(Factory.Areas.Batch.Processes.Release);
     }
 }
コード例 #14
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 IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            if (this.IsActive)
            {
                IBaseMessageContext myContext = pInMsg.Context;
                var inboundHttpHeaders        = (string)pInMsg.Context.Read("InboundHttpHeaders", "http://schemas.microsoft.com/BizTalk/2006/01/Adapters/WCF-properties");
                if (null == inboundHttpHeaders)
                {
                    throw new System.Security.SecurityException("Access to service denied.");
                }

                try
                {
                    var apiKey          = Components.Helpers.Security.GetApiKeyFromHttpHeaders(inboundHttpHeaders);
                    var receivePortName = (string)pInMsg.Context.Read("ReceivePortName", "http://schemas.microsoft.com/BizTalk/2003/system-properties");
                    var isValidService  = Components.Helpers.Security.IsValidService(apiKey, receivePortName);

                    if (!isValidService)
                    {
                        throw new Exception("Access to service denied.");
                    }
                }
                catch (Exception e)
                {
                    throw new System.Security.SecurityException("Access to service denied.");
                }
            }

            return(pInMsg);
        }
 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}'.");
     }
 }
 public override void Execute(IBaseMessageContext messageContext, string originalValue, ref string newValue)
 {
     if (ExtractionMode == ExtractionMode.Demote)
     {
         base.Execute(messageContext, originalValue, ref newValue);
         if (originalValue.TryParseQName(out var prefix, out _))
         {
             newValue = prefix.IsNullOrEmpty()
                                         ? newValue
                                         : prefix + ":" + newValue;
         }
         if (_logger.IsDebugEnabled)
         {
             _logger.DebugFormat("Demoting property {0} with QName value {1} from context.", PropertyName, newValue);
         }
     }
     else
     {
         if (originalValue.TryParseQName(out _, out var localPart))
         {
             originalValue = localPart;
         }
         if (_logger.IsDebugEnabled)
         {
             _logger.DebugFormat("Extracting localPart from QName value {0} from context.", originalValue);
         }
         base.Execute(messageContext, originalValue, ref newValue);
     }
 }
        public static string ToXml(this IBaseMessageContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            // cache xmlns while constructing xml infoset...
            var nsCache     = new XmlDictionary();
            var xmlDocument = new XElement(
                "context",
                Enumerable.Range(0, (int)context.CountProperties).Select(
                    i => {
                var value = context.ReadAt(i, out var name, out var ns);
                // give each property element a name of 'p' and store its actual name inside the 'n' attribute, which avoids
                // the cost of the name.IsValidQName() check for each of them as the name could be an xpath expression in the
                // case of a distinguished property
                return(name.IndexOf("password", StringComparison.OrdinalIgnoreCase) > -1
                                                        ? null
                                                        : new XElement(
                           (XNamespace)nsCache.Add(ns).Value + "p",
                           new XAttribute("n", name),
                           context.IsPromoted(name, ns) ? new XAttribute("promoted", true) : null,
                           value));
            }));

            // ... and declare/alias all of them at the root element level to minimize xml string size
            for (var i = 0; nsCache.TryLookup(i, out var xds); i++)
            {
                xmlDocument.Add(new XAttribute(XNamespace.Xmlns + "s" + xds.Key.ToString(CultureInfo.InvariantCulture), xds.Value));
            }

            return(xmlDocument.ToString(SaveOptions.DisableFormatting));
        }
コード例 #18
0
        public object Clone()
        {
            int partCount = this.PartCount;
            IBaseMessageFactory factory  = new MessageFactory();
            IBaseMessage        message  = factory.CreateMessage();
            Message             message2 = (Message)message;

            message2.messageId = this.MessageID;
            IBaseMessageContext oldCtx = this.Context;

            if (oldCtx != null)
            {
                IBaseMessageContext context2 = PipelineUtil.CloneMessageContext(oldCtx);
                message.Context = context2;
            }
            Exception errorInfo = this.GetErrorInfo();

            if (errorInfo != null)
            {
                message.SetErrorInfo(errorInfo);
            }
            string bodyPartName = this.BodyPartName;

            for (int i = 0; i < partCount; i++)
            {
                string           str2;
                IBaseMessagePart partByIndex = this.GetPartByIndex(i, out str2);
                IBaseMessagePart part        = ((MessagePart)partByIndex).CopyMessagePart(factory);
                message.AddPart(str2, part, bodyPartName == str2);
            }
            return(message);
        }
コード例 #19
0
        /// <summary>
        /// Loads a BizTalk message from the set of files exported from
        /// the BizTalk Admin Console or HAT
        /// </summary>
        /// <param name="contextFile">Path to the *_context.xml file</param>
        /// <returns>The loaded message</returns>
        /// <remarks>
        /// Context files have no type information for properties
        /// in the message context, so all properties are
        /// added as strings to the context.
        /// </remarks>
        public static IBaseMessage LoadMessage(string contextFile)
        {
            IBaseMessage        msg  = _factory.CreateMessage();
            IBaseMessageContext ctxt = _factory.CreateMessageContext();

            msg.Context = ctxt;

            XPathDocument     doc   = new XPathDocument(contextFile);
            XPathNavigator    nav   = doc.CreateNavigator();
            XPathNodeIterator props = nav.Select("//Property");

            foreach (XPathNavigator prop in props)
            {
                ctxt.Write(
                    prop.GetAttribute("Name", ""),
                    prop.GetAttribute("Namespace", ""),
                    prop.GetAttribute("Value", "")
                    );
            }

            XPathNodeIterator parts = nav.Select("//MessagePart");

            foreach (XPathNavigator part in parts)
            {
                LoadPart(msg, part, contextFile);
            }
            return(msg);
        }
コード例 #20
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);
        }
 public void ReadLocationConfiguration(IBaseMessageContext context)
 {
     string propertyNS = "http://microservicebus.biztalk";
     this.HostAddress = (string)Extract(context, "address", propertyNS, false, true);
     this.Port = (int)Extract(context, "port", propertyNS, false, true);
     this.ContentType = (string)Extract(context, "contentType", propertyNS, false, true);
 }
コード例 #22
0
        public static string GetProperty <T>(this IBaseMessageContext context, MessageContextProperty <T, string> property)
            where T : MessageContextPropertyBase, new()
        {
            var value = context.Read(property.Name, property.Namespace);

            return((string)value);
        }
コード例 #23
0
 public Context(IBaseMessageContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     _context = context;
 }
コード例 #24
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);
     }
 }
コード例 #25
0
        public static TR?GetProperty <T, TR>(this IBaseMessageContext context, MessageContextProperty <T, TR> property)
            where T : MessageContextPropertyBase, new()
            where TR : struct
        {
            var value = context.Read(property.Name, property.Namespace);

            return(value != null ? (TR?)Convert.ChangeType(value, typeof(TR)) : null);
        }
コード例 #26
0
ファイル: UnzipComponent.cs プロジェクト: choonkeun/BizTalk
        public void Disassemble(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            IBaseMessagePart bodyPart = pInMsg.BodyPart;

            if (bodyPart != null)
            {
                Stream originalStream = bodyPart.GetOriginalDataStream();

                if (originalStream != null)
                {
                    using (ZipInputStream zipInputStream = new ZipInputStream(originalStream))
                    {
                        if (_password != null && _password.Length > 0)
                        {
                            zipInputStream.Password = _password;
                        }

                        ZipEntry entry = zipInputStream.GetNextEntry();

                        while (entry != null)
                        {
                            MemoryStream memStream = new MemoryStream();
                            byte[]       buffer    = new Byte[1024];

                            int bytesRead = 1024;
                            while (bytesRead != 0)
                            {
                                bytesRead = zipInputStream.Read(buffer, 0, buffer.Length);
                                memStream.Write(buffer, 0, bytesRead);
                            }

                            string fileName  = entry.FileName.ToString();   //file name in zip file
                            string extension = Path.GetExtension(fileName);

                            IBaseMessage outMessage;
                            outMessage = pContext.GetMessageFactory().CreateMessage();
                            outMessage.AddPart("Body", pContext.GetMessageFactory().CreateMessagePart(), true);
                            memStream.Position       = 0;
                            outMessage.BodyPart.Data = memStream;


                            IBaseMessageContext context = pInMsg.Context;
                            string receivePortName      = context.Read("ReceivePortName", "http://schemas.microsoft.com/BizTalk/2003/system-properties").ToString();
                            string fullPath             = context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties").ToString();
                            string filePath             = Path.GetDirectoryName(fullPath);

                            outMessage.Context = PipelineUtil.CloneMessageContext(pInMsg.Context);
                            outMessage.Context.Promote("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", fileName);
                            outMessage.Context.Promote("ReceivePortName", "http://schemas.microsoft.com/BizTalk/2003/system-properties", receivePortName);

                            _qOutMessages.Enqueue(outMessage);

                            entry = zipInputStream.GetNextEntry();
                        }
                    }
                }
            }
        }
 private object Extract(IBaseMessageContext context, string prop, string propNS, object fallback, bool isRequired)
 {
     Object o = context.Read(prop, propNS);
     if (!isRequired && null == o)
         return fallback;
     if (null == o)
         throw new NoSuchProperty(propNS + "#" + prop);
     return o;
 }
        public static void EnsureSftpOutboundTransport(this IBaseMessageContext context)
        {
            var outboundTransportClassId = context.GetProperty(BtsProperties.OutboundTransportCLSID).IfNotNullOrEmpty(g => new Guid(g));

            if (outboundTransportClassId != SftpAdapterOutboundTransportClassId)
            {
                throw new InvalidOperationException("Outbound SFTP transport is required on this leg of the message exchange pattern.");
            }
        }
コード例 #29
0
        public static bool TryRead(this IBaseMessageContext ctx, ContextProperty property, out object val)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            return((val = ctx.Read(property.PropertyName, property.PropertyNamespace)) != null);
        }
コード例 #30
0
 public ITransformFixtureInputSetup Context(IBaseMessageContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     MessageContext = context;
     return(this);
 }
コード例 #31
0
 public ITransformStream ExtendWith(IBaseMessageContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     _context = context;
     return(this);
 }
コード例 #32
0
        public static object Read(this IBaseMessageContext ctx, ContextProperty property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            return(ctx.Read(property.PropertyName, property.PropertyNamespace));
        }
コード例 #33
0
 public void UpdateMessageTypeContext(IBaseMessageContext context, string newNamespace, string name)
 {
     context.Promote(MessageTypeContextName, MessageTypeContextNs, string.Concat(newNamespace, "#", name));
 }