コード例 #1
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!(predicateCondition.Property is HeaderProperty))
            {
                return(null);
            }
            HeaderContainsPredicate headerContainsPredicate = (HeaderContainsPredicate)SinglePropertyContainsPredicate.CreateFromInternalCondition <HeaderContainsPredicate>(condition, predicateCondition.Property.Name);

            if (headerContainsPredicate == null)
            {
                return(null);
            }
            try
            {
                headerContainsPredicate.MessageHeader = new HeaderName(predicateCondition.Property.Name);
            }
            catch (ArgumentOutOfRangeException)
            {
                return(null);
            }
            return(headerContainsPredicate);
        }
コード例 #2
0
        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
            }));
        }
コード例 #3
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (predicateCondition.Value.RawValues.Count != 1 || !predicateCondition.Name.Equals("isMessageType"))
            {
                return(null);
            }
            MessageType messageType;

            try
            {
                messageType = (MessageType)Enum.Parse(typeof(MessageType), predicateCondition.Value.RawValues[0]);
            }
            catch (ArgumentException)
            {
                return(null);
            }
            return(new MessageTypeMatchesPredicate
            {
                MessageType = messageType
            });
        }
コード例 #4
0
        internal static TransportRulePredicate CreateFromInternalCondition <T>(Condition condition, string propertyName) where T : SizeOverPredicate, new()
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!predicateCondition.Name.Equals("greaterThanOrEqual") || !predicateCondition.Property.Name.Equals(propertyName) || predicateCondition.Value.RawValues.Count != 1)
            {
                return(null);
            }
            ulong num;

            if (!ulong.TryParse(predicateCondition.Value.RawValues[0], out num))
            {
                return(null);
            }
            T t = Activator.CreateInstance <T>();

            if (num == 0UL)
            {
                t.Size = ByteQuantifiedSize.FromKB(0UL);
            }
            else
            {
                t.Size = ByteQuantifiedSize.FromBytes(num);
            }
            return(t);
        }
コード例 #5
0
 internal static PsComplianceRulePredicateBase FromEnginePredicate(PredicateCondition predicate)
 {
     if (predicate is GreaterThanOrEqualPredicate && predicate.Property.Name.Equals("Item.WhenCreated"))
     {
         return(PsContentDateFromPredicate.FromEnginePredicate(predicate as GreaterThanOrEqualPredicate));
     }
     if (predicate is LessThanOrEqualPredicate && predicate.Property.Name.Equals("Item.WhenCreated"))
     {
         return(PsContentDateToPredicate.FromEnginePredicate(predicate as LessThanOrEqualPredicate));
     }
     if (predicate is TextQueryPredicate)
     {
         return(PsContentMatchQueryPredicate.FromEnginePredicate(predicate as TextQueryPredicate));
     }
     if (predicate is EqualPredicate && predicate.Property.Name.Equals("Item.AccessScope"))
     {
         return(PsAccessScopeIsPredicate.FromEnginePredicate(predicate as EqualPredicate));
     }
     if (predicate is ContentContainsSensitiveInformationPredicate)
     {
         return(PsContentContainsSensitiveInformationPredicate.FromEnginePredicate(predicate as ContentContainsSensitiveInformationPredicate));
     }
     if (predicate is ContentMetadataContainsPredicate)
     {
         return(PsContentPropertyContainsWordsPredicate.FromEnginePredicate(predicate as ContentMetadataContainsPredicate));
     }
     throw new UnexpectedConditionOrActionDetectedException();
 }
コード例 #6
0
        internal static IEnumerable <PsComplianceRulePredicateBase> ConvertEngineConditionToTaskConditions(Microsoft.Office.CompliancePolicy.PolicyEvaluation.Condition condition)
        {
            List <PsComplianceRulePredicateBase> list = new List <PsComplianceRulePredicateBase>();
            QueryPredicate queryPredicate             = condition as QueryPredicate;

            if (queryPredicate != null)
            {
                AndCondition andCondition = queryPredicate.SubCondition as AndCondition;
                if (andCondition == null)
                {
                    return(list);
                }
                using (List <Microsoft.Office.CompliancePolicy.PolicyEvaluation.Condition> .Enumerator enumerator = andCondition.SubConditions.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Microsoft.Office.CompliancePolicy.PolicyEvaluation.Condition condition2 = enumerator.Current;
                        list.AddRange(PsHoldRule.ConvertEngineConditionToTaskConditions(condition2));
                    }
                    return(list);
                }
            }
            if (condition is PredicateCondition)
            {
                PredicateCondition predicate = condition as PredicateCondition;
                list.Add(PsComplianceRulePredicateBase.FromEnginePredicate(predicate));
            }
            else if (!(condition is TrueCondition))
            {
                throw new UnexpectedConditionOrActionDetectedException();
            }
            return(list);
        }
コード例 #7
0
        internal static TransportRulePredicate CreateFromInternalCondition <T>(Condition condition, string internalPredicateName, string internalPropertyName) where T : SmtpAddressesPredicate, new()
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!predicateCondition.Name.Equals(internalPredicateName) || !predicateCondition.Property.Name.Equals(internalPropertyName))
            {
                return(null);
            }
            List <SmtpAddress> list = new List <SmtpAddress>(predicateCondition.Value.RawValues.Count);

            for (int i = 0; i < predicateCondition.Value.RawValues.Count; i++)
            {
                SmtpAddress item = new SmtpAddress(predicateCondition.Value.RawValues[i]);
                if (item.IsValidAddress)
                {
                    list.Add(item);
                }
            }
            T t = Activator.CreateInstance <T>();

            if (list.Count > 0)
            {
                t.Addresses = list.ToArray();
            }
            return(t);
        }
コード例 #8
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!predicateCondition.Name.Equals("senderAttributeContains"))
            {
                return(null);
            }
            Word[] array = new Word[predicateCondition.Value.RawValues.Count];
            for (int i = 0; i < predicateCondition.Value.RawValues.Count; i++)
            {
                try
                {
                    array[i] = new Word(predicateCondition.Value.RawValues[i]);
                }
                catch (ArgumentOutOfRangeException)
                {
                    return(null);
                }
            }
            return(new SenderAttributeContainsPredicate
            {
                Words = array
            });
        }
コード例 #9
0
        internal static TransportRulePredicate CreateFromInternalCondition <T>(Condition condition, string internalPropertyName) where T : SinglePropertyContainsPredicate, new()
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!predicateCondition.Name.Equals("contains") || !predicateCondition.Property.Name.Equals(internalPropertyName))
            {
                return(null);
            }
            Word[] array = new Word[predicateCondition.Value.RawValues.Count];
            for (int i = 0; i < predicateCondition.Value.RawValues.Count; i++)
            {
                try
                {
                    array[i] = new Word(predicateCondition.Value.RawValues[i]);
                }
                catch (ArgumentOutOfRangeException)
                {
                    return(null);
                }
            }
            T t = Activator.CreateInstance <T>();

            t.Words = array;
            return(t);
        }
コード例 #10
0
        internal static TransportRulePredicate CreateFromInternalCondition <T>(Condition condition, string internalPropertyName) where T : SinglePropertyMatchesPredicate, new()
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if ((!predicateCondition.Name.Equals("matches") && !predicateCondition.Name.Equals("matchesRegex")) || !predicateCondition.Property.Name.Equals(internalPropertyName))
            {
                return(null);
            }
            bool useLegacyRegex = !predicateCondition.Name.Equals("matchesRegex");

            Pattern[] array = new Pattern[predicateCondition.Value.RawValues.Count];
            for (int i = 0; i < predicateCondition.Value.RawValues.Count; i++)
            {
                try
                {
                    array[i] = new Pattern(predicateCondition.Value.RawValues[i], useLegacyRegex, false);
                }
                catch (ArgumentException)
                {
                    return(null);
                }
            }
            T t = Activator.CreateInstance <T>();

            t.UseLegacyRegex = useLegacyRegex;
            t.patterns       = array;
            return(t);
        }
コード例 #11
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!predicateCondition.Name.Equals("senderAttributeMatches") && !predicateCondition.Name.Equals("senderAttributeMatchesRegex"))
            {
                return(null);
            }
            bool useLegacyRegex = !predicateCondition.Name.Equals("senderAttributeMatchesRegex");

            Pattern[] array = new Pattern[predicateCondition.Value.RawValues.Count];
            for (int i = 0; i < predicateCondition.Value.RawValues.Count; i++)
            {
                try
                {
                    array[i] = new Pattern(predicateCondition.Value.RawValues[i], useLegacyRegex, false);
                }
                catch (ArgumentException)
                {
                    return(null);
                }
            }
            return(new SenderAttributeMatchesPredicate(useLegacyRegex)
            {
                Patterns = array
            });
        }
コード例 #12
0
        private static bool IsImportanceCondition(Condition condition, Importance importance)
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(false);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            return(predicateCondition.Name.Equals("is") && predicateCondition.Property is HeaderProperty && predicateCondition.Property.Name.Equals("Importance") && predicateCondition.Value.RawValues.Count == 1 && predicateCondition.Value.RawValues[0].Equals(importance.ToString()));
        }
コード例 #13
0
            public override bool Equals(object obj)
            {
                PredicateCondition c = obj as PredicateCondition;

                if (c == null)
                {
                    return(false);
                }

                return(m_predicate.Equals(c.m_predicate) && m_invert == c.m_invert);
            }
コード例 #14
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            if (condition.ConditionType != ConditionType.Or)
            {
                return(null);
            }
            OrCondition orCondition = (OrCondition)condition;

            if (orCondition.SubConditions.Count != 2)
            {
                return(null);
            }
            if (orCondition.SubConditions[0].ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            if (orCondition.SubConditions[1].ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition  = (PredicateCondition)orCondition.SubConditions[0];
            PredicateCondition predicateCondition2 = (PredicateCondition)orCondition.SubConditions[1];

            if (!predicateCondition.Name.Equals("contains") || !predicateCondition2.Name.Equals("contains") || !predicateCondition.Property.Name.Equals("Message.Subject") || !predicateCondition2.Property.Name.Equals("Message.Body"))
            {
                return(null);
            }
            if (predicateCondition.Value.RawValues.Count != predicateCondition2.Value.RawValues.Count)
            {
                return(null);
            }
            Word[] array = new Word[predicateCondition.Value.RawValues.Count];
            for (int i = 0; i < predicateCondition.Value.RawValues.Count; i++)
            {
                if (predicateCondition.Value.RawValues[i] != predicateCondition2.Value.RawValues[i])
                {
                    return(null);
                }
                try
                {
                    array[i] = new Word(predicateCondition.Value.RawValues[i]);
                }
                catch (ArgumentOutOfRangeException)
                {
                    return(null);
                }
            }
            return(new SubjectOrBodyContainsPredicate
            {
                Words = array
            });
        }
コード例 #15
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!predicateCondition.Name.Equals("attachmentIsUnsupported"))
            {
                return(null);
            }
            return(new AttachmentIsUnsupportedPredicate());
        }
コード例 #16
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!predicateCondition.Name.Equals("hasSenderOverride") || !predicateCondition.Property.Name.Equals("X-Ms-Exchange-Organization-Dlp-SenderOverrideJustification"))
            {
                return(null);
            }
            return(new HasSenderOverridePredicate());
        }
コード例 #17
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!predicateCondition.Name.Equals("is") || !predicateCondition.Property.Name.Equals("Message.AttachmentTypes") || predicateCondition.Value.RawValues.Count != 1 || !predicateCondition.Value.RawValues[0].Equals("executable"))
            {
                return(null);
            }
            return(new AttachmentHasExecutableContentPredicate());
        }
コード例 #18
0
        internal override PredicateCondition ToEnginePredicate()
        {
            PredicateCondition result = null;

            try
            {
                result = new ContentMetadataContainsPredicate(base.Words.ToList <string>());
            }
            catch (CompliancePolicyValidationException innerException)
            {
                throw new InvalidContentContentPropertyContainsWordsException(Strings.InvalidContentPropertyContainsWordsPredicate, innerException);
            }
            return(result);
        }
コード例 #19
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            bool flag = false;

            if (condition.ConditionType == ConditionType.Not)
            {
                condition = ((NotCondition)condition).SubCondition;
                flag      = true;
            }
            if (condition.ConditionType != ConditionType.And)
            {
                return(null);
            }
            AndCondition andCondition = (AndCondition)condition;

            if (andCondition.SubConditions.Count != 2 || andCondition.SubConditions[0].ConditionType != ConditionType.Not || andCondition.SubConditions[1].ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            NotCondition notCondition = (NotCondition)andCondition.SubConditions[0];

            if (notCondition.SubCondition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition  = (PredicateCondition)notCondition.SubCondition;
            PredicateCondition predicateCondition2 = (PredicateCondition)andCondition.SubConditions[1];

            if (!predicateCondition.Name.Equals("is") || !predicateCondition.Property.Name.Equals("Message.Auth") || predicateCondition.Value.RawValues.Count != 1 || !predicateCondition.Value.RawValues[0].Equals("<>"))
            {
                return(null);
            }
            if (!predicateCondition2.Name.Equals("isInternal") || !predicateCondition2.Property.Name.Equals("Message.From") || predicateCondition2.Value.RawValues.Count != 0)
            {
                return(null);
            }
            FromScopePredicate fromScopePredicate = new FromScopePredicate();

            if (flag)
            {
                fromScopePredicate.Scope = FromUserScope.NotInOrganization;
            }
            else
            {
                fromScopePredicate.Scope = FromUserScope.InOrganization;
            }
            return(fromScopePredicate);
        }
コード例 #20
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!predicateCondition.Name.Equals("is") || !predicateCondition.Property.Name.Equals("Message.AttachmentExtensions"))
            {
                return(null);
            }
            Word[] array = (from value in predicateCondition.Value.RawValues
                            select new Word(value)).ToArray <Word>();
            return(new AttachmentExtensionMatchesWordsPredicate(array));
        }
コード例 #21
0
        private void AddPredicateToCondition <T>(List <Condition> subConditions, string conditionTag, string propertyName, bool negateCondition, T[] values)
        {
            if (values == null || values.Length == 0)
            {
                return;
            }
            PredicateCondition predicateCondition = ClientAccessRuleParser.Instance.CreatePredicate(conditionTag, ClientAccessRuleParser.Instance.CreateProperty(propertyName), from value in values
                                                                                                    select value.ToString());

            if (negateCondition)
            {
                subConditions.Add(new NotCondition(predicateCondition));
                return;
            }
            subConditions.Add(predicateCondition);
        }
コード例 #22
0
        internal static TransportRulePredicate CreateFromInternalConditionWithSession(Condition condition, IConfigDataProvider session)
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if ((!predicateCondition.Name.Equals("is") && !predicateCondition.Name.Equals("contains")) || !(predicateCondition.Property is HeaderProperty) || !predicateCondition.Property.Name.Equals("X-MS-Exchange-Organization-Classification") || predicateCondition.Value.RawValues.Count != 1)
            {
                return(null);
            }
            return(new HasClassificationPredicate(session)
            {
                Classification = Utils.GetClassificationADObjectId(predicateCondition.Value.RawValues[0], session)
            });
        }
コード例 #23
0
ファイル: DecisionTree.cs プロジェクト: AdamStefan/DataMining
 public static string GetStringCondition(PredicateCondition condition)
 {
     switch (condition)
     {
         case PredicateCondition.Equal:
             return "=";
             break;
         case PredicateCondition.LessThanOrEqual:
             return "<=";
             break;
         case PredicateCondition.GreaterThan:
             return  ">";
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
コード例 #24
0
        internal override Condition ToInternalCondition()
        {
            PredicateCondition item  = TransportRuleParser.Instance.CreatePredicate("exists", TransportRuleParser.Instance.CreateProperty("Message.SclValue"), new ShortList <string>());
            PredicateCondition item2 = TransportRuleParser.Instance.CreatePredicate("greaterThanOrEqual", TransportRuleParser.Instance.CreateProperty("Message.SclValue"), new ShortList <string>
            {
                this.SclValue.ToString()
            });

            return(new AndCondition
            {
                SubConditions =
                {
                    item,
                    item2
                }
            });
        }
コード例 #25
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!(predicateCondition.Property is HeaderProperty))
            {
                return(null);
            }
            if (!predicateCondition.Name.Equals("notExists") || !predicateCondition.Property.Name.Equals("X-MS-Exchange-Organization-Classification"))
            {
                return(null);
            }
            return(new HasNoClassificationPredicate());
        }
コード例 #26
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            if (condition.ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition = (PredicateCondition)condition;

            if (!predicateCondition.Name.Equals("attachmentPropertyContains"))
            {
                return(null);
            }
            AttachmentPropertyContainsWordsPredicate attachmentPropertyContainsWordsPredicate = new AttachmentPropertyContainsWordsPredicate();

            attachmentPropertyContainsWordsPredicate.Words = (from w in predicateCondition.Value.RawValues
                                                              select new Word(w)).ToArray <Word>();
            return(attachmentPropertyContainsWordsPredicate);
        }
コード例 #27
0
        internal override Condition ToInternalCondition()
        {
            if (this.Importance != Importance.Normal)
            {
                return(WithImportancePredicate.CreateImportancePredicate(this.Importance));
            }
            PredicateCondition item  = WithImportancePredicate.CreateImportancePredicate(Importance.High);
            PredicateCondition item2 = WithImportancePredicate.CreateImportancePredicate(Importance.Low);

            return(new NotCondition(new OrCondition
            {
                SubConditions =
                {
                    item,
                    item2
                }
            }));
        }
コード例 #28
0
        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);
        }
コード例 #29
0
        internal override Condition ToInternalCondition()
        {
            ShortList <string> shortList = new ShortList <string>();

            foreach (Word word in this.Words)
            {
                shortList.Add(word.ToString());
            }
            PredicateCondition item  = TransportRuleParser.Instance.CreatePredicate("contains", TransportRuleParser.Instance.CreateProperty("Message.Subject"), shortList);
            PredicateCondition item2 = TransportRuleParser.Instance.CreatePredicate("contains", TransportRuleParser.Instance.CreateProperty("Message.Body"), shortList);

            return(new OrCondition
            {
                SubConditions =
                {
                    item,
                    item2
                }
            });
        }
コード例 #30
0
        internal static TransportRulePredicate CreateFromInternalCondition(Condition condition)
        {
            if (condition.ConditionType != ConditionType.And)
            {
                return(null);
            }
            AndCondition andCondition = (AndCondition)condition;

            if (andCondition.SubConditions.Count != 2 || andCondition.SubConditions[0].ConditionType != ConditionType.Predicate || andCondition.SubConditions[1].ConditionType != ConditionType.Predicate)
            {
                return(null);
            }
            PredicateCondition predicateCondition  = (PredicateCondition)andCondition.SubConditions[0];
            PredicateCondition predicateCondition2 = (PredicateCondition)andCondition.SubConditions[1];

            if (!predicateCondition.Name.Equals("exists") || !predicateCondition.Property.Name.Equals("Message.SclValue"))
            {
                return(null);
            }
            if (!predicateCondition2.Name.Equals("greaterThanOrEqual") || !predicateCondition2.Property.Name.Equals("Message.SclValue") || predicateCondition2.Value.RawValues.Count != 1)
            {
                return(null);
            }
            int input;

            if (!int.TryParse(predicateCondition2.Value.RawValues[0], out input))
            {
                return(null);
            }
            SclOverPredicate sclOverPredicate = new SclOverPredicate();

            try
            {
                sclOverPredicate.SclValue = new SclValue(input);
            }
            catch (ArgumentOutOfRangeException)
            {
                return(null);
            }
            return(sclOverPredicate);
        }
コード例 #31
0
        internal override Condition ToInternalCondition()
        {
            ShortList <string> valueEntries = new ShortList <string>
            {
                "<>"
            };
            PredicateCondition subCondition = TransportRuleParser.Instance.CreatePredicate("is", TransportRuleParser.Instance.CreateProperty("Message.Auth"), valueEntries);

            valueEntries = new ShortList <string>();
            NotCondition       item         = new NotCondition(subCondition);
            PredicateCondition item2        = TransportRuleParser.Instance.CreatePredicate("isInternal", TransportRuleParser.Instance.CreateProperty("Message.From"), valueEntries);
            AndCondition       andCondition = new AndCondition();

            andCondition.SubConditions.Add(item);
            andCondition.SubConditions.Add(item2);
            if (this.Scope == FromUserScope.NotInOrganization)
            {
                return(new NotCondition(andCondition));
            }
            return(andCondition);
        }