Example #1
0
        private static string GetTrackingId(IDictionary <string, object> requestProperties, IDictionary <string, string> requestHeaders)
        {
            TrackingIdMessageProperty trackingIdMessageProperty;
            string trackingId;

            if (!TrackingIdMessageProperty.TryGet <TrackingIdMessageProperty>(requestProperties, out trackingIdMessageProperty))
            {
                if (!TrackingContext.TryGetHeader(requestHeaders, "TrackingId", out trackingId))
                {
                    if (!requestHeaders.ContainsKey("MessageId"))
                    {
                        Guid guid = Guid.NewGuid();
                        trackingId = TrackingContext.AppendRoleInstanceInformationToTrackingId(guid.ToString());
                        TrackingIdMessageProperty.TryAdd(requestProperties, trackingId);
                    }
                    else
                    {
                        UniqueId uniqueId    = new UniqueId(requestHeaders["MessageId"]);
                        Guid     trackingId1 = TrackingContext.GetTrackingId(uniqueId);
                        trackingId = TrackingContext.AppendRoleInstanceInformationToTrackingId(trackingId1.ToString());
                    }
                }
                TrackingIdMessageProperty.TryAdd(requestProperties, trackingId);
            }
            else
            {
                trackingId = trackingIdMessageProperty.Id;
            }
            return(trackingId);
        }
        public static TrackingIdMessageProperty Read(IDictionary <string, object> messageProperties)
        {
            TrackingIdMessageProperty trackingIdMessageProperty;

            if (!TrackingIdMessageProperty.TryGet <TrackingIdMessageProperty>(messageProperties, out trackingIdMessageProperty))
            {
                throw new ArgumentException(SRClient.TrackingIDPropertyMissing, "messageProperties");
            }
            return(trackingIdMessageProperty);
        }
        public static bool TryAdd(IDictionary <string, object> messageProperties, string trackingId)
        {
            TrackingIdMessageProperty trackingIdMessageProperty;

            if (messageProperties == null || TrackingIdMessageProperty.TryGet <TrackingIdMessageProperty>(messageProperties, out trackingIdMessageProperty))
            {
                return(false);
            }
            messageProperties.Add("TrackingId", new TrackingIdMessageProperty(trackingId));
            return(true);
        }
Example #4
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);
        }