public void TaskSent(ExecutorTask task, Message message) { task.AddStatus(TaskStatus.Sent); task.TelegramMessageId = message.MessageId; _dbContext.SaveChanges(); }
public static void TaskThread() { try { ExecutorTask task = pool.GetObject(); task.Execute(); pool.ReleaceObject(task); } catch (PoolException e) { Console.WriteLine("Error ==> " + e.ToString()); } }
private string GetTaskText(ExecutorTask task) { if (task is ExecutorCommentsTask commentsTask) { return($"Здравствуй, товарищ! Необходимо оставить комментарии под этими постами: {Environment.NewLine}" + string.Join(Environment.NewLine, commentsTask.Groups)); } Debug.Assert(false, "New ExecutorTask type has been added"); return(string.Empty); }
public void TaskCanceled(ExecutorTask task) { task.AddStatus(TaskStatus.Canceled); _dbContext.Entry(task).Reference(t => t.Task).Load(); if (task.Task.ExecutorTasks.All(x => x.LastStatus == TaskStatus.Canceled)) { task.Task.Status = GlobalTaskStatus.Canceled; } _dbContext.SaveChanges(); }
private InlineKeyboardMarkup GetTaskMarkup(ExecutorTask task, TaskMessageButtons buttonType) { var list = new List <InlineKeyboardButton>(); switch (buttonType) { case TaskMessageButtons.Accept: list.Add(InlineKeyboardButton.WithCallbackData("Задача принята", $"{ACCEPT_KEYWORD};{task.Task.Id}")); break; case TaskMessageButtons.Complete: list.Add(InlineKeyboardButton.WithCallbackData("Задача выполнена", $"{DONE_KEYWORD};{task.Task.Id}")); break; default: break; } return(new InlineKeyboardMarkup(list.ToArray())); }
public async System.Threading.Tasks.Task CancelTask(ExecutorTask task) { await _botClient.DeleteMessageAsync(new Telegram.Bot.Types.ChatId(task.Executor.TelegramId), task.TelegramMessageId); _taskRepository.TaskCanceled(task); }
public async System.Threading.Tasks.Task SendTask(ExecutorTask task) { var message = await _botClient.SendTextMessageAsync(task.Executor.TelegramId, GetTaskText(task), ParseMode.Default, true, false, 0, GetTaskMarkup(task, TaskMessageButtons.Accept)); _taskRepository.TaskSent(task, message); }
public ExecutorTaskVM(ExecutorTask x) { Task = x; Executor = Task.Executor; Status = x.Statuses.LastOrDefault(); }