Exemplo n.º 1
0
 private void UpdateSchema(DatabaseStatus status)
 {
     try
     {
         status.Items = _finder.QueryItems().Count();
         status.Details = _finder.QueryDetails().Count();
         status.DetailCollections = _finder.QueryDetailCollections().Count();
         status.AuthorizedRoles = _finder.Query<AuthorizationRule>().Count();
         status.HasSchema = true;
     }
     catch (Exception ex)
     {
         status.HasSchema = false;
         status.SchemaError = ex.Message;
         status.SchemaException = ex;
     }
 }
Exemplo n.º 2
0
 private void UpdateConnection(DatabaseStatus status)
 {
     try
     {
         using (IDbConnection conn = GetConnection())
         {
             conn.Open();
             conn.Close();
             status.ConnectionType = conn.GetType().Name;
         }
         status.IsConnected = true;
         status.ConnectionError = null;
     }
     catch (Exception ex)
     {
         status.IsConnected = false;
         status.ConnectionError = ex.Message;
         status.ConnectionException = ex;
     }
 }
Exemplo n.º 3
0
        private void UpdateItems(DatabaseStatus status)
        {
            try
            {
                status.StartPageID = _host.CurrentSite.StartPageID;
                status.RootItemID = _host.CurrentSite.RootItemID;
                status.StartPage = _persister.Get(status.StartPageID);
                status.RootItem = _persister.Get(status.RootItemID);
                status.IsInstalled = status.RootItem != null && status.StartPage != null;

                status.HasUsers = _credentialService.GetUser("administrator") != null;
            }
            catch (Exception ex)
            {
                status.IsInstalled = false;
                status.ItemsError = ex.Message;
            }
        }
Exemplo n.º 4
0
        public DatabaseStatus GetStatus()
        {
            DatabaseStatus status = new DatabaseStatus();

            UpdateConnection(status);
            UpdateSchema(status);
            UpdateItems(status);

            return status;
        }