//update timer public JsonResult json_updateTaskProgress() { var pars = Request.Params; int task_id = Convert.ToInt32(pars["task_id"]); var curUser = Session["user"]; int person_id = Convert.ToInt32(((Themes.Models.user)curUser).person_id); int task_person_id = this.getCurTaskPerson(task_id, person_id).First().task_person_id; using (Themes.Models.prjEntities ctx = new Themes.Models.prjEntities()) { var cur_task_person = ( from tp in ctx.task_person where tp.task_person_id == task_person_id select tp ).First(); /* First check if there is any open timer then update end_timestamp else create new with open end_timestamp */ var q = ( from tpt in ctx.tp_timer where tpt.task_person.task_person_id == task_person_id && tpt.task_person.user_task_status_id != 3 &&/*Not Finalized*/ tpt.end_stamp == null /*open timer*/ select tpt ); if (q.Count() != 0) { q.First().end_stamp = DateTime.Now; q.First().is_commited = true; q.First().task_person.user_task_status_id = 2 /*Progressing*/; ctx.SaveChanges(); } else { var newTimer = new Themes.Models.tp_timer() { t_p_id = task_person_id, start_stamp = DateTime.Now, end_stamp = null, is_commited = false }; ctx.tp_timer.AddObject(newTimer); ctx.SaveChanges(); } } //return back current timer status after operation return(Json(new { result = this.getTaskPersontimerStat(task_id, person_id) }, JsonRequestBehavior.AllowGet)); }
public JsonResult json_saveNewTask() { var pars = Request.Params; string task_title = pars["Task_title"]; string task_description = pars["Task_description"]; string task_deadline = pars["task_deadline"]; string filenames = pars["filenames"]; using (Themes.Models.prjEntities ctx = new Themes.Models.prjEntities()) { Themes.Models.task newTask = new Themes.Models.task() { title = task_title, description = task_description, task_status_id = 2,/*Progressing*/ stamp = DateTime.Now, is_active = true }; ctx.task.AddObject(newTask); ctx.SaveChanges(); } //(2) add document objects for Task return(Json(new { result = "done" }, JsonRequestBehavior.AllowGet)); }
//Adds new descriptive content for specific task person public JsonResult json_saveNewTaskStat() { var pars = Request.Params; int task_id = Convert.ToInt32(pars["task_id"]); string description = pars["description"]; var curUser = Session["user"]; int person_id = Convert.ToInt32(((Themes.Models.user)curUser).person_id); int task_person_id = this.getCurTaskPerson(task_id, person_id).First().task_person_id; using (Themes.Models.prjEntities ctx = new Themes.Models.prjEntities()) { var newTaskProgress = new Themes.Models.tp_progress() { t_p_id = task_person_id, description = description, datetime = DateTime.Now }; ctx.tp_progress.AddObject(newTaskProgress); ctx.SaveChanges(); } return(Json(new { result = "done" }, JsonRequestBehavior.AllowGet)); }
public JsonResult json_saveUserSequence() { var pars = Request.Params; int task_id = Convert.ToInt32(pars["task_id"]); string[] person_ids = pars["taskUsersSequence"].Split(','); using (Themes.Models.prjEntities ctx = new Themes.Models.prjEntities()) { foreach (var item in person_ids) { Themes.Models.task_person tp = new Themes.Models.task_person() { task_id = task_id, person_id = Convert.ToInt32(item), user_task_status_id = 1 /*Not Started*/ }; ctx.task_person.AddObject(tp); ctx.SaveChanges(); } } return(Json(new { result = "done" }, JsonRequestBehavior.AllowGet)); }
//if tjhere is any open timer close it . and finalu task_person obect goes to finalize stat public JsonResult json_finalizeTaskPerson() { var pars = Request.Params; int task_id = Convert.ToInt32(pars["task_id"]); var curUser = Session["user"]; int person_id = Convert.ToInt32(((Themes.Models.user)curUser).person_id); using (Themes.Models.prjEntities ctx = new Themes.Models.prjEntities()) { var cur_task_person = ( from tp in ctx.task_person where tp.task_id == task_id && tp.user_task_status_id != 3 /*NOT (finalized)*/ orderby tp.task_person_id ascending select tp ).First(); if (this.getTaskPersontimerStat(task_id, person_id) == "pause") //timer open { //close timer var open_time_task_person = ( from tpt in ctx.tp_timer where tpt.task_person.task_person_id == cur_task_person.task_person_id && tpt.task_person.user_task_status_id == 2 && /*Progressing*/ tpt.end_stamp == null /*open timer*/ select tpt ).First(); open_time_task_person.end_stamp = DateTime.Now; } //finally finalize task person cur_task_person.user_task_status_id = 3; ctx.SaveChanges(); } return(Json(new { result = "done" }, JsonRequestBehavior.AllowGet)); }