private Microsoft.Exchange.MessagingPolicies.Rules.Condition CombineUsingAnd(params Microsoft.Exchange.MessagingPolicies.Rules.Condition[] conditions) { int num = 0; Microsoft.Exchange.MessagingPolicies.Rules.Condition result = null; foreach (Microsoft.Exchange.MessagingPolicies.Rules.Condition condition in conditions) { if (condition != null) { num++; result = condition; } } if (num == 0) { return(Microsoft.Exchange.MessagingPolicies.Rules.Condition.True); } if (num == 1) { return(result); } AndCondition andCondition = new AndCondition(); foreach (Microsoft.Exchange.MessagingPolicies.Rules.Condition item in conditions) { andCondition.SubConditions.Add(item); } return(andCondition); }
private Microsoft.Exchange.MessagingPolicies.Rules.Condition CreateRecipientCondition() { if (this.recipient == null) { return(null); } Property property = JournalingRuleParser.Instance.CreateProperty("Message.Sender"); ShortList <string> shortList = new ShortList <string>(); shortList.Add(this.recipient.ToString()); PredicateCondition predicateCondition = JournalingRuleParser.Instance.CreatePredicate("isMemberOf", property, shortList); PredicateCondition predicateCondition2 = JournalingRuleParser.Instance.CreatePredicate("isSameUser", property, shortList); Microsoft.Exchange.MessagingPolicies.Rules.Condition condition = this.CombineUsingOr(new Microsoft.Exchange.MessagingPolicies.Rules.Condition[] { predicateCondition, predicateCondition2 }); Property property2 = JournalingRuleParser.Instance.CreateProperty("Message.EnvelopeRecipients"); PredicateCondition predicateCondition3 = JournalingRuleParser.Instance.CreatePredicate("isMemberOf", property2, shortList); PredicateCondition predicateCondition4 = JournalingRuleParser.Instance.CreatePredicate("isSameUser", property2, shortList); Microsoft.Exchange.MessagingPolicies.Rules.Condition condition2 = this.CombineUsingOr(new Microsoft.Exchange.MessagingPolicies.Rules.Condition[] { predicateCondition3, predicateCondition4 }); return(this.CombineUsingOr(new Microsoft.Exchange.MessagingPolicies.Rules.Condition[] { condition, condition2 })); }
private bool TryReadRecipientCondition(Microsoft.Exchange.MessagingPolicies.Rules.Condition condition) { if (condition.ConditionType != ConditionType.Or) { return(false); } List <Microsoft.Exchange.MessagingPolicies.Rules.Condition> subConditions = ((OrCondition)condition).SubConditions; if (subConditions.Count != 2) { return(false); } foreach (Microsoft.Exchange.MessagingPolicies.Rules.Condition condition2 in subConditions) { if (condition2.ConditionType != ConditionType.Or) { return(false); } List <Microsoft.Exchange.MessagingPolicies.Rules.Condition> subConditions2 = ((OrCondition)condition2).SubConditions; using (List <Microsoft.Exchange.MessagingPolicies.Rules.Condition> .Enumerator enumerator2 = subConditions2.GetEnumerator()) { if (enumerator2.MoveNext()) { Microsoft.Exchange.MessagingPolicies.Rules.Condition condition3 = enumerator2.Current; if (condition3.ConditionType != ConditionType.Predicate) { return(false); } PredicateCondition predicateCondition = condition3 as PredicateCondition; if (!predicateCondition.Name.Equals("isMemberOf") && !predicateCondition.Name.Equals("isSameUser")) { return(false); } if (!predicateCondition.Property.Name.Equals("Message.Sender") && !predicateCondition.Property.Name.Equals("Message.EnvelopeRecipients")) { return(false); } this.recipient = new SmtpAddress?(new SmtpAddress(predicateCondition.Value.RawValues[0])); return(true); } } } return(false); }
internal JournalingRule Serialize() { Microsoft.Exchange.MessagingPolicies.Rules.Condition condition = this.CreateScopeCondition(); Microsoft.Exchange.MessagingPolicies.Rules.Condition condition2 = this.CreateRecipientCondition(); Microsoft.Exchange.MessagingPolicies.Rules.Condition condition3 = this.CombineUsingAnd(new Microsoft.Exchange.MessagingPolicies.Rules.Condition[] { condition, condition2 }); Microsoft.Exchange.MessagingPolicies.Rules.Action item = this.CreateAction(); JournalingRule journalingRule = (JournalingRule)JournalingRuleParser.Instance.CreateRule(base.Name); journalingRule.Condition = condition3; journalingRule.Actions.Add(item); journalingRule.ExpiryDate = this.ExpiryDate; journalingRule.GccRuleType = JournalRuleObject.ConvertJournalRuleTypeToGccType(this.RuleType); journalingRule.Enabled = (this.enabled ? RuleState.Enabled : RuleState.Disabled); return(journalingRule); }
private bool TryReadScopeCondition(Microsoft.Exchange.MessagingPolicies.Rules.Condition condition) { if (condition.ConditionType != ConditionType.Predicate) { return(false); } if (((PredicateCondition)condition).Name != "equal") { return(false); } string name = ((PredicateCondition)condition).Property.Name; if (name == "Microsoft.Exchange.Journaling.External") { this.Scope = JournalRuleScope.External; return(true); } if (name == "Microsoft.Exchange.Journaling.Internal") { this.Scope = JournalRuleScope.Internal; return(true); } return(false); }
internal TransportRule ToInternalRule() { AndCondition andCondition = new AndCondition(); List <RuleBifurcationInfo> list = new List <RuleBifurcationInfo>(); andCondition.SubConditions.Add(Microsoft.Exchange.MessagingPolicies.Rules.Condition.True); int num = -1; if (this.conditions != null) { foreach (TransportRulePredicate transportRulePredicate in this.conditions) { if (transportRulePredicate.Rank <= num) { throw new ArgumentException(Strings.InvalidPredicateSequence, "Conditions"); } num = transportRulePredicate.Rank; if (transportRulePredicate is BifurcationInfoPredicate) { BifurcationInfoPredicate bifurcationInfoPredicate = (BifurcationInfoPredicate)transportRulePredicate; RuleBifurcationInfo ruleBifurcationInfo; RuleBifurcationInfo item = bifurcationInfoPredicate.ToRuleBifurcationInfo(out ruleBifurcationInfo); list.Add(item); if (ruleBifurcationInfo != null) { list.Add(ruleBifurcationInfo); } } else { Microsoft.Exchange.MessagingPolicies.Rules.Condition item2 = transportRulePredicate.ToInternalCondition(); andCondition.SubConditions.Add(item2); } } } if (this.exceptions != null && this.exceptions.Length > 0) { OrCondition orCondition = new OrCondition(); andCondition.SubConditions.Add(new NotCondition(orCondition)); num = -1; foreach (TransportRulePredicate transportRulePredicate2 in this.exceptions) { if (transportRulePredicate2.Rank <= num) { throw new ArgumentException(Strings.InvalidPredicateSequence, "Exceptions"); } num = transportRulePredicate2.Rank; if (transportRulePredicate2 is BifurcationInfoPredicate) { BifurcationInfoPredicate bifurcationInfoPredicate2 = (BifurcationInfoPredicate)transportRulePredicate2; RuleBifurcationInfo ruleBifurcationInfo3; RuleBifurcationInfo ruleBifurcationInfo2 = bifurcationInfoPredicate2.ToRuleBifurcationInfo(out ruleBifurcationInfo3); ruleBifurcationInfo2.Exception = true; list.Add(ruleBifurcationInfo2); if (ruleBifurcationInfo3 != null) { ruleBifurcationInfo3.Exception = true; list.Add(ruleBifurcationInfo3); } } else { Microsoft.Exchange.MessagingPolicies.Rules.Condition item3 = transportRulePredicate2.ToInternalCondition(); orCondition.SubConditions.Add(item3); } } if (orCondition.SubConditions.Count == 0) { orCondition.SubConditions.Add(Microsoft.Exchange.MessagingPolicies.Rules.Condition.False); } } TransportRule transportRule = new TransportRule(base.Name, andCondition); transportRule.Enabled = this.State; transportRule.Comments = this.Comments; if (list.Count > 0) { transportRule.Fork = list; } foreach (Microsoft.Exchange.MessagingPolicies.Rules.Action item4 in this.CreateActions()) { transportRule.Actions.Add(item4); } return(transportRule); }