CreateOrAttachToBrokerInstanceAsync() public static method

public static CreateOrAttachToBrokerInstanceAsync ( ILogger logger = null ) : Task
logger ILogger
return Task
Esempio n. 1
0
        public async Task StartUpAsync()
        {
            try {
                int 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);
            }
        }
Esempio n. 2
0
        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);
            }
        }