Exemplo n.º 1
0
 public static DatabaseResource GetDbResource(string path)
 {
     lock (DatabaseResourcesLock)
     {
         DatabaseResource databaseResource;
         if (_dbResources != null && _dbResources.TryGetValue(path, out databaseResource))
         {
             databaseResource.AddRef();
             return(databaseResource);
         }
         databaseResource = new DatabaseResource(path);
         if (null == _dbResources)
         {
             _dbResources = new Dictionary <string, DatabaseResource>();
         }
         _dbResources.Add(path, databaseResource);
         return(databaseResource);
     }
 }
Exemplo n.º 2
0
 public static DatabaseResource GetDbResource(string path)
 {
     lock (DatabaseResourcesLock)
     {
         DatabaseResource databaseResource;
         if (_dbResources != null && _dbResources.TryGetValue(path, out databaseResource))
         {
             databaseResource.AddRef();
             return databaseResource;
         }
         databaseResource = new DatabaseResource(path);
         if (null == _dbResources)
         {
             _dbResources = new Dictionary<string, DatabaseResource>();
         }
         _dbResources.Add(path, databaseResource);
         return databaseResource;
     }
 }
Exemplo n.º 3
0
        private readonly bool _isTmp; // We won't hang onto the global session factory if we know we're temporary
        private ProteomeDb(String path, bool isTmp)
        {
            _schemaVersionMajor = -1; // unknown
            _schemaVersionMinor = -1; // unknown
            _schemaVersionMajorAsRead = -1; // unknown
            _schemaVersionMinorAsRead = -1; // unknown
            _isTmp = isTmp;
            _databaseResource = DatabaseResource.GetDbResource(path);

            using (var session = OpenSession())
            {
                // Is this even a proper protDB file? (https://skyline.gs.washington.edu/labkey/announcements/home/issues/exceptions/thread.view?rowId=14893)
                using (IDbCommand command = session.Connection.CreateCommand())
                {
                    command.CommandText =
                        "SELECT count(*) FROM sqlite_master WHERE type='table' AND name='ProteomeDbProteinName'"; // Not L10N
                    var obj = command.ExecuteScalar();
                    if (Convert.ToInt32(obj) == 0)
                        throw new FileLoadException(
                            String.Format(Resources.ProteomeDb_ProteomeDb__0__does_not_appear_to_be_a_valid___protDB__background_proteome_file_, path));
                }

                // Do we need to update the db to current version?
                ReadVersion(session);
            }
            if (_schemaVersionMajor != SCHEMA_VERSION_MAJOR_CURRENT)
            {
                throw new FileLoadException(
                    String.Format(Resources.SessionFactoryFactory_EnsureVersion_Background_proteome_file__0__has_a_format_which_is_newer_than_the_current_software___Please_update_to_the_latest_software_version_and_try_again_,
                        Path));
            }
            else if (_schemaVersionMinor < SCHEMA_VERSION_MINOR_CURRENT)
            {
                using (var session = OpenWriteSession())
                {
                    UpdateSchema(session);
                }
            }
        }
Exemplo n.º 4
0
 public static void ReleaseAll()
 {
     DatabaseResource.ReleaseAll();
 }