public void Send(ReminderNotification item) { string text; if (item.Message == "info") { text = @"Hello! If you want to use reminder, please write this: <Message> <DateTimeUtc> Messages without datetime returns imideatly"; } else { text = $"{item.Message} at {item.DateTime:R}"; } var chatId = new ChatId(long.Parse(item.ContactId)); try { _client.SendTextMessageAsync(chatId, text) .GetAwaiter() .GetResult(); } catch (HttpRequestException exception) { throw new ReminderSenderException(exception); } }
public void send(ReminderNotification notification) { var text = $"{notification.Title}{notification.Text}"; var chatID = new ChatId(long.Parse(notification.UserId)); _client.SendTextMessageAsync(null, text, ParseMode.Html); }
public void Send(ReminderNotification item) { if (_fail) { throw new ReminderSenderException(null); } }
public void Send(ReminderNotification notification) { if (ShouldFail) { throw new HttpRequestException("Telegram NE DOSTUPEN"); } }
public Task SendAsync(ReminderNotification item) { if (_fail) { throw new ReminderSenderException(null); } return(Task.CompletedTask); }
public void ReminderNotification(IRemindersManager remindersManager, Reminder reminder) { Application.Current.Dispatcher.Invoke((Action) delegate { var form = new ReminderNotification(remindersManager, reminder); form.Owner = this; form.Show(); }); }
public void Send(ReminderNotification notification) { var text = $"{notification.Header}{notification.Text}"; var chatId = new ChatId(long.Parse(notification.ChatId)); _client.SendTextMessageAsync(chatId, text) .GetAwaiter() .GetResult(); }
public async Task SendAsync(ReminderNotification item) { var text = $"{item.Message} at {item.DateTime:R}"; var chatId = new ChatId(long.Parse(item.ContactId)); try { await _client.SendTextMessageAsync(chatId, text); } catch (HttpRequestException exception) { throw new ReminderSenderException(exception); } }
private void OnSenderTimerTick(object state) { var items = _storage.FindBy(ReminderItemFilter.ByStatus(ReminderItemStatus.Ready)); foreach (var item in items) { var notification = new ReminderNotification( item.Title, item.Message, item.User.ChatId); try { _sender.Send(notification); UpdateStatus(item, ReminderItemStatus.Sent); } catch (HttpRequestException exception) { _logger.LogWarning("Failed to sent item", exception); UpdateStatus(item, ReminderItemStatus.Failed); } } }
public void send(ReminderNotification notification) { }
public Task SendAsync(ReminderNotification item) => _fail?Task.FromException(new ReminderSenderException(null)) : Task.CompletedTask;