Ejemplo n.º 1
0
        /// <summary>
        ///     Configure the Notification / Alert settings.
        /// </summary>
        private void ConfigureAlertSettings()
        {
            var alertProps =
                new ConfigureAlertRequestProperties();

            var alert = this.RecoveryServicesClient.GetAzureSiteRecoveryAlertSetting();

            if (alert == null || alert.Count == 0 || alert[0].Properties == null)
            {
                alertProps.CustomEmailAddresses = new List <string>();
                alertProps.Locale       = Thread.CurrentThread.CurrentCulture.ToString();
                alertProps.SendToOwners = SendToOwners.DoNotSend;
            }
            else
            {
                // Alert is singleton from service side.
                alertProps.CustomEmailAddresses = alert[0].Properties.CustomEmailAddresses;
                alertProps.Locale       = alert[0].Properties.Locale;
                alertProps.SendToOwners = alert[0].Properties.SendToOwners;
            }


            if (this.EnableEmailSubscriptionOwner.IsPresent)
            {
                alertProps.SendToOwners = SendToOwners.Send;
            }

            if (this.DisableEmailToSubscriptionOwner.IsPresent)
            {
                alertProps.SendToOwners = SendToOwners.DoNotSend;
            }

            if (!string.IsNullOrEmpty(this.LocaleID))
            {
                alertProps.Locale = this.LocaleID;
            }

            if (this.CustomEmailAddress != null && this.CustomEmailAddress.Length != 0)
            {
                Utilities.ValidateCustomEmails(this.CustomEmailAddress);
                alertProps.CustomEmailAddresses = this.CustomEmailAddress;
            }

            var alertRequest = new ConfigureAlertRequest();

            alertRequest.Properties = alertProps;
            var response =
                this.RecoveryServicesClient.SetAzureSiteRecoveryAlertSetting(alertRequest);

            this.WriteObject(new ASRAlertSetting(response));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Disable the alerts.
        /// </summary>
        private void DisableAlerts()
        {
            var alertProps =
                new ConfigureAlertRequestProperties();

            alertProps.CustomEmailAddresses = new List <string>();
            alertProps.Locale       = Thread.CurrentThread.CurrentCulture.ToString();
            alertProps.SendToOwners = SendToOwners.DoNotSend;

            var alertRequest = new ConfigureAlertRequest();

            alertRequest.Properties = alertProps;
            var alert =
                this.RecoveryServicesClient.SetAzureSiteRecoveryAlertSetting(alertRequest);

            this.WriteObject(new ASRAlertSetting(alert));
        }