private void Save() { int?port = null; if (int.TryParse(Port, out var port_)) { port = port_; } settings.UpdateSettings(User, Password, Host, port, Database); }
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 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; }); }
private void Save() { settings.UpdateSettings(User, Password, Host, Database); }