Esempio n. 1
0
 public static void AppendScenarios(StringBuilder keyNameString, ContextProperty cp)
 {
     foreach (Scenario s in cp.Scenarios)
     {
         keyNameString.Append(InstanceUtils.BuildSegmentScenarioName(s)).Append(Environment.NewLine);
     }
 }
Esempio n. 2
0
        public void Test_FromXml_CreateCurrentForPeriod()
        {
            TestContextProperty tcp = new TestContextProperty();

            tcp.ContextID       = "current_ForPeriod";
            tcp.EntitySchema    = "http://www.aucent.com/test";
            tcp.EntityValue     = "Aucent Corporation";
            tcp.PeriodStartDate = new DateTime(2004, 1, 15);
            tcp.PeriodEndDate   = new DateTime(2004, 7, 31);
            tcp.PeriodType      = Element.PeriodType.duration;

            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("root");

            doc.AppendChild(root);

            XmlElement          elem       = tcp.Append(doc, root, null);
            XmlNamespaceManager theManager = new XmlNamespaceManager(doc.NameTable);

            theManager.AddNamespace("link2", "http://www.xbrl.org/2003/instance");

            ArrayList       errors = null;
            ContextProperty cpBack = null;

            Assert.IsTrue(ContextProperty.TryCreateFromXml(elem, theManager, out cpBack, ref errors), errors.Count > 0 ? ((ParserMessage)errors[0]).Message : string.Empty);

            Assert.IsTrue(tcp.ValueEquals(cpBack), "objects don't match");
        }
Esempio n. 3
0
        public bool ReportingPeriodEquals(ContextProperty cp)
        {
            if (this.MyContextProperty == null)
            {
                if (cp != null)
                {
                    return(false);
                }

                if (cp == null)
                {
                    return(true);
                }
            }

            if (this.MyContextProperty == cp)
            {
                return(true);
            }
            if (this.MyContextProperty.PeriodType != cp.PeriodType)
            {
                return(false);
            }
            if (this.MyContextProperty.PeriodStartDate != cp.PeriodStartDate)
            {
                return(false);
            }
            if (this.MyContextProperty.PeriodEndDate != cp.PeriodEndDate)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
        public void SegVsScenarioScenarioWins()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddSegment("key1", "key1", "key1", "key1");
            cp1.PeriodType      = Element.PeriodType.duration;
            cp1.PeriodStartDate = new DateTime(2000, 1, 1);
            cp1.PeriodEndDate   = new DateTime(2000, 1, 2);

            cp2.AddScenario("key2", "key2", "key2", "key2");
            cp2.PeriodType      = Element.PeriodType.duration;
            cp2.PeriodStartDate = new DateTime(2000, 1, 1);
            cp2.PeriodEndDate   = new DateTime(2000, 1, 2);

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper("key1", cp1);
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper("key2", cp2);

            // no segments before segments
            Assert.AreEqual(-1, CompareSegments(cuw1.contextRef.Segments, cuw2.contextRef.Segments), "segments are not equal");
            Assert.AreEqual(0, CompareDates(cuw1, cuw2), "dates are not equal");

            // no scenario before scenario
            Assert.AreEqual(-1, CompareScenarios(cuw2.contextRef.Scenarios, cuw1.contextRef.Scenarios), "scenario 1 sort wrong");

            Assert.AreEqual(-1, Compare(cuw2, cuw1), "1 sort wrong");
            Assert.AreEqual(1, Compare(cuw1, cuw2), "2 sort wrong");
        }
Esempio n. 5
0
        public void Test_FromXml_MissingPeriod()
        {
            TestContextProperty tcp = new TestContextProperty();

            tcp.ContextID    = "current_ForPeriod";
            tcp.EntitySchema = "http://www.aucent.com/test";
            //tcp.EntityValue = "Aucent Corporation";
//			tcp.PeriodStartDate = new DateTime( 2004, 1, 15 );
//			tcp.PeriodEndDate = new DateTime( 2004, 7, 31 );
            tcp.PeriodType = Element.PeriodType.duration;

            tcp.Scenarios.Add(new Scenario("name", "MA", "residence", "fid", "http://www.someInsuranceCo.com/scenarios"));
            tcp.Scenarios.Add(new Scenario("name2", "true", "nonSmoker", "fid", "http://www.someInsuranceCo.com/scenarios"));
            tcp.Scenarios.Add(new Scenario("name3", "34", "minAge", "fid", "http://www.someInsuranceCo.com/scenarios"));
            tcp.Scenarios.Add(new Scenario("name4", "49", "maxAge", "fid", "http://www.someInsuranceCo.com/scenarios"));

            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("root");

            doc.AppendChild(root);

            XmlElement          elem       = tcp.Append(doc, root, null);
            XmlNamespaceManager theManager = new XmlNamespaceManager(doc.NameTable);

            theManager.AddNamespace("link2", "http://www.xbrl.org/2003/instance");

            ArrayList       errors = null;
            ContextProperty cpBack = null;

            Assert.IsFalse(ContextProperty.TryCreateFromXml(elem, theManager, out cpBack, ref errors), errors.Count > 0 ? ((ParserMessage)errors[0]).Message : string.Empty);
        }
Esempio n. 6
0
        private string GetFileName(IBaseMessagePart part)
        {
            var    receivedFileNameProperty = new ContextProperty(FileProperties.ReceivedFileName);
            var    receivedFileName         = part.PartProperties.Read(receivedFileNameProperty.PropertyName, receivedFileNameProperty.PropertyNamespace) as string;
            string fileName;
            string extension = string.Empty;

            if (!string.IsNullOrEmpty(receivedFileName))
            {
                fileName = receivedFileName;
            }
            else
            {
                if (!string.IsNullOrEmpty(part.ContentType))
                {
                    extension = MimeUtils.GetFileExtensionForMimeType(part.ContentType);
                }
                else if (!string.IsNullOrEmpty(DefaultZipEntryFileExtension))
                {
                    extension = string.Concat(".", DefaultZipEntryFileExtension);
                }


                fileName = Guid.NewGuid() + extension;
            }

            return(fileName);
        }
Esempio n. 7
0
        public void SimpleCompareTestWithSegment()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.PeriodType = Element.PeriodType.duration;
            cp1.AddSegment("key1", "key1", "key1", "key1");

            cp2.PeriodType = Element.PeriodType.instant;

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper("key1", cp1);
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper("key2", cp2);

            Assert.AreEqual(-1, Compare(cuw2, cuw1), "1 sort wrong");
            Assert.AreEqual(1, Compare(cuw1, cuw2), "2 sort wrong");

            ArrayList test = new ArrayList();

            test.Add(cuw1);
            test.Add(cuw2);

            test.Sort(new SortByDurationFirst());

            Assert.AreEqual(cuw2.KeyName, ((MergedContextUnitsWrapper)test[0]).KeyName);
        }
Esempio n. 8
0
        /// <summary>
        /// Method which updates, or adds a new name value property into the Message Context value collection
        /// </summary>
        /// <typeparam name="T">Type of property value.</typeparam>
        /// <param name="propName">Name of the property to create or update</param>
        /// <param name="propNamespace">Namespace of the property to create or update</param>
        /// <param name="value">Value of the property - name and namespace to be created or updated with</param>
        /// <param name="promote">Boolean value to determine if the property should be Property Promoted (which follows all the BizTalk Proper rules for property promotion), or distinguished. True means to property promote, which also means the namespace, name and value must adhere to the BizTalk proper rules for property promotion. This includes, an existing property schema, matching schema namespace, and 255 character limitation of a string data type, and other BizTalk Proper validation procedures.</param>
        public void SetProperty <T>(string propName, string propNamespace, T value, bool promote)
        {
            if (string.IsNullOrEmpty(propName) == true || string.IsNullOrEmpty(propNamespace) == true)
            {
                return;
            }

            string key = string.Format("{0}#{1}", propNamespace, propName);

            try
            {
                // create a context property
                ContextProperty prop = new ContextProperty()
                {
                    Name      = propName,
                    Namespace = propNamespace,
                    Value     = value.ToString(),
                    Promote   = promote,
                    Dirty     = true
                };
                // add or update property in the dictionary
                if (contextProperties.ContainsKey(key) == false)
                {
                    contextProperties.Add(key, prop);
                }
                else
                {
                    contextProperties[key] = prop;
                }
            }
            catch (Exception ex)
            {
                TraceProvider.Logger.TraceInfo("Error setting context property {0}: {1}", key, ex.Message);
            }
        }
Esempio n. 9
0
        public void DateTest()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.PeriodType      = Element.PeriodType.duration;
            cp1.PeriodStartDate = new DateTime(2006, 1, 1);
            cp1.PeriodEndDate   = new DateTime(2006, 3, 31);

            cp2.PeriodType      = Element.PeriodType.duration;
            cp2.PeriodStartDate = new DateTime(2006, 4, 1);
            cp2.PeriodEndDate   = new DateTime(2006, 6, 30);

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper("key1", cp1);
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper("key2", cp2);

            /// x == y -> 0
            /// x > y -> 1
            /// x < y -> -1

            ArrayList arrg = new ArrayList();

            arrg.Add(cuw2);
            arrg.Add(cuw1);
            arrg.Sort(new SortByDurationFirst());

            Assert.AreEqual(cp2.PeriodEndDate, ((MergedContextUnitsWrapper)arrg[0]).contextRef.PeriodEndDate, "index 0 wrong");
            Assert.AreEqual(cp1.PeriodEndDate, ((MergedContextUnitsWrapper)arrg[1]).contextRef.PeriodEndDate, "index 1 wrong");
        }
Esempio n. 10
0
        /// <summary>
        /// Retrieves the current entry in the Message Context Value collection if present, otherwise it returns the default value.
        /// </summary>
        /// <param name="propName">The Name of the property to retrieve</param>
        /// <param name="propNamespace">The namespace of the property name to retrieve</param>
        /// <param name="defaultValue">Default value returned if the conversion cannot be performed.</param>
        /// <returns>Value of the property.</returns>
        public T GetProperty <T>(string propName, string propNamespace, T defaultValue)
        {
            if (string.IsNullOrEmpty(propName) == true || string.IsNullOrEmpty(propNamespace) == true)
            {
                return(defaultValue);
            }

            string key = string.Format("{0}#{1}", propNamespace, propName);

            try
            {
                ContextProperty prop = null;
                if (this.contextProperties.TryGetValue(key, out prop) == true)
                {
                    if (prop.Value != null)
                    {
                        if (typeof(T).IsEnum == true)
                        {
                            return((T)Enum.Parse(typeof(T), prop.Value.ToString()));
                        }
                        else
                        {
                            return((T)Convert.ChangeType(prop.Value, typeof(T)));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TraceProvider.Logger.TraceInfo("Error retrieving context property {0}: {1}", key, ex.Message);
            }
            // return default value, if property cannot be read
            return(defaultValue);
        }
Esempio n. 11
0
        /// <summary>
        /// Gets the property value based on the context property source.
        /// </summary>
        /// <param name="inputMessage">Instance of the input message.</param>
        /// <param name="contextProperty">Instance of the context property.</param>
        /// <returns>Property value.</returns>
        private object GetPropertyValue(IBaseMessage inputMessage, ContextProperty contextProperty)
        {
            // evaluate property
            object value = null;

            switch (contextProperty.Source)
            {
            case ContextPropertySource.Literal:
                // literal value specified in the Value field
                value = contextProperty.Value;
                break;

            case ContextPropertySource.Context:
                // read the value from the message context
                value = inputMessage.Context.Read(contextProperty.Name, contextProperty.Namespace);
                break;

            case ContextPropertySource.Expression:
                // evaluate the expression defined by the context property
                var expression = new Expressions.DynamicExpression(contextProperty.Value, Expressions.ExpressionLanguage.Csharp);
                value = expression.Invoke(this.ExpressionContext);
                break;
            }
            return(value);
        }
Esempio n. 12
0
        public static void BuildSharedKeyParts(StringBuilder keyNameString, ContextProperty cp, bool includeEntityID)
        {
            if (includeEntityID)
            {
                keyNameString.Append(TraceUtility.FormatStringResource("DragonView.Data.EntityIDColon", cp.EntityValue));
                keyNameString.Append(Environment.NewLine);
            }

            foreach (Segment s in cp.Segments)
            {
                keyNameString.Append(InstanceUtils.BuildSegmentScenarioName(s)).Append(Environment.NewLine);
            }

            if (cp.PeriodType == Element.PeriodType.duration)
            {
                keyNameString.Append(string.Format("{0} - {1}",
                                                   cp.PeriodStartDate.ToString("d"),
                                                   cp.PeriodEndDate.ToString("d")));
            }
            else if (cp.PeriodType == Element.PeriodType.instant)
            {
                // instant
                keyNameString.Append(cp.PeriodStartDate.ToString("d"));
            }
            else             //forever
            {
                keyNameString.Append(TraceUtility.FormatStringResource("DragonView.Data.Forever"));
            }

            keyNameString.Append(Environment.NewLine);
        }
Esempio n. 13
0
 public MergedContextUnitsWrapper(string keyName, ContextProperty cp, UnitProperty up)
     : this(keyName, cp)
 {
     if (up != null)
     {
         this.UPS.Add(up);
     }
 }
Esempio n. 14
0
        static GameButton()
        {
            DefaultStyleKeyProperty.OverrideMetadata(
                typeof(GameButton),
                new FrameworkPropertyMetadata(typeof(GameButton)));

            ContextProperty.OverrideMetadata(
                typeof(GameButton),
                new FrameworkPropertyMetadata((o, args) => ((GameButton)o).UpdateStyleForVisualStudioBug()));
        }
Esempio n. 15
0
        private void PopulateNumeric()
        {
            Element.PeriodType periodType = Element.PeriodType.duration;
            element               = new Node(Element.CreateMonetaryElement("test", false, Element.BalanceType.credit, periodType));
            contextRef            = new ContextProperty();
            contextRef.PeriodType = periodType;

            unitRef = new UnitProperty();

            markupData = "-123.12";
        }
Esempio n. 16
0
        private ContextProperty CreateInstantContext(string id, string schema, string val, DateTime start)
        {
            ContextProperty cp = new ContextProperty();

            cp.ContextID       = id;
            cp.EntitySchema    = schema;
            cp.EntityValue     = val;
            cp.PeriodType      = Element.PeriodType.instant;
            cp.PeriodStartDate = start;
            return(cp);
        }
Esempio n. 17
0
        private void PopulateNonNumeric()
        {
            Element.PeriodType periodType = Element.PeriodType.duration;
            element               = new Node(Element.CreateElement(Element.DataTypeCode.String, "test", false, periodType));
            contextRef            = new ContextProperty();
            contextRef.PeriodType = periodType;

            unitRef = null;

            markupData = "Test Markup Data";
        }
Esempio n. 18
0
        private ContextProperty CreateDurationContext(string id, string schema, string val, DateTime start, DateTime end)
        {
            ContextProperty cp = new ContextProperty();

            cp.ContextID       = id;
            cp.EntitySchema    = schema;
            cp.EntityValue     = val;
            cp.PeriodType      = Element.PeriodType.duration;
            cp.PeriodStartDate = start;
            cp.PeriodEndDate   = end;
            return(cp);
        }
Esempio n. 19
0
        //private void CreateMsg(IPipelineContext pContext, IBaseMessageContext sourceContext, string nodeXml, string bodyPartName, ContextProperty[] propertyBag, List<Part> otherPartList)
        //{
        //    XmlDocument xDoc = new System.Xml.XmlDocument();
        //    xDoc.LoadXml(nodeXml);

        //    IBaseMessage newMsg = pContext.GetMessageFactory().CreateMessage();
        //    IBaseMessagePart bodyMsgPart = pContext.GetMessageFactory().CreateMessagePart();

        //    System.IO.MemoryStream memStrm = new MemoryStream();
        //    xDoc.PreserveWhitespace = true;
        //    xDoc.Save(memStrm);
        //    memStrm.Position = 0;
        //    memStrm.Seek(0, System.IO.SeekOrigin.Begin);
        //    bodyMsgPart.Data = memStrm;

        //    newMsg.Context = sourceContext;

        //    newMsg.AddPart(bodyPartName, bodyMsgPart, true);
        //    foreach(Part otherPart in otherPartList)
        //    {
        //        IBaseMessagePart part = pContext.GetMessageFactory().CreateMessagePart();
        //        part.Charset = "utf-8";
        //        part.ContentType = otherPart.ContentType;
        //        part.Data = GetPartStream(otherPart.Data);
        //        newMsg.AddPart(otherPart.PartName, part, false);
        //    }

        //    ContextProperty emulateXmlProp = propertyBag.FirstOrDefault(prop => prop.Namespace == BTSProperties.emulateXMLDisassembler.Name.Namespace
        //                                && prop.Name == BTSProperties.emulateXMLDisassembler.Name.Name);
        //    if (emulateXmlProp != null && emulateXmlProp.Value == "true")
        //    {
        //        IDocumentSpec docSpec = pContext.GetDocumentSpecByType(xDoc.DocumentElement.NamespaceURI + "#" + xDoc.DocumentElement.LocalName);
        //        IEnumerator annotations = docSpec.GetPropertyAnnotationEnumerator();
        //        newMsg.Context.Write(BTSProperties.documentSpecName.Name.Name,
        //                                                BTSProperties.documentSpecName.Name.Namespace,
        //                                                docSpec.DocSpecStrongName);
        //        newMsg.Context.Promote(BTSProperties.messageType.Name.Name, BTSProperties.messageType.Name.Namespace, docSpec.DocType);
        //        newMsg.Context.Promote(BTSProperties.suspendOnRoutingFailure.Name.Name, BTSProperties.suspendOnRoutingFailure.Name.Namespace, true);
        //        if (annotations != null)
        //            while (annotations.MoveNext())
        //            {
        //                IPropertyAnnotation annotation = (IPropertyAnnotation)annotations.Current;
        //                // Use annotation.Name or Namespace to get the data to demote in message
        //                // Make manual demoting using annotation.Xpath.

        //                System.Xml.XmlNode contextNode = xDoc.SelectSingleNode(annotation.XPath);
        //                if (contextNode != null)
        //                {
        //                    newMsg.Context.Promote(annotation.Name,
        //                                        annotation.Namespace,
        //                                        contextNode.InnerText);
        //                }


        //            }

        //        annotations = docSpec.GetDistinguishedPropertyAnnotationEnumerator();
        //        if (annotations != null)
        //        {
        //            while (annotations.MoveNext())
        //            {
        //                DictionaryEntry de = (DictionaryEntry)annotations.Current;
        //                XsdDistinguishedFieldDefinition distinguishedField = (XsdDistinguishedFieldDefinition)de.Value;

        //                // Use annotation.Name or Namespace to get the data to
        //                // promote from message
        //                System.Xml.XmlNode contextNode = xDoc.SelectSingleNode(distinguishedField.XPath);

        //                if (contextNode != null)
        //                {
        //                    newMsg.Context.Write(de.Key.ToString(),
        //                                    Globals.DistinguishedFieldsNamespace,
        //                                    contextNode.InnerText);
        //                }
        //            }
        //        }
        //    }


        //    this.attachPropetyBag(newMsg, propertyBag);

        //    qOutputMsgs.Enqueue(newMsg);
        //    pContext.ResourceTracker.AddResource(memStrm);
        //}

        //private void CreateRawMsg(IPipelineContext pContext, IBaseMessageContext sourceContext, string messageContent, string bodyPartName, ContextProperty[] propertyBag, List<Part> otherPartList)
        //{
        //    IBaseMessage newMsg = pContext.GetMessageFactory().CreateMessage();
        //    IBaseMessagePart bodyMsgPart = pContext.GetMessageFactory().CreateMessagePart();
        //    System.IO.MemoryStream memStrm = new MemoryStream();
        //    StreamWriter sw = new StreamWriter(memStrm);
        //    sw.Write(messageContent);
        //    sw.Flush();
        //    memStrm.Position = 0;

        //    bodyMsgPart.Data = memStrm;

        //    newMsg.Context = sourceContext;
        //    newMsg.AddPart(bodyPartName, bodyMsgPart, true);
        //    foreach (Part otherPart in otherPartList)
        //    {
        //        IBaseMessagePart part = pContext.GetMessageFactory().CreateMessagePart();
        //        part.Charset = "utf-8";
        //        part.ContentType = otherPart.ContentType;
        //        part.Data = GetPartStream(otherPart.Data);
        //        newMsg.AddPart(otherPart.PartName, part, false);
        //    }

        //    newMsg.Context.Promote(BTSProperties.suspendOnRoutingFailure.Name.Name, BTSProperties.suspendOnRoutingFailure.Name.Namespace, true);

        //    this.attachPropetyBag(newMsg, propertyBag);

        //    qOutputMsgs.Enqueue(newMsg);
        //    pContext.ResourceTracker.AddResource(memStrm);
        //}
        #endregion

        private void attachPropetyBag(IBaseMessage newMsg, ContextProperty[] propertyBag)
        {
            ContextProperty rcvportNameProp = null;

            foreach (ContextProperty prop in propertyBag)
            {
                if (prop.Promoted)
                {
                    newMsg.Context.Promote(prop.Name,
                                           prop.Namespace,
                                           formatValue(prop.Value));
                }
                else
                {
                    newMsg.Context.Write(prop.Name,
                                         prop.Namespace,
                                         formatValue(prop.Value));
                }

                if (prop.Namespace == BTSProperties.receivePortName.Name.Namespace && prop.Name == BTSProperties.receivePortName.Name.Name)
                {
                    rcvportNameProp = prop;
                }
            }

            if (rcvportNameProp != null)
            {
                Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\BizTalk Server\3.0\Administration");
                string mgmtDbName   = (string)registryKey.GetValue("MgmtDBName");
                string mgmtDbServer = (string)registryKey.GetValue("MgmtDBServer");

                using (DBEntities.MgmtDbEntities entities = new DBEntities.MgmtDbEntities(this.getConnectionStrings(mgmtDbServer, mgmtDbName)))
                {
                    var portIDs = from p in entities.bts_receiveport
                                  where p.nvcName == rcvportNameProp.Value
                                  select new PortInfo
                    {
                        ID   = p.uidGUID,
                        Name = p.nvcName
                    };


                    if (portIDs.Count() > 0)
                    {
                        Guid portID = portIDs.First().ID;
                        newMsg.Context.Promote(BTSProperties.receivePortID.Name.Name,
                                               BTSProperties.receivePortID.Name.Namespace,
                                               portID.ToString("B"));
                    }
                }
            }
        }
Esempio n. 20
0
        private ContextProperty CreateDurationContextWithScenario(string id, string schema, string val, DateTime start, DateTime end)
        {
            ContextProperty cp = new ContextProperty();

            cp.ContextID       = id;
            cp.EntitySchema    = schema;
            cp.EntityValue     = val;
            cp.PeriodType      = Element.PeriodType.duration;
            cp.PeriodStartDate = start;
            cp.PeriodEndDate   = end;
            cp.AddScenario("og", "Audited", "rel", "http://www.StandardAdvantage.com/em/og/2004-12-28");
            return(cp);
        }
Esempio n. 21
0
 /// <summary>
 /// Initializes the Context Value collection with Message Context values being passed in.
 /// </summary>
 /// <param name="contextProperties">Collection of BizTalk Message Context values</param>
 public MessageContextAccessorFact(Dictionary <string, object> contextProperties)
 {
     foreach (var keyValuePair in contextProperties)
     {
         string[]        names = keyValuePair.Key.Split('#');
         ContextProperty prop  = new ContextProperty()
         {
             Name      = names[1],
             Namespace = names[0],
             Value     = keyValuePair.Value.ToString()
         };
         this.contextProperties.Add(keyValuePair.Key, prop);
     }
 }
Esempio n. 22
0
        public void SimpleCompareTest()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.PeriodType = Element.PeriodType.duration;
            cp2.PeriodType = Element.PeriodType.instant;

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper("key1", cp1);
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper("key2", cp2);

            Assert.AreEqual(1, Compare(cuw2, cuw1), "1 sort wrong");
            Assert.AreEqual(-1, Compare(cuw1, cuw2), "2 sort wrong");
        }
Esempio n. 23
0
        /// <summary>
        /// Gets a dictionary collection of the context properties that have been changed.
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, object> GetChangedValues()
        {
            Dictionary <string, object> changedContextProp = new Dictionary <string, object>();

            foreach (var keyValuePair in this.contextProperties)
            {
                ContextProperty prop = keyValuePair.Value;
                if (prop.Dirty == true)
                {
                    changedContextProp.Add(keyValuePair.Key, prop.Value);
                }
            }
            return(changedContextProp);
        }
Esempio n. 24
0
        public void SimpleSegmentTest()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddSegment("key1", "key1", "key1", "key1");
            cp2.AddSegment("key2", "key2", "key2", "key2");

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper("key1", cp1);
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper("key2", cp2);

            // and compare them
            Assert.AreEqual(1, Compare(cuw2, cuw1), "1 sort wrong");
            Assert.AreEqual(-1, Compare(cuw1, cuw2), "2 sort wrong");
            Assert.AreEqual(0, Compare(cuw1, cuw1), "3 sort wrong");
        }
Esempio n. 25
0
        public void OneSegBeforeTwoScenarios()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddScenario("key11", "key11", "key11", "key11");
            cp1.AddScenario("key3", "key3", "key3", "key3");

            cp2.AddSegment("key1", "key1", "key1", "key1");

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper("key1", cp1);
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper("key2", cp2);

            // and compare them
            Assert.AreEqual(-1, Compare(cuw2, cuw1), "1 sort wrong");
            Assert.AreEqual(1, Compare(cuw1, cuw2), "2 sort wrong");
        }
Esempio n. 26
0
        public void Disassemble(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            //load up the Excel reader:
            Stream originalStream = pInMsg.BodyPart.GetOriginalDataStream();
            string fileName = (string) pInMsg.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties");
            _reader = GetDataReader(fileName, originalStream);

            //store the incoming context properties to write out again:
            _contextProperties = new List<ContextProperty>();
            for (int i = 0; i < pInMsg.Context.CountProperties; i++)
            {
                ContextProperty property = new ContextProperty();
                property.Value = pInMsg.Context.ReadAt(i, out property.Name, out property.Namespace);
                property.IsPromoted = pInMsg.Context.IsPromoted(property.Name, property.Namespace);
                _contextProperties.Add(property);
            }
        }
        public void Disassemble(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            //load up the Excel reader:
            Stream originalStream = pInMsg.BodyPart.GetOriginalDataStream();
            string fileName       = (string)pInMsg.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties");

            _reader = GetDataReader(fileName, originalStream);

            //store the incoming context properties to write out again:
            _contextProperties = new List <ContextProperty>();
            for (int i = 0; i < pInMsg.Context.CountProperties; i++)
            {
                ContextProperty property = new ContextProperty();
                property.Value      = pInMsg.Context.ReadAt(i, out property.Name, out property.Namespace);
                property.IsPromoted = pInMsg.Context.IsPromoted(property.Name, property.Namespace);
                _contextProperties.Add(property);
            }
        }
Esempio n. 28
0
        public void DurationScenarioBeforeNoSegNoScenarioInstant()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddScenario("key1", "key1", "key1", "key1");
            cp1.PeriodType      = Element.PeriodType.duration;
            cp1.PeriodStartDate = new DateTime(2000, 1, 1);
            cp1.PeriodEndDate   = new DateTime(2000, 1, 2);

            cp2.PeriodType      = Element.PeriodType.instant;
            cp2.PeriodStartDate = new DateTime(2000, 1, 1);

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper("key1", cp1);
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper("key2", cp2);

            Assert.AreEqual(1, Compare(cuw2, cuw1), "1 sort wrong");
            Assert.AreEqual(-1, Compare(cuw1, cuw2), "2 sort wrong");
        }
Esempio n. 29
0
        private static Dictionary <string, ContextProperty> ParseContextProperties(Dictionary <string, object> _contextProperties)
        {
            var _contextPropertiesParsed = new Dictionary <string, ContextProperty>();

            foreach (var keyValuePair in _contextProperties)
            {
                string[]        names = keyValuePair.Key.Split('#');
                ContextProperty prop  = new ContextProperty()
                {
                    Name      = names[1],
                    Namespace = names[0],
                    Value     = keyValuePair.Value.ToString(),
                    DataType  = keyValuePair.Value.GetType().FullName,
                };
                _contextPropertiesParsed.Add(keyValuePair.Key, prop);
            }

            return(_contextPropertiesParsed);
        }
Esempio n. 30
0
        public void TwoSegsBeforeOneSeg()
        {
            ContextProperty cp1 = new ContextProperty();
            ContextProperty cp2 = new ContextProperty();

            cp1.AddSegment("key1", "key1", "key1", "key1");
            cp1.AddSegment("key3", "key3", "key3", "key3");

            cp2.AddSegment("key2", "key2", "key2", "key2");

            MergedContextUnitsWrapper cuw1 = new MergedContextUnitsWrapper("key1", cp1);
            MergedContextUnitsWrapper cuw2 = new MergedContextUnitsWrapper("key2", cp2);

            // and compare them
            Assert.AreEqual(1, CompareSegments(cp2.Segments, cp1.Segments), "segment sort 1 wrong");
            Assert.AreEqual(-1, CompareSegments(cp1.Segments, cp2.Segments), "segment sort 2 wrong");

            Assert.AreEqual(1, Compare(cuw2, cuw1), "1 sort wrong");
            Assert.AreEqual(-1, Compare(cuw1, cuw2), "2 sort wrong");
        }
        public static void Copy(this IBaseMessageContext ctx, ContextProperty source, ContextProperty destination)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            if (destination == null)
            {
                throw new ArgumentNullException("destination");
            }

            object sourceValue;

            if (ctx.TryRead(source, out sourceValue))
            {
                throw new InvalidOperationException("Could not find the specified source property in BizTalk context.");
            }

            ctx.Promote(destination, sourceValue);
        }