Beispiel #1
0
        protected override void Handle(StartProjectTaskCommand request)
        {
            if (TaskRecorder.HasActiveTask)
            {
                DuplicateTaskValidator taskValidator = new DuplicateProjectTaskValidator(TaskRecorder.ActiveTask,
                                                                                         request.ProjectDto.ID, request.ProjectStageDto.ID, request.WorksetDto.ID,
                                                                                         request.IsAddCost, request.IsMistake);
                taskValidator.ValidateDuplicate();
            }

            if (TaskService.AskBeforeStartNewTaskResult() == DialogResult.No)
            {
                return;
            }

            DateTime currentTime = Database.GetCurrentTime();

            if (TaskRecorder.HasActiveTask)
            {
                TaskRepository.Finish(TaskRecorder.ActiveTask, currentTime);
                TaskRecorder.StopActiveTask(currentTime);
            }

            Project      project        = ProjectRepository.Load(request.ProjectDto.ID);
            ProjectStage projectStage   = ProjectStageRepository.Load(request.ProjectStageDto.ID);
            Workset      workset        = WorksetRepository.Load(request.WorksetDto.ID);
            ProjectTask  newProjectTask = TaskFactory.CreateProjectTask(TaskRepository.NextIdentity(), project, projectStage,
                                                                        workset, request.IsAddCost, request.IsMistake);

            TaskRepository.Save(newProjectTask, currentTime);
            TaskRecorder.StartNewTask(newProjectTask, currentTime);
            WorkTimer.Start();
        }
Beispiel #2
0
        protected override void Handle(StopTaskCommand request)
        {
            ActiveTaskValidator validator = new ActiveTaskValidator(TaskRecorder.HasActiveTask);

            validator.CheckIfAnyTaskIsRunning();

            if (TaskService.AskBeforeStopActiveTaskResult() == DialogResult.No)
            {
                return;
            }

            BaseTask activeTask = TaskRecorder.ActiveTask;
            DateTime endTime    = Database.GetCurrentTime();

            TaskRepository.Finish(activeTask, endTime);

            TaskRecorder.StopActiveTask(endTime);

            WorkTimer.Stop();
        }