Esempio n. 1
0
 public void DeleteConfigurationAlert(ConfigurationAlert alert)
 {
     using (LiteDatabase db = new LiteDatabase(connectionString))
     {
         LiteCollection <ConfigurationAlert> col = db.GetCollection <ConfigurationAlert>(configurationAlertsCollectionName);
         col.Delete(alert.Id);
     }
 }
        public void ValidateAtLeastOneCertificateAuthority()
        {
            IEnumerable <PrivateCertificateAuthorityConfig> found = configurationRepository.GetAll <PrivateCertificateAuthorityConfig>();

            if (found == null && !runtimeCacheRepository.ConfigurationAlertExists(AlertType.NoCertificateAuthoritiesConfigured))
            {
                ConfigurationAlert alert = new ConfigurationAlert()
                {
                    Created       = DateTime.Now,
                    AlertState    = AlertState.Open,
                    AlertSeverity = AlertSeverity.Error,
                    AlertType     = AlertType.NoCertificateAuthoritiesConfigured,
                    Id            = Guid.NewGuid(),
                    Message       = "There must be at least one certificate authority before certificate manager can issue new certificates."
                };

                runtimeCacheRepository.InsertConfigurationAlert(alert);
            }
        }
        public static IHtmlContent AlertSeverityHtmlString(ConfigurationAlert alert)
        {
            string html = @"<span class='{#css-class#}'>
                            <strong>
                                <i class='fa {#icon-class#}'></i>
                                {#AlertSeverity#}
                            </strong>
                        </span>";

            if (alert.AlertSeverity == Entities.Enumerations.AlertSeverity.Error)
            {
                html = html.Replace("{#css-class#}", "text-danger");
                html = html.Replace("{#icon-class#}", "fa-exclamation-triangle");
            }
            else
            {
                html = html.Replace("{#css-class#}", "text-success");
                html = html.Replace("{#icon-class#}", "fa-info");
            }

            html = html.Replace("{#AlertSeverity#}", alert.AlertSeverity.ToString());

            return(new HtmlString(html));
        }