Пример #1
0
        public TrinityMysqlDatabaseProvider(IConnectionSettingsProvider settings)
        {
            string Database = settings.GetSettings().DB;
            string User     = settings.GetSettings().User;
            string Password = settings.GetSettings().Password;
            string Host     = settings.GetSettings().Host;

            try
            {
                var config = MySqlConfiguration.Create(Database, Host, User, Password);
                model = DataAccessModel.BuildDataAccessModel <TrinityDatabase>(config);
                try
                {
                    model.Create(DatabaseCreationOptions.IfDatabaseNotExist);
                }
                catch (Exception)
                {
                    // already exists, its ok
                }
                var temp = GetCreatureTemplates();
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(Host))
                {
                    MessageBox.Show($"Cannot connect to MySql database: {e.Message} Check your settings.");
                }
                model = null;
            }
        }
 public DatabaseConfigViewModel(IConnectionSettingsProvider settings)
 {
     SaveAction    = Save;
     Database      = settings.GetSettings().DB;
     User          = settings.GetSettings().User;
     Password      = settings.GetSettings().Password;
     Host          = settings.GetSettings().Host;
     this.settings = settings;
 }
Пример #3
0
 public DatabaseConfigViewModel(IConnectionSettingsProvider settings)
 {
     SaveAction    = Save;
     Database      = settings.GetSettings().Database;
     Port          = (settings.GetSettings().Port ?? 3306).ToString();
     User          = settings.GetSettings().User;
     Password      = settings.GetSettings().Password;
     Host          = settings.GetSettings().Host;
     this.settings = settings;
 }
        public SoapConfigViewModel(IConnectionSettingsProvider settings, ISoapClientFactory clientFactory)
        {
            port          = (settings.GetSettings().Port ?? 7878).ToString();
            user          = settings.GetSettings().User;
            pass          = settings.GetSettings().Password;
            host          = settings.GetSettings().Host ?? "127.0.0.1";
            this.settings = settings;

            Save = new DelegateCommand(() =>
            {
                int?port = null;
                if (int.TryParse(Port, out int port_))
                {
                    port = port_;
                }
                settings.UpdateSettings(User, Password, Host, port);
                IsModified = false;
            });

            TestConnection = new AsyncAutoCommand(async() =>
            {
                int?port = null;
                if (int.TryParse(Port, out int port_))
                {
                    port = port_;
                }
                var client = new TrinitySoapClient(clientFactory, host, port ?? 0, user !, pass !);
                try
                {
                    var response = await client.ExecuteCommand("server info");
                    if (response.Success)
                    {
                        TestConnectionOutput = "Success:\n" + response.Message;
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(response.Message))
                        {
                            TestConnectionOutput =
                                "Server responded, but response ill-formed. Is it TrinityCore based server?";
                        }
                        else
                        {
                            TestConnectionOutput = "Server responded, but command failed: " + response.Message;
                        }
                    }
                }
                catch (Exception e)
                {
                    TestConnectionOutput = "Connection failed: " + e.Message;
                }
            }, _ => !string.IsNullOrEmpty(host) && int.TryParse(port, out var _) && !string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(pass));

            PropertyChanged += (_, _) => TestConnection.RaiseCanExecuteChanged();
        }
        public TrinityMySqlDatabaseProvider(IConnectionSettingsProvider settings,
                                            DatabaseLogger databaseLogger,
                                            ICurrentCoreVersion currentCoreVersion)
        {
            this.currentCoreVersion = currentCoreVersion;
            string?host = settings.GetSettings().Host;

            DataConnection.TurnTraceSwitchOn();
            DataConnection.WriteTraceLine  = databaseLogger.Log;
            DataConnection.DefaultSettings = new MySqlSettings(settings.GetSettings());
        }
Пример #6
0
 public DatabaseProvider(CachedDatabaseProvider cachedDatabase,
                         NullDatabaseProvider nullDatabaseProvider,
                         IConnectionSettingsProvider settings,
                         IMessageBoxService messageBoxService)
 {
     if (settings.GetSettings().IsEmpty)
     {
         impl = nullDatabaseProvider;
     }
     else
     {
         try
         {
             cachedDatabase.TryConnect();
             impl = cachedDatabase;
         }
         catch (Exception e)
         {
             impl = nullDatabaseProvider;
             messageBoxService.ShowDialog(new MessageBoxFactory <bool>().SetTitle("Database error")
                                          .SetIcon(MessageBoxIcon.Error)
                                          .SetMainInstruction("Couldn't connect to the database")
                                          .SetContent(e.Message)
                                          .WithOkButton(true)
                                          .Build());
         }
     }
 }
Пример #7
0
        public TrinityMysqlDatabaseProvider(IConnectionSettingsProvider settings)
        {
            string?Host = settings.GetSettings().Host;

            try
            {
                DataConnection.DefaultSettings = new MySqlSettings(settings.GetSettings());
                model = new TrinityDatabase();
                var temp = GetCreatureTemplates().ToList();
            }
            catch (Exception e)
            {
                if (!string.IsNullOrEmpty(Host))
                {
                    MessageBox.Show($"Cannot connect to MySql database: {e.Message} Check your settings.");
                }
                model = null;
            }
        }
Пример #8
0
        public DatabaseConfigViewModel(IConnectionSettingsProvider settings)
        {
            database      = settings.GetSettings().Database;
            port          = (settings.GetSettings().Port ?? 3306).ToString();
            user          = settings.GetSettings().User;
            pass          = settings.GetSettings().Password;
            host          = settings.GetSettings().Host;
            this.settings = settings;

            Save = new DelegateCommand(() =>
            {
                int?port = null;
                if (int.TryParse(Port, out int port_))
                {
                    port = port_;
                }
                settings.UpdateSettings(User, Password, Host, port, Database);
                IsModified = false;
            });
        }
Пример #9
0
        public SoapRemoteConnectorService(IConnectionSettingsProvider connectionSettings,
                                          ISoapClientFactory soapClientFactory)
        {
            this.connectionSettings = connectionSettings;
            var settings = connectionSettings.GetSettings();

            if (settings.IsEmpty)
            {
                trinitySoapClient = null;
            }
            else
            {
                trinitySoapClient = new TrinitySoapClient(soapClientFactory, settings.Host !, settings.Port !.Value, settings.User !, settings.Password !);
            }
        }
Пример #10
0
 public MySqlExecutor(IConnectionSettingsProvider connectionSettingsProvider)
 {
     settings = new MySqlSettings(connectionSettingsProvider.GetSettings());
 }