public JsonResult AddProcessRun(int processid, string name, string des) { HttpStatusCode status = HttpStatusCode.OK; string message; object response; Process process = processService.findProcess(processid); Process processrun = processService.createProcessRun(process, name, des); List <Role> role = roleService.findListRoleOfProcess(processid); List <Role> rolerun = roleService.addRoleRun(role, processrun.Id); List <Step> liststep = stepService.findStepsOfProcess(processid); List <Step> liststeprun = stepService.addStepRun(liststep, processrun.Id); foreach (Step step in liststep) { List <TaskProcess> listtask = taskService.findTaskOfStep(step.Id); taskService.addListTaskRun(listtask, rolerun, liststeprun); } message = "Created ProcessRun Successfully"; response = new { message = message, status = status }; return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult Detail(int processid) { string idUser = User.Identity.GetUserId(); Process processrun = processService.findProcess(processid, true); if (processrun == null) { return(HttpNotFound()); } List <Role> listrole = roleService.findListRoleOfProcess(processid); Group group = groupService.findGroup(processrun.IdGroup); List <RoleRun> listroleruns = roleService.findlistrolerun(listrole); List <Step> listStep = stepService.findStepsOfProcess(processid); ProcessRun runprocess = processService.findProcessRunByProcessId(processrun.Id); ProcessRun ktra = db.ProcessRuns.Where(x => x.IdProcess == processrun.Id).FirstOrDefault(); List <StepRun> liststepofrunprocess = new List <StepRun>(); if (runprocess != null) { liststepofrunprocess = stepService.findStepsOfRunProcess(runprocess.Id); } List <Step> listnextstep1 = new List <Step>(); List <Step> listnextstep2 = new List <Step>(); Step start = listStep.Where(x => x.StartStep == true).FirstOrDefault(); if (start != null) { listnextstep1.Add(start); } int z = 0; int t = 0; for (int j = 0; j < listStep.Count; j++) { if (j < listnextstep1.Count()) { if (listnextstep1[j].NextStep1 == 0) { break; } do { if (z == listStep.Count) { z = 0; } if (listStep[z].Key == listnextstep1[j].NextStep2 && listStep[z].StartStep == false) { listnextstep2.Add(listStep[z]); if (listnextstep1[j].Figure == "Diamond") { } else { z = 0; break; } } if (listStep[z].Key == listnextstep1[j].NextStep1 && listStep[z].StartStep == false) { listnextstep1.Add(listStep[z]); if (listnextstep1[j].Figure == "Diamond") { } else { z = 0; break; } } z++; } while (z < listStep.Count); } } if (listnextstep2.Count() > 0) { for (int j = 0; j < listStep.Count; j++) { if (j < listnextstep2.Count()) { if (listnextstep2[j].NextStep1 == 0) { break; } do { if (listStep[t].Key == listnextstep2[j].NextStep1 && listStep[t].StartStep == false) { listnextstep2.Add(listStep[t]); t = 0; break; } t++; } while (t < listStep.Count); } } } List <Step> liststepgiong = new List <Step>(); for (int i = 0; i < listnextstep1.Count; i++) { for (int j = 0; j < listnextstep2.Count; j++) { if (listnextstep1[i].Key == listnextstep2[j].Key) { liststepgiong.Add(listnextstep2[j]); } } } for (int i = 0; i < listnextstep2.Count; i++) { if (liststepgiong.Count != 0 && listnextstep2.Count != 0) { for (int j = 0; j < liststepgiong.Count; j++) { if (listnextstep2[i].Key == liststepgiong[j].Key) { listnextstep2.Remove(listnextstep2[i]); } } } } //hàm xóa các phần tử giống nhau trong mảng //cho list 1 IEnumerable <Step> gionglist1 = listnextstep1.Distinct(); listnextstep1 = gionglist1.ToList(); // cho list 2 IEnumerable <Step> gionglist2 = listnextstep2.Distinct(); listnextstep2 = gionglist2.ToList(); foreach (Step item in listnextstep2) { listnextstep1.Add(item); } StepRun runnextstep = new StepRun(); foreach (StepRun steprun in liststepofrunprocess.Where(x => x.Status1.Name == "Running")) { runnextstep = steprun; } //get processrun file string processRunPath = string.Format("Upload/{0}/{1}", group.Id, processrun.Id); List <FileManager> files = fileService.findFiles(group.Id, processRunPath); ViewData["ListRole"] = listrole; ViewData["ProcessRun"] = processrun; ViewData["ListRoleRuns"] = listroleruns; ViewBag.ListRunStep = liststepofrunprocess.Where(x => x.Figure == "Step"); ViewBag.Checkprocessrun = ktra; ViewData["StepisNext"] = runnextstep; ViewData["UserRoles"] = participateService.getRoleOfMember(idUser, group.Id); //file ViewData["Files"] = files; return(View(listnextstep1)); }
public ActionResult Show(int processid) { string idUser = User.Identity.GetUserId(); Process process = processService.findProcess(processid); Group group = groupService.findGroup(process.IdGroup); List <Step> listStep = stepService.findStepsOfProcess(processid); List <Role> listRole = processService.findListRole(process.Id); //statics //dynamic expando = new ExpandoObject(); //var processStatisticModel = expando as IDictionary<string, object>; //processStatisticModel.Add("totalstep", listStep.Count); //processStatisticModel.Add("totalrole", listRole.Count); //tìm file group string processPath = string.Format("Upload/{0}/{1}", group.Id, process.Id); List <FileManager> files = fileService.findFiles(group.Id, processPath); List <Step> listnextstep1 = new List <Step>(); List <Step> listnextstep2 = new List <Step>(); Step start = listStep.Where(x => x.StartStep == true).FirstOrDefault(); if (start != null) { listnextstep1.Add(start); } int z = 0; int t = 0; for (int j = 0; j < listStep.Count; j++) { if (j < listnextstep1.Count()) { if (listnextstep1[j].NextStep1 == 0) { break; } do { if (z == listStep.Count) { z = 0; } if (listStep[z].Key == listnextstep1[j].NextStep2 && listStep[z].StartStep == false) { listnextstep2.Add(listStep[z]); if (listnextstep1[j].Figure == "Diamond") { } else { z = 0; break; } } if (listStep[z].Key == listnextstep1[j].NextStep1 && listStep[z].StartStep == false) { listnextstep1.Add(listStep[z]); if (listnextstep1[j].Figure == "Diamond") { } else { z = 0; break; } } z++; } while (z < listStep.Count); } } if (listnextstep2.Count() > 0) { for (int j = 0; j < listStep.Count; j++) { if (j < listnextstep2.Count()) { if (listnextstep2[j].NextStep1 == 0) { break; } do { if (listStep[t].Key == listnextstep2[j].NextStep1 && listStep[t].StartStep == false) { listnextstep2.Add(listStep[t]); t = 0; break; } t++; } while (t < listStep.Count); } } } List <Step> liststepgiong = new List <Step>(); for (int i = 0; i < listnextstep1.Count; i++) { for (int j = 0; j < listnextstep2.Count; j++) { if (listnextstep1[i].Key == listnextstep2[j].Key) { liststepgiong.Add(listnextstep2[j]); } } } for (int i = 0; i < listnextstep2.Count; i++) { if (liststepgiong.Count != 0 && listnextstep2.Count != 0) { for (int j = 0; j < liststepgiong.Count; j++) { if (listnextstep2[i].Key == liststepgiong[j].Key) { listnextstep2.Remove(listnextstep2[i]); } } } } //hàm xóa các phần tử giống nhau trong mảng //cho list 1 IEnumerable <Step> gionglist1 = listnextstep1.Distinct(); listnextstep1 = gionglist1.ToList(); // cho list 2 IEnumerable <Step> gionglist2 = listnextstep2.Distinct(); listnextstep2 = gionglist2.ToList(); foreach (Step item in listnextstep2) { listnextstep1.Add(item); } List <Step> liststepshow = listnextstep1.Where(x => x.Figure == "Step" && (x.IsRun == false || x.IsRun == null)).ToList(); ViewData["Group"] = group; ViewData["Process"] = process; ViewData["ListRole"] = listRole; //ViewData["Statistic"] = processStatisticModel; ViewData["UserRoles"] = participateService.getRoleOfMember(idUser, group.Id); ViewData["ListManager"] = participateService.findMembersInGroup(group.Id).Where(x => x.IsManager).ToList(); ViewData["Files"] = files; ViewData["listnextstep1"] = liststepshow; //get maximum file config ViewData["FileMaxSize"] = db.ConfigRules.Find("filesize"); return(View()); }