private void SetAction(bool responseCodeModified, bool responseTextModified, bool actionModified, bool pathModified, bool timeIntervalModified) { if (responseCodeModified || responseTextModified || actionModified || timeIntervalModified || pathModified) { string customResponseCode = this.CustomResponseCode; bool flag = false; if (!responseCodeModified && !SmtpResponse.Empty.Equals(this.rule.Action.Response)) { customResponseCode = this.rule.Action.Response.StatusCode; flag = true; } string customResponseText = this.CustomResponseString; bool flag2 = false; if (!responseTextModified && !SmtpResponse.Empty.Equals(this.rule.Action.Response)) { customResponseText = this.rule.Action.Response.StatusText[0]; flag2 = true; } TimeSpan timeInterval = timeIntervalModified ? this.TimeInterval : this.rule.Action.Delay; InterceptorAgentAction interceptorAgentAction; LocalizedString warning; LocalizedString localizedString; if (!InterceptorHelper.TryCreateAction(actionModified ? this.Action : this.rule.Action.Action, customResponseCode, responseCodeModified || flag, customResponseText, responseTextModified || flag2, timeInterval, pathModified ? this.Path : this.rule.Action.Path, out interceptorAgentAction, out warning, out localizedString)) { base.WriteError(new LocalizedException(localizedString), ErrorCategory.InvalidData, actionModified ? this.Action : this.rule.Action.Action); } this.WriteWarningAndReset(warning); if (actionModified && InterceptorAgentAction.IsArchivingBehavior(interceptorAgentAction.Action)) { this.WriteWarning(InterceptorHelper.GetArchivedItemRetentionMessage(interceptorAgentAction.Action, this.Identity.ToString(), this.Path, 14)); } this.rule.Action = interceptorAgentAction; } }
protected override void InternalValidate() { base.InternalValidate(); if (base.Fields.IsModified("ExpireTime") && DateTime.UtcNow > this.ExpireTime.ToUniversalTime()) { base.WriteError(new LocalizedException(Strings.InterceptorErrorExpireTimePassed(this.ExpireTime.ToString("G"))), ErrorCategory.InvalidData, "ExpireTime"); } List <InterceptorAgentCondition> conditions; LocalizedString localizedString; if (!InterceptorHelper.TryCreateConditions(this.Condition, out conditions, out localizedString)) { base.WriteError(new LocalizedException(localizedString), ErrorCategory.InvalidData, this.Condition); return; } if (this.Event == InterceptorAgentEvent.Invalid) { base.WriteError(new LocalizedException(Strings.InterceptorErrorEventInvalid), ErrorCategory.InvalidData, this.Event); } if (this.Action == InterceptorAgentRuleBehavior.NoOp) { base.WriteError(new LocalizedException(Strings.InterceptorErrorActionInvalid), ErrorCategory.InvalidData, this.Action); } if (!InterceptorHelper.ValidateEventConditionPairs(this.Event, conditions, out localizedString)) { base.WriteError(new LocalizedException(localizedString), ErrorCategory.InvalidArgument, this.Condition); } if (!InterceptorHelper.ValidateEventActionPairs(this.Event, this.Action, out localizedString)) { base.WriteError(new LocalizedException(localizedString), ErrorCategory.InvalidArgument, this.Condition); } InterceptorAgentAction interceptorAgentAction; LocalizedString warning; if (!InterceptorHelper.TryCreateAction(this.Action, this.CustomResponseCode, base.Fields.IsChanged("CustomResponseCode"), this.CustomResponseString, base.Fields.IsChanged("CustomResponseText"), this.TimeInterval, this.Path, out interceptorAgentAction, out warning, out localizedString)) { base.WriteError(new LocalizedException(localizedString), ErrorCategory.InvalidData, this.Action); } this.WriteWarningAndReset(warning); if (InterceptorAgentAction.IsArchivingBehavior(interceptorAgentAction.Action)) { this.WriteWarning(InterceptorHelper.GetArchivedItemRetentionMessage(interceptorAgentAction.Action, this.Name, this.Path, 14)); } this.ResolveTargets(); if (!base.HasErrors) { this.rule = new InterceptorAgentRule(this.Name, this.Description, conditions, interceptorAgentAction, this.Event, this.Source, this.CreatedBy); } }