示例#1
0
        public DynamicJsonValue GenerateDatabaseInfo()
        {
            var envs = GetAllStoragesEnvironment().ToList();

            if (envs.Any(x => x.Environment == null))
            {
                return(null);
            }
            var size         = new Size(envs.Sum(env => env.Environment.Stats().AllocatedDataFileSizeInBytes));
            var databaseInfo = new DynamicJsonValue
            {
                [nameof(DatabaseInfo.HasRevisionsConfiguration)]  = DocumentsStorage.RevisionsStorage.Configuration != null,
                [nameof(DatabaseInfo.HasExpirationConfiguration)] = ExpiredDocumentsCleaner != null,
                [nameof(DatabaseInfo.IsAdmin)]     = true, //TODO: implement me!
                [nameof(DatabaseInfo.IsEncrypted)] = DocumentsStorage.Environment.Options.EncryptionEnabled,
                [nameof(DatabaseInfo.Name)]        = Name,
                [nameof(DatabaseInfo.Disabled)]    = false, //TODO: this value should be overwritten by the studio since it is cached
                [nameof(DatabaseInfo.TotalSize)]   = new DynamicJsonValue
                {
                    [nameof(Size.HumaneSize)]  = size.HumaneSize,
                    [nameof(Size.SizeInBytes)] = size.SizeInBytes
                },
                [nameof(DatabaseInfo.IndexingErrors)] = IndexStore.GetIndexes().Sum(index => index.GetErrorCount()),
                [nameof(DatabaseInfo.Alerts)]         = NotificationCenter.GetAlertCount(),
                [nameof(DatabaseInfo.UpTime)]         = null, //it is shutting down
                [nameof(DatabaseInfo.BackupInfo)]     = PeriodicBackupRunner.GetBackupInfo(),
                [nameof(DatabaseInfo.DocumentsCount)] = DocumentsStorage.GetNumberOfDocuments(),
                [nameof(DatabaseInfo.IndexesCount)]   = IndexStore.GetIndexes().Count(),
                [nameof(DatabaseInfo.RejectClients)]  = false, //TODO: implement me!
                [nameof(DatabaseInfo.IndexingStatus)] = IndexStore.Status.ToString(),
                ["CachedDatabaseInfo"] = true
            };

            return(databaseInfo);
        }