public static void DeleteEtrsByDlpPolicy(Guid dlpGuid, IConfigDataProvider dataSession) { IEnumerable <TransportRule> enumerable; string message; if (!DlpUtils.TryGetTransportRules(dataSession, out enumerable, out message)) { throw new InvalidOperationException(message); } foreach (TransportRule transportRule in enumerable) { TransportRule transportRule2 = (TransportRule)TransportRuleParser.Instance.GetRule(transportRule.Xml); Guid guid; if (transportRule2.TryGetDlpPolicyId(out guid) && guid.Equals(dlpGuid)) { dataSession.Delete(transportRule); } } }
private void SaveTransportRule(TransportRule instance) { bool flag = MessagingPoliciesSyncLogDataSession.IsNameNewOrChangedForTenantScopedObject(instance); Guid empty = Guid.Empty; bool flag2 = false; if (instance.OrganizationId != OrganizationId.ForestWideOrgId && instance.IsChanged(TransportRuleSchema.Xml)) { flag2 = true; if (!instance.Guid.Equals(Guid.Empty)) { TransportRule transportRuleByGuid = DlpUtils.GetTransportRuleByGuid(this.dataSession, this.rulesCollectionName, instance.Guid); TransportRule transportRule = (TransportRule)TransportRuleParser.Instance.GetRule(transportRuleByGuid.Xml); transportRule.TryGetDlpPolicyId(out empty); } } this.dataSession.Save(instance); if (flag || flag2) { TransportRule transportRuleByName = DlpUtils.GetTransportRuleByName(this.dataSession, this.rulesCollectionName, instance.Name); Guid empty2 = Guid.Empty; List <KeyValuePair <string, object> > list = null; if (transportRuleByName != null) { TransportRule transportRule2 = (TransportRule)TransportRuleParser.Instance.GetRule(transportRuleByName.Xml); transportRule2.TryGetDlpPolicyId(out empty2); if (!empty2.Equals(empty)) { flag = true; list = new List <KeyValuePair <string, object> >(); list.Add(new KeyValuePair <string, object>("DLPPolicyId", empty2)); } } Guid value; if (flag && this.GetExternalDirectoryOrganizationIdToLog(transportRuleByName, out value)) { TenantSettingSyncLogGenerator.Instance.LogChangesForSave(transportRuleByName, new Guid?(value), new Guid?(transportRuleByName.ImmutableId), list); } } }
protected bool RuleDlpPolicyIdMatches(TransportRule rule) { Guid guid; return(rule.TryGetDlpPolicyId(out guid) && guid.Equals(this.taskObject.TargetItem.ImmutableId)); }