Exemplo n.º 1
0
 public void Comment(EditModel model)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 2
0
 public void Own(EditModel model, int currentStatus)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 3
0
 public void Refuse(EditModel model)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
 public void UpdateTaskProperty(EditModel model)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public void Assign(EditModel model)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public void Refuse(EditModel model)
 {
     Task task = session.Load<Task>(model.TaskItem.LiteItem.Id);
     task.RefuseAccept();
 }
Exemplo n.º 7
0
 public void Comment(EditModel model)
 {
     Task task = session.Load<Task>(model.TaskItem.LiteItem.Id);
     User current = session.Load<User>(model.CurrentUser.Id);
     if (model.AddresseeId.HasValue)
     {
         User addressee = session.Load<User>(model.AddresseeId);
         task.Comment(current, addressee, model.Comment);
     }
     else
     {
         task.AddHistory(current, model.Comment);
     }
 }
Exemplo n.º 8
0
        public void UpdateTaskProperty(EditModel model)
        {
            Task task = session.Load<Task>(model.TaskItem.LiteItem.Id);

            task.Project = session.Load<Project>(model.CurrentProject.TailSelectedProject.Id);
            setParent(task, model.TaskItem.Parent);
            if (model.TaskItem != null)
            {
                setAccepter(task, model.TaskItem.Accepter);
            }
            model.TaskItem.Fill(task);
            task.UpdateProperty();
        }
Exemplo n.º 9
0
        public void Accept(EditModel model)
        {
            Task task = session.Load<Task>(model.TaskItem.LiteItem.Id);

            task.Accept(model.TaskItem.Quality);
            if (model.AutoAcceptParent)
            {
                task.AutoAcceptAncestors();
            }
        }
Exemplo n.º 10
0
        public void Handle(EditModel model)
        {
            int currentStatus = model.SelectedQualifiedStatus.Stage;
            Task task = session.Load<Task>(model.TaskItem.LiteItem.Id);

            string comment = model.Comment;
            if (currentStatus == (int)Status.Own)
            {
                task.Own();
            }
            else if (currentStatus == (int)Status.BeginWork)
            {
                task.BeginWork();
            }
            else if (currentStatus == (int)Status.Pause)
            {
                task.Pause();
            }
            else if (currentStatus == (int)Status.Doubt)
            {
                task.Doubt();
            }
            else if (currentStatus == (int)Status.Complete)
            {
                task.Complete();
                if (model.AutoCompleteParent)
                {
                    task.AutoCompleteAncestors();
                }
            }
            else if (currentStatus == (int)Status.Quit)
            {
                task.Quit();
            }
            else if (currentStatus == (int)Status.Dissent)
            {
                task.Dissent();
            }
        }
Exemplo n.º 11
0
        public void Assign(EditModel model)
        {
            Task task = session.Load<Task>(model.TaskItem.LiteItem.Id);

            if (model.TaskItem.Owner.Id != null)
            {
                task.Owner = session.Load<User>(model.TaskItem.Owner.Id);
                task.Assign();
            }
            else
            {
                task.CancelAssign();
            }

        }
Exemplo n.º 12
0
        public EditModel GetEdit(int taskId, UserModel currentUser)
        {
            Task task = session.Load<Task>(taskId);

            EditModel model = new EditModel();
            model.FilledBy(task);

            model.CurrentUser = currentUser;
            model.QualifiedStatus = getQualifiedStatus(task.CurrentStatus, task);

            #region Depend on services and project id

            int projectId = task.Project.Id;
            int currentUserId = currentUser.Id.Value;

            model.CanOwn = _authService.GetTokens(currentUserId, projectId).Contains(Token.Owner);
            model.Owners = _userService.GetOwners(projectId);
            model.Accepters = _userService.GetAccepters(projectId);
            model.AllDifficulties = _projectConfigService.GetDifficulties(projectId);
            model.AllPriorities = _projectConfigService.GetPriorities(projectId);
            model.AllQualities = _projectConfigService.GetQualities(projectId);
            model.CurrentProject = _projectService.GetDropdownlistLink(currentUser.Id.Value, projectId);

            model.CanAutoCompleteParent = CanAutoComplete(taskId);
            model.CanAutoAccepterParent = CanAutoAccept(taskId);

            #endregion

            model.Attachments = new List<AttachmentModel>();
            foreach (Attachment attachment in task.Attachments)
            {
                AttachmentModel item = new AttachmentModel();
                item.FilledBy(attachment);
                model.Attachments.Add(item);
            }

            return model;
        }
Exemplo n.º 13
0
 private ActionResult redirectAfterEdit(EditModel model)
 {
     switch (model.Redirect)
     {
         case RedirectPage.Current:
             return RedirectToAction("Edit", new { taskId = model.TaskItem.LiteItem.Id });
         case RedirectPage.Previous:
             return RedirectToAction("Edit", new { taskId = model.PreviousTaskId });
         case RedirectPage.Next:
             return RedirectToAction("Edit", new { taskId = model.NextTaskId });
         case RedirectPage.Parent:
             return RedirectToAction("Edit", new { taskId = model.TaskItem.Parent.Id });
         case RedirectPage.Close:
             return Content("<script type=\"text/javascript\">window.open('','_self').close()</script>");
         //TODO:
         default: throw new Exception();
     }
 }
Exemplo n.º 14
0
        public ActionResult Edit(int taskId, EditModel model, IList<HttpPostedFileBase> file)
        {
            if (model.IdOrName == SearchBy.Name)
            {
                string strSelectedParentId = Request.Form["selectedParentTaskId"];
                if (!string.IsNullOrEmpty(strSelectedParentId))
                {
                    model.TaskItem.Parent.Id =
                        Convert.ToInt32(Request.Form["selectedParentTaskId"]);
                }
                //TODO: should use a specific viewmodel for parent task search
                ModelState.Remove("TaskItem.Parent.Id");
            }

            bool autoCompleteParent = model.AutoCompleteParent;

            ModelState.Remove("TaskItem.Parent.Title");
            //when only comment the taskItem should be null
            model.TaskItem = model.TaskItem ?? new FullItemModel();
            model.TaskItem.LiteItem = model.TaskItem.LiteItem ?? new LiteItemModel();
            model.TaskItem.LiteItem.Id = taskId;

            #region deal with task is virtual

            if (model.TaskItem.LiteItem.Virtual && model.TaskItem.ExpectedWorkPeriod.HasValue)
            {
                model = fillEditModel(taskId);
                ModelState.AddModelError("TaskItem.LiteItem.Virtual", "* 虚任务不能包含工时 ");
                return View(model);
            }

            #endregion

            #region deal with the attachments

            upload(file, taskId);

            #endregion

            #region deal with own

            if (model.Own)
            {
                model.TaskItem.Owner = userHelper.CurrentUser;
                _taskService.Assign(model);
                return redirectAfterEdit(model);
            }

            #endregion

            IList<TaskProcess> processess = getProcesses();

            #region deal with task process

            if (processess.Contains(TaskProcess.Publish))
            {
                if (model.TaskItem.Parent.Id.HasValue)
                {
                    if (string.IsNullOrEmpty(_taskService.GetTitle(model.TaskItem.Parent.Id.Value)))
                    {
                        ViewBag.ShowNotFound = true;
                        model = fillEditModel(taskId);
                        return View(model);
                    }
                    bool parentIsOffspring = _taskService.ParentIsOffspring(taskId, model.TaskItem.Parent.Id.Value);
                    if (parentIsOffspring ||
                        taskId == model.TaskItem.Parent.Id.Value)
                    {
                        ViewBag.ParentIsOwnOffspring = true;
                        model = fillEditModel(taskId);
                        return View(model);
                    }
                }
                if (!ModelState.IsValid)
                {
                    model = fillEditModel(taskId);
                    return View(model);
                }
                if (getPrivilegeInProject(model.CurrentProject.TailSelectedProject.Id) != PrivilegeInProject.HasPublish)
                {
                    //throw new NotImplementedException();
                }
                _taskService.UpdateTaskProperty(model);
            }
            if (processess.Contains(TaskProcess.Assign))
            {
                _taskService.Assign(model);
            }
            if (processess.Contains(TaskProcess.Remove))
            {
                _taskService.Remove(taskId, model.Comment);
                return redirectAfterEdit(model);
            }
            if (processess.Contains(TaskProcess.Resume))
            {
                _taskService.Resume(taskId, model.Comment);
            }
            if (processess.Contains(TaskProcess.InProcess))
            {
                _taskService.Handle(model);
            }
            if (processess.Contains(TaskProcess.Accept))
            {
                if (model.TaskItem.HasAccepted)
                {
                    _taskService.Accept(model);
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(model.Comment))
                    {
                        ModelState.AddModelError("Comment", "* 拒绝验收时必须说明原因");
                        model = fillEditModel(taskId);
                        return View(model);
                    }
                    _taskService.Refuse(model);
                }
            }

            #endregion

            #region deal with comments

            if (model.Comment.RealEmpty())
            {
                if (processess.IsNullOrEmpty())
                {
                    ModelState.Remove("TaskItem.Title");
                    ModelState.AddModelError("Comment", "* 没有其他改动时,留言不能为空");
                    model = fillEditModel(taskId);
                    return View(model);
                }
            }
            else
            {
                model.Comment = model.Comment.FixTags();
                model.CurrentUser = userHelper.CurrentUser;
                _taskService.Comment(model);
            }

            #endregion

            return redirectAfterEdit(model);
        }