Esempio n. 1
0
        public async Task <SubTask> AddSubtask(SubTask subTask)
        {
            _dbContext.SubTasks.Add(subTask);
            await _dbContext.SaveChangesAsync();

            return(subTask);
        }
Esempio n. 2
0
        public long AddSubTask(SubTask iSubTask)
        {
            if (iSubTask == null)
            {
                throw new Exception("La sous tâche est nulle");
            }

            //Validation des conditions
            var mainTask = GetMainTaskById(iSubTask.MainTaskId, Library.Tools.Enums.GranularityEnum.Nude);

            if (mainTask.Status != EquinoxeExtend.Shared.Enum.MainTaskStatusEnum.Dev && iSubTask.Progression != 0)
            {
                throw new Exception("L'avancement d'une sous tâche requiert que la tâche soit en cours");
            }

            if (mainTask.Status != EquinoxeExtend.Shared.Enum.MainTaskStatusEnum.Dev &&
                mainTask.Status != EquinoxeExtend.Shared.Enum.MainTaskStatusEnum.Waiting)
            {
                throw new Exception("L'ajout d'une sous tâche n'est pas possible pour ce status de tâche");
            }

            //Validation des superpositions de package
            if (iSubTask.ProjectGUID != null)
            {
                if (!IsProjectCanJoinThisMainTask(mainTask.MainTaskId, (Guid)iSubTask.ProjectGUID))
                {
                    throw new Exception("Ce projet est déjà utilisé dans une tâche en cours");
                }
            }

            var entity = new T_E_SubTask();

            entity.Merge(iSubTask);
            return(DBReleaseDataService.AddSubTask(entity));
        }
Esempio n. 3
0
        public void UpdateSubTask(SubTask iSubTask)
        {
            if (iSubTask == null)
            {
                throw new Exception("La sous tâche est null");
            }
            if (iSubTask.SubTaskId < 1)
            {
                throw new Exception("L'id de la sous tâche est invalide");
            }

            //Vérification que le projet est toujours le même
            var originalSubTask = DBReleaseDataService.GetSubTask(iSubTask.SubTaskId);

            if (originalSubTask.ProjectGUID != iSubTask.ProjectGUID)
            {
                throw new Exception("Le projet d'une tâche de projet ne peut pas être modifiée");
            }

            //Validation des conditions
            var mainTask = GetMainTaskById(iSubTask.MainTaskId, Library.Tools.Enums.GranularityEnum.Nude);

            if (mainTask.Status != EquinoxeExtend.Shared.Enum.MainTaskStatusEnum.Dev && iSubTask.Progression != 0)
            {
                throw new Exception("L'avancement d'un sous tâche requiert que la tâche soit en cours");
            }

            var entity = new T_E_SubTask();

            entity.Merge(iSubTask);
            DBReleaseDataService.UpdateSubTask(entity);
        }
Esempio n. 4
0
 private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     try
     {
         while (!backgroundWorker1.CancellationPending)
         {
             myTask = server.getTask(id);
             if (myTask != null)
             {
                 myTask.execute();
                 server.complete(id, myTask);
                 backgroundWorker1.ReportProgress(0, ++completedTaskCount);
             }
             else
             {
                 Thread.Sleep(1000);
             }
         }
     }
     catch (SystemException)
     {
         MessageBox.Show("Соединение было потеряно.");
         isLostConnection = true;
     }
 }
        private void SubTaskAddButton_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(SubTaskTextBox.Text))
            {
                MessageHelper.DisplayWarning("Please supply subtask name!", "Error");
                return;
            }

            if (ImportanceComboBox.SelectedIndex == -1)
            {
                MessageHelper.DisplayWarning("Please select importance level!", "Error");
                return;
            }

            SubTask task = new SubTask()
            {
                MainTask   = CurrentlyEditedTask,
                Name       = SubTaskTextBox.Text,
                Importance = (ImportanceLevel)Enum.Parse(typeof(ImportanceLevel), ImportanceComboBox.SelectedItem.ToString())
            };

            BackupTask.SubTasks.Add(task);

            SubTaskList.Items.Refresh();
        }
Esempio n. 6
0
        public async Task <JsonResult> FindITaskLst()
        {
            CWTask cwtask = new CWTask();

            List <ImplementTask> taskLst = await cwtask.FindITaskLstAsync();

            List <SubTask> subtaskLst = new List <SubTask>();

            foreach (ImplementTask itsk in taskLst)
            {
                SubTask sub = new SubTask {
                    ID               = itsk.ID,
                    Warehouse        = itsk.Warehouse,
                    DeviceCode       = itsk.DeviceCode,
                    Type             = (int)itsk.Type,
                    Status           = (int)itsk.Status,
                    SendStatusDetail = (int)itsk.SendStatusDetail,
                    SendDtime        = itsk.SendDtime.ToString(),
                    CreateDate       = itsk.CreateDate.ToString(),
                    HallCode         = itsk.HallCode,
                    FromLctAddress   = itsk.FromLctAddress,
                    ToLctAddress     = itsk.ToLctAddress,
                    ICCardCode       = itsk.ICCardCode,
                    Distance         = itsk.Distance,
                    CarSize          = itsk.CarSize,
                    CarWeight        = itsk.CarWeight,
                    IsComplete       = itsk.IsComplete,
                    LocSize          = itsk.LocSize
                };
                subtaskLst.Add(sub);
            }

            return(Json(subtaskLst));
        }
Esempio n. 7
0
        public async Task <JsonResult> FindITask(int tid)
        {
            SubTask       subtask = null;
            ImplementTask itsk    = await new CWTask().FindAsync(tid);

            if (itsk != null)
            {
                subtask = new SubTask
                {
                    ID               = itsk.ID,
                    Warehouse        = itsk.Warehouse,
                    DeviceCode       = itsk.DeviceCode,
                    Type             = (int)itsk.Type,
                    Status           = (int)itsk.Status,
                    SendStatusDetail = (int)itsk.SendStatusDetail,
                    SendDtime        = itsk.SendDtime.ToString(),
                    CreateDate       = itsk.CreateDate.ToString(),
                    HallCode         = itsk.HallCode,
                    FromLctAddress   = itsk.FromLctAddress,
                    ToLctAddress     = itsk.ToLctAddress,
                    ICCardCode       = itsk.ICCardCode,
                    Distance         = itsk.Distance,
                    CarSize          = itsk.CarSize,
                    CarWeight        = itsk.CarWeight,
                    IsComplete       = itsk.IsComplete,
                    LocSize          = itsk.LocSize
                };
            }
            return(Json(subtask, JsonRequestBehavior.AllowGet));
        }
        public IActionResult AddSubTask(string error)
        {
            ViewBag.Error = error == null ? "" : error;
            SubTask model = new SubTask();

            return(View(model));
        }
Esempio n. 9
0
        public IActionResult AddTask(AddTaskModel model)
        {
            Db.ToDoId++;
            Db.SubTaskId++;

            ToDo todo = new ToDo()
            {
                Id              = Db.ToDoId,
                Title           = model.Title,
                Descrition      = model.Description,
                ImporanceOfTask = model.ImporanceOfTask,
                Status          = Status.NotDone,
                Type            = model.Type,
            };

            SubTask subtask = new SubTask()
            {
                Id         = Db.SubTaskId,
                Title      = model.SubTaskTitle,
                Descrition = model.SubTaskDescrition,
                SubStatus  = model.SubStatus
            };

            todo.SubTasks.Add(subtask);

            Db.Users.FirstOrDefault(u => u.FirstName == "John").ToDos.Add(todo);

            return(View("_AddedTask"));
        }
        public IActionResult PostSubTask([FromBody] SubTask subTaskModel)
        {
            try
            {
                if (subTaskModel != null && subTaskModel.TaskId != 0)
                {
                    _subTaskRepository.Add(subTaskModel);
                    UpdateTask(subTaskModel.TaskId);
                    return(StatusCode(StatusCodes.Status201Created));
                }
                else
                {
                    if (subTaskModel.TaskId == 0)
                    {
                        _logger.LogWarning("Subtask must have a parent task ID");
                        return(StatusCode(StatusCodes.Status206PartialContent));
                    }
                    else
                    {
                        _logger.LogWarning("Empty sub task Object passed as a parameter");
                    }

                    return(StatusCode(StatusCodes.Status204NoContent));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex));
            }
        }
Esempio n. 11
0
        public IActionResult EditSubTask(SubTask subTask)
        {
            var parentTask = tasksRepository.GetTask(subTask.TaskModelTaskID);

            if (ModelState.IsValid)
            {
                unitOfWork.Tasks.SaveSubTask(parentTask, subTask);
                unitOfWork.SaveChangesTaskContext();

                return(RedirectToAction("Edit", new { taskId = parentTask.TaskID }));
            }
            else
            {
                if (subTask.SubTaskID == 0)
                {
                    ViewBag.Title = "Create New Sub Task";
                }
                else
                {
                    SubTask currentSubTask = unitOfWork.Tasks.GetSubTask(subTask.SubTaskID);

                    ViewBag.Comments = currentSubTask.TaskComments;
                    ViewBag.Title    = "Edit Sub Task";
                }

                return(View(subTask));
            }
        }
Esempio n. 12
0
        public virtual JsonResult CreateTask(
            [DataSourceRequest] DataSourceRequest request,
            ProjectDetailsViewModel task)
        {
            var projectId = int.Parse(this.Session["ProjectId"].ToString());

            if (this.ModelState.IsValid)
            {
                var taskdb = new SubTask()
                {
                    ProjectId       = projectId,
                    Title           = task.Title,
                    ParentId        = task.ParentTaskId,
                    Start           = task.Start,
                    End             = task.End,
                    PercentComplete = 0,
                    Price           = 0,
                    IsUserNotified  = false
                };

                this.subTaskService.Add(taskdb);

                task.TaskId       = taskdb.Id;
                task.ParentTaskId = taskdb.ParentId;
            }

            return(this.Json(new[] { task }.ToDataSourceResult(request, this.ModelState)));
        }
        public IActionResult AddNewTask(TasksViewModel model)
        {
            ToDoTask task = new ToDoTask()
            {
                Id          = Db.TaskId,
                Title       = model.Title,
                Description = model.Description,
                Priority    = model.Priority,
                Status      = model.Status,
                TaskType    = model.TaskType,
            };

            Db.TaskId++;
            Db._tasksDb.Add(task);//Add task in Db._taskDb;

            SubTask subtask = new SubTask()
            {
                Id          = Db.SubTaskId,
                Title       = model.TitleSubTask,
                Description = model.DescriptionSubTask,
                Status      = model.StatusSubTask,
            };

            Db.SubTaskId++;
            task.SubTasks.Add(subtask);//Add subtask in SubTasks-List of task;

            User user = Db._usersDb.FirstOrDefault(x => x.Id == 3);

            user.CreatedTasks.Add(task);//Add task to login user - Megan Morton;

            return(View("_AddedTask"));
        }
        private IEnumerable <SubTask> GetSubTasks(DataLayer.Entities.Task task)
        {
            //you should always close your sqlConnection or put it into using statement so it will be disposed
            using (var sqlConnection = new SqlConnection(_connectionString))
            {
                sqlConnection.Open();//it will throw exception if connection is not opened
                var sqlCommand = new SqlCommand
                {
                    Connection  = sqlConnection,
                    CommandText = $"select * from dbo.SubTask where ParentTaskId={task.Id}"
                };
                var dataReader = sqlCommand.ExecuteReader();

                var result = new List <SubTask>();
                while (dataReader.Read())
                {
                    var subTask = new SubTask
                    {
                        Id          = (int)dataReader["Id"],
                        Description = (string)dataReader["Description"],
                        ParentTask  = task,
                        Status      = (DataLayer.Enums.Status)dataReader["Status"],
                        Title       = (string)dataReader["Title"]
                    };
                    result.Add(subTask);
                }
                return(result);
            }
        }
Esempio n. 15
0
 public void start()
 {
     try
     {
         channel = new TcpChannel();
         ChannelServices.RegisterChannel(channel, false);
         Console.WriteLine("Введите адрес сервера (tcp://localhost:8080/RemoteTask)");
         string addr = Console.ReadLine();
         server = (RemoteTask)Activator.GetObject(typeof(RemoteTask), addr);
         id     = server.joinToServer();
         while (true)
         {
             myTask = server.getTask(id);
             if (myTask != null)
             {
                 myTask.execute();
                 server.complete(id, myTask);
                 taskCount++;
                 Console.Clear();
                 Console.WriteLine("Выполнено задач: " + taskCount);
             }
             else
             {
                 Thread.Sleep(1000);
                 Console.Clear();
                 Console.WriteLine("Ожидаю задачу...");
             }
         }
     }
     catch (SystemException)
     {
         Console.WriteLine("Соединение было потеряно, завершение работы.\n"
                           + "Нажмите для продолжения...");
     }
 }
Esempio n. 16
0
        public void DeleteSubTask(int id)
        {
            SubTask subtask = entities.SubTask.Find(id);

            entities.SubTask.Remove(subtask);
            entities.SaveChanges();
        }
Esempio n. 17
0
        public ImplementTask FindITask(int tid)
        {
            string url     = baseURL + "FindITask";
            string param   = "tid=" + tid;
            string jsonStr = HttpRequest.HttpGet(url, param);

            if (jsonStr == "null" || string.IsNullOrEmpty(jsonStr))
            {
                return(null);
            }

            SubTask       itsk    = JsonConvert.DeserializeObject <SubTask>(jsonStr);
            ImplementTask subtask = new ImplementTask
            {
                ID               = itsk.ID,
                Warehouse        = itsk.Warehouse,
                DeviceCode       = itsk.DeviceCode,
                Type             = (EnmTaskType)itsk.Type,
                Status           = (EnmTaskStatus)itsk.Status,
                SendStatusDetail = (EnmTaskStatusDetail)itsk.SendStatusDetail,
                SendDtime        = DateTime.Parse(itsk.SendDtime),
                CreateDate       = DateTime.Parse(itsk.CreateDate),
                HallCode         = itsk.HallCode,
                FromLctAddress   = itsk.FromLctAddress,
                ToLctAddress     = itsk.ToLctAddress,
                ICCardCode       = itsk.ICCardCode,
                Distance         = itsk.Distance,
                CarSize          = itsk.CarSize,
                CarWeight        = itsk.CarWeight,
                IsComplete       = itsk.IsComplete,
                LocSize          = itsk.LocSize
            };

            return(subtask);
        }
Esempio n. 18
0
        public static ToDo MapToDo(ToDoDto toDoDto)
        {
            ToDo toDo = new ToDo()
            {
                Id              = toDoDto.Id,
                TaskName        = toDoDto.TaskName,
                TaskDescription = toDoDto.TaskDescription,
                IsCompleted     = (bool)toDoDto.IsCompleted,
                UserId          = toDoDto.UserId
            };

            List <SubTask> listOfSubTask = new List <SubTask>();

            foreach (SubTaskDto subTaskDto in toDoDto.SubTasks)
            {
                SubTask subTask = new SubTask()
                {
                    Id          = subTaskDto.Id,
                    SubTaskName = subTaskDto.SubTaskName,
                    IsCompleted = (bool)subTaskDto.IsCompleted,
                    ToDoId      = subTaskDto.ToDoId
                };
                listOfSubTask.Add(subTask);
            }
            toDo.SubTasks = listOfSubTask;

            return(toDo);
        }
Esempio n. 19
0
        public void EditIsUnderWork(int ID, bool Is)
        {
            SubTask subTask = unitOfWork.SubTasks.GetSubTaskIncludingProject(ID);

            subTask.IsUnderWork = Is;

            if (Is)
            {
                SubTaskSession opensubtaskSession = unitOfWork.SubTaskSessions.GetOpenSubTask(userManager.GetUserId(HttpContext.User));
                if (opensubtaskSession != null)
                {
                    CloseOpenSubTasksession(opensubtaskSession, opensubtaskSession.SubTask);
                    unitOfWork.SubTasks.Edit(opensubtaskSession.SubTask);
                }

                SubTaskSession subTaskSession = new SubTaskSession()
                {
                    FK_SubTaskID  = ID,
                    SessStartDate = DateTime.Now,
                    EmpId         = userManager.GetUserId(HttpContext.User)
                };
                subTaskSession = unitOfWork.SubTaskSessions.Add(subTaskSession);
            }
            else
            {
                SubTaskSession subTaskSession = unitOfWork.SubTaskSessions.GetLastSessBySubTaskID(ID);
                CloseOpenSubTasksession(subTaskSession, subTask);
            }
            subTask = unitOfWork.SubTasks.Edit(subTask);
        }
Esempio n. 20
0
        public SubTaskDTO GetSubTask(int id, int?taskId)
        {
            SubTask subtask = null;

            if (taskId == null)
            {
                subtask = Database.SubTasks.Get(id);
            }
            else
            {
                var subTasksFromTaskId = Database.SubTasks.GetAll(taskId.Value);

                if (subTasksFromTaskId != null)
                {
                    subtask = subTasksFromTaskId.FirstOrDefault(x => x.Id == id);
                }
            }
            if (subtask != null)
            {
                var result = subTaskFactory.CreateSubTask(subtask);
                return(result);
            }
            else
            {
                throw new ValidationException("SubTask not found", "");
            }
        }
        public async Task UpdateOptions(SubTask dbSubTask, ICollection <AnswerSubTaskOption> answerSubTaskOptions)
        {
            var newOptions = answerSubTaskOptions.Where(opt => opt.Id == 0);

            foreach (var newOption in newOptions)
            {
                dbSubTask.AnswerSubTaskOptions.Add(newOption);
                await _repository.SaveChanges();
            }

            var notNewOptions = answerSubTaskOptions.Where(opt => opt.Id != 0).ToList();

            foreach (var modelAnswerOption in notNewOptions)
            {
                var answerSubTask = dbSubTask.AnswerSubTaskOptions.FirstOrDefault(a => a.Id == modelAnswerOption.Id);
                if (answerSubTask != null)
                {
                    answerSubTask.Text      = modelAnswerOption.Text;
                    answerSubTask.IsCorrect = modelAnswerOption.IsCorrect;
                }
            }

            var optionIds = notNewOptions.Select(opt => opt.Id).ToList();

            if (optionIds.Any())
            {
                var toRemoveOptions = dbSubTask.AnswerSubTaskOptions.Where(opt => !optionIds.Contains(opt.Id)).ToList();
                for (int i = 0; i < toRemoveOptions.Count; i++)
                {
                    _repository.Remove(toRemoveOptions[i]);
                    await _repository.SaveChanges();
                }
            }
        }
Esempio n. 22
0
        public IActionResult EditSubTask(int subtaskId)
        {
            Team    team    = unitOfWork.Teams.GetTeamWithTeamLeaderId(userManager.GetUserId(HttpContext.User));
            SubTask subTask = unitOfWork.SubTasks.GetSubTaskWithEngineer(subtaskId);
            List <ApplicationUser> TeamMembers = unitOfWork.Engineers.GetEngineersInsideTeam(team.Id).ToList();

            TeamMembers.RemoveAll(e => e.UserName == HttpContext.User.Identity.Name);

            var subTaskVM = new SubTaskViewModel
            {
                SubTaskId   = subtaskId,
                Name        = subTask.Name,
                Description = subTask.Description,
                StartDate   = subTask.StartDate.Value.Date.ToShortDateString() ?? "",
                EndDate     = subTask.EndDate.Value.Date.ToShortDateString() ?? "",
                Assignee    = subTask.Engineer.Id,
                Status      = subTask.Status,
                Priority    = subTask.Priority,
                TeamMembers = TeamMembers
            };

            var index = subTaskVM.TeamMembers.FindIndex(x => x.Id == subTaskVM.Assignee.ToString());
            var item  = subTaskVM.TeamMembers[index];

            subTaskVM.TeamMembers[index] = subTaskVM.TeamMembers[0];
            subTaskVM.TeamMembers[0]     = item;

            //subTaskVM.TeamMembers.OrderBy(x => x.Id == subTask.FK_EngineerID).ToList();

            return(PartialView("_SubTaskModal", subTaskVM));
        }
Esempio n. 23
0
        public void EditProgress(int ID, int progress)
        {
            SubTask subTask = unitOfWork.SubTasks.GetSubTaskIncludingTask(ID);

            int subTaskLastProgress = subTask.Progress;

            //Shaker
            //Activity task = unitOfWork.Tasks.GetById(subTask.FK_TaskId);
            Activity task = subTask.Task;

            List <SubTask> subTasks             = unitOfWork.SubTasks.GetSubTasksByTaskId(subTask.FK_TaskId);
            int            totalSubTaskDuration = 0;

            foreach (var item in subTasks)
            {
                totalSubTaskDuration += (int)(item.EndDate - item.StartDate).Value.TotalDays;
            }

            int subtaskDuration = (int)(subTask.EndDate - subTask.StartDate).Value.TotalDays;

            task.Progress   += ((progress - subTaskLastProgress) * (subtaskDuration)) / (totalSubTaskDuration);
            task             = unitOfWork.Tasks.Edit(task);
            subTask.Progress = progress;
            subTask          = unitOfWork.SubTasks.Edit(subTask);
        }
Esempio n. 24
0
        public void CompleteSubTask(int subTaskID)
        {
            SubTask completedSubTask = GetSubTask(subTaskID);

            completedSubTask.Status      = "Closed";
            completedSubTask.IsCompleted = true;
        }
Esempio n. 25
0
        public void AddSubtask(SubTaskDto request)
        {
            var task = _taskRepository.GetAll().FirstOrDefault(x => x.Id == request.TaskId);

            if (task == null)
            {
                throw new TaskException("Task does not exist");
            }

            if (string.IsNullOrWhiteSpace(request.Title))
            {
                throw new TaskException("Title is required");
            }


            var subtask = new SubTask
            {
                Title           = request.Title,
                TaskDescription = request.TaskDescription,
                TodoId          = request.TaskId,
                IsCompleted     = false
            };

            _subTaskRepository.Insert(subtask);
        }
Esempio n. 26
0
        public void SaveSubTask(TaskModel task, SubTask subTask)
        {
            var parentTask = GetTask(task.TaskID);

            if (subTask.SubTaskID == 0)
            {
                subTask.Username   = GetLoggedInUser();
                subTask.ParentTask = parentTask.Name;

                parentTask.Subtasks.Add(subTask);
            }
            else
            {
                SubTask subTaskToSave = parentTask.Subtasks.First(s => s.SubTaskID == subTask.SubTaskID);
                if (subTaskToSave != null)
                {
                    subTaskToSave.Name         = subTask.Name;
                    subTaskToSave.Description  = subTask.Description;
                    subTaskToSave.Status       = subTask.Status;
                    subTaskToSave.TaskComments = subTask.TaskComments;
                    subTaskToSave.Username     = subTask.Username;

                    if (subTaskToSave.Status == "Closed")
                    {
                        subTaskToSave.IsCompleted = true;
                    }
                }
            }
        }
    private void _addSubTask(SubTask subTask)
    {
        // get prefab from objectpool
        GameObject subTaskGameObject = _pool.GetObject();

        // attach to subTaskGroup LayoutGroup
        subTaskGameObject.transform.SetParent(_subTaskGroup.transform);

        // Set parameters
        SubTaskItem subTaskItem = subTaskGameObject.GetComponent <SubTaskItem>();

        subTaskItem.SetId(subTask.Id);
        subTaskItem.SetText(subTask.Title + "[" + subTask.Id + "]");
        subTaskItem.SetBonus(subTask.IsBonus);
        subTaskItem.SetStatus(subTask.Status);
        subTaskItem.SetPrechecked(subTask.Status);

        // Set buttons and data (Help should always be avalible)
        subTaskItem.SetAvalibeButtons((subTask.Warning != null), (subTask.Tools != null), (subTask.Information != null), true);
        if (subTask.Tools != null)
        {
            subTaskItem.Tools = subTask.Tools;
        }
        if (subTask.Warning != null)
        {
            subTaskItem.Warning = subTask.Warning;
        }
        if (subTask.Information != null)
        {
            subTaskItem.Info = subTask.Information;
        }

        // Add to private list for removal later
        _subTaskList.Add(subTaskGameObject);
    }
        public virtual JsonResult CreateTask(
            [DataSourceRequest] DataSourceRequest request, 
            ProjectDetailsViewModel task)
        {
            var projectId = int.Parse(this.Session["ProjectId"].ToString());

            if (this.ModelState.IsValid)
            {
                var taskdb = new SubTask()
                                 {
                                     ProjectId = projectId, 
                                     Title = task.Title, 
                                     ParentId = task.ParentTaskId, 
                                     Start = task.Start, 
                                     End = task.End, 
                                     PercentComplete = 0, 
                                     Price = 0, 
                                     IsUserNotified = false
                                 };

                this.subTaskService.Add(taskdb);

                task.TaskId = taskdb.Id;
                task.ParentTaskId = taskdb.ParentId;
            }

            return this.Json(new[] { task }.ToDataSourceResult(request, this.ModelState));
        }
Esempio n. 29
0
        public ActionResult <Task> Edit([FromBody] FromAngularTask t)
        {
            var proj = this.projectService.GetById(t.project);
            var date = DateTime.UtcNow;

            var task = this.taskService.GetById(t.id);

            task.Name        = t.name;
            task.Priority    = t.priority;
            task.Status      = t.status;
            task.Type        = t.type;
            task.Description = t.description;
            task.EndDate     = t.endDate;

            task.HandledBy = new List <string>();
            foreach (var user in t.users)
            {
                if (user.Length > 0)
                {
                    var account = this.accountService.GetByProperty("username", user)[0];
                    if (account != null)
                    {
                        proj.Assignees.Add(account.Id);
                        proj.Assignees = proj.Assignees.Distinct().ToList();
                        account.AssignedProjects.Add(proj.Id);
                        account.AssignedProjects = account.AssignedProjects.Distinct().ToList();
                        task.HandledBy.Add(account.Id);
                        task.HandledBy = task.HandledBy.Distinct().ToList();
                        this.accountService.Update(account.Id, account);
                    }
                }
            }

            foreach (var subt in task.SubTasksIds)
            {
                this.subTaskService.Remove(subt);
            }

            task.SubTasksIds = new List <string>();
            foreach (var sub in t.subTasks)
            {
                if (sub.Description != null && sub.Description != string.Empty)
                {
                    var subtask = new SubTask();
                    subtask.Description    = sub.Description;
                    subtask.DateOfCreation = date;
                    subtask.ParentTaksId   = task.Id;
                    this.subTaskService.Create(subtask);
                    subtask = this.subTaskService.GetAll().Where(a => a.Description.Equals(sub) && a.DateOfCreation.Date.Equals(date.Date) && a.DateOfCreation.Hour.Equals(date.Hour) && a.DateOfCreation.Minute.Equals(date.Minute) && a.DateOfCreation.Second.Equals(date.Second)).FirstOrDefault();
                    task.SubTasksIds.Add(subtask.Id);
                }
            }

            proj.NumberOfAssignees = proj.Assignees.Count();
            this.projectService.Update(proj.Id, proj);
            this.taskService.Update(task.Id, task);

            return(this.taskService.GetById(task.Id));
        }
Esempio n. 30
0
        public static bool AddPlan(string p, long id)
        {
            try
            {
                if (TaskDictionary.GetInstance().find(0) == null)
                {
                    Model.Elements.Task task = new Model.Elements.Task();
                    task.name  = "DEFAULT";
                    task.id    = 0;
                    task.scale = 31;
                    TaskDictionary.GetInstance().Add(task);

                    STask st = new STask();
                    st.name  = "DEFAULT_STASK";
                    st.id    = 0;
                    st.order = 0;
                    STaskDictionary.GetInstance().Add(st);

                    SubTask subt = new SubTask();
                    subt.name  = p;
                    subt.id    = id;
                    subt.showT = DateTime.Now;
                    SubTaskDictionary.GetInstance().Add(subt);

                    EPlan plan = new EPlan();
                    plan.name  = p;
                    plan.id    = id;
                    plan.showT = DateTime.Now;
                    EPlanDictionary.GetInstance().Add(plan);

                    st.subtaskID.Add(subt.id);
                    task.staskID.Add(st.id);
                }
                else
                {
                    Model.Elements.Task task = TaskDictionary.GetInstance().find(0);

                    SubTask subt = new SubTask();
                    subt.name  = p;
                    subt.id    = id;
                    subt.showT = DateTime.Now;
                    SubTaskDictionary.GetInstance().Add(subt);

                    EPlan plan = new EPlan();
                    plan.name  = p;
                    plan.id    = id;
                    plan.showT = DateTime.Now;
                    EPlanDictionary.GetInstance().Add(plan);

                    STaskDictionary.GetInstance().find(0).subtaskID.Add(subt.id);
                }
                return(true);
            }
            catch (Exception ex)
            {
                Logger.WriteLogs("MainFormController/AddPlan Error: " + ex.Message);
                return(false);
            }
        }
Esempio n. 31
0
        public bool Delete(int id)
        {
            var subTask = new SubTask {
                Id = id
            };

            return(_subTaskService.Delete(subTask));
        }
        public void AddAttachments(
            SubTask dbtask, 
            List<HttpPostedFileBase> uploadedAttachments, 
            HttpServerUtility server)
        {
            if (uploadedAttachments == null)
            {
                return;
            }

            if (!Directory.Exists(server.MapPath(TasksConstants.MainContentFolder)))
            {
                Directory.CreateDirectory(server.MapPath(TasksConstants.MainContentFolder));
            }

            if (!Directory.Exists(server.MapPath(TasksConstants.MainContentFolder + "\\" + dbtask.ProjectId)))
            {
                Directory.CreateDirectory(server.MapPath(TasksConstants.MainContentFolder + "\\" + dbtask.ProjectId));
            }

            if (
                !Directory.Exists(
                    server.MapPath(TasksConstants.MainContentFolder + "\\" + dbtask.ProjectId + "\\" + dbtask.Id)))
            {
                Directory.CreateDirectory(
                    server.MapPath(TasksConstants.MainContentFolder + "\\" + dbtask.ProjectId + "\\" + dbtask.Id));
            }

            foreach (var file in uploadedAttachments)
            {
                var filename = Path.GetFileName(file.FileName);
                file.SaveAs(
                    server.MapPath(
                        TasksConstants.MainContentFolder + "\\" + dbtask.ProjectId + "\\" + dbtask.Id + "\\" + filename));
                this.Update(dbtask);
            }
        }
        public void UpdateProgress(SubTask task)
        {
            this.Update(task);

            while (true)
            {
                if (task.ParentId != null)
                {
                    task = this.GetById(task.ParentId.Value);
                    task.PercentComplete = task.Subtasks.Sum(x => x.PercentComplete) / task.Subtasks.Count;
                    this.Update(task);
                }
                else
                {
                    break;
                }
            }
        }
 public void Add(SubTask task)
 {
     this.tasks.Add(task);
     this.UpdateProjectDetails(task.Project);
 }
        public void Update(SubTask task)
        {
            var durationInDays = (task.End - task.Start).Days;
            task.Price = task.Users.Sum(user => (user.Salary / 20) * durationInDays);
            this.tasks.Update(task);

            this.UpdateProjectDetails(task.Project);
        }