public WorldDatabaseProvider(DatabaseResolver databaseResolver,
                                     NullWorldDatabaseProvider nullWorldDatabaseProvider,
                                     IWorldDatabaseSettingsProvider settingsProvider,
                                     IMessageBoxService messageBoxService,
                                     ILoadingEventAggregator loadingEventAggregator,
                                     IEventAggregator eventAggregator,
                                     IContainerProvider containerProvider) : base(nullWorldDatabaseProvider)
        {
            if (settingsProvider.Settings.IsEmpty)
            {
                eventAggregator.GetEvent <AllModulesLoaded>().Subscribe(loadingEventAggregator.Publish <DatabaseLoadedEvent>, true);
                return;
            }

            try
            {
                var cachedDatabase = containerProvider.Resolve <CachedDatabaseProvider>((typeof(IAsyncDatabaseProvider), databaseResolver.ResolveWorld()));
                cachedDatabase.TryConnect();
                impl = cachedDatabase;
            }
            catch (Exception e)
            {
                impl = nullWorldDatabaseProvider;
                messageBoxService.ShowDialog(new MessageBoxFactory <bool>().SetTitle("Database error")
                                             .SetIcon(MessageBoxIcon.Error)
                                             .SetMainInstruction("Couldn't connect to the database")
                                             .SetContent(e.Message)
                                             .WithOkButton(true)
                                             .Build());
            }
        }
예제 #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));
        }
예제 #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)
 {
 }