Exemple #1
0
        public void TaskSent(ExecutorTask task, Message message)
        {
            task.AddStatus(TaskStatus.Sent);
            task.TelegramMessageId = message.MessageId;

            _dbContext.SaveChanges();
        }
Exemple #2
0
 public static void TaskThread()
 {
     try {
         ExecutorTask task = pool.GetObject();
         task.Execute();
         pool.ReleaceObject(task);
     } catch (PoolException e) {
         Console.WriteLine("Error ==> " + e.ToString());
     }
 }
Exemple #3
0
        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);
        }
Exemple #4
0
        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();
        }
Exemple #5
0
        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()));
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        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);
        }
Exemple #8
0
 public ExecutorTaskVM(ExecutorTask x)
 {
     Task     = x;
     Executor = Task.Executor;
     Status   = x.Statuses.LastOrDefault();
 }