private void CheckReadyReminders(object state) { var readyToSendItems = _storage.GetList(ReminderItemStatus.Awaiting); foreach (var reminderItem in readyToSendItems) { try { _sender.Send(reminderItem.ContactId, reminderItem.Message); reminderItem.Status = ReminderItemStatus.SuccessfullySent; OnSendingSucceeded( this, new ActionSucceededEventArgs(reminderItem)); // Raise event SendingSucceeded; } catch (Exception exception) { reminderItem.Status = ReminderItemStatus.Failed; OnSendingFailed( this, new SendingFailedEventArgs(reminderItem, exception)); // Raise event SendingFailed; } _storage.Update(reminderItem);; } }
private void CheckAwaitingReminders(object _) //Подчеркивание "_" = не используем! { var readyItems = _storage.GetList(new[] { ReminderItemStatus.Awaiting }).Where(i => i.IsTimeToSend); foreach (var readyItem in readyItems) { readyItem.Status = ReminderItemStatus.ReadyToSend; _storage.Update(readyItem); } }
private void CheckAwaitingReminders(object _) { var readyItems = _storage.GetList( new[] { ReminderItemStatus.Awaiting }) .Where(i => i.IsTimeToSend); foreach (var readyItem in readyItems) { readyItem.Status = ReminderItemStatus.ReadyToSent; _storage.Update(readyItem); } }
private void CheckAwaitingReminders(object dummy) { List <ReminderItem> awaitingItems = _storage.GetList(ReminderItemStatus.Awaiting); foreach (ReminderItem reminderItem in awaitingItems) { if (reminderItem.IsTimeToSend) { reminderItem.Status = ReminderItemStatus.ReadyToSend; _storage.Update(reminderItem); } } }
public IActionResult GetList([FromQuery(Name = "status")] ReminderItemStatus[] statuses = null) { _logger.LogInformation($"{nameof(GetList)} called"); if (statuses == null || statuses.Length == 0) { statuses = new[] { ReminderItemStatus.Awaiting, ReminderItemStatus.Failed, ReminderItemStatus.ReadyToSend, ReminderItemStatus.SuccessfullySent } } ; List <ReminderItem> reminderItems = _storage.GetList(statuses); List <ReminderItemGetModel> result = reminderItems .Select(ri => new ReminderItemGetModel(ri)) .ToList(); return(Ok(result)); }
public IActionResult GetList([FromQuery(Name = "status")] ReminderItemStatus status) { List <ReminderItemGetModel> list = _storage .GetList(status) .Select(ri => new ReminderItemGetModel(ri)) .ToList(); return(Ok(list)); }
private void CheckAwatingReminders(object _) //not used { // List<ReminderItemStatus> statuses = new List<ReminderItemStatus>() // { // var items = _storage.GetList(statuses); // }; var readyItems = _storage.GetList(new[] { ReminderItemStatus.Awaiting }); //list.where i :=> i.IsTimeToSend; foreach (var readyItem in readyItems) { readyItem.Status = ReminderItemStatus.ReadyToSend; _storage.Update(readyItem); } }
public IActionResult GetAll() { var reminderItems = _storage.GetList(new[] { ReminderItemStatus.Awaiting, ReminderItemStatus.Failed, ReminderItemStatus.ReadyToSend, ReminderItemStatus.SuccessfullySent }); List <ReminderItemGetModel> result = reminderItems .Select(ri => new ReminderItemGetModel(ri)) .ToList(); return(Ok(result)); }