internal void ValidateGlobalLocalConflict(string identity, string[] registryKeys, string propertyName, MonitoringItemTypeEnum monitoringItemType) { if (registryKeys != null) { foreach (string text in registryKeys) { if (string.Compare(text, identity, true) == 0) { base.WriteError(new PropertyAlreadyHasAnOverrideException(propertyName, this.helper.MonitoringItemIdentity, monitoringItemType.ToString()), ErrorCategory.ResourceExists, null); } else { string[] array = MonitoringOverrideHelpers.SplitMonitoringItemIdentity(text, '~'); if (array.Length > 1 && string.Compare(array[0], this.helper.HealthSet, true) == 0 && string.Compare(array[1], this.helper.MonitoringItemName, true) == 0) { if (array.Length == 4 && !string.IsNullOrWhiteSpace(this.helper.TargetResource)) { return; } if (array.Length == 4 && string.IsNullOrWhiteSpace(this.helper.TargetResource)) { base.WriteError(new MonitoringItemAlreadyHasLocalOverrideException(this.helper.MonitoringItemIdentity, monitoringItemType.ToString(), this.GenerateMonitoringItemIdentityString(text)), ErrorCategory.ResourceExists, null); } else if (array.Length == 3 && !string.IsNullOrWhiteSpace(this.helper.TargetResource)) { base.WriteError(new MonitoringItemAlreadyHasGlobalOverrideException(this.helper.MonitoringItemIdentity, monitoringItemType.ToString(), this.GenerateMonitoringItemIdentityString(text)), ErrorCategory.ResourceExists, null); } } } } } }
internal string GetPropertyName(string registryKeyName) { string[] array = MonitoringOverrideHelpers.SplitMonitoringItemIdentity(registryKeyName, '~'); if (array != null && array.Length >= 3) { return(array[2]); } return(string.Empty); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); try { if (base.RegistryKeyHive != null) { foreach (object obj in Enum.GetValues(typeof(MonitoringItemTypeEnum))) { MonitoringItemTypeEnum monitoringItemTypeEnum = (MonitoringItemTypeEnum)obj; string text = monitoringItemTypeEnum.ToString(); using (RegistryKey registryKey = base.RegistryKeyHive.OpenSubKey(string.Format("{0}\\{1}", ServerMonitoringOverrideBase.OverridesBaseRegistryKey, text))) { if (registryKey != null) { string[] subKeyNames = registryKey.GetSubKeyNames(); foreach (string text2 in subKeyNames) { using (RegistryKey registryKey2 = registryKey.OpenSubKey(text2)) { string propertyValue = (string)registryKey2.GetValue("PropertyValue", string.Empty); string expirationTime = (string)registryKey2.GetValue("ExpirationTime", string.Empty); string applyVersion = (string)registryKey2.GetValue("ApplyVersion", string.Empty); string createdBy = (string)registryKey2.GetValue("CreatedBy", string.Empty); string createdTime = (string)registryKey2.GetValue("TimeUpdated", string.Empty); string[] array2 = MonitoringOverrideHelpers.SplitMonitoringItemIdentity(text2, '~'); base.WriteObject(new MonitoringOverrideObject((array2.Length >= 1) ? array2[0] : string.Empty, (array2.Length >= 2) ? array2[1] : string.Empty, (array2.Length >= 4) ? array2[3] : string.Empty, text, base.GetPropertyName(text2), propertyValue, expirationTime, applyVersion, createdBy, createdTime)); } } } } } } } catch (IOException ex) { base.WriteError(new FailedToRunServerMonitoringOverrideException(base.ServerName, ex.ToString()), ErrorCategory.ObjectNotFound, null); } catch (SecurityException ex2) { base.WriteError(new FailedToRunServerMonitoringOverrideException(base.ServerName, ex2.ToString()), ExchangeErrorCategory.Authorization, null); } catch (UnauthorizedAccessException ex3) { base.WriteError(new FailedToRunServerMonitoringOverrideException(base.ServerName, ex3.ToString()), ExchangeErrorCategory.Authorization, null); } finally { TaskLogger.LogExit(); } }
protected override void InternalValidate() { base.InternalValidate(); this.helper.ParseAndValidateIdentity(this.Identity, false); if (base.Fields.IsModified("ApplyVersion")) { MonitoringOverrideHelpers.ValidateApplyVersion(this.ApplyVersion); } if (base.Fields.IsModified("Duration")) { MonitoringOverrideHelpers.ValidateOverrideDuration(this.Duration); return; } this.Duration = new EnhancedTimeSpan?(EnhancedTimeSpan.FromDays(365.0)); }
internal void ParseAndValidateIdentity(string monitoringItemIdentity, bool global) { this.MonitoringItemIdentity = monitoringItemIdentity; this.HealthSet = null; this.MonitoringItemName = null; this.TargetResource = null; string[] array = MonitoringOverrideHelpers.SplitMonitoringItemIdentity(monitoringItemIdentity, '\\'); if (array.Length < 2 || (global && array.Length != 2) || array.Length > 3 || string.IsNullOrWhiteSpace(array[0]) || string.IsNullOrWhiteSpace(array[1])) { throw new InvalidIdentityException(this.MonitoringItemIdentity, global ? "<HealthSet>\\<MonitoringItemName>" : "<HealthSet>\\<MonitoringItemName>\\[TargetResource]"); } this.HealthSet = array[0]; this.MonitoringItemName = array[1]; if (array.Length == 3 && !string.IsNullOrWhiteSpace(array[2])) { this.TargetResource = array[2]; } }
protected override void InternalBeginProcessing() { TaskLogger.LogEnter(); base.InternalBeginProcessing(); this.helper.ParseAndValidateIdentity(this.Identity, true); if (base.Fields.IsModified("ApplyVersion")) { MonitoringOverrideHelpers.ValidateApplyVersion(this.ApplyVersion); } if (base.Fields.IsModified("Duration")) { MonitoringOverrideHelpers.ValidateOverrideDuration(this.Duration); } else { this.Duration = new EnhancedTimeSpan?(EnhancedTimeSpan.FromDays(365.0)); } TaskLogger.LogExit(); }
internal string GenerateMonitoringItemIdentityString(string fullString) { string[] array = MonitoringOverrideHelpers.SplitMonitoringItemIdentity(fullString, '~'); if (array != null) { if (array.Length == 4) { return(string.Format("{0}{1}{2}{1}{3}", new object[] { array[0], '\\', array[1], array[3] })); } if (array.Length == 3) { return(string.Format("{0}{1}{2}", array[0], '\\', array[1])); } } return(fullString); }