Exemplo n.º 1
0
        public TelegramHostedService(EmployeeProvider employeeProvider, ILogger <TelegramHostedService> logger, SqlServer sqlServer, IConfiguration config)
        {
            this._config = Startup.Config.UserBot;

            this._employeeProvider = employeeProvider;
            this._logger           = logger;
            this._sqlServer        = sqlServer;

            if (this._config.ApiUrl != null)
            {
                _httpClient = new HttpClient(new ProxyMessageHandler(this._config.ApiUrl));
            }
            else
            {
                _httpClient = new HttpClient();
            }

            this._cts       = new CancellationTokenSource();
            _telegramClient = new Telegram.Bot.TelegramBotClient(this._config.Token, _httpClient);

            if (!TimeSpan.TryParse(this._config.TimeToCancelTurns, out this._timeToCancelTurns))
            {
                this._timeToCancelTurns = TimeSpan.FromHours(6);
            }
        }
Exemplo n.º 2
0
        public NotificationsHostedService(EmployeeProvider employeeProvider, ILogger <NotificationsHostedService> logger, SqlServer sqlServer, IConfiguration config)
        {
            this._config = Startup.Config.UserBot;

            this._employeeProvider = employeeProvider;
            this._logger           = logger;
            this._sqlServer        = sqlServer;

            this._cts       = new CancellationTokenSource();
            _httpClient     = new HttpClient();
            _telegramClient = new Telegram.Bot.TelegramBotClient(this._config.Token, _httpClient);
        }