private bool CanSkipRule(Rule rule) { if (rule.Actions == null) { this.context.TraceDebug <string>("Skipping rule with no actions: \"{0}.\"", rule.Name); return(true); } if (!this.context.IsOof && RuleLoader.IsOofRule(rule)) { this.context.TraceDebug <string>("Skipping OOF rule: \"{0}.\"", rule.Name); return(true); } if ((rule.StateFlags & RuleStateFlags.TempDisabled) != (RuleStateFlags)0) { if (!this.context.ShouldExecuteDisabledAndInErrorRules) { this.context.TraceDebug <string>("Skipping temporarily disabled rule: \"{0}.\"", rule.Name); return(true); } this.context.TraceDebug <string>("Including temporarily disabled rule: \"{0}\" for test message", rule.Name); } if ((rule.StateFlags & RuleStateFlags.LegacyOofRule) != (RuleStateFlags)0) { this.context.TraceDebug <string>("Skipping legacy OOF rule \"{0}.\"", rule.Name); return(true); } if ((rule.StateFlags & RuleStateFlags.Enabled) == (RuleStateFlags)0 && (rule.StateFlags & RuleStateFlags.OnlyWhenOOFEx) == (RuleStateFlags)0) { if (!this.context.ShouldExecuteDisabledAndInErrorRules) { this.context.TraceDebug <string>("Skipping disabled rule \"{0}.\"", rule.Name); return(true); } this.context.TraceDebug <string>("Including disabled rule: \"{0}\" for test message", rule.Name); } if ((rule.StateFlags & RuleStateFlags.Error) != (RuleStateFlags)0) { if (!this.context.ShouldExecuteDisabledAndInErrorRules) { this.context.TraceDebug <string>("Skipping rule \"{0},\" it is in error.", rule.Name); return(true); } this.context.TraceDebug <string>("Including in error rule: \"{0}\" for test message", rule.Name); } if (this.IsSafeMessage() && RuleLoader.IsJunkEmailRule(rule)) { this.context.TraceDebug <string>("Skipping junk email rule \"{0}\" for this trusted message.", rule.Name); return(true); } return(false); }
private FolderEvaluationResult EvaluateRulesOnCurrentFolder() { FolderEvaluationResult folderEvaluationResult = null; string stage = ServerStrings.FolderRuleStageLoading; try { RuleUtil.FaultInjection((FaultInjectionLid)3353750845U); List <Rule> list = this.context.LoadRules(); if (list == null) { return(null); } stage = ServerStrings.FolderRuleStageEvaluation; folderEvaluationResult = new FolderEvaluationResult(this.context, list); if (this.context.SharedPropertiesBetweenAgents == null) { this.context.SharedPropertiesBetweenAgents = new Dictionary <PropertyDefinition, object>(); } foreach (Rule rule in folderEvaluationResult.Rules) { this.context.CurrentRule = rule; if (this.EvaluateRule(rule, folderEvaluationResult)) { if ((rule.StateFlags & RuleStateFlags.ExitAfterExecution) != (RuleStateFlags)0) { this.context.TraceDebug <string>("Encountered exit level rule {0} ", rule.Name); folderEvaluationResult.ExitExecution = true; this.context.SharedPropertiesBetweenAgents[ItemSchema.IsStopProcessingRuleApplicable] = true; } if (RuleLoader.IsJunkEmailRule(rule)) { this.context.TraceDebug <string>("Processed junk email rule {0} ", rule.Name); this.context.SharedPropertiesBetweenAgents[SharedProperties.ItemMovedByJunkMailRule] = folderEvaluationResult.IsMessageMoved; break; } if (RuleLoader.IsNeverClutterOverrideRule(rule)) { this.context.SharedPropertiesBetweenAgents[ItemSchema.InferenceNeverClutterOverrideApplied] = true; } this.context.SharedPropertiesBetweenAgents[ItemSchema.ItemMovedByConversationAction] = this.context.ShouldSkipMoveRule; this.context.SharedPropertiesBetweenAgents[ItemSchema.ItemMovedByRule] = folderEvaluationResult.IsMessageMoved; if (!folderEvaluationResult.ShouldContinue) { this.context.TraceDebug("Terminate rules processing on current folder"); break; } } } this.context.CurrentRule = null; } catch (StoragePermanentException exception) { this.context.RecordError(exception, stage); } catch (ExchangeDataException exception2) { this.context.RecordError(exception2, stage); } catch (MapiPermanentException exception3) { this.context.RecordError(exception3, stage); } catch (DataValidationException exception4) { this.context.RecordError(exception4, stage); } finally { this.context.CurrentRule = null; } return(folderEvaluationResult); }