public TCManager() { var set = Settings.Default; AuthDatabase = new AuthDatabase(set.DBHost, set.DBPort, set.DBUsername, set.DBPassword.DecryptString(Encoding.Unicode.GetBytes(set.Entropy)).ToInsecureString(), set.DBAuthName); CharDatabase = new CharDatabase(set.DBHost, set.DBPort, set.DBUsername, set.DBPassword.DecryptString(Encoding.Unicode.GetBytes(set.Entropy)).ToInsecureString(), set.DBCharName); WorldDatabase = new WorldDatabase(set.DBHost, set.DBPort, set.DBUsername, set.DBPassword.DecryptString(Encoding.Unicode.GetBytes(set.Entropy)).ToInsecureString(), set.DBWorldName); _triggers = new Dictionary<string, TriggerKey>(); }
private async void DownloadApplyTDB() { var result = _messageService.Show("This will create the 'world' database. If the database already exists, it will be overwritten! Continue?", "Warning!", MessageButton.YesNo, MessageImage.Warning); if (result == MessageResult.Yes) { Progress<int> progress = new Progress<int>(val => { TDBSetupProgress = val; }); //var wizard = e.Source as Xceed.Wpf.Toolkit.Wizard; //if (Wizard != null) //{ // Wizard.CanSelectNextPage = false; // Wizard.CanSelectPreviousPage = false; //} TDBSetupWorking = true; string tempDir = FileHelper.GenerateTempDirectory(); string file = Path.Combine(tempDir, "TDB.7z"); string extractTo = Path.Combine(tempDir, "TDB"); Directory.CreateDirectory(extractTo); await TDB.DownloadTDBAsync(progress, file); await TDB.Extract7zAsync(file, extractTo, progress); string[] files = Directory.GetFiles(extractTo); string tdbSql = ""; foreach (string f in files) { if (Path.GetFileName(f).StartsWith("TDB_full")) { tdbSql = f; break; } } if (!string.IsNullOrEmpty(tdbSql)) { MySqlDatabase db = new WorldDatabase(MySQLHost, MySQLPort, MySQLUsername, MySQLPassword, "world"); await db.CreateDatabaseAsync(); await TDB.ApplyAsync(tdbSql, db, progress, new CancellationTokenSource()); } FileHelper.DeleteDirectory(tempDir); TDBSetupWorking = false; } }