public void removeprocessrun(int idprocess) { ProcessRun processrun = findProcessRunByProcessId(idprocess); if (processrun != null) { Process process = findProcess(processrun.Id); List <Role> listrole = roleService.findListRoleOfProcess(idprocess); List <RoleRun> listrolerun = roleService.findlistrolerun(listrole); List <StepRun> liststeprun = stepService.findStepsOfRunProcess(processrun.Id); foreach (StepRun steprun in liststeprun) { List <TaskProcessRun> listtaskrun = taskService.findruntaskofstep(steprun.Id); if (listtaskrun.Any()) { taskService.deletelisttaskrun(listtaskrun); } } if (liststeprun.Any()) { stepService.removelistStepRun(liststeprun); } if (listrolerun.Any()) { roleService.removelistRoleRun(listrolerun); } removeProcessRun(processrun); removeProcess(process); } }
/// <summary> /// Xóa một group /// </summary> /// <param name="group">Model Group</param> public void removeGroup(Group group) { List <Participate> listUser = participateService.findMembersInGroup(group.Id); //remove process List <Process> processes = processService.findListProcess(group.Id); foreach (Process pr in processes) { if (pr.IsRun) { ProcessRun prRun = processService.findProcessRun(pr.Id); processService.removeprocessrun(prRun.Id); } else { processService.removeProcess(pr.Id); } } //todo find file in group and remove files string groupPath = string.Format("Upload/{0}", group.Id); fileService.removeDirectory(groupPath); //remove user in group participateService.removeUsersInGroup(listUser); //remove tất cả các process của group processService.removeProcesses(group.Id); db.Groups.Remove(group); db.SaveChanges(); }
public StepRun addstartstep(int idprocess) { List <Step> step = findStepsOfProcess(idprocess); Status status = db.Status.Where(y => y.Name == "Running").FirstOrDefault(); ProcessRun idrun = db.ProcessRuns.Where(x => x.IdProcess == idprocess).FirstOrDefault(); StepRun steprun = new StepRun(); foreach (Step item in step.Where(x => x.StartStep == true)) { steprun.idProcess = idrun.Id; steprun.Name = item.Name; steprun.StartStep = item.StartStep; steprun.NextStep1 = item.NextStep1; steprun.NextStep2 = item.NextStep2; steprun.Key = item.Key; steprun.Figure = item.Figure; steprun.Status = status.Id; steprun.CloneFrom = item.Id; steprun.Created_At = DateTime.Now; steprun.Updated_At = DateTime.Now; db.StepRuns.Add(steprun); db.SaveChanges(); } return(steprun); }
public void removeProcessRun(ProcessRun processrun) { string processRunPath = string.Format("Upload/{0}/run/{1}", processrun.Process.IdGroup, processrun.Id); fileService.removeDirectory(processRunPath); db.ProcessRuns.Remove(processrun); db.SaveChanges(); }
public JsonResult AddNextStepInRunProcess(int idStep, int idnextstep, int idstepdiamond) { string IdUser = User.Identity.GetUserId(); HttpStatusCode status = HttpStatusCode.OK; string message; object response; Step stepchoosenext = stepService.findStep(idnextstep); Step idstepdk = stepService.findStep(idstepdiamond); StepRun runstep = stepService.findsteprun(idStep); stepService.changestatustep(runstep.Id, IdUser); ProcessRun processrun = processService.findProcessRun(runstep.idProcess); if (idstepdk != null) { stepService.addrunnextstep(processrun.Id, idstepdk); } //List<Step> liststep = stepService.findStepsOfProcess(processrun.IdProcess); List <TaskProcessRun> listruntask = taskService.findruntaskofstep(idStep); List <TaskProcessRun> listtaskclose = listruntask.Where(x => x.Status1.Name == "Finish").ToList(); //List<Step> nextstep = new List<Step>(); StepRun runnextstep = new StepRun(); //foreach (var item in liststep) //{ // if (runstep.NextStep1 == item.Key && item.StartStep == false) // { // nextstep.Add(item); // } //} if (stepchoosenext != null) { if (listtaskclose.Count == listruntask.Count) { runnextstep = stepService.addrunnextstep(processrun.Id, stepchoosenext); } } //foreach (var nexts in nextstep) //{ List <TaskProcess> listtasknextstep = taskService.findTaskOfStep(stepchoosenext.Id); taskService.addlistruntask(listtasknextstep, runnextstep); //} message = "Created ProcessRun Successfully"; response = new { message = message, status = status }; SetFlash(FlashType.success, "Next step success"); return(Json(response, JsonRequestBehavior.AllowGet)); }
public void addrunprocess(Process process) { Status status = db.Status.Where(y => y.Name == "Running").FirstOrDefault(); ProcessRun runpro = new ProcessRun(); runpro.IdProcess = process.Id; runpro.Name = process.Name; runpro.Status = status.Id; runpro.Description = process.Description; runpro.Start_At = DateTime.Now; runpro.Create_At = DateTime.Now; runpro.Update_At = DateTime.Now; db.ProcessRuns.Add(runpro); db.SaveChanges(); }
public void RunProcess(IRepository repository, IFTP ftp, ILogger logger) { try { Boolean runStatus = false; String localWorkingPathSubDir = String.Format("{0:yyyyMMddHmmss}", DateTime.Now); var process = repository.GetFirst <Process>(x => x.Name == "I02U"); var processRun = new ProcessRun { ProcessId = process.ProcessId, Start = DateTime.Now }; repository.Create <ProcessRun>(processRun); repository.Save(); logger.Log(repository, processRun.ProcessRunId, "Update Order Replenishment Process Start"); logger.Log(repository, processRun.ProcessRunId, "Fetching FTP file(s)"); if (GetFTPFiles(repository, logger, ftp, processRun.ProcessRunId, localWorkingPathSubDir) == true) { logger.Log(repository, processRun.ProcessRunId, "Loading FTP file(s) into SQL Server"); if (LoadFTPFilesIntoDB(repository, logger, processRun.ProcessRunId, localWorkingPathSubDir) == true) { logger.Log(repository, processRun.ProcessRunId, "Creating consolidated file"); if (CreateConsolidatedI02UFile(repository, logger, processRun.ProcessRunId) == true) { logger.Log(repository, processRun.ProcessRunId, "Update Order Replenishment Process completed successfully"); runStatus = true; } } } processRun.End = DateTime.Now; processRun.RunStatus = runStatus; repository.Update <ProcessRun>(processRun); repository.Save(); } catch (Exception e) { logger.Log(repository, 0, "RunProcess() failed", 3, e.Message); } }
public void RunProcess(IRepository repository, ILogger logger) { logTypes = repository.Get <LogType>(); var process = repository.GetFirst <Process>(x => x.Name == "I02"); var processRun = new ProcessRun { ProcessId = process.ProcessId, Start = DateTime.Now }; repository.Create <ProcessRun>(processRun); repository.Save(); logger.Log(repository, processRun.ProcessRunId, "Order Replenishment Process Start"); logger.Log(repository, processRun.ProcessRunId, "Fetching RVS File"); if (getRvsFile(repository, logger, processRun.ProcessRunId) == true) { splitFile(repository, logger, processRun.ProcessRunId); } }
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 ProcessRun findProcessRunByProcessId(int idProcess) { ProcessRun process = db.ProcessRuns.Where(x => x.IdProcess == idProcess).FirstOrDefault(); return(process); }
public ProcessRun findProcessRun(int idProcess) { ProcessRun process = db.ProcessRuns.Find(idProcess); return(process); }
private bool backgroundWorker_DoFullUpgrade(object sender, DoWorkEventArgs e, string host, string file) { BackgroundWorker bw = (BackgroundWorker)sender; try { LogWrite("Performing full upgrade."); string remote_file = host + "/" + file; string local_file = System.IO.Path.GetTempPath() + System.IO.Path.GetFileName(file); // remove file if exist if (System.IO.File.Exists(local_file)) { System.IO.File.Delete(local_file); } LogWrite("Downloading OptionsOracle installation file..."); WebDownload web = new WebDownload(bw); Exception ex = web.DownloadFile(remote_file, local_file); if (ex != null) { LogWrite("Download failed!"); e.Result = "Failed"; throw ex; } LogWrite("Download completed. Starting installation..."); // start installation process ProcessRun pro = new ProcessRun(); int exit_code = pro.RunProcess(local_file); if (exit_code == 0) { LogWrite("Full upgrade installation completed."); e.Result = "OK"; } else if (exit_code == 1602) { LogWrite("Full upgrade installation aborted!"); e.Result = "Failed"; } else { LogWrite("Full upgrade installation failed!"); e.Result = "Failed"; } } catch (Exception ex) { LogWrite("Full upgrade installation failed! (" + ex.Message + ");Full upgrade installation failed!"); e.Result = "Failed"; return(false); } return(true); }
public ActionResult MyTask(int groupid) { string idUser = User.Identity.GetUserId(); List <Process> listprocess = processService.findListProcess(groupid); //if (listprocess.Count == 0) return HttpNotFound(); //tìm role user trong group Participate userrole = participateService.getRoleOfMember(idUser, groupid); //tìm tất cả các role nào user đc phân trong processrun List <RoleRun> listrolerun = roleService.findlistrolerunbyiduser(idUser); List <Role> listrole = new List <Role>(); foreach (var rolerun in listrolerun) { Role role = roleService.findrolebyidrolerun(rolerun); listrole.Add(role); } //tìm tất cả các task user đc gán trong từng process // sau đó kiểm trả các task nào user đc gán bằng roleid trong list task trên // => tìm ra đc các task user đc gán có trong từng process List <ProcessRun> listprocessrun = new List <ProcessRun>(); List <object> jListProcessRun = new List <object>(); foreach (var process in listprocess) { ProcessRun processrun = processService.findProcessRunByProcessId(process.Id); if (processrun != null) { listprocessrun.Add(processrun); } } foreach (var processrun in listprocessrun) { List <StepRun> liststeprun = stepService.findStepsOfRunProcess(processrun.Id); //tạo Jprocessrun List <object> jlisttaskrunopen = new List <object>(); List <object> jlisttaskrundone = new List <object>(); //List<object> jlisttaskrunfinish = new List<object>(); foreach (var steprun in liststeprun) { List <TaskProcessRun> listtaskrun = taskService.findruntaskofstep(steprun.Id); if (listtaskrun.Any()) { foreach (var taskrun in listtaskrun) { object jTaskRun = new { id = taskrun.Id, name = taskrun.Name, description = taskrun.Description, rolename = taskrun.IdRole == null ? "Manager" : taskrun.Role.Name, status = taskrun.Status1.Name, valueform = taskrun.ValueFormJson }; if (userrole.IsManager) { if (taskrun.Status1.Name == "Open") { jlisttaskrunopen.Add(jTaskRun); } if (taskrun.Status1.Name == "Done") { jlisttaskrundone.Add(jTaskRun); } //if (taskrun.Status1.Name == "Finish") //{ // jlisttaskrunfinish.Add(jTaskRun); //} } else { foreach (var role in listrole) { if (taskrun.IdRole == role.Id) { if (taskrun.Status1.Name == "Open") { jlisttaskrunopen.Add(jTaskRun); } if (taskrun.Status1.Name == "Done") { jlisttaskrundone.Add(jTaskRun); } //if (taskrun.Status1.Name == "Finish") //{ // jlisttaskrunfinish.Add(jTaskRun); //} break; } } } } } } object jprocessrun = new { id = processrun.IdProcess, name = processrun.Name, status = processrun.Status1.Name, task = new { open = jlisttaskrunopen, done = jlisttaskrundone, //finish = jlisttaskrunfinish } }; jListProcessRun.Add(jprocessrun); } //khúc này nó sẽ return cái html về client //nên mình phải gán data vào view //var listprocesses = JArray.FromObject(jListProcessRun); ViewData["ListProcessRun"] = JArray.FromObject(jListProcessRun); return(View()); }