protected override void StampChangesOn(IConfigurable dataObject) { RuleStorage ruleStorage = (RuleStorage)dataObject; ruleStorage.ResetChangeTracking(true); base.PsRulePresentationObject = new PsHoldRule(ruleStorage); PsHoldRule psHoldRule = (PsHoldRule)base.PsRulePresentationObject; base.PsRulePresentationObject.PopulateTaskProperties(this, base.DataSession as IConfigurationSession); if (base.PsRulePresentationObject.ReadOnly) { throw new TaskRuleIsTooAdvancedToModifyException(base.PsRulePresentationObject.Name); } if (ruleStorage.Mode == Mode.PendingDeletion) { base.WriteError(new ErrorCommonComplianceRuleIsDeletedException(ruleStorage.Name), ErrorCategory.InvalidOperation, null); } base.StampChangesOn(dataObject); this.CopyExplicitParameters(); if (!Utils.ValidateContentDateParameter(psHoldRule.ContentDateFrom, psHoldRule.ContentDateTo)) { throw new InvalidContentDateFromAndContentDateToPredicateException(); } if (!psHoldRule.GetTaskActions().Any <PsComplianceRuleActionBase>()) { base.WriteError(new RuleContainsNoActionsException(psHoldRule.Name), ErrorCategory.InvalidData, psHoldRule); } psHoldRule.UpdateStorageProperties(this, base.DataSession as IConfigurationSession, false); }
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); }
protected override IConfigurable PrepareDataObject() { RuleStorage ruleStorage = (RuleStorage)base.PrepareDataObject(); ruleStorage.Name = base.Name; ruleStorage.SetId(((ADObjectId)this.policyStorage.Identity).GetChildId(base.Name)); PsHoldRule psHoldRule = new PsHoldRule(ruleStorage) { Comment = base.Comment, Disabled = base.Disabled, Mode = Mode.Enforce, Policy = Utils.GetUniversalIdentity(this.policyStorage), Workload = this.policyStorage.Workload, ContentMatchQuery = this.ContentMatchQuery, ContentDateFrom = this.ContentDateFrom, ContentDateTo = this.ContentDateTo, HoldContent = this.HoldContent, HoldDurationDisplayHint = this.HoldDurationDisplayHint }; if (!psHoldRule.GetTaskActions().Any <PsComplianceRuleActionBase>()) { throw new RuleContainsNoActionsException(psHoldRule.Name); } ADObjectId adobjectId; base.TryGetExecutingUserId(out adobjectId); psHoldRule.UpdateStorageProperties(this, base.DataSession as IConfigurationSession, true); return(ruleStorage); }
protected override void WriteResult(IConfigurable dataObject) { PsHoldRule psHoldRule = new PsHoldRule(dataObject as RuleStorage); psHoldRule.PopulateTaskProperties(this, base.DataSession as IConfigurationSession); base.WriteResult(psHoldRule); }
protected override void WriteResult(IConfigurable dataObject) { PsHoldRule psHoldRule = new PsHoldRule(dataObject as RuleStorage); psHoldRule.PopulateTaskProperties(this, base.DataSession as IConfigurationSession); if (psHoldRule.ReadOnly) { this.WriteWarning(Strings.WarningTaskRuleIsTooAdvancedToRead(psHoldRule.Name)); } base.WriteResult(psHoldRule); }
internal override void UpdateStorageProperties(Task task, IConfigurationSession configurationSession, bool isNewRule) { base.UpdateStorageProperties(task, configurationSession, isNewRule); if (base.ObjectState != ObjectState.Unchanged) { PolicyRule policyRule = new PolicyRule { Condition = PsHoldRule.ConvertTaskConditionsToEngineCondition(this.GetTaskConditions()), Actions = PsHoldRule.ConvertTaskActionsToEngineActions(this.GetTaskActions()), Comments = base.Comment, Enabled = (base.Enabled ? RuleState.Enabled : RuleState.Disabled), ImmutableId = base.Guid, Name = base.Name }; base.RuleBlob = this.GetRuleXmlFromPolicyRule(policyRule); } }
internal override void PopulateTaskProperties(Task task, IConfigurationSession configurationSession) { base.PopulateTaskProperties(task, configurationSession); if (!string.IsNullOrEmpty(base.RuleBlob)) { PolicyRule policyRuleFromRuleBlob = this.GetPolicyRuleFromRuleBlob(); if (policyRuleFromRuleBlob.IsTooAdvancedToParse) { base.ReadOnly = true; } else { this.SetTaskConditions(PsHoldRule.ConvertEngineConditionToTaskConditions(policyRuleFromRuleBlob.Condition)); this.SetTaskActions(PsHoldRule.ConvertEngineActionsToTaskActions(policyRuleFromRuleBlob.Actions)); } base.ResetChangeTracking(); } }
protected override void CopyExplicitParameters() { base.CopyExplicitParameters(); PsHoldRule psHoldRule = (PsHoldRule)base.PsRulePresentationObject; if (base.Fields.IsModified("HoldContent")) { psHoldRule.HoldContent = this.HoldContent; } if (base.Fields.IsModified("HoldDurationDisplayHint")) { psHoldRule.HoldDurationDisplayHint = this.HoldDurationDisplayHint; } if (base.Fields.IsModified("ContentDateFrom")) { psHoldRule.ContentDateFrom = this.ContentDateFrom; } if (base.Fields.IsModified("ContentDateTo")) { psHoldRule.ContentDateTo = this.ContentDateTo; } }