public void Start(ILogger logger) { Started = true; _logger = logger; _osuDatabaseLoader = new LOsuDatabaseLoader(new BeatmapLoaderLogger(_mainWindowHandle), _sqliteControler, new Beatmap()); //_osuDatabaseLoader = new OsuDatabaseLoader(_logger, _modParser, _sqliteControler, _mainWindowHandle); new System.Threading.Thread(() => { string osudb = Path.Combine(_settingsHandle.Get <string>(_names.MainOsuDirectory), "osu!.db"); if (File.Exists(osudb)) { string newOsuFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Files", "osu!.db"); if (File.Exists(newOsuFile)) { File.Delete(newOsuFile); } File.Copy(osudb, newOsuFile); _osuDatabaseLoader.LoadDatabase(newOsuFile); File.Delete(newOsuFile); } else { _mainWindowHandle.BeatmapsLoaded = "Could not locate osu!.db"; } }).Start(); }
public void Start(ILogger logger) { Started = true; _logger = logger; _osuDatabaseLoader = new OsuDatabaseLoader(_logger, _modParser, _sqliteControler, _mainWindowHandle); new System.Threading.Thread(() => { string osudb = Path.Combine(_settingsHandle.Get<string>(_names.MainOsuDirectory), "osu!.db"); string newOsuFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Files", "osu!.db"); if (File.Exists(newOsuFile)) File.Delete(newOsuFile); File.Copy(osudb, newOsuFile); _osuDatabaseLoader.LoadDatabase(newOsuFile); File.Delete(newOsuFile); }).Start(); }
public void Initalize() { _osuDatabaseLoader = new LOsuDatabaseLoader(new BeatmapLoaderLogger(_mainWindowHandle), _sqliteControler, new Beatmap()); new System.Threading.Thread(() => { string osudb = Path.Combine(_settings.Get <string>(_names.MainOsuDirectory), "osu!.db"); if (File.Exists(osudb)) { string newOsuFile = ""; try { newOsuFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Files", "osu!.db"); if (File.Exists(newOsuFile)) { File.Delete(newOsuFile); } File.Copy(osudb, newOsuFile); File.SetAttributes(newOsuFile, FileAttributes.Normal); _osuDatabaseLoader.LoadDatabase(newOsuFile); File.Delete(newOsuFile); } catch (Exception e) { _mainWindowHandle.BeatmapsLoaded = "loading osu!.db FAILED: " + e.Message; _logger?.Log("loading osu!.db FAILED\nsrc:{0}\ndest:{1}\n{2}\n{3} ", LogLevel.Error, osudb, newOsuFile, e.Message, e.StackTrace); } } else { _mainWindowHandle.BeatmapsLoaded = "Could not locate osu!.db"; } }).Start(); }
public void Initalize() { _osuDatabaseLoader = new OsuDatabaseLoader(new BeatmapLoaderLogger(_mainWindowHandle), _databaseControler, new Beatmap()); new System.Threading.Thread(() => { string osudb = Path.Combine(_settings.Get <string>(_names.MainOsuDirectory), "osu!.db"); if (File.Exists(osudb)) { string newOsuFile = ""; try { newOsuFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Files", "osu!.db"); if (File.Exists(newOsuFile)) { File.Delete(newOsuFile); } File.Copy(osudb, newOsuFile); File.SetAttributes(newOsuFile, FileAttributes.Normal); _osuDatabaseLoader.LoadDatabase(newOsuFile); if (_logger is IContextAwareLogger contextAwareLogger) { contextAwareLogger.SetContextData("osu!username", string.IsNullOrEmpty(_osuDatabaseLoader.Username) ? "null" : _osuDatabaseLoader.Username); } File.Delete(newOsuFile); } catch (Exception e) { _mainWindowHandle.BeatmapsLoaded = "loading osu!.db FAILED!"; var osuDbLoadFailedException = new OsuDbLoadFailedException($"loading osu!.db FAILED\n{e.Message}", e); osuDbLoadFailedException.Data["src"] = osudb; osuDbLoadFailedException.Data["dest"] = newOsuFile; osuDbLoadFailedException.Data["osuDbVersion"] = _osuDatabaseLoader.FileDate; osuDbLoadFailedException.Data["counts"] = $"{_osuDatabaseLoader.ExpectedNumberOfMapSets} - {_osuDatabaseLoader.ExpectedNumOfBeatmaps}"; osuDbLoadFailedException.Data["stack"] = e.StackTrace; if (_logger is IContextAwareLogger contextAwareLogger) { contextAwareLogger.SetContextData("osu!username", string.IsNullOrEmpty(_osuDatabaseLoader.Username) ? "null" : _osuDatabaseLoader.Username); } _logger?.Log(osuDbLoadFailedException, LogLevel.Error); MessageBox.Show("Failed to load osu! beatmap database: " + Environment.NewLine + string.Format("Exception: {0},{1}", e.Message, e.StackTrace), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { _databaseControler.EndMassStoring(); } } else { _mainWindowHandle.BeatmapsLoaded = "Could not locate osu!.db"; } }).Start(); }