public JsonResult doCheck() { String uid = Convert.ToString(Session["uid"]); var taskid = Convert.ToInt32(Request["id"]); var time = Request["time"]; if (String.IsNullOrWhiteSpace(time)) { return(Fail("请填写时间")); } else { T_TaskDAO taskdao = new T_TaskDAO(); T_Task task = new T_Task() { id = taskid }; task = taskdao.GetByModel(task); task.statusId = 3; task.endTime = Convert.ToDateTime(time); task.beginTime = DateTime.Now; int taskresult = taskdao.Update(task); if (taskresult > 0) { T_UserDAO userdao = new T_UserDAO(); T_User user = new T_User() { id = uid }; user = userdao.GetByModel(user); T_Task_HistoryDAO historydao = new T_Task_HistoryDAO(); T_Task_History history = new T_Task_History() { taskId = taskid, userName = user.name, content = "接受任务", descr = uid }; int result = historydao.Add(history); if (result > 0) { return(Success("已通过!", null)); } else { return(Success("已通过,但未记录", null)); } } else { return(Fail("操作失败,请重试。")); } } }
//----------任务详情视图----------------------- public ActionResult Task() { String taskid = Request["id"]; String uid = Convert.ToString(Session["uid"]); String roleid = Convert.ToString(Session["roleid"]); if (String.IsNullOrWhiteSpace(taskid) || String.IsNullOrWhiteSpace(uid) || String.IsNullOrWhiteSpace(roleid)) { return(Fail("参数不足,请重试")); } //参数不足会返回错误信息 else { T_Task_HistoryDAO historydao = new T_Task_HistoryDAO(); T_Task_History history = new T_Task_History() { taskId = Convert.ToInt32(taskid) }; List <T_Task_History> hislist = historydao.GetAllByModel(history); ViewBag.list = hislist; T_Task_History title = historydao.GetByModel(history); ViewBag.uid = uid; T_TaskDAO taskdao = new T_TaskDAO(); T_Task task = new T_Task() { id = Convert.ToInt32(taskid) }; task = taskdao.GetByModel(task); Session["title"] = task.title; Session["tid"] = task.id; Session["roleid"] = roleid; ViewBag.content = task.content; ViewBag.createtime = task.createTime; ViewBag.begintime = task.beginTime; ViewBag.endtime = task.endTime; ViewBag.statusid = task.statusId; Session["statusid"] = ViewBag.statusid; ViewBag.status = task.statusIdEntity.descr; //根据任务编号返回跟任务相关的各种信息 T_Task_UserDAO tuserdao = new T_Task_UserDAO(); T_Task_User tuser = new T_Task_User() { taskId = Convert.ToInt32(Request["id"]) }; List <T_Task_User> tuserlist = tuserdao.GetAllByModel(tuser); ViewBag.tuser = tuserlist; return(View()); } }
//----------任务列表视图----------------------- public ActionResult List() { uid = Request["uid"]; if (String.IsNullOrWhiteSpace(Request["uid"])) { return(Fail("没有足够的参数")); } else { T_Task_HistoryDAO historydao = new T_Task_HistoryDAO(); T_Task_History history = new T_Task_History() { descr = uid }; List <T_Task_History> HistoryList = historydao.GetAllByModel(history); T_TaskDAO T_taskdao = new T_TaskDAO(); taskList = new List <T_Task>(); T_Task_StatusDAO statusdao = new T_Task_StatusDAO(); foreach (T_Task_History item in HistoryList) { T_Task task = new T_Task() { id = item.taskId }; T_Task t = T_taskdao.GetByModel(task); T_Task_Status status = new T_Task_Status() { id = t.statusId }; T_Task_Status s = statusdao.GetByModel(status); item.taskIdEntity.content = s.descr; } ViewBag.uid = uid; ViewBag.list = HistoryList; return(View()); } }
//-----提交任务进度------------- public JsonResult AddReport() { String uid = Convert.ToString(Session["uid"]); var title = Request["taskTitle"]; var content = Request["content"]; var des = Request["descr"]; var tid = Session["tid"]; if (!String.IsNullOrWhiteSpace(title) && !String.IsNullOrWhiteSpace(content) && !String.IsNullOrWhiteSpace(des)) { T_UserDAO T_UserDao = new T_UserDAO(); T_User user = new T_User() { id = uid }; user = T_UserDao.GetByModel(user); //user.name; String u = user.name; if (user == null) { return(Fail("用户验证失败,请重新登录")); } else { int i; T_TaskDAO T_TaskDao = new T_TaskDAO(); T_Task task = new T_Task() { title = title }; task = T_TaskDao.GetByModel(task);// task.id; String descr = "汇报任务"; T_Task_HistoryDAO T_Task_HistoryDao = new T_Task_HistoryDAO(); if (Convert.ToInt32(des) == 4) { //默认为汇报任务,当选择任务完成时,提交任务完成 descr = "任务完成"; T_Task_HistoryDAO finishdao = new T_Task_HistoryDAO(); T_Task_History finish = new T_Task_History() { taskId = Convert.ToInt32(tid), userName = user.name, content = "任务完成,等待验收", descr = descr, userId = uid, }; i = finishdao.Add(finish); T_TaskDAO Taskupdatedao = new T_TaskDAO(); T_Task takk = Taskupdatedao.GetById(Convert.ToInt32(tid)); takk.endTime = DateTime.Now; takk.statusId = 4; Taskupdatedao.Update(takk); return(Success("提交成功,等待验收", null)); } else { T_Task_History history = new T_Task_History(); //汇报完成同时生成一条历史记录 history.taskId = task.id; history.userName = user.name; history.content = Request["content"]; history.descr = descr; history.userId = uid; i = T_Task_HistoryDao.Add(history); }; if (i > 0) { return(Success("汇报成功!", null)); } else { return(Fail("添加失败,请重试。")); } } } else { return(Fail("提交失败,请填写完各项再提交。")); } }
public JsonResult doDistribute() { String uid = Convert.ToString(Session["uid"]); var title = Request["title"]; var userid = Request["userid"]; var name = Request["name"]; var content = Request["content"]; var starttime = Request["starttime"]; var endtime = Request["endtime"]; if (String.IsNullOrWhiteSpace(content) || String.IsNullOrWhiteSpace(name) || String.IsNullOrWhiteSpace(userid) || String.IsNullOrWhiteSpace(title)) { return(Fail("参数不完整,请填写完毕再提交。")); } else { T_TaskDAO taskdao = new T_TaskDAO(); T_Task task = new T_Task() { id = Convert.ToInt32(title) }; task = taskdao.GetByModel(task); task.beginTime = Convert.ToDateTime(starttime); task.endTime = Convert.ToDateTime(endtime); task.statusId = 3; if (taskdao.Update(task) > 0) { T_Task_UserDAO taskuserdao = new T_Task_UserDAO(); T_Task_User taskuser = new T_Task_User() { userId = userid, taskId = task.id, descr = content }; if (taskuserdao.Add(taskuser) > 0) { T_Task_HistoryDAO historydao = new T_Task_HistoryDAO(); T_Task_History history = new T_Task_History() { taskId = task.id, descr = "分配任务" }; history = historydao.GetByModel(history); if (history == null) { T_UserDAO userdao = new T_UserDAO(); T_User user = new T_User() { id = uid }; user = userdao.GetByModel(user); history = new T_Task_History() { taskId = task.id, userName = user.name, descr = "分配任务", content = "任务已分配。" }; if (historydao.Add(history) > 0) { return(Success("已成功分发任务给" + name, null)); } else { return(Fail("已分配,但未记录到任务历史中。")); } } else { return(Success("已成功分发任务给" + name, null)); } } else { return(Fail("任务还没成功分配给" + name)); } } else { return(Fail("任务还没成功分配给" + name)); } } }