/// <summary> /// set the alert notification defaults. This list will contain all of the alerts /// </summary> private void LoadAlertNotificationDefaults() { this.alertNotifications = new List <AgentAlertNotificationHelper>(); JobServer jobServer = GetJobServer(); AgentAlertNotificationHelper alertNotification; foreach (Alert alert in jobServer.Alerts) { alertNotification = new AgentAlertNotificationHelper(alert.Name, notifyEmail: false, notifyPager: false, alert: alert); this.alertNotifications.Add(alertNotification); } }
/// <summary> /// Load alerts that notify this operator /// </summary> private void LoadAlertNotificationData() { if (this.alertNotifications != null) { return; } // defaults in create ode if (createMode) { LoadAlertNotificationDefaults(); return; } this.alertNotifications = new List <AgentAlertNotificationHelper>(); Microsoft.SqlServer.Management.Smo.Agent.Operator agentOperator = GetCurrentOperator(); JobServer jobServer = GetJobServer(); // see all alerts that notifuy this operator DataTable notifications = agentOperator.EnumNotifications(); DataRow alertRow; bool notifyEmail; bool notifyPager; AgentAlertNotificationHelper alertNotification; // Add every alert to the structure foreach (Alert alert in jobServer.Alerts) { alertRow = null; // see if the alert notifies us already foreach (DataRow row in notifications.Rows) { if ((string)row["AlertName"] == alert.Name) { alertRow = row; break; } } // set if the current alert notifies this operator // if so so how if (alertRow != null) { notifyEmail = (bool)alertRow["UseEmail"]; notifyPager = (bool)alertRow["UsePager"]; } else { notifyEmail = false; notifyPager = false; } alertNotification = new AgentAlertNotificationHelper(alert.Name , notifyEmail , notifyPager , alert); this.alertNotifications.Add(alertNotification); } }