public static Func <InstanceInfo, bool> MatchesTo(InstanceInfo instance) { Func <InstanceInfo, bool> matchingPredicate = x => x.GetConnectionString() == instance.GetConnectionString(); return(matchingPredicate); }
private void btnAddConnectionString_Click(object sender, EventArgs e) { if (ValidateAddConnectionForm()) { InstanceInfo instance = this.cmbConnection.SelectedItem as InstanceInfo; if (instance != null) { string cnnString = instance.GetConnectionString(); IEnumerable <InstanceInfo> instances = this.lstConnectionStrings.Items.OfType <InstanceInfo>(); if (!instances.Any(x => cnnString.Equals(x.GetConnectionString()))) { lstConnectionStrings.Items.Add(instance); UpdateControlsState(); } return; } ConnectionGroupInfo groupInfo = cmbConnection.SelectedItem as ConnectionGroupInfo; if (groupInfo != null) { lstConnectionStrings.Items.Clear(); InstanceInfo[] instances = groupInfo.Connections.ToArray(); lstConnectionStrings.Items.AddRange(instances); UpdateControlsState(groupInfo.Name); } } }
protected void LoadConnectionGroups( ConnectionType connectionType, ConnectionsManager connectionsManager) { List <ConnectionGroupInfo> groups = connectionsManager .GetDirectGroups(connectionType.Id); foreach (ConnectionGroupInfo groupInfo in groups) { List <InstanceInfo> instances = groupInfo.Connections; InstanceInfo firstInstance = instances.FirstOrDefault(); if (firstInstance != null) { if (instances.Count == 1 && firstInstance.GetConnectionString().Equals(groupInfo.Name)) { continue; } if (!instances.TrueForAll(i => i.IsDynamicConnection)) { this.cmbConnection.Items.Add(groupInfo); } } } }
public static TdConnection CreateTdConnection(InstanceInfo instanceInfo, bool validateLicense = false) { if (validateLicense) { instanceInfo.ValidateLicense(true).ThrowIfNotCorrect(); } return(new TdConnection(instanceInfo.GetConnectionString())); }
public static TdConnection CreateTdConnection(InstanceInfo instanceInfo, bool validateLicense = false) { if (validateLicense) { instanceInfo.ValidateLicense(true).ThrowIfNotCorrect(); } return new TdConnection(instanceInfo.GetConnectionString()); }
protected bool ValidateAddConnectionForm() { InstanceInfo instance = this.cmbConnection.SelectedItem as InstanceInfo; ConnectionGroupInfo group = this.cmbConnection.SelectedItem as ConnectionGroupInfo; if ((instance == null || string.IsNullOrEmpty(instance.GetConnectionString())) && (group == null || group.Connections.IsNullOrEmpty()) ) { this.errorProvider.SetError(this.cmbConnection, this.GetLocalizedText("SelectServerError")); return(false); } this.errorProvider.SetError(this.cmbConnection, string.Empty); return(true); }
private void SelectInstance(InstanceInfo instanceInfo) { IEnumerable <InstanceInfo> instances = this.cmbConnection.Items.OfType <InstanceInfo>(); InstanceInfo firstConnection = instances.FirstOrDefault( x => x.GetConnectionString() == instanceInfo.GetConnectionString() && x.IsODBC == instanceInfo.IsODBC); if (firstConnection == null) { this.cmbConnection.Items.Add(instanceInfo); this.cmbConnection.SelectedItem = instanceInfo; } else { this.cmbConnection.SelectedItem = firstConnection; } }
public static NetworkInformationConnection CreateNetworkInformationConnection(InstanceInfo instanceInfo) { return(NetworkInformationConnection.Parse( instanceInfo.GetConnectionString() )); }
public static ActiveDirectoryConnection CreateActiveDirectoryConnection(InstanceInfo instanceInfo) { string connectionPath = instanceInfo.GetConnectionString(); return(new ActiveDirectoryConnection(connectionPath)); }
public static SQLiteConnection CreateSQLiteExternalConnection(InstanceInfo instanceInfo) { return(new SQLiteConnection(instanceInfo.GetConnectionString())); }
public static NetworkInformationConnection CreateNetworkInformationConnection(InstanceInfo instanceInfo) { return NetworkInformationConnection.Parse( instanceInfo.GetConnectionString() ); }
public static ActiveDirectoryConnection CreateActiveDirectoryConnection(InstanceInfo instanceInfo) { string connectionPath = instanceInfo.GetConnectionString(); return new ActiveDirectoryConnection(connectionPath); }
public static SQLiteConnection CreateSQLiteExternalConnection(InstanceInfo instanceInfo) { return new SQLiteConnection(instanceInfo.GetConnectionString()); }
public IQueryConnection CreateQueryConnection(QuerySource sourceType, InstanceInfo instance) { bool isOdbc = instance.IsODBC; QuerySource queryType = instance.Type; instance.SetSettings(this._model.Settings); if (sourceType == QuerySource.SQLite) { IStorageManager storageManager = this._model.GetVaultProcessor( instance.ConnectionGroup ?? new ConnectionGroupInfo() ); AttachingSqliteQueryConnection sqliteQueryConnection; string connectionString = instance.GetConnectionString(); SqliteConnectionParameters connectionParameters = SqliteConnectionParameters.Parse(connectionString); if (connectionParameters.IsValid) { sqliteQueryConnection = new SqliteInnerQueryConnection( storageManager.CurrentStorage, connectionParameters ); } else { sqliteQueryConnection = new SqliteInternalQueryConnection( storageManager.CurrentStorage, instance ); } if (storageManager.HistoryStorage != null) { foreach (var historyStorage in storageManager.HistoryStorage) { sqliteQueryConnection.AddDatabaseToAttach( historyStorage.Alias, historyStorage.FileName ); } } if (storageManager.ReportStorage != null) { sqliteQueryConnection.AddDatabaseToAttach( "report", storageManager.ReportStorage.FileName ); } return(sqliteQueryConnection); } if (isOdbc) { OdbcConnection odbcConnection = ConnectionFactory.CreateOdbcConnection(instance, true); return(new OdbcQueryConnection(odbcConnection)); } if (sourceType == queryType) { switch (sourceType) { case QuerySource.MSSQL: SqlConnection sqlConnection = ConnectionFactory.CreateSqlConnection(instance, true); return(new MsSqlQueryConnection(sqlConnection)); case QuerySource.TDSQL: TdConnection tdConnection = ConnectionFactory.CreateTdConnection(instance, true); return(new TeradataSqlQueryConnection(tdConnection)); case QuerySource.SQLiteExternal: SQLiteConnection sqliteConnection = ConnectionFactory.CreateSQLiteExternalConnection(instance); return(new SqliteExternalQueryConnection(sqliteConnection)); case QuerySource.ActiveDirectory: ActiveDirectoryConnection activeDirectoryConnection = ConnectionFactory.CreateActiveDirectoryConnection(instance); return(new ActiveDirectoryQueryConnection(activeDirectoryConnection)); case QuerySource.EventLog: EventLogConnection eventLogConnection = ConnectionFactory.CreateEventLogConnection(instance); return(new EventLogQueryConnection(eventLogConnection)); case QuerySource.NetworkInformation: NetworkInformationConnection networkInfoConnection = ConnectionFactory.CreateNetworkInformationConnection(instance); return(new NetworkInformationQueryConnection(networkInfoConnection)); } } string errorMessage = String.Format( "There is no QueryConnection defined. QuerySource: {0}, QueryType: {1}", sourceType, queryType ); Log.ErrorFormat(errorMessage); throw new ArgumentException(errorMessage); }
public IQueryConnection CreateQueryConnection(QuerySource sourceType, InstanceInfo instance) { bool isOdbc = instance.IsODBC; QuerySource queryType = instance.Type; instance.SetSettings(this._model.Settings); if (sourceType == QuerySource.SQLite) { IStorageManager storageManager = this._model.GetVaultProcessor( instance.ConnectionGroup ?? new ConnectionGroupInfo() ); AttachingSqliteQueryConnection sqliteQueryConnection; string connectionString = instance.GetConnectionString(); SqliteConnectionParameters connectionParameters = SqliteConnectionParameters.Parse(connectionString); if (connectionParameters.IsValid) { sqliteQueryConnection = new SqliteInnerQueryConnection( storageManager.CurrentStorage, connectionParameters ); } else { sqliteQueryConnection = new SqliteInternalQueryConnection( storageManager.CurrentStorage, instance ); } if (storageManager.HistoryStorage != null) { foreach (var historyStorage in storageManager.HistoryStorage) { sqliteQueryConnection.AddDatabaseToAttach( historyStorage.Alias, historyStorage.FileName ); } } if (storageManager.ReportStorage != null) { sqliteQueryConnection.AddDatabaseToAttach( "report", storageManager.ReportStorage.FileName ); } return sqliteQueryConnection; } if (isOdbc) { OdbcConnection odbcConnection = ConnectionFactory.CreateOdbcConnection(instance, true); return new OdbcQueryConnection(odbcConnection); } if (sourceType == queryType) { switch (sourceType) { case QuerySource.MSSQL: SqlConnection sqlConnection = ConnectionFactory.CreateSqlConnection(instance, true); return new MsSqlQueryConnection(sqlConnection); case QuerySource.TDSQL: TdConnection tdConnection = ConnectionFactory.CreateTdConnection(instance, true); return new TeradataSqlQueryConnection(tdConnection); case QuerySource.SQLiteExternal: SQLiteConnection sqliteConnection = ConnectionFactory.CreateSQLiteExternalConnection(instance); return new SqliteExternalQueryConnection(sqliteConnection); case QuerySource.ActiveDirectory: ActiveDirectoryConnection activeDirectoryConnection = ConnectionFactory.CreateActiveDirectoryConnection(instance); return new ActiveDirectoryQueryConnection(activeDirectoryConnection); case QuerySource.EventLog: EventLogConnection eventLogConnection = ConnectionFactory.CreateEventLogConnection(instance); return new EventLogQueryConnection(eventLogConnection); case QuerySource.NetworkInformation: NetworkInformationConnection networkInfoConnection = ConnectionFactory.CreateNetworkInformationConnection(instance); return new NetworkInformationQueryConnection(networkInfoConnection); } } string errorMessage = String.Format( "There is no QueryConnection defined. QuerySource: {0}, QueryType: {1}", sourceType, queryType ); Log.ErrorFormat(errorMessage); throw new ArgumentException(errorMessage); }