public AuthDatabaseProvider(TrinityMySqlDatabaseProvider trinityDatabase,
                                    NullAuthDatabaseProvider nullAuthDatabaseProvider,
                                    IAuthDatabaseSettingsProvider settingsProvider,
                                    IMessageBoxService messageBoxService
                                    ) : base(nullAuthDatabaseProvider)
        {
            if (settingsProvider.Settings.IsEmpty)
            {
                return;
            }

            try
            {
                using var db = new TrinityAuthDatabase();
                if (db.Connection.State != ConnectionState.Open)
                {
                    db.Connection.Open();
                    db.Connection.Close();
                }
                impl = trinityDatabase;
            }
            catch (Exception e)
            {
                impl = nullAuthDatabaseProvider;
                messageBoxService.ShowDialog(new MessageBoxFactory <bool>().SetTitle("Database error")
                                             .SetIcon(MessageBoxIcon.Error)
                                             .SetMainInstruction("Couldn't connect to the auth database")
                                             .SetContent(e.Message)
                                             .WithOkButton(true)
                                             .Build());
            }
        }
Esempio n. 2
0
 public BaseTrinityMySqlDatabaseProvider(IWorldDatabaseSettingsProvider settings,
                                         IAuthDatabaseSettingsProvider authSettings,
                                         DatabaseLogger databaseLogger,
                                         ICurrentCoreVersion currentCoreVersion)
 {
     this.currentCoreVersion = currentCoreVersion;
     DataConnection.TurnTraceSwitchOn();
     DataConnection.WriteTraceLine  = databaseLogger.Log;
     DataConnection.DefaultSettings = new MySqlWorldSettings(settings.Settings, authSettings.Settings);
 }
        public BaseDatabaseConfigViewModel(IWorldDatabaseSettingsProvider worldSettingsProvider,
                                           IAuthDatabaseSettingsProvider authDatabaseSettingsProvider)
        {
            var dbSettings = worldSettingsProvider.Settings;

            WorldDatabase.Database   = dbSettings.Database;
            WorldDatabase.Port       = (dbSettings.Port ?? 3306).ToString();
            WorldDatabase.User       = dbSettings.User;
            WorldDatabase.Password   = dbSettings.Password;
            WorldDatabase.Host       = dbSettings.Host;
            WorldDatabase.IsModified = false;

            var authDbSettings = authDatabaseSettingsProvider.Settings;

            AuthDatabase.Database   = authDbSettings.Database;
            AuthDatabase.Port       = (authDbSettings.Port ?? 3306).ToString();
            AuthDatabase.User       = authDbSettings.User;
            AuthDatabase.Password   = authDbSettings.Password;
            AuthDatabase.Host       = authDbSettings.Host;
            AuthDatabase.IsModified = false;


            Save = new DelegateCommand(() =>
            {
                if (AuthDatabase.IsModified)
                {
                    authDatabaseSettingsProvider.Settings = AuthDatabase;
                    AuthDatabase.IsModified = false;
                }

                if (WorldDatabase.IsModified)
                {
                    worldSettingsProvider.Settings = WorldDatabase;
                    WorldDatabase.IsModified       = false;
                }
            });

            Watch(WorldDatabase, s => s.IsModified, nameof(IsModified));
            Watch(AuthDatabase, s => s.IsModified, nameof(IsModified));
        }
Esempio n. 4
0
 public DatabaseConfigViewModel(IWorldDatabaseSettingsProvider worldSettingsProvider,
                                IAuthDatabaseSettingsProvider authDatabaseSettingsProvider) : base(worldSettingsProvider, authDatabaseSettingsProvider)
 {
 }
 public TrinityWrathMySqlDatabaseProvider(IWorldDatabaseSettingsProvider settings, IAuthDatabaseSettingsProvider authSettings, DatabaseLogger databaseLogger, ICurrentCoreVersion currentCoreVersion) : base(settings, authSettings, databaseLogger, currentCoreVersion)
 {
 }