Beispiel #1
0
 public AppStartEnvironment(int environmentId, int categoryId, int releaseUpdateId, int databaseVersionId,
     string title, string serverInstance, string connectionInfo, string databaseName, string userName,
     string password, AppStartDatabaseVersion dbVersion)
 {
     EnvironmentId = environmentId;
     CategoryId = categoryId;
     ReleaseUpdateId = releaseUpdateId;
     DatabaseVersionId = databaseVersionId;
     Title = title;
     ServerInstance = serverInstance;
     ConnectionInfo = connectionInfo;
     DatabaseName = databaseName;
     UserName = userName;
     Password = password;
     DbVersion = dbVersion;
     switch (dbVersion.DbType)
     {
         case DatabaseEngineType.SqlServer:
             int backslash = serverInstance.IndexOf('\\');
             ServerName = 0 < backslash ? serverInstance.Substring(0, backslash) : serverInstance;
             InstanceName = 0 < backslash ? serverInstance.Substring(backslash + 1) : string.Empty;
             SidOrServiceName = string.Empty;
             Port = string.Empty;
             break;
         case DatabaseEngineType.Oracle:
             int slash = serverInstance.IndexOf('/');
             string serverAndPort = 0 < slash ? serverInstance.Substring(0, slash) : serverInstance;
             SidOrServiceName = 0 < slash ? serverInstance.Substring(slash + 1) : string.Empty;
             int colon = serverAndPort.IndexOf(':');
             ServerName = 0 < colon ? serverAndPort.Substring(0, colon) : serverAndPort;
             Port = 0 < colon ? serverAndPort.Substring(colon + 1) : "21";
             InstanceName = string.Empty;
             break;
         default:
             throw new ArgumentOutOfRangeException("dbVersion");
     }
 }
Beispiel #2
0
 private bool LoadDatabaseVersions(SqlConnection conn)
 {
     _dbVersionsByName.Clear();
     _dbVersionsById.Clear();
     SqlCommand cmd = new SqlCommand("SELECT v.id, t.title, v.title FROM dbTypes t, dbVersions v WHERE v.dbType_id = t.id", conn);
     using (SqlDataReader rdr = cmd.ExecuteReader())
     {
         while (rdr.Read())
         {
             int id = rdr.GetInt32(0);
             string typTitle = rdr.GetString(1);
             string verTitle = rdr.GetString(2);
             string title = string.Format("{0} {1}", typTitle, verTitle);
             AppStartDatabaseVersion databaseVersion = new AppStartDatabaseVersion(id, title, verTitle);
             _dbVersionsByName.Add(title, databaseVersion);
             _dbVersionsById.Add(id, databaseVersion);
         }
     }
     return _dbVersionsByName.Count > 0;
 }