public static string GetProperty <T>(this XLANGMessage message, MessageContextProperty <T, string> property)
            where T : MessageContextPropertyBase, new()
        {
            var value = message.GetPropertyValue(property.Type);

            return((string)value);
        }
        public static TR?GetProperty <T, TR>(this XLANGMessage message, MessageContextProperty <T, TR> property)
            where T : MessageContextPropertyBase, new()
            where TR : struct
        {
            var value = message.GetPropertyValue(property.Type);

            return((TR?)value);
        }
        /// <summary>
        /// Reads a property in the context of the message
        /// </summary>
        /// <typeparam name="TContextProperty">Type of the target property</typeparam>
        /// <typeparam name="TExpected">Expected type of the value</typeparam>
        /// <param name="message">BizTalk pipeline message</param>
        /// <param name="isMandatory">Indication if it is mandatory for the property to be present</param>
        /// <returns>Value from the property, if present</returns>
        /// <exception cref="BizTalk.Extended.Core.Exceptions.ContextPropertyNotFoundException">Thrown when a mandatory property is not present</exception>
        public static TExpected ReadContextProperty <TContextProperty, TExpected>(this XLANGMessage message, bool isMandatory) where TContextProperty : MessageContextPropertyBase, new()
        {
            Guard.NotNull(message, "message");

            object value = message.GetPropertyValue(typeof(TContextProperty));

            if (value == null && isMandatory)
            {
                var propertyInstance = new TContextProperty();
                throw new ContextPropertyNotFoundException(propertyInstance.Name.Name, propertyInstance.Name.Namespace);
            }

            return(ContextPropertySerializer.DeserializeFromContextPropertyValue <TExpected>(value));
        }
Beispiel #4
0
        /// <summary>
        /// Gets XLANG message context property
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="prop"></param>
        /// <returns></returns>
        private static string GetMsgProperty(XLANGMessage msg, Type prop)
        {
            if (msg == null)
            {
                throw new System.ArgumentNullException("msg");
            }
            if (null == prop)
            {
                throw new System.ArgumentNullException("prop");
            }
            object obj    = null;
            string result = string.Empty;

            try
            {
                obj = msg.GetPropertyValue(prop);
                if (obj != null)
                {
                    result = obj.ToString();
                }
            }
            catch (InvalidPropertyTypeException ex)
            {
                Logger.WriteWarning(ex.ToString(), 14000);
            }
            catch (Exception ex)
            {
                Logger.WriteError(ex.ToString(), 14000);
                throw ex;
            }
            finally
            {
                if (obj != null)
                {
                    obj = null;
                }
            }
            return(result);
        }
Beispiel #5
0
 public static bool IsHeaderExist(XLANGMessage message, Type type)
 {
     return(message.GetPropertyValue(type) != null);
 }
Beispiel #6
0
        /// <summary>
        /// Clears the properties set for the original WCF transport
        /// </summary>
        /// <param name="outboundMessage">The message which will have its context cleared for the original adapter properties</param>
        private static void ClearOriginalWCFAdapterProperties(XLANGMessage outboundMessage)
        {
            System.Diagnostics.Debug.WriteLine("ClearOriginalTransportProperties(outboundMessage) called.");

            try
            {
                if (outboundMessage.GetPropertyValue(typeof(WCF.AffiliateApplicationName)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.AffiliateApplicationName), string.Empty);
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.ClientCertificate)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.ClientCertificate), string.Empty);
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.Identity)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.Identity), string.Empty);
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.IsolationLevel)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.IsolationLevel), string.Empty);
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.MessageClientCredentialType)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.MessageClientCredentialType), "None");
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.ProxyAddress)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.ProxyAddress), string.Empty);
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.ProxyUserName)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.ProxyUserName), string.Empty);
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.ProxyPassword)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.ProxyPassword), string.Empty);
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.ProxyToUse)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.ProxyToUse), "None");
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.ReplyToAddress)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.ReplyToAddress), string.Empty);
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.ReferencedBindings)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.ReferencedBindings), string.Empty);
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.To)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.To), string.Empty);
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.SecurityMode)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.SecurityMode), "None");
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.TransportProtectionLevel)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.TransportProtectionLevel), "None");
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.UserName)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.UserName), string.Empty);
                }

                if (outboundMessage.GetPropertyValue(typeof(WCF.Password)) != null)
                {
                    outboundMessage.SetPropertyValue(typeof(WCF.Password), string.Empty);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(
                    "ClearOriginalTransportProperties() failed with exception: "
                    + ex.Message);
            }
        }
        }//Pipeline Business Layer

        public void StartActivity(XLANGMessage unConstructedXMessage, XLANGMessage constructedXMessage, string interfaceName, string stageName, string EventID)
        {
            Interface items = new Interface();

            items = readConfigOrch(interfaceName);

            foreach (var stage in items.stages)
            {
                if (stage.stageName == stageName)
                {
                    if (stage.startActivity == true)
                    {
                        //If tracking id is not already present create a new tracking id.
                        if (constructedXMessage.GetPropertyValue(typeof(Kovai.AtomicScope.TrackingSchema.StageActivityId)) == null)
                        {
                            _activityInfo.ActivityId = Guid.NewGuid().ToString();

                            unConstructedXMessage.SetPropertyValue(typeof(Kovai.AtomicScope.TrackingSchema.StageActivityId), _activityInfo.ActivityId.ToString());
                        }


                        //Otherwise use the tracking id which is already present in the message context
                        else
                        {
                            _activityInfo.ActivityId = (string)constructedXMessage.GetPropertyValue(typeof(Kovai.AtomicScope.TrackingSchema.StageActivityId));
                        }

                        //Create a new activity id on start activity method and write it to message context.
                        //_activityInfo.ActivityId = Guid.NewGuid().ToString();
                        _activityInfo.EventId = EventID;
                        unConstructedXMessage.SetPropertyValue(typeof(Kovai.AtomicScope.TrackingSchema.StageActivityId), _activityInfo.ActivityId.ToString());
                        _activityInfo.StartTime = DateTime.UtcNow;

                        //When we start the activity the previous stage will be set to "."
                        if (constructedXMessage.GetPropertyValue(typeof(Kovai.AtomicScope.TrackingSchema.PreviousStage)) == null)
                        {
                            _activityInfo.PreviousStage = ".";
                        }
                        else
                        {
                            _activityInfo.PreviousStage = (string)constructedXMessage.GetPropertyValue(typeof(Kovai.AtomicScope.TrackingSchema.CurrentStage));
                        }
                        unConstructedXMessage.SetPropertyValue(typeof(Kovai.AtomicScope.TrackingSchema.PreviousStage), _activityInfo.PreviousStage);
                        unConstructedXMessage.SetPropertyValue(typeof(Kovai.AtomicScope.TrackingSchema.CurrentStage), stageName);

                        if (stage.archiveMessagePayloadDB == true)
                        {
                            _activityInfo.ArchiveId = Guid.NewGuid().ToString();
                            // ArchiveMessage(inMsg, stage, _activityInfo);
                        }
                        else
                        {
                            _activityInfo.ArchiveId = null;
                        }

                        _activityInfo.InterfaceName = interfaceName;

                        _activityInfo.CurrentStage = stageName;

                        _activityInfo.StartTime = DateTime.UtcNow;
                        ArchiveMessageXlang(constructedXMessage, stage, _activityInfo);
                        _activityInfo.customTrackData = stage.customTrackData;
                        getCustomPropertiesOrch(constructedXMessage, _activityInfo.customTrackData);
                        StartActivity(_activityInfo);//DataLayerCall
                    }
                }
            }
        }//Orchestration Business Layer