Exemplo n.º 1
0
        internal void FindURIRuleUpdates(ref string pageCookie, out URIRulePackageData newRules, out URIRulePackageData deletedRules, bool activeOnly = false)
        {
            newRules     = null;
            deletedRules = null;
            QueryFilter queryFilter = QueryFilter.AndTogether(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.Equal, RuleBase.RuleTypeProperty, 1),
                new ComparisonFilter(ComparisonOperator.Equal, KesSpamSchema.ActiveOnlyProperty, activeOnly),
                base.BuildVersionParam
            });
            List <URIRule> list = base.FindPagedRules <URIRule>(queryFilter, ref pageCookie, 1000);

            if (list != null && list.Count > 0)
            {
                List <URIRule> list2 = (from item in list
                                        where item.IsActive.Value
                                        select item).ToList <URIRule>();
                if (list2.Any <URIRule>())
                {
                    newRules = base.GenerateURIRulePackageData(list2);
                }
                List <URIRule> list3 = (from item in list
                                        where !item.IsActive.Value
                                        select item).ToList <URIRule>();
                if (list3.Count > 0)
                {
                    deletedRules = base.GenerateURIRulePackageData(list3);
                }
            }
        }
Exemplo n.º 2
0
        internal void FindURIRuleUpdates(ref DateTime changedDate, out URIRulePackageData newRules, out URIRulePackageData deletedRules, bool activeOnly = false)
        {
            newRules     = null;
            deletedRules = null;
            QueryFilter queryFilter = QueryFilter.AndTogether(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.Equal, RuleBase.RuleTypeProperty, 1),
                new ComparisonFilter(ComparisonOperator.Equal, KesSpamSchema.ActiveOnlyProperty, activeOnly),
                base.BuildVersionParam
            });

            if (changedDate != DateTime.MinValue)
            {
                DateTime dateTime = changedDate.Subtract(TimeSpan.FromSeconds(30.0));
                queryFilter = QueryFilter.AndTogether(new QueryFilter[]
                {
                    queryFilter,
                    new ComparisonFilter(ComparisonOperator.Equal, RuleBase.ChangedDatetimeProperty, dateTime)
                });
            }
            List <URIRule> list = base.DataProvider.Find <URIRule>(queryFilter, null, true, null).Cast <URIRule>().ToList <URIRule>();

            if (list != null && list.Count > 0)
            {
                List <URIRule> list2 = (from item in list
                                        where item.IsActive.Value
                                        select item).ToList <URIRule>();
                if (list2 != null && list2.Any <URIRule>())
                {
                    newRules = base.GenerateURIRulePackageData(list2);
                }
                List <URIRule> list3 = (from item in list
                                        where !item.IsActive.Value
                                        select item).ToList <URIRule>();
                if (list3 != null && list3.Count > 0)
                {
                    deletedRules = base.GenerateURIRulePackageData(list3);
                }
                changedDate = (from item in list
                               where item.ChangeDatetime != null
                               select item.ChangeDatetime.Value).Max <DateTime>();
            }
        }