/// <summary> /// Загрузить БД /// </summary> /// <param name="dbName">Имя загружаемой БД</param> public void LoadDB(string dbName) { if (slim.TryEnterWriteLock(500)) { string old_name_db = string.Empty; try { if (IsSrvValid) { old_name_db = adapter.InitialCatalog; if (state == DBState.Default) { adapter.InitialCatalog = dbName; provider.Adapter.InitialCatalog = dbName; DataBase.LoadDB(provider); state = DBState.Loaded; } } } catch (Exception ex) { adapter.InitialCatalog = old_name_db; provider.Adapter.InitialCatalog = old_name_db; throw new Exception(ex.Message, ex); } finally { slim.ExitWriteLock(); } } }
/// <summary> /// Загрузить БД /// </summary> public void LoadDB() { bool blocked = false; try { if (mutex.WaitOne(1000)) { blocked = true; if (state == DataBaseState.Default) { dataBase.LoadDB(); state = DataBaseState.Loaded; } else { throw new Exception("Текущее состояние не позволяет загрузить БД"); } } else { throw new TimeoutException(); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } finally { if (blocked) { mutex.ReleaseMutex(); } } }