Example #1
0
 public RoutingMatrixCell(RoutingMatrixCell rhs, bool readOnly, bool createNewId, IRoutingItemCollection senders, IRoutingItemCollection recipients)
     : base(rhs, readOnly, createNewId, senders, recipients)
 {
     m_identifier = Guid.Empty;
     IPolicyLanguageItem description = createNewId ? rhs.Description.Clone() : rhs.Description;
     IPolicyLanguageItem color = createNewId ? rhs.Color.Clone() : rhs.Color;
     SetDefaults(description, color, rhs.Precedence);
 }
Example #2
0
        public void TestConstruct()
        {
            RoutingMatrixCell matrixCell = new RoutingMatrixCell(new TranslateableLanguageItem("cellName1"), 
                new TranslateableLanguageItem("cellDescription1"), new TranslateableLanguageItem("cellColour1"), 1, null, null);

            Assert.AreEqual("cellName1", matrixCell.Name.Value);
            Assert.AreEqual("cellDescription1", matrixCell.Description.Value);
            Assert.AreEqual("cellColour1", matrixCell.Color.Value);
            Assert.AreEqual(1, matrixCell.Precedence);
        }
Example #3
0
        public void TestSecondConstruct()
        {
            RoutingMatrixCell matrixCell = new RoutingMatrixCell(new TranslateableLanguageItem("cellName1"),
                new TranslateableLanguageItem("cellDescription1"), new TranslateableLanguageItem("cellColour1"), 2, true, null, null);

            Assert.AreEqual("cellName1", matrixCell.Name.Value);
            Assert.AreEqual("cellDescription1", matrixCell.Description.Value);
            Assert.AreEqual("cellColour1", matrixCell.Color.Value);
            Assert.AreEqual(2, matrixCell.Precedence);
            Assert.IsTrue(matrixCell.ReadOnly);
        }
Example #4
0
        public void TestDeepCopy()
        {
            RoutingMatrixCell origMatrixCell = new RoutingMatrixCell(new TranslateableLanguageItem("cellName1"),
                new TranslateableLanguageItem("cellDescription1"), new TranslateableLanguageItem("cellColour1"), 2, false, null, null);

            RoutingMatrixCell matrixCell = origMatrixCell.DeepCopy(true) as RoutingMatrixCell;
            Assert.AreEqual("cellName1", matrixCell.Name.Value);
            Assert.AreEqual("cellDescription1", matrixCell.Description.Value);
            Assert.AreEqual("cellColour1", matrixCell.Color.Value);
            Assert.AreEqual(2, matrixCell.Precedence);
            Assert.IsTrue(matrixCell.ReadOnly);
        }
Example #5
0
        public static void BuildMatrixReadOnlyCells(RoutingTable routingTable)
        {
            IRoutingItemCollection senders = new RoutingItemCollection(Guid.NewGuid(), "");
            IRoutingItemCollection recipients = new RoutingItemCollection(Guid.NewGuid(), "");

            IRoutingMatrixCell cell = new RoutingMatrixCell(new TranslateableLanguageItem("Important"), new TranslateableLanguageItem("High Priority Scanning"), new TranslateableLanguageItem("Red"), 0, true, senders, recipients);
            routingTable["{A81631A6-6AA3-45F7-AADD-4853447E5BD6}", "{FA13BE82-9EB1-407E-9DD5-8005F3E840E4}"] = cell;

            IRoutingMatrixCell cell2 = new RoutingMatrixCell(new TranslateableLanguageItem("Sort of important"), new TranslateableLanguageItem("Sort of High Priority Scanning"), new TranslateableLanguageItem("Yellow"), 1, true, senders, recipients);
            routingTable["{A81631A6-6AA3-45F7-AADD-4853447E5BD6}", "{13A8EBE5-8B1E-4919-82E2-8A860DE4043E}"] = cell2;

            IRoutingMatrixCell cell3 = new RoutingMatrixCell(new TranslateableLanguageItem("Who cares"), new TranslateableLanguageItem("Very Low Priority Scanning"), new TranslateableLanguageItem("Brown"), 2, true, senders, recipients);
            routingTable["{0DAACC5C-6167-42C7-AED0-55D1D9CC5096}", "{13A8EBE5-8B1E-4919-82E2-8A860DE4043E}"] = cell3;

            IRoutingMatrixCell cell4 = new RoutingMatrixCell(new TranslateableLanguageItem("Not important at all"), new TranslateableLanguageItem("Very, very, very Low Priority Scanning"), new TranslateableLanguageItem("Black"), 3, true, senders, recipients);
            routingTable["{0DAACC5C-6167-42C7-AED0-55D1D9CC5096}", "{FA13BE82-9EB1-407E-9DD5-8005F3E840E4}"] = cell4;
        }
Example #6
0
        public static void BuildMatrixCells(List<string[]> cellsData, RoutingTable routingTable, IRoutingItemCollections senders, IRoutingItemCollections recipients)
        {
            IRoutingItemCollection sender = new RoutingItemCollection(Guid.NewGuid(), "");
            IRoutingItemCollection recipient = new RoutingItemCollection(Guid.NewGuid(), "");

            // There is a cell for each intersection of sources and destinations
            // This method assumes that the cell data collection is of the correct size
            int i = 0;
            foreach (IRoutingItemCollection senderCollection in senders)
            {
                foreach (IRoutingItemCollection recipientCollection in recipients)
                {
                    IRoutingMatrixCell cell = new RoutingMatrixCell(new TranslateableLanguageItem(cellsData[i][0]), new TranslateableLanguageItem(cellsData[i][1]), new TranslateableLanguageItem(cellsData[i][2]), Convert.ToInt32(cellsData[i][3]), sender, recipient);
                    routingTable[senderCollection, recipientCollection] = cell;
                    i++;
                }
            }
        }
Example #7
0
        public static void BuildMatrixCells(RoutingTable routingTable)
        {
            PolicyCataloguesCache policyCataloguesCache = PolicyCataloguesCache.Instance();
            IRoutingItemCollection senders1 = policyCataloguesCache.LocationsCollections[new Guid("{A81631A6-6AA3-45F7-AADD-4853447E5BD6}")];
            Assert.IsNotNull(senders1, "Expected the sources 1 to be valid");
            IRoutingItemCollection recipients1 = policyCataloguesCache.LocationsCollections[new Guid("{FA13BE82-9EB1-407E-9DD5-8005F3E840E4}")];
            Assert.IsNotNull(recipients1, "Expected the destinations 1 to be valid");
            IRoutingItemCollection senders2 = policyCataloguesCache.LocationsCollections[new Guid("{0DAACC5C-6167-42C7-AED0-55D1D9CC5096}")];
            Assert.IsNotNull(senders2, "Expected the sources 2 to be valid");
            IRoutingItemCollection recipients2 = policyCataloguesCache.LocationsCollections[new Guid("{13A8EBE5-8B1E-4919-82E2-8A860DE4043E}")];
            Assert.IsNotNull(recipients2, "Expected the destinations 2 to be valid");
            
            IRoutingMatrixCell cell = new RoutingMatrixCell(new TranslateableLanguageItem("Important"), new TranslateableLanguageItem("High Priority Scanning"), new TranslateableLanguageItem("Red"), 1, senders1, recipients1);
            routingTable["{A81631A6-6AA3-45F7-AADD-4853447E5BD6}", "{FA13BE82-9EB1-407E-9DD5-8005F3E840E4}"] = cell;

            IRoutingMatrixCell cell2 = new RoutingMatrixCell(new TranslateableLanguageItem("Sort of important"), new TranslateableLanguageItem("Sort of High Priority Scanning"), new TranslateableLanguageItem("Yellow"), 2, senders1, recipients2);
            routingTable["{A81631A6-6AA3-45F7-AADD-4853447E5BD6}", "{13A8EBE5-8B1E-4919-82E2-8A860DE4043E}"] = cell2;

            IRoutingMatrixCell cell3 = new RoutingMatrixCell(new TranslateableLanguageItem("Who cares"), new TranslateableLanguageItem("Very Low Priority Scanning"), new TranslateableLanguageItem("Brown"), 3, senders2, recipients1);
            routingTable["{0DAACC5C-6167-42C7-AED0-55D1D9CC5096}", "{13A8EBE5-8B1E-4919-82E2-8A860DE4043E}"] = cell3;

            IRoutingMatrixCell cell4 = new RoutingMatrixCell(new TranslateableLanguageItem("Not important at all"), new TranslateableLanguageItem("Very, very, very Low Priority Scanning"), new TranslateableLanguageItem("Black"), 4, senders2, recipients2);
            routingTable["{0DAACC5C-6167-42C7-AED0-55D1D9CC5096}", "{FA13BE82-9EB1-407E-9DD5-8005F3E840E4}"] = cell4;
        }
 public OfflineRoutingMatrixCell(RoutingMatrixCell rhs, bool readOnly, bool createNewId)
     : base(rhs, readOnly, createNewId, null, null)
 {
 }
        private void AddMatrixCells(XmlNodeList cellNodes, IRoutingTable routingTable)
        {
            List<string> exclusions = new List<string>();
            exclusions.Add("name");
            exclusions.Add("description");
            exclusions.Add("color");
            exclusions.Add("precedence");
            exclusions.Add("readonly");

            foreach (XmlNode cellNode in cellNodes)
            {
                string senderId = cellNode.Attributes.GetNamedItem("SenderAddressCollectionId").InnerText;
                string recipientId = cellNode.Attributes.GetNamedItem("RecipientAddressCollectionId").InnerText;
                string name = cellNode.Attributes.GetNamedItem("name").InnerText;
                string description = cellNode.Attributes.GetNamedItem("description").InnerText;
                string color = cellNode.Attributes.GetNamedItem("color").InnerText;
                string precedence = cellNode.Attributes.GetNamedItem("precedence").InnerText;
                bool readOnly = PolicyUtilities.IsReadOnly(cellNode);

                IRoutingMatrixCell matrixCell = new RoutingMatrixCell(name, description, color, Convert.ToInt32(precedence), routingTable.ReadOnly || readOnly);
                new XmlCustomAttributesReader(matrixCell, cellNode.Attributes, exclusions).Read();

                routingTable[senderId, recipientId] = matrixCell;
            }
        }
        public void TestWriteRoutingMatrixCellAttributes()
        {
            Guid languageId = new Guid("{CBEB31FA-7FE8-4E27-A01A-1D19AFCA604C}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}")] = "Custom routing";
            language[new Guid("{8809EBFF-D902-4C91-BE56-1ABD13C054A1}")] = "Test policy";
            language[new Guid("{EBF8443B-4912-44F2-89BE-A0A055332D1B}")] = "This is my first custom property";
            language[new Guid("{8053E60C-EED7-464D-84EA-ECB51C291237}")] = "This is my second custom property";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;

            Guid catalogueGuid = new Guid("{751AEC6C-C164-4E6A-8581-A9ECCED87013}");
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueGuid, languageId, catalogueStore);

            IRoutingItemCollection senders1 = new RoutingItemCollection(new Guid("{79C512E8-3912-4709-B7D7-E91EFA3BD9FD}"), "Test sources");
            IRoutingItemCollection recipients1 = new RoutingItemCollection(new Guid("{FDC166E4-EBE5-4285-8F09-6A145D88C707}"), "Test destinations");
            
            IRoutingMatrixCell cell1 = new RoutingMatrixCell(new TranslateableLanguageItem("C1"), new TranslateableLanguageItem("Description of the blue cell"), new TranslateableLanguageItem("blue"), 1, senders1, recipients1);
            cell1["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}");
            cell1["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}");

            IRoutingMatrixCell cell2 = new RoutingMatrixCell(new TranslateableLanguageItem("C2"), new TranslateableLanguageItem("Description of the red cell"), new TranslateableLanguageItem("red"), 2, senders1, recipients1);
            IRoutingMatrixCell cell3 = new RoutingMatrixCell(new TranslateableLanguageItem("C3"), new TranslateableLanguageItem("Description of the green cell"), new TranslateableLanguageItem("green"), 3, senders1, recipients1);

            RoutingTable routingTable = new RoutingTable(new Guid("{AF6E5D89-0C6F-4B10-9A6C-658D13CD3EA8}"), new TranslateableLanguageItem("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}"), ChannelType.SMTP);

            routingTable["{A81631A6-6AA3-45F7-AADD-4853447E5BD6}", "{D23F36C4-953F-4ED9-B1EB-8921BD50562B}"] = cell1;
            routingTable["{FA13BE82-9EB1-407E-9DD5-8005F3E840E4}", "{4E1B9EAB-E892-4E47-BBE6-9D70B2438333}"] = cell2;
            routingTable["{3AD507B6-5E1E-44BB-9ABF-C27A31603C1B}", "{D23F36C4-953F-4ED9-B1EB-8921BD50562B}"] = cell3;

            XmlStore store = new XmlStore();

            ObjectModel.PolicySet policySet = new ObjectModel.PolicySet(new Guid("{8FC9EB93-C376-4E96-B22E-71FAA848393D}"), new TranslateableLanguageItem("{8809EBFF-D902-4C91-BE56-1ABD13C054A1}"), store, policyCatalogue, false);
            P5Policy policy = new P5Policy(store, policySet, new Guid("{C0F6D4BB-CBF1-41FC-8A28-616D6FC1DC73}"), new TranslateableLanguageItem("Test rule"), PolicyStatus.Active);

            IPolicyObjectCollection<IPolicyObject> channels = new PolicyObjectCollection<IPolicyObject>();
            PolicyChannel channel = new PolicyChannel(new Guid("{390F589A-24B0-4DF0-B750-D47EDD1FF0BE}"), new TranslateableLanguageItem("Test channel"), ChannelType.SMTP);
            channel.Routing = routingTable;
            channels.Add(channel);

            Store.IPolicyStoreWriter writer = store.Writer;
            Assert.IsNotNull(writer, "Expected a valid [IPolicyStoreWriter] writer");
            writer.WritePolicySet(policySet);
            writer.WritePolicy(policySet, policy);
            writer.WriteChildCollection(policySet, policy, policy.Name.Value, channels);
            writer.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteRoutingMatrixCellAttributes.xml", store.StoreXML);
        }
Example #11
0
        private IRoutingMatrixCell ReadRoutingCell(XmlNode cellNode, bool parentReadOnly)
        {
            if (null == cellNode)
                return null;

            List<string> exclusions = new List<string>();
            exclusions.Add("SourceRoutingItemCollectionId");
            exclusions.Add("DestinationRoutingItemCollectionId");
            exclusions.Add("name");
            exclusions.Add("description");
            exclusions.Add("color");
            exclusions.Add("precedence");
            exclusions.Add("readonly");

            XmlNode sourceNode = cellNode.Attributes.GetNamedItem("SourceRoutingItemCollectionId");
            XmlNode destinationNode = cellNode.Attributes.GetNamedItem("DestinationRoutingItemCollectionId");

            IPolicyLanguageItem name = LanguageItemFactory.Create(cellNode.Attributes.GetNamedItem("name").InnerText);
            IPolicyLanguageItem description = LanguageItemFactory.Create(cellNode.Attributes.GetNamedItem("description").InnerText);
            IPolicyLanguageItem color = LanguageItemFactory.Create(cellNode.Attributes.GetNamedItem("color").InnerText);
            int precedence = Convert.ToInt32(cellNode.Attributes.GetNamedItem("precedence").InnerText, CultureInfo.InvariantCulture);
            bool readOnly = PolicyUtilities.IsReadOnly(cellNode) || parentReadOnly;

            IRoutingMatrixCell matrixCell;
            if ((null != sourceNode) && (null != destinationNode))
            {
                string senderId = sourceNode.InnerText;
                string recipientId = destinationNode.InnerText;

                PolicyCataloguesCache policyCataloguesCache = PolicyCataloguesCache.Instance();
                IRoutingItemCollection senders = policyCataloguesCache.LocationsCollections[new Guid(senderId)];
                IRoutingItemCollection recipients = policyCataloguesCache.LocationsCollections[new Guid(recipientId)];
                matrixCell = new RoutingMatrixCell(name, description, color, precedence, readOnly, senders, recipients);
            }
            else
                matrixCell = new RoutingMatrixCell(name, description, color, precedence, readOnly, null, null);

            new XmlCustomAttributesReader(matrixCell, cellNode.Attributes, exclusions).Read();

            return matrixCell;
        }