public TrackingRepository(IUpdateInfoHelper updateInfoHelper, IConfiguration configuration) { _updateInfoHelper = updateInfoHelper; var _optionsBuilder = new DbContextOptionsBuilder <TrackingContext>() .UseMySql(configuration.GetConnectionString(CONNECTION_STRING)); _options = _optionsBuilder.Options; }
public TimerService( ITrackingRepository trackingRepository, IPullAndBearClient pullAndBearClient, IBershkaClient bershkaClient, IBotService botService, ITextConverter textConverter, IUpdateInfoHelper updateInfoHelper) { _trackingRepository = trackingRepository ?? throw new ArgumentNullException(nameof(trackingRepository)); _pullAndBearClient = pullAndBearClient ?? throw new ArgumentNullException(nameof(pullAndBearClient)); _bershkaClient = bershkaClient ?? throw new ArgumentNullException(nameof(bershkaClient)); _botService = botService ?? throw new ArgumentNullException(nameof(botService)); _textConverter = textConverter ?? throw new ArgumentNullException(nameof(textConverter)); _updateInfoHelper = updateInfoHelper ?? throw new ArgumentNullException(nameof(updateInfoHelper)); var existedItems = _trackingRepository.GetItemsAsync().Result; itemsQueue = existedItems.Any() ? new Queue <Item>(existedItems) : new Queue <Item>(); timer = new Timer(10000); // 10 sec timer.Elapsed += OnTimedEvent; timer.AutoReset = true; timer.Enabled = true; }