public static void BuildActionMatrix(IPolicy policy, ActionMatrix actionMatrix, ActionGroup actionGroup, IRoutingItemCollections senders, IRoutingItemCollections recipients) { ConditionGroup conditionGroup = new ConditionGroup(new Guid("{661EDD6F-D750-493A-9932-E56C8C22E2CF}"), new TranslateableLanguageItem("Test condition group"), ConditionLogic.AND, false); policy.Conditions.Add(conditionGroup); // Just fill out each cell with the same condition group for now... int i = 0; foreach (IRoutingItemCollection senderCollection in senders) { foreach (IRoutingItemCollection recipientCollection in recipients) { ActionMatrixCell cell = new ActionMatrixCell(senderCollection, recipientCollection); cell.AddActionCondition(conditionGroup, actionGroup, false); actionMatrix[senderCollection, recipientCollection] = cell; i++; } } }
public static void BuildActionMatrix(IPolicy policy, ActionMatrix actionMatrix, ActionGroup actionGroup) { ConditionGroup conditionGroup = new ConditionGroup(new Guid("{661EDD6F-D750-493A-9932-E56C8C22E2CF}"), new TranslateableLanguageItem("Test condition group"), ConditionLogic.AND, false); policy.Conditions.Add(conditionGroup); PolicyCataloguesCache policyCataloguesCache = PolicyCataloguesCache.Instance(); IRoutingItemCollection senders1 = policyCataloguesCache.LocationsCollections[new Guid("{A81631A6-6AA3-45F7-AADD-4853447E5BD6}")]; IRoutingItemCollection senders2 = policyCataloguesCache.LocationsCollections[new Guid("{0DAACC5C-6167-42C7-AED0-55D1D9CC5096}")]; IRoutingItemCollection recipients1 = policyCataloguesCache.LocationsCollections[new Guid("{FA13BE82-9EB1-407E-9DD5-8005F3E840E4}")]; IRoutingItemCollection recipients2 = policyCataloguesCache.LocationsCollections[new Guid("{13A8EBE5-8B1E-4919-82E2-8A860DE4043E}")]; ActionMatrixCell actionMatrixCell1 = new ActionMatrixCell(senders1, recipients1); actionMatrixCell1.AddActionCondition(conditionGroup, actionGroup, false); ActionMatrixCell actionMatrixCell2 = new ActionMatrixCell(senders1, recipients2); actionMatrixCell1.AddActionCondition(conditionGroup, actionGroup, false); actionMatrix[senders1, recipients1] = actionMatrixCell1; actionMatrix[senders1, recipients2] = actionMatrixCell2; ConditionGroup conditionGroup2 = new ConditionGroup(new Guid("{D64056E5-A19D-4B29-8F4A-A70337B42A19}"), new TranslateableLanguageItem("Test condition group 2"), ConditionLogic.AND, false); policy.Conditions.Add(conditionGroup2); ActionMatrixCell actionMatrixCell3 = new ActionMatrixCell(senders2, recipients2); actionMatrixCell3.AddActionCondition(conditionGroup2, actionGroup, false); ActionMatrixCell actionMatrixCell4 = new ActionMatrixCell(senders2, recipients1); actionMatrixCell4.AddActionCondition(conditionGroup2, actionGroup, false); actionMatrix[senders2, recipients2] = actionMatrixCell3; actionMatrix[senders2, recipients1] = actionMatrixCell4; }
public void TestWriteActionMatrixAttributes() { Guid languageId = new Guid("{CBEB31FA-7FE8-4E27-A01A-1D19AFCA604C}"); PolicyLanguage language = new PolicyLanguage(languageId, "en"); language[new Guid("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}")] = "Test condition"; language[new Guid("{5570ABC5-188E-4893-92E4-6930802F9C05}")] = "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); IDataItem dataItem = DataItem.CreateDataItem(new TranslateableLanguageItem("Test data item"), DataType.Long, 10); ObjectModel.IAction action = new ObjectModel.Action(new Guid("{26BCFA7E-3605-4EE7-ACC6-0AFB4D5EBB71}"), "CustomAction.dll", "Test.Clean", RunAt.Client, false, 1); //TODO JE action.DataElements.Add(new DataElement(new Guid("{EB56B397-954D-45C2-ADBA-263372A8B59F}"), new TranslateableLanguageItem("Test data item stored in data element"), new NonTranslateableLanguageItem(""), DataType.Long, dataItem)); ActionGroup actionGroup = new ObjectModel.ActionGroup(new Guid("{987B7C8B-5ADD-4696-8456-DDE11D95CE0B}"), new TranslateableLanguageItem("Test action group"), 1); actionGroup.Actions.Add(action); ActionMatrix actionMatrix = new ObjectModel.ActionMatrix(); ConditionGroup conditionGroup = new ConditionGroup(new Guid("{661EDD6F-D750-493A-9932-E56C8C22E2CF}"), new TranslateableLanguageItem("Profanity"), ConditionLogic.OR, false); IRoutingItemCollection senders = new RoutingItemCollection(new Guid("{79C512E8-3912-4709-B7D7-E91EFA3BD9FD}"), "Test sources"); IRoutingItemCollection recipients = new RoutingItemCollection(new Guid("{FDC166E4-EBE5-4285-8F09-6A145D88C707}"), "Test destinations"); ActionMatrixCell actionMatrixCell = new ObjectModel.ActionMatrixCell(senders, recipients); actionMatrixCell.AddActionCondition(conditionGroup, actionGroup, false); actionMatrix["{A81631A6-6AA3-45F7-AADD-4853447E5BD6}", "{D23F36C4-953F-4ED9-B1EB-8921BD50562B}"] = actionMatrixCell; actionMatrix["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}"); actionMatrix["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}"); IPolicyObjectCollection<IActionMatrix> actions = new PolicyObjectCollection<IActionMatrix>(); actions.Add(actionMatrix); PolicyChannel channel = new PolicyChannel(new Guid("{390F589A-24B0-4DF0-B750-D47EDD1FF0BE}"), new TranslateableLanguageItem("Test channel"), ChannelType.SMTP); channel.Actions = actionMatrix; IPolicyObjectCollection<IPolicyObject> channels = new PolicyObjectCollection<IPolicyObject>(); channels.Add(channel); XmlStore store = new XmlStore(); ObjectModel.PolicySet policySet = new ObjectModel.PolicySet(new Guid("{8FC9EB93-C376-4E96-B22E-71FAA848393D}"), new TranslateableLanguageItem("{5570ABC5-188E-4893-92E4-6930802F9C05}"), store, policyCatalogue, false); P5Policy policy = new P5Policy(store, policySet, new Guid("{C0F6D4BB-CBF1-41FC-8A28-616D6FC1DC73}"), new TranslateableLanguageItem("Test policy"), PolicyStatus.Active); IPolicyStoreWriter writer = store.Writer; writer.WritePolicySet(policySet); writer.WritePolicy(policySet, policy); writer.WriteConditionGroup(policySet, policy, conditionGroup); writer.WriteChildCollection(policySet, policy, policy.Name.Value, channels); writer.Close(); TestHelpers.CompareXml(m_testPath + "ExpectedWriteActionMatrixAttributes.xml", store.StoreXML); }