private void UpdateTask()
 {
     foreach (var taskId in _taskList.Keys)
     {
         var taskEntity  = (Katrin.Domain.Impl.ProjectTask)_objectSpace.GetOrNew("ProjectTask", taskId, "TaskTimeHistories");
         var historyList = taskEntity.TaskTimeHistories.ToList();
         historyList            = historyList.Where(c => c.IsDeleted == false).ToList();
         taskEntity.ActualInput = historyList.Select(c => c.ActualInput).Cast <double?>().Sum();
         taskEntity.Effort      = historyList.Select(c => c.Effort).Cast <double?>().Sum();
         taskEntity.Overtime    = historyList.Select(c => c.Overtime).Cast <double?>().Sum();
         TaskOperator.UpdateTaskStatus(taskEntity);
     }
 }
        protected override bool OnSaving()
        {
            var sourceTask = (ProjectTask)ObjectEntity;

            if (newTaskOne.ActualWorkHours < sourceTask.Effort ||
                newTaskOne.QuoteWorkHours < sourceTask.ActualInput)
            {
                XtraMessageBox.Show(ResourceService.GetString("SplitTaskTip"),
                                    ResourceService.GetString("Katrin"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information,
                                    MessageBoxDefaultButton.Button1);
                return(false);
            }
            var entityOne = (ProjectTask)_objectSpace.GetOrNew("ProjectTask", newTaskOne.TaskId, null);

            entityOne.TaskNumber         = newTaskOne.TaskNumber;
            entityOne.ProjectIterationId = newTaskOne.ProjectIterationId;
            entityOne.QuoteWorkHours     = newTaskOne.QuoteWorkHours;
            entityOne.ActualWorkHours    = newTaskOne.ActualWorkHours;
            entityOne.Name = newTaskOne.Name;
            TaskOperator.UpdateTaskStatus(entityOne);

            bool needCopy  = newTaskTwo.TaskId == Guid.Empty?true:false;
            var  entityTwo = (ProjectTask)_objectSpace.GetOrNew("ProjectTask", newTaskTwo.TaskId, null);

            entityTwo.TaskNumber         = newTaskTwo.TaskNumber;
            entityTwo.ProjectIterationId = newTaskTwo.ProjectIterationId;
            entityTwo.QuoteWorkHours     = newTaskTwo.QuoteWorkHours;
            entityTwo.ActualWorkHours    = newTaskTwo.ActualWorkHours;
            entityTwo.Name = newTaskTwo.Name;
            if (needCopy)
            {
                entityTwo.Description      = entityOne.Description;
                entityTwo.EndDate          = entityOne.EndDate;
                entityTwo.OwnerId          = entityOne.OwnerId;
                entityTwo.PriorityCode     = entityOne.PriorityCode;
                entityTwo.ProjectId        = entityOne.ProjectId;
                entityTwo.ProjectModuleId  = entityOne.ProjectModuleId;
                entityTwo.StartDate        = entityOne.StartDate;
                entityTwo.TaskCategoryCode = entityOne.TaskCategoryCode;
                entityTwo.StatusCode       = 1;
            }
            return(base.OnSaving());
        }
        private bool UpdateTask(TaskTimeHistory task)
        {
            var projectTask = new Katrin.Domain.Impl.ProjectTask();

            if (taskList.Select(c => c.TaskId).Contains(task.TaskId))
            {
                projectTask = taskList.Where(c => c.TaskId == task.TaskId).First();
            }
            else
            {
                projectTask = (Katrin.Domain.Impl.ProjectTask)_objectSpace.GetOrNew("ProjectTask", task.TaskId, null);
                taskList.Add(projectTask);
            }
            projectTask.ActualInput = Convert.ToDouble(projectTask.ActualInput ?? 0) + task.ActualInput;
            projectTask.Effort      = Convert.ToDouble(projectTask.Effort ?? 0) + task.Effort;
            if (task.TaskTimeHistoryId != Guid.Empty)
            {
                projectTask.Effort -= task.SourceEffort;
            }
            task.SourceEffort    = task.Effort;
            projectTask.Overtime = Convert.ToDouble(projectTask.Overtime ?? 0) + task.Overtime;
            if (task.TaskTimeHistoryId == Guid.Empty)
            {
                projectTask.Description = projectTask.Description ?? " " + task.Description;
            }

            TaskOperator.UpdateTaskStatus(projectTask);

            if (projectTask.Effort > projectTask.ActualWorkHours)
            {
                _newEffortView.ValidateResult = false;
                XtraMessageBox.Show(StringParser.Parse("OverEffortMessage"),
                                    StringParser.Parse("Katrin"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information,
                                    MessageBoxDefaultButton.Button1);
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
        private bool UpdateTask(Katrin.Domain.Impl.ProjectTask taskEntity, TaskTimeHistory task)
        {
            if (taskEntity == null)
            {
                return(true);
            }
            taskEntity.ActualInput = Convert.ToDouble(taskEntity.ActualInput ?? 0) + task.ActualInput;
            taskEntity.Effort      = Convert.ToDouble(taskEntity.Effort ?? 0) + task.Effort;
            taskEntity.Overtime    = Convert.ToDouble(taskEntity.Overtime ?? 0) + task.Overtime;

            TaskOperator.UpdateTaskStatus(taskEntity);

            if (taskEntity.Effort > taskEntity.ActualWorkHours)
            {
                _taskEffortView.ValidateResult = false;
                XtraMessageBox.Show(StringParser.Parse("OverEffortMessage"),
                                    StringParser.Parse("Katrin"),
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information,
                                    MessageBoxDefaultButton.Button1);
                return(false);
            }
            return(true);
        }