Beispiel #1
0
 public bool OpenDatabase(string databaseFilePath)
 {
     if (localDatabase != null)
     {
         localDatabase.Dispose();
         localDatabase = null;
     }
     if (!String.IsNullOrWhiteSpace(databaseFilePath))
     {
         if (File.Exists(databaseFilePath))
         {
             try
             {
                 localDatabase = LocalDatabase.OpenDatabase(databaseFilePath);
                 if (!localDatabase.CheckIfMetadataExists())
                 {
                     LocalDatabaseStatus = DatabaseStatus.CORRUPTED;
                     return(false);
                 }
                 DatabaseMetadata = localDatabase.GetMetadata();
                 if (String.IsNullOrEmpty(DatabaseMetadata.Version))
                 {
                     LocalDatabaseStatus = DatabaseStatus.CORRUPTED;
                     return(false);
                 }
                 if (!Migration.Migrate(localDatabase, DatabaseMetadata))
                 {
                     LocalDatabaseStatus = DatabaseStatus.CORRUPTED;
                     return(false);
                 }
                 UpdateNonFictionBookCount();
                 UpdateFictionBookCount();
                 UpdateSciMagArticleCount();
             }
             catch
             {
                 LocalDatabaseStatus = DatabaseStatus.CORRUPTED;
                 return(false);
             }
             LocalDatabaseStatus = DatabaseStatus.OPENED;
             return(true);
         }
         else
         {
             LocalDatabaseStatus = DatabaseStatus.NOT_FOUND;
         }
     }
     else
     {
         LocalDatabaseStatus = DatabaseStatus.NOT_SET;
     }
     return(false);
 }