Esempio n. 1
0
        public JsonResult RunProcess(int idprocess)
        {
            HttpStatusCode status = HttpStatusCode.OK;
            string         message;
            object         response;
            Process        findprocess = processService.findProcess(idprocess);
            List <Step>    liststep    = stepService.findStepsOfProcess(idprocess);

            processService.addrunprocess(findprocess);
            StepRun            runstep        = stepService.addstartstep(idprocess);
            Step               idsteprunstart = liststep.Where(x => x.Key == runstep.Key && x.StartStep == true).FirstOrDefault();
            List <TaskProcess> listtaskrun    = taskService.findTaskOfStep(idsteprunstart.Id);

            taskService.addlistruntask(listtaskrun, runstep);
            message  = "Created ProcessRun Successfully";
            response = new { message = message, status = status };
            SetFlash(FlashType.success, "Create Run Process");
            return(Json(response, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        public StepRun completestepinrunprocess(int idrunprocess, List <Step> liststep)
        {
            Status  status  = db.Status.Where(y => y.Name == "Running").FirstOrDefault();
            StepRun steprun = new StepRun();

            foreach (Step step in liststep)
            {
                steprun.idProcess  = idrunprocess;
                steprun.Name       = step.Name;
                steprun.StartStep  = step.StartStep;
                steprun.NextStep1  = step.NextStep1;
                steprun.NextStep2  = step.NextStep2;
                steprun.Key        = step.Key;
                steprun.Figure     = step.Figure;
                steprun.Status     = status.Id;
                steprun.Created_At = DateTime.Now;
                steprun.Updated_At = DateTime.Now;
                db.StepRuns.Add(steprun);
                db.SaveChanges();
            }
            return(steprun);
        }
Esempio n. 3
0
        public StepRun addrunnextstep(int idrunprocess, Step step)
        {
            Status  status  = db.Status.Where(y => y.Name == "Running").FirstOrDefault();
            StepRun steprun = new StepRun();

            //foreach (var item in liststeprun)
            //{
            steprun.idProcess  = idrunprocess;
            steprun.Name       = step.Name;
            steprun.StartStep  = step.StartStep;
            steprun.NextStep1  = step.NextStep1;
            steprun.NextStep2  = step.NextStep2;
            steprun.Key        = step.Key;
            steprun.Figure     = step.Figure;
            steprun.Status     = status.Id;
            steprun.CloneFrom  = step.Id;
            steprun.Created_At = DateTime.Now;
            steprun.Updated_At = DateTime.Now;
            db.StepRuns.Add(steprun);
            db.SaveChanges();
            //}
            return(steprun);
        }
Esempio n. 4
0
        public void addlistruntask(List <TaskProcess> listtask, StepRun runstep)
        {
            Status status = db.Status.Where(y => y.Name == "Open").FirstOrDefault();

            foreach (TaskProcess task in listtask)
            {
                TaskProcessRun runtask = new TaskProcessRun();
                runtask.IdStep         = runstep.Id;
                runtask.IdRole         = task.IdRole;
                runtask.Name           = task.Name;
                runtask.Description    = task.Description;
                runtask.Status         = status.Id;
                runtask.ValueInputText = task.ValueInputText;
                runtask.ValueInputFile = task.ValueInputFile;
                runtask.ValueFormJson  = task.ValueFormJson;
                runtask.Color          = task.Color;
                runtask.Position       = task.Position;
                runtask.CloneForm      = task.Id;
                runtask.Created_At     = DateTime.Now;
                runtask.Updated_At     = DateTime.Now;
                db.TaskProcessRuns.Add(runtask);
                db.SaveChanges();
            }
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
 public void removeStepRun(StepRun step)
 {
     db.StepRuns.Remove(step);
     db.SaveChanges();
 }
Esempio n. 7
0
        public StepRun findsteprun(int idstep)
        {
            StepRun steprun = db.StepRuns.Find(idstep);

            return(steprun);
        }