Пример #1
0
		private static async Task StoreActiveDatabaseNames(ServerRecord server, AsyncServerClient client, IAsyncDocumentSession session)
		{
			AdminStatistics adminStatistics = await client.GlobalAdmin.GetStatisticsAsync();

			server.IsUnauthorized = false;

			server.ClusterName = adminStatistics.ClusterName;
			server.ServerName = adminStatistics.ServerName;
			server.MemoryStatistics = adminStatistics.Memory;

			foreach (var loadedDatabase in adminStatistics.LoadedDatabases)
			{
				var databaseRecord = await session.LoadAsync<DatabaseRecord>(server.Id + "/" + loadedDatabase.Name);
				if (databaseRecord == null)
				{
					databaseRecord = new DatabaseRecord { Name = loadedDatabase.Name, ServerId = server.Id, ServerUrl = server.Url };
					await session.StoreAsync(databaseRecord);
				}

				databaseRecord.LoadedDatabaseStatistics = loadedDatabase;
			}
			server.LoadedDatabases = adminStatistics.LoadedDatabases.Select(database => database.Name).ToArray();
		}
Пример #2
0
		private static async Task StoreDatabaseNames(ServerRecord server, AsyncServerClient client, IAsyncDocumentSession session)
		{
			server.Databases = await client.GetDatabaseNamesAsync(1024);
			
			foreach (var databaseName in server.Databases.Concat(new[] {Constants.SystemDatabase}))
			{
				var databaseRecord = await session.LoadAsync<DatabaseRecord>(server.Id + "/" + databaseName);
				if (databaseRecord == null)
				{
					databaseRecord = new DatabaseRecord {Name = databaseName, ServerId = server.Id, ServerUrl = server.Url};
					await session.StoreAsync(databaseRecord);
				}
			}
		}