public static PersonTask CreateTask(IDataReader reader) { var task = new PersonTask(); task.Id = reader.GetInt32(reader.GetOrdinal("taskId")); task.Statement = reader.GetString(reader.GetOrdinal("Statement")); task.Deadline = reader.GetDateTime(reader.GetOrdinal("Deadline")); task.IsInQa = reader.GetBoolean(reader.GetOrdinal("IsInQa")); task.EctsMark = reader["EctsMark"].ToString(); task.Comment = reader["Comment"].ToString(); task.Description = reader["Description"].ToString(); task.Assignee = CreatePerson(reader, ASSIGNEE); task.Author = CreatePerson(reader, AUTHOR); task.Subejct = CreateSubject(reader); task.Status = CreateStatus(reader); task.Type = CreateType(reader); int grade; if (int.TryParse(reader["Grade"].ToString(), out grade)) { task.Grade = grade; } return(task); }
private async Task <bool> AddTaskDailyAsync(PersonTask newTask) { var list = await context.PersonTaskDailys.Where(p => p.TaskId == newTask.ID).ToListAsync(); if (list.Count > 0) { context.PersonTaskDailys.RemoveRange(list);//增加前先全部删除 } //增加到任务日志。从开始时间到完成时间(预期完成时间),每一天都会生成一条记录,增加前先根据任务ID删除 DateTime endTime = newTask.predDeadTime.Date; if (newTask.complTime != null && newTask.complTime.Value.Year != 1900) { endTime = newTask.complTime.Value.Date; } TimeSpan timeSpan = endTime.Subtract(newTask.perdStartTime.Date); int totalDay = timeSpan.Days + 1; for (int i = 0; i < totalDay; i++) { PersonTaskDaily daily = new PersonTaskDaily() { TaskId = newTask.ID, DateLine = newTask.perdStartTime.Date.AddDays(i) }; context.PersonTaskDailys.Add(daily); } return(true);//下面方法一起提交,这里就不需要提交了,所以此方法用了private }
public JsonResult TestForFailStructure() { var personTask = new PersonTask().findPersonWithId(5); if (personTask.Status == ServiceResultStatus.Fail) { return(Json(personTask.Message, JsonRequestBehavior.AllowGet)); } var result = personTask.Data; return(Json(result, JsonRequestBehavior.AllowGet)); }
public JsonResult TestForSuccessStructure() { var personTask = new PersonTask().getAllPersonWithHelper(); if (personTask.Status == ServiceResultStatus.Fail) { return(Json(personTask.Message, JsonRequestBehavior.AllowGet)); } var result = personTask.Data; return(Json(result, JsonRequestBehavior.AllowGet)); }
public async Task <JsonResult> SaveTask(PersonTask task) { if (task.ID == "0" || string.IsNullOrEmpty(task.ID)) { task.ID = CommonHelper.GetRandomString("TK"); task.publishTime = DateTime.Now; } if (task.complTime == null || task.complTime.Value.Year == 1900) { task.complTime = Convert.ToDateTime("1900-01-01"); } var result = await pTaskRepo.AddOrUpdateAsync(task); return(Json(new { isOk = result })); }
public async Task <bool> AddOrUpdateAsync(PersonTask ptask) { try { var taskNew = await GetTaskAsync(ptask.ID); bool isNew = false; if (taskNew == null || string.IsNullOrEmpty(taskNew.ID)) { isNew = true; } foreach (var p in taskNew.GetType().GetProperties()) { //更新属性 var v = ptask.GetType().GetProperty(p.Name).GetValue(ptask); if (v != null) { //其他字段更新 p.SetValue(taskNew, v); } } if (isNew) { context.PersonTasks.Add(taskNew); } await AddTaskDailyAsync(taskNew); int res = await context.SaveChangesAsync(); return(res > 0); } catch { return(false); } }
public async Task <ActionResult> MyTaskPublishEdit(string taskId) { PersonTask task = await pTaskRepo.GetTaskAsync(taskId); if (task == null || string.IsNullOrEmpty(task.ID)) { task.perdStartTime = DateTime.Now; task.predDeadTime = DateTime.Now.AddDays(1); } //产品 var ItemList = new List <SelectListItem>(); var items = await itemsRepo.GetListItemsAsync(); var items2 = new SelectList(items, "ItemID", "NAME"); ItemList.AddRange(items2); ViewBag.ItemList = ItemList; //项目 var ProdList = new List <SelectListItem>(); var prods = await prodRepo.GetListAsync(); var prods2 = new SelectList(prods, "ProID", "NAME"); ProdList.AddRange(prods2); ViewBag.ProdList = ProdList; //任务类型 var TaskTypeList = new List <SelectListItem>(); var tasktypes = await codeRepo.GetTaskTypeListAsync(); var tasktypes2 = new SelectList(tasktypes, "ID", "NAME"); TaskTypeList.AddRange(tasktypes2); ViewBag.TaskTypeList = TaskTypeList; //任务状态 var TaskStatusList = new List <SelectListItem>(); var taskstatus = await codeRepo.GetTaskStatusListAsync(); var taskstatus2 = new SelectList(taskstatus, "id", "name"); TaskStatusList.AddRange(taskstatus2); ViewBag.TaskStatusList = TaskStatusList; //人员 var UserList = new List <SelectListItem>(); var userlist = await userRepo.GetUserListAsync(); var userlist2 = new SelectList(userlist, "Uid", "Name"); UserList.AddRange(userlist2); ViewBag.UserList = UserList; //完成程度 var TaskComplDegree = new List <SelectListItem>(); var taskDegree = await codeRepo.GetCodesListAsync(ECodesTypeId.taskComplDegree); var taskDegree2 = new SelectList(taskDegree, "Code", "Text"); TaskComplDegree.AddRange(taskDegree2); ViewBag.TaskComplDegreeV = TaskComplDegree; //服务态度 var ServiceAttri = new List <SelectListItem>(); var serAttri = await codeRepo.GetCodesListAsync(ECodesTypeId.serviceAttri); var serAttri2 = new SelectList(serAttri, "Code", "Text"); ServiceAttri.AddRange(serAttri2); ViewBag.ServiceAttriV = ServiceAttri; //完成速度 var ComplSpeed = new List <SelectListItem>(); var speed = await codeRepo.GetCodesListAsync(ECodesTypeId.complSpeed); var speed2 = new SelectList(speed, "Code", "Text"); ComplSpeed.AddRange(speed2); ViewBag.ComplSpeedV = ComplSpeed; //困难程度 var TaskDiffLevel = new List <SelectListItem>(); var diffLevel = await codeRepo.GetCodesListAsync(ECodesTypeId.taskDiffLevel); var diffLevel2 = new SelectList(diffLevel, "Code", "Text"); TaskDiffLevel.AddRange(diffLevel2); ViewBag.TaskDiffLevelV = TaskDiffLevel; if (string.IsNullOrEmpty(taskId) || taskId == "0") { var session = Session["CurrentUser"] as CurrentUser; task.publisherID = task.handlerID = task.followerID = session.Sys_User.Uid; task.perdStartTime = DateTime.Now; task.predDeadTime = DateTime.Now.AddDays(1); } else { if (task.complTime == null || task.complTime.Value.Year <= 1900) { task.complTime = null; } } return(View(task)); }
protected void btnSubmit_Click(object sender, EventArgs e) { Logic lo = new Logic(); Taskk t = new Taskk(); t.Title = tasktitle.Value; t.Description = taskdesc.Value; t.IsComplete = false; //DateTime.Parse(Calendar1.SelectedDate) if (tasktitle.Value.Length == 0 || taskdesc.Value.Length == 0) { Label lb = new Label(); lb.Text = "Empty Fields Are Not Allowed"; Panel1.CssClass = "divError"; icon.CssClass = "img"; icon.ImageUrl = "~/assets/icons/error3.png"; icon.Visible = true; PlaceHolder1.Controls.Add(lb); } else if (tasktitle.Value.Length != 0 && taskdesc.Value.Length != 0) { if (Calendar1.SelectedDate != null) { t.DateCreated = (DateTime)Calendar1.SelectedDate; bool resp1 = lo.CreateTask(t); int last = lo.GetLastTaskID(); PersonTask pt = new PersonTask(); string u = Session["username"].ToString(); Person pp = lo.GetPerson(u); pt.PersonId = pp.Id; //lo.GetPersonID("ay"); pt.TaskkId = last; bool resp2 = lo.CreatePersonTask(pt); if (resp1 == true && resp2 == true) { Label lb = new Label(); lb.Text = "New Task Added Successfully"; Panel1.CssClass = "divSuccess"; icon.CssClass = "img"; icon.ImageUrl = "~/assets/icons/success3.png"; icon.Visible = true; PlaceHolder1.Controls.Add(lb); } else if (resp1 != true || resp2 != true) { Label lb = new Label(); lb.Text = "New Task Could Not Be Added"; Panel1.CssClass = "divError"; icon.CssClass = "img"; icon.ImageUrl = "~/assets/icons/error3.png"; icon.Visible = true; PlaceHolder1.Controls.Add(lb); } } else if (Calendar1.SelectedDate == null) { Label lb = new Label(); lb.Text = "No Date Selected"; Panel1.CssClass = "divError"; icon.CssClass = "img"; icon.ImageUrl = "~/assets/icons/error3.png"; icon.Visible = true; PlaceHolder1.Controls.Add(lb); } } }
public Controller() { dbCon = new IntegrationTestSampleEntities(); personTask = new PersonTask(dbCon); messageTask = new PersonMessageTask(dbCon); }