Exemplo n.º 1
0
 private Task HandlingConsumeOperationalClientAsync(Func <FakeOperationalClient, Task> actionAsync, string operationName)
 {
     try
     {
         return(_botApiClient.ConsumeOperationalClientAsync(
                    actionAsync,
                    () => _logger.LogError($"Fake Bot API Sender the [{operationName}] operation failed, the Fake Bot API Client ({_botApiClient.ComponentState.FooBar()}) cannot be consumed.")));
     }
     catch (Exception e)
     {
         _logger.LogError($"Fake Bot API Sender the [{operationName}] operation failed, an exception has occurred.{Environment.NewLine}{e}");
         return(Task.CompletedTask);
     }
 }
Exemplo n.º 2
0
        private async Task PollUpdatesAsync()
        {
            try
            {
                var updates = await _botApiClient.ConsumeOperationalClientAsync(_ => _.GetUpdatesAsync(), () =>
                {
                    AbortPollingUpdates();
                    return(Task.FromResult(Enumerable.Empty <FakeBotUpdate>()));
                });

                foreach (var update in updates)
                {
                    await SendUpdateCommand(update);
                }
            }
            catch (Exception e)
            {
                _logger.LogError($"Fake Bot API Poller the polling operation failed, an exception has occurred.{Environment.NewLine}{e}");
            }
        }