Example #1
0
        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);
            }
        }
Example #2
0
        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);
        }
Example #3
0
 public void Send(ReminderNotification item)
 {
     if (_fail)
     {
         throw new ReminderSenderException(null);
     }
 }
Example #4
0
 public void Send(ReminderNotification notification)
 {
     if (ShouldFail)
     {
         throw new HttpRequestException("Telegram NE DOSTUPEN");
     }
 }
Example #5
0
 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();
     });
 }
Example #7
0
        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();
        }
Example #8
0
        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);
            }
        }
Example #9
0
        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);
                }
            }
        }
Example #10
0
 public void send(ReminderNotification notification)
 {
 }
Example #11
0
 public Task SendAsync(ReminderNotification item) =>
 _fail?Task.FromException(new ReminderSenderException(null)) : Task.CompletedTask;