Ejemplo n.º 1
0
        public static TrackingIdHeader Read(MessageHeaders messageHeaders)
        {
            TrackingIdHeader trackingIdHeader;

            if (!TrackingIdHeader.TryRead(messageHeaders, out trackingIdHeader))
            {
                throw new ArgumentException(SRClient.TrackingIDHeaderMissing, "messageHeaders");
            }
            return(trackingIdHeader);
        }
Ejemplo n.º 2
0
        internal static string GetTrackingId(MessageProperties messageProperties, MessageHeaders messageHeaders, WebOperationContext webOperationContext)
        {
            string id;
            TrackingIdMessageProperty trackingIdMessageProperty;
            TrackingIdHeader          trackingIdHeader;

            if (!TrackingIdMessageProperty.TryGet <TrackingIdMessageProperty>(messageProperties, out trackingIdMessageProperty))
            {
                string str = null;
                if (webOperationContext != null)
                {
                    str = webOperationContext.IncomingRequest.Headers.Get("TrackingId");
                }
                if (TrackingIdHeader.TryRead(messageHeaders, out trackingIdHeader))
                {
                    id = trackingIdHeader.Id;
                }
                else if (messageHeaders.RelatesTo != null)
                {
                    Guid trackingId = TrackingContext.GetTrackingId(messageHeaders.RelatesTo);
                    id = TrackingContext.AppendRoleInstanceInformationToTrackingId(trackingId.ToString());
                }
                else if (messageHeaders.MessageId != null)
                {
                    Guid guid = TrackingContext.GetTrackingId(messageHeaders.MessageId);
                    id = TrackingContext.AppendRoleInstanceInformationToTrackingId(guid.ToString());
                }
                else if (string.IsNullOrEmpty(str))
                {
                    Guid guid1 = Guid.NewGuid();
                    id = TrackingContext.AppendRoleInstanceInformationToTrackingId(guid1.ToString());
                }
                else
                {
                    id = TrackingContext.AppendRoleInstanceInformationToTrackingId(str);
                }
                TrackingIdMessageProperty.TryAdd(messageProperties, id);
            }
            else
            {
                id = trackingIdMessageProperty.Id;
            }
            return(id);
        }
Ejemplo n.º 3
0
        public static bool TryRead(MessageHeaders messageHeaders, out TrackingIdHeader trackingIdHeader)
        {
            trackingIdHeader = null;
            if (messageHeaders == null)
            {
                return(false);
            }
            int num = messageHeaders.FindHeader("TrackingId", "http://schemas.microsoft.com/servicebus/2010/08/protocol/");

            if (num >= 0)
            {
                using (XmlDictionaryReader readerAtHeader = messageHeaders.GetReaderAtHeader(num))
                {
                    readerAtHeader.ReadStartElement();
                    trackingIdHeader = new TrackingIdHeader(readerAtHeader.ReadString());
                }
            }
            return(trackingIdHeader != null);
        }
Ejemplo n.º 4
0
        public static bool TryAddOrUpdate(MessageHeaders messageHeaders, string trackingId)
        {
            if (messageHeaders == null)
            {
                return(false);
            }
            TrackingIdHeader trackingIdHeader = new TrackingIdHeader(trackingId);
            int num = messageHeaders.FindHeader("TrackingId", "http://schemas.microsoft.com/servicebus/2010/08/protocol/");

            if (num < 0)
            {
                messageHeaders.Add(trackingIdHeader);
            }
            else
            {
                messageHeaders.RemoveAt(num);
                messageHeaders.Add(trackingIdHeader);
            }
            return(true);
        }