Beispiel #1
0
        public async Task AwaitTaskAsync(Task task)
        {
            if (task == null)
            {
                TaskDone?.Invoke(this, null);
                return;
            }

            _container.ShowLoadingView();

            try
            {
                await task;
                _container.ShowContentView();
            }
            catch (Exception exception)
            {
                _lastTask = task;

                if (Error != null)
                {
                    _container.ShowErrorView();
                    Error.Invoke(this, exception);
                }
                else
                {
                    _container.ShowErrorView(exception);
                }
            }

            TaskDone?.Invoke(this, null);
        }
        public void HandleFinishedFinalTask(Tuple <DbTarget, DbTarget> tuple, string userEmail, IMongoDatabase db)
        {
            TaskDone td = new TaskDone()
            {
                FinishDate   = DateTime.Now.AddDays(-1.0),
                TaskId       = tuple.Item2.Id,
                NextTaskId   = null,
                TaskName     = tuple.Item2.Name,
                NextTaskName = null,
                UserEmail    = userEmail,
                Solution     = tuple.Item2.Solution,
                IsPublic     = tuple.Item2.IsPublic
            };

            IMongoCollection <TaskDone> col = db.GetCollection <TaskDone>("tasksDone");

            col.InsertOne(td);
            int bonus = 100 * Convert.ToInt32(Math.Ceiling(Convert.ToDouble(tuple.Item2.ActiveDays / (tuple.Item2.Elapsed - (tuple.Item2.Difficulty - tuple.Item2.WeekendsRemained)))));

            Notification n = new Notification()
            {
                Body        = String.Format("You finished the task: {0}. Our congratulations! You finished the whole task successfully! By the way, we give you {1} bonuses for using Premium account services", tuple.Item2.Name, bonus),
                Title       = "Task finished",
                Seen        = false,
                SendingTime = DateTime.Now,
                Type        = "FinalTaskDone",
                UserEmail   = userEmail
            };

            AddBonusForUser(userEmail, bonus);

            IMongoCollection <Notification> col2 = db.GetCollection <Notification>("notifications");

            col2.InsertOne(n);
        }
 public void Handle(TaskDone @event)
 {
     using (var session = _documentStore.OpenSession())
     {
         var projectTreeNode = session.Load <ProjectTreeNode>(@event.ProjectId);
         projectTreeNode.NumberOfOpenTasks--;
         session.SaveChanges();
     }
 }
 public void Handle(TaskDone @event)
 {
     using (var session = _documentStore.OpenSession())
     {
         var taskInGridView = session.Load <TaskInGridView>(@event.TaskId);
         taskInGridView.IsDone = true;
         session.SaveChanges();
     }
 }
Beispiel #5
0
        public void Start()
        {
            foreach (var command in _pipeline)
            {
                command.Execute();
            }
            _pipeline.Clear();

            TaskDone?.Invoke(this, new TaskEventArgs(Thread.CurrentThread));
        }
Beispiel #6
0
        /// <summary>
        /// Event if a task was complete
        /// </summary>
        /// <param name="sender">The task wich completed there work</param>
        /// <param name="e">The task done dataset from the task</param>
        private void ProgressTask_TaskComplete(object sender, TaskDone e)
        {
            EventHandler <WorkerSetTaskDone> handler = TaskComplete;

            alreadyDoneWorkload += e.TotalWorkload;
            if (alreadyDoneWorkload == totalWorkLoad)
            {
                handler?.Invoke(this, new WorkerSetTaskDone(totalWorkLoad, sender));
            }
            ProgressTask_ProgressChanged(sender, new TaskProgressChanged(totalWorkLoad, 0));
        }
Beispiel #7
0
        public TaskDone ConvertTaskDone(taskdone t)
        {
            TaskDone taskDone = new TaskDone {
                TaskDoneID        = t.taskDoneID,
                IsDone            = t.isDone,
                Student_studentID = t.student_studentID,
                Task_taskID       = t.task_taskID,
                Student           = new Student(),
                Task = new Tasks()
            };

            return(taskDone);
        }
Beispiel #8
0
        public void DoneTask(BuildNode node, DateTime time, CommandResult result)
        {
            _logger.LogDebug($"BuildProcess.DoneTask: {time}");
            var task = FindTask(node);

            if (task == null)
            {
                return;
            }
            _logger.LogDebug($"BuildProcess.DoneTask: Task: {task.GetHashCode()}");
            task.Done(result.IsSuccess, result.Message, result.Result);
            Silent = result.Silent;
            TaskDone?.Invoke(task);
            CurrentTasks.Remove(task);
            if (IsDone || IsAborted)
            {
                DoneBuild(time);
            }
        }
Beispiel #9
0
        public void KeyFileGenerator(string TargetFile, byte[] SettingsByte)
        {
            File.WriteAllBytes(TargetFile, SettingsByte);

            var    Filestream = new FileStream(TargetFile, FileMode.Append);
            Random random     = new Random();

            long loop = 0;
            byte bytevalue;

            while (loop < Size - 2)
            {
                bytevalue = (byte)random.Next(256);
                Filestream.WriteByte(bytevalue);
                loop++;
            }
            Filestream.Dispose();

            TaskDone?.Invoke();
        }
Beispiel #10
0
        public void When_Task_Is_Done_The_Grid_Read_Model_Is_Updated()
        {
            var taskId    = Fixture.Create <string>();
            var projectId = Fixture.Create <string>();

            using (var session = DocumentStore.OpenSession())
            {
                var taskInGridView = new TaskInGridView(taskId, projectId,
                                                        Fixture.Create <string>(), Fixture.Create <TaskDeadline>(), TaskPriority.Low.DisplayName, false);
                session.Store(taskInGridView);
                session.SaveChanges();
            }

            var eventHandler = new TaskDoneEventHandler(DocumentStore);
            var taskDone     = new TaskDone(taskId, projectId);

            eventHandler.Handle(taskDone);

            var allTasksInProjectQuery     = new AllTasksInProjectQuery(projectId);
            var taskInGridViewQueryHandler = new TaskInGridViewQueryHandler();
            var task = taskInGridViewQueryHandler.Handle(allTasksInProjectQuery)[0];

            Assert.That(task.IsDone, Is.True);
        }
Beispiel #11
0
 protected void Done(ConverterEventArgs e)
 {
     TaskDone?.Invoke(this, e);
 }
 private void OnTaskDone()
 {
     TaskDone?.Invoke(this, EventArgs.Empty);
 }
 public void PostTaskDone(TaskDone data)
 {
     _context.TasksDone.Add(data);
     _context.SaveChanges();
 }
 protected virtual void OnTaskDone()
 {
     TaskDone?.Invoke(this, EventArgs.Empty);
 }
 public void PutTaskDone(long id, [FromBody] TaskDone data)
 {
     _context.TasksDone.Update(data);
     _context.SaveChanges();
 }
Beispiel #16
0
 private void Apply(TaskDone @event)
 {
     _isDone = true;
 }
 protected virtual void OnTaskDone(string text)
 {
     TaskDone?.Invoke(this, text);
 }