public override void Execute() { MessageItem deliveredMessage = base.Context.DeliveredMessage; StorePropertyDefinition propertyDefinitionForTag = base.Context.GetPropertyDefinitionForTag(this.value.PropTag); if (!RuleUtil.IsMultiValueTag(this.value.PropTag)) { base.Context.TraceDebug <PropTag, object>("Setting single value property '{0}' to '{1}'", this.value.PropTag, this.value.Value ?? "null"); deliveredMessage[propertyDefinitionForTag] = this.value.Value; return; } Array array = this.value.Value as Array; if (RuleUtil.IsNullOrEmpty(array)) { base.Context.TraceDebug <PropTag>("Clearing the existing multi-value property '{0}' since new value specified in rule was null or empty.", this.value.PropTag); deliveredMessage[propertyDefinitionForTag] = this.value.Value; return; } Array array2 = deliveredMessage.TryGetProperty(propertyDefinitionForTag) as Array; if (RuleUtil.IsNullOrEmpty(array2)) { base.Context.TraceDebug <PropTag, int>("Setting multi-value property '{0}' to {1} elements, since no existing value were found.", this.value.PropTag, array.Length); deliveredMessage[propertyDefinitionForTag] = array; return; } Type elementType = array2.GetType().GetElementType(); Array array3 = Array.CreateInstance(elementType, array2.Length + array.Length); array2.CopyTo(array3, 0); array.CopyTo(array3, array2.Length); base.Context.TraceDebug <PropTag, int>("Setting multi-value property '{0}' to {1} elements, which contains the concatenated array of existing and new values.", this.value.PropTag, array3.Length); deliveredMessage[propertyDefinitionForTag] = array3; }
public DelegateWorkItem(IRuleEvaluationContext context, AdrEntry[] recipients, int actionIndex) : base(context, actionIndex) { if (RuleUtil.IsNullOrEmpty(recipients)) { throw new ArgumentException("Delegate recipient list is empty"); } this.recipients = recipients; }
public ForwardWorkItem(IRuleEvaluationContext context, AdrEntry[] recipients, RuleAction.Forward.ActionFlags flags, int actionIndex) : base(context, actionIndex) { if (RuleUtil.IsNullOrEmpty(recipients)) { throw new ArgumentException("Forward recipient list is empty"); } this.flags = flags; this.recipients = recipients; }
private void CreateWorkItemForDelegate(FolderEvaluationResult result, RuleAction.Delegate action, int actionIndex) { if (RuleUtil.IsNullOrEmpty(action.Recipients)) { this.context.TraceError("Delegate recipient list is empty"); return; } result.AddWorkItem(new DelegateWorkItem(this.context, action.Recipients, actionIndex)); }
private void UpdateDeliveredMessage() { base.Context.TraceDebug("Deferred action: Updating delivered message."); MessageItem deliveredMessage = base.Context.DeliveredMessage; if (!RuleUtil.IsNullOrEmpty(this.MoveToFolderEntryId) && !RuleUtil.IsNullOrEmpty(this.MoveToStoreEntryId)) { deliveredMessage[ItemSchema.MoveToStoreEntryId] = this.MoveToStoreEntryId; deliveredMessage[ItemSchema.MoveToFolderEntryId] = this.MoveToFolderEntryId; } deliveredMessage[ItemSchema.HasDeferredActionMessage] = true; }
private void CreateWorkItemForOofReply(FolderEvaluationResult result, RuleAction.OOFReply action, int actionIndex) { string className = this.context.Message.ClassName; if (ObjectClass.IsDsn(className) || ObjectClass.IsMdn(className)) { this.context.TraceDebug("Do not generate OOF reply for Dsn or Mdn messages"); return; } if ((this.context.Message.AutoResponseSuppress & AutoResponseSuppress.OOF) != AutoResponseSuppress.None) { this.context.TraceDebug("Do not generate OOF reply when Oof Reply is being suppressed"); return; } if (ObjectClass.IsOfClass(className, "IPM.Note.Rules.ExternalOofTemplate.Microsoft") || ObjectClass.IsOfClass(className, "IPM.Note.Rules.OofTemplate.Microsoft")) { this.context.TraceDebug("Do not generate OOF reply for Oof Message"); return; } if (ObjectClass.IsOutlookRecall(className) || ObjectClass.IsOfClass(className, "IPM.Recall.Report.Failure") || ObjectClass.IsOfClass(className, "IPM.Recall.Report.Success")) { this.context.TraceDebug("Do not generate OOF reply for outlook recall Message"); return; } if (null == this.context.Message.Sender) { this.context.TraceDebug("Do not generate OOF reply for an unknown sender"); return; } string routingType = this.context.Message.Sender.RoutingType; if (string.IsNullOrEmpty(routingType) || (!(routingType == "SMTP") && !(routingType == "EX") && !routingType.Equals("X400"))) { this.context.TraceDebug <string>("Do not generate OOF reply for address type {0}", routingType ?? "<null>"); return; } if (RuleUtil.IsNullOrEmpty(action.ReplyTemplateMessageEntryID)) { this.context.TraceError("Replay template message id is empty"); return; } bool?valueAsNullable = this.context.Message.GetValueAsNullable <bool>(ItemSchema.DelegatedByRule); if (valueAsNullable != null && valueAsNullable.Value) { this.context.TraceDebug("Do not generate OOF reply for messages delegated by rule."); return; } result.AddWorkItem(new OofReplyWorkItem(this.context, action.ReplyTemplateMessageEntryID, actionIndex)); }
private void CreateWorkItemForForward(FolderEvaluationResult result, RuleAction.Forward action, int actionIndex) { if (ObjectClass.IsDsn(this.context.Message.ClassName) || ObjectClass.IsMdn(this.context.Message.ClassName)) { this.context.TraceDebug("Do not forward for Dsn or Mdn messages"); return; } if (this.context.Message.Sensitivity == Sensitivity.Private) { this.context.TraceDebug("Do not forward private message"); return; } object obj = this.context.Message.TryGetProperty(MessageItemSchema.RecipientReassignmentProhibited); if (obj is bool && (bool)obj) { this.context.TraceDebug("Do not forward message is recipient reassignment is prohibited"); return; } if ((this.context.Message.AutoResponseSuppress & AutoResponseSuppress.AutoReply) != AutoResponseSuppress.None && RuleLoader.IsOofRule(this.context.CurrentRule)) { this.context.TraceDebug("Do not forward message is auto reply is suppressed"); return; } if (RuleUtil.IsNullOrEmpty(action.Recipients)) { this.context.TraceError("Forward recipient list is empty"); return; } if (!this.context.LimitChecker.CheckAndIncrementForwardeeCount(action.Recipients.Length)) { this.context.TraceDebug(string.Concat(new object[] { "Rule ", this.context.CurrentRule.Name, " is forwarding to ", action.Recipients.Length, " additional recipients, which reached the accumulated forwardee limit, evaluation skipped." })); return; } result.AddWorkItem(new ForwardWorkItem(this.context, action.Recipients, action.Flags, actionIndex)); }
public bool CheckAndIncrementContentRestrictionCount(int count, byte[] valueToCompare) { return(RuleUtil.IsNullOrEmpty(valueToCompare) || 1000000 >= valueToCompare.Length || this.CheckAndIncrementContentRestrictionCount(count)); }