Ejemplo n.º 1
0
        public void UpdateOutdatedItems(IList <Item> items)
        {
            foreach (var item in items)
            {
                var task = _contentHandler.GetScreenshot(item);

                string filename = task.Result;

                if (filename != null)
                {
                    _logger.Info($"Got screenshot of: {item.Name}");
                    var now = DateTime.Now;

                    item.LastChecked  = now;
                    item.Modified     = now;
                    item.UserNotified = false; //krc

                    _itemsRepository.Update(item);

                    Models.Screenshot screenshot = new Models.Screenshot();

                    screenshot.ItemId     = item.Id;
                    screenshot.ScrnshtURL = filename;
                    screenshot.DateTaken  = now;

                    _screenshotRepository.Create(screenshot);

                    _logger.Info("Updated item: " + item.Name);
                }
                else
                {
                    if (item.Failed >= 3)
                    {
                        item.IsActive = false;
                    }
                    else
                    {
                        item.Failed++;
                    }

                    _itemsRepository.Update(item);
                    _logger.Info($"Failed to get screenshot of item: {item.Name}");
                }
            }
        }