Beispiel #1
0
 /// <summary>
 /// Sets XLANG message context property
 /// </summary>
 /// <param name="msg"></param>
 /// <param name="prop"></param>
 /// <param name="value"></param>
 private static void SetMsgProperty(XLANGMessage msg, Type prop, object value)
 {
     if (msg == null)
     {
         throw new System.ArgumentNullException("msg");
     }
     if (null == prop)
     {
         throw new System.ArgumentNullException("prop");
     }
     if (value == null)
     {
         throw new System.ArgumentNullException("value");
     }
     try
     {
         msg.SetPropertyValue(prop, value);
     }
     catch (InvalidPropertyTypeException ex)
     {
         Logger.WriteWarning(ex.ToString(), 14000);
     }
     catch (Microsoft.XLANGs.Core.PropertyUpdateDisallowedException ex)
     {
         Logger.WriteWarning(ex.ToString(), 14000);
     }
     catch (Exception ex)
     {
         Logger.WriteError(ex.ToString(), 14000);
         throw ex;
     }
 }
 public static void SetProperty <T>(this XLANGMessage message, MessageContextProperty <T, string> property, string value)
     where T : MessageContextPropertyBase, new()
 {
     if (value != null)
     {
         message.SetPropertyValue(property.Type, value);
     }
 }
        /// <summary>
        /// Writes to the context of the message
        /// </summary>
        /// <typeparam name="TContextProperty">Type of the target property</typeparam>
        /// <param name="message">BizTalk pipeline message</param>
        /// <param name="value">Requested value of the property</param>
        public static void WriteContextProperty <TContextProperty>(this XLANGMessage message, object value) where TContextProperty : MessageContextPropertyBase, new()
        {
            Guard.NotNull(message, "message");

            object actualValue = ContextPropertySerializer.SerializeToContextPropertyValue <TContextProperty>(value);

            message.SetPropertyValue(typeof(TContextProperty), actualValue);
        }
 public static void DeleteProperty <T>(this XLANGMessage message, MessageContextProperty <T, object> property)
     where T : MessageContextPropertyBase, new()
 {
     message.SetPropertyValue(property.Type, null);
 }
 public static void SetProperty <T, TV>(this XLANGMessage message, MessageContextProperty <T, TV> property, TV value)
     where T : MessageContextPropertyBase, new()
     where TV : struct
 {
     message.SetPropertyValue(property.Type, value);
 }
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);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Applies the TransMock transport configuration to the context of the provided message
        /// </summary>
        /// <param name="outboundMessage">The outbound message instance that is to be sent over the dynamic send port</param>
        /// <param name="customBehaviorConfig">A string representing the custom behavior configuration</param>
        private static void ApplyMockTransportConfig(XLANGMessage outboundMessage, string customBehaviorConfig)
        {
            // Adding the mock binding properties to tme message context
            outboundMessage.SetPropertyValue(typeof(WCF.BindingType), "mockBinding");
            outboundMessage.SetPropertyValue(
                typeof(WCF.BindingConfiguration),
                @"<binding name=""mockBinding"" Encoding=""UTF-8"" />");
            outboundMessage.SetPropertyValue(typeof(WCF.Action), "*");

            if (string.IsNullOrEmpty(customBehaviorConfig))
            {
                outboundMessage.SetPropertyValue(
                    typeof(WCF.EndpointBehaviorConfiguration),
                    @"<behavior name=""EndpointBehavior"" />");
            }
            else
            {
                outboundMessage.SetPropertyValue(
                    typeof(WCF.EndpointBehaviorConfiguration),
                    customBehaviorConfig);
            }

            outboundMessage.SetPropertyValue(typeof(WCF.OutboundBodyLocation), "UseTemplate");
            outboundMessage.SetPropertyValue(
                typeof(WCF.OutboundXmlTemplate),
                @"<bts-msg-body xmlns=""http://www.microsoft.com/schemas/bts2007"" encoding=""base64""/>");

            outboundMessage.SetPropertyValue(typeof(WCF.InboundBodyLocation), @"UseBodyPath");
            outboundMessage.SetPropertyValue(typeof(WCF.InboundBodyPathExpression), @"/MessageContent");
            outboundMessage.SetPropertyValue(typeof(WCF.InboundNodeEncoding), @"Base64");
            outboundMessage.SetPropertyValue(typeof(WCF.PropagateFaultMessage), true);

            outboundMessage.SetPropertyValue(typeof(WCF.UseSSO), false);
            outboundMessage.SetPropertyValue(typeof(WCF.EnableTransaction), false);
        }
        }//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