예제 #1
0
        public async Task <SessionModel> OpenSession(string connectionName)
        {
            try
            {
                var entry = await _connectionStringService.GetConnectionStringEntry(connectionName);

                var driver     = _schemaManagerService.GetDriver(entry.ProviderName);
                var connection = await driver.OpenConnection(entry.ConnectionString);

                var session = new SessionModel
                {
                    SessionId   = Guid.NewGuid(),
                    SessionName = entry.Name,
                    Driver      = driver,
                    Connetion   = connection,
                    Schema      = null
                };

                lock (_sessions)
                {
                    _sessions.Add(session);
                }

                return(session);
            }
            catch (Exception thrown)
            {
                Debug.WriteLine(thrown);
                throw;
            }
        }
예제 #2
0
        public async Task <DataTable[]> GetSchemaTablesAsync(string connectionName, string collectionName, string[] restrictions)
        {
            var connectionEntry = await _connectionStringService.GetConnectionStringEntry(connectionName);

            var databaseDriver = _schemaManagerService.GetDriver(connectionEntry.ProviderName);

            if (string.IsNullOrWhiteSpace(collectionName))
            {
                var dataTables = await databaseDriver.SchemaFetchService
                                 .GetAllSchemaCollections(connectionEntry.ConnectionString, 2);

                return(dataTables);
            }
            else
            {
                var dataTable = await databaseDriver.SchemaFetchService
                                .GetSchemaCollection(connectionEntry.ConnectionString, collectionName, restrictions);

                var dataTables = new DataTable[] { dataTable };
                return(dataTables);
            }
        }