Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <summary>
        /// Get message context
        /// </summary>
        /// <param name="contextProperty"></param>
        /// <param name="msgContext"></param>
        /// <returns></returns>
        private string GetMessageContextItemValue(string serializedContextProperty, IBaseMessageContext msgContext)
        {
            MessageContextDescription msgContextDes = (MessageContextDescription)SerializeToObject(typeof(MessageContextDescription), serializedContextProperty);

            if (!string.IsNullOrEmpty(msgContextDes.PropertyName) && !string.IsNullOrEmpty(msgContextDes.PropertyNamespace))
            {
                return(ReadProperty(msgContext, msgContextDes.PropertyName, msgContextDes.PropertyNamespace));
            }
            return(string.Empty);
        }