Example #1
0
 /// <summary>
 /// 新增一条任务 
 /// </summary>
 /// <param name="taskStr"></param>
 public string AddTask(string taskStr)
 {
     Task task = new Task();
     TempTask ttask = (TempTask)JsonConvert.DeserializeObject(taskStr, typeof(TempTask));
     //下面是两行很有水准的枚举类型强制转换
     task.TaskType = (EnumTaskType)Enum.Parse(typeof(EnumTaskType), ttask.TaskType.ToString());
     task.TaskCategory = (EnumTaskCategory)Enum.Parse(typeof(EnumTaskCategory), ttask.TaskCategory);
     task.Week = ttask.Week;
     task.Month = Int32.Parse(ttask.Month);
     task.QualityFactor = 0;
     task.ScheduledStartTime = ttask.ScheduledStartTime;
     task.ScheduledFinishTime = ttask.ScheduledFinishTime;
     task.ScheduledBonus = ttask.ScheduledBonus;
     task.TaskFinishStandard = ttask.TaskFinishStandard;
     task.TaskContent = ttask.TaskContent;
     task.TaskTitle = ttask.TaskTitle;
     task.CheckerName = ttask.CheckerName;
     task.SecondLevelTitle = ttask.SecondLevelTitle;
     task.ProjectID = ttask.ProjectID;
     task.TaskerID = ttask.TaskerNameId;
     task.CheckerID = ttask.CheckerNameId;
     task.Memo = ttask.Memo;
     TaskService ts = new TaskService();
     ts.New(task);
     return "success";
 }