private async void AddOrChangeBrokerUserBtn_Click(object sender, RoutedEventArgs e) { try { if (await CredentialManager.IsBrokerUserCredentialSavedAsync(_logger)) { CredentialManager.RemoveCredentials(_logger); } var count = await CredentialManager.GetAndSaveCredentialsFromUserAsync(_logger); if (count >= CredentialManager.MaxCredUIAttempts) { await SetErrorTextAsync(Monitor.Resources.Info_TooManyLoginAttempts); } } catch (Exception ex) when(!ex.IsCriticalException()) { _logger?.LogError(Monitor.Resources.Error_AddOrChangeUserFailed, ex.Message); await SetErrorTextAsync(ex.Message); } }
public async Task StartUpAsync() { try { int id = 0; if (Properties.Settings.Default.UseDifferentBrokerUser) { if (await CredentialManager.IsBrokerUserCredentialSavedAsync(_logger)) { id = await BrokerManager.CreateOrAttachToBrokerInstanceAsync(_logger); } else { await SetErrorTextAsync(Monitor.Resources.Info_DidNotFindSavedCredentails); var count = await CredentialManager.GetAndSaveCredentialsFromUserAsync(_logger); if (count >= CredentialManager.MaxCredUIAttempts) { await SetErrorTextAsync(Monitor.Resources.Info_TooManyLoginAttempts); } } } else { id = await BrokerManager.CreateOrAttachToBrokerInstanceAsync(_logger); } if (id != 0) { await SetStatusTextAsync(Monitor.Resources.Status_BrokerStarted.FormatInvariant(id)); } } catch (Exception ex) when(!ex.IsCriticalException()) { _logger?.LogError(Monitor.Resources.Error_StartUpFailed, ex.Message); await SetErrorTextAsync(ex.Message); } }