public static ConnectionDetail[] RecentConnections() { var configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var connectionSection = (ConnectionSection) configuration.Sections["DBViewConnections"]; if (connectionSection == null || connectionSection.Connections == null) return null; var connectionDetails = new ConnectionDetail[connectionSection.Connections.Count]; var count = 0; foreach (ConnectionElement connection in connectionSection.Connections) connectionDetails[count++] = connection.ToConnectionDetail(); return connectionDetails; }
public void FromConnectionDetail(ConnectionDetail connectionDetail) { ConnName = connectionDetail.ConnName; DataSourceName = connectionDetail.DataSourceName; DBType = connectionDetail.DBType; AuthType = connectionDetail.AuthType; Username = connectionDetail.UserName; Password = connectionDetail.PassWord; HostName = connectionDetail.HostName; PortNumber = connectionDetail.PortNumber; ServiceName = connectionDetail.ServiceName; InitialCatalog = connectionDetail.InitialCatalog; }
public static void SaveConnection(ConnectionDetail connectionDetail) { var connectionElement = new ConnectionElement(); connectionElement.FromConnectionDetail(connectionDetail); var configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var connectionsSection = (ConnectionSection) configuration.Sections["DBViewConnections"]; if (connectionsSection != null) connectionsSection.Connections.Add(connectionElement); else { connectionsSection = new ConnectionSection(); connectionsSection.Connections.Add(connectionElement); configuration.Sections.Add("DBViewConnections", connectionsSection); } connectionsSection.SectionInformation.ForceSave = true; configuration.Save(ConfigurationSaveMode.Full); }
public static IDBViewProvider RetrieveDbProvider(ConnectionDetail connectionDetail) { switch (connectionDetail.DBType) { case DBType.Oracle: var dbProvider = new OracleProvider(connectionDetail); dbProvider.OpenConnection(); return dbProvider; case DBType.MySql: var mySqlProvider = new MySqlProvider(connectionDetail); mySqlProvider.OpenConnection(); return mySqlProvider; case DBType.SqlServer: var sqlServerProvider = new SqlServerProvider(connectionDetail); sqlServerProvider.OpenConnection(); return sqlServerProvider; default: return null; } }
public static void DeleteConnection(ConnectionDetail connectionDetail) { var connectionElement = new ConnectionElement(); connectionElement.FromConnectionDetail(connectionDetail); var configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var connectionsSection = (ConnectionSection) configuration.Sections["DBViewConnections"]; if (connectionsSection == null) return; connectionsSection.Connections.Remove(connectionElement); connectionsSection.SectionInformation.ForceSave = true; configuration.Save(ConfigurationSaveMode.Full); }
public MySqlProvider(ConnectionDetail connectionDetail) : base(connectionDetail) { }
public ConnectionNode(ConnectionDetail connectionDetail, TabControl queryTabs) : base(connectionDetail.ConnName) { QueryTabs = queryTabs; Tag = connectionDetail; }
public SqlServerProvider(ConnectionDetail connectionDetail) : base(connectionDetail) { }
protected GenericDBProvider(ConnectionDetail connectionDetail) { ConnectionDetail = connectionDetail; }
public OracleProvider(ConnectionDetail connectionDetail) : base(connectionDetail) { }