Beispiel #1
0
        public Process UpdateProcess(Process requestObj, ProcessViewModel request, Guid versionId)
        {
            int processVersion = requestObj.Version;

            List <Process> processes = repo.Find(null, x => x.VersionId == requestObj.VersionId)?.Items;

            if (processes != null)
            {
                foreach (Process process in processes)
                {
                    if (processVersion < process.Version)
                    {
                        processVersion = process.Version;
                        versionId      = process.VersionId;
                    }
                }
            }

            requestObj.Version   = processVersion + 1;
            requestObj.VersionId = versionId;
            requestObj.Name      = request.Name;
            requestObj.Id        = Guid.NewGuid();
            requestObj.Status    = "Published";

            return(repo.Add(requestObj));
        }
Beispiel #2
0
        public async Task <bool> Add(ProcessDto model)
        {
            var artProcess = _mapper.Map <Process>(model);

            _repoProcess.Add(artProcess);
            return(await _repoProcess.SaveAll());
        }
        public async Task <IActionResult> AddDepartment(int userId, DepartmentForCreationDto departmentForCreation)
        {
            var creator = await _userRepo.GetUser(userId);

            Console.WriteLine(int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value));

            if (creator.Id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var department = _mapper.Map <Department>(departmentForCreation);

            department.User = creator;

            _repo.Add(department);

            if (await _repo.SaveAll())
            {
                var jobToReturn = _mapper.Map <DepartmentForCreationDto>(department);
                return(CreatedAtRoute("GetDepartment", new { deptName = department.DeptName, userId = userId }, jobToReturn));
            }

            throw new Exception("Creation of Department failed on save");
        }
        public Process Create(string name, int version)
        {
            var process = new Process {
                Name    = name,
                Version = version
            };

            return(_processRepository.Add(process));
        }
Beispiel #5
0
        public void Start()
        {
            var process = _processRepository.Get(new CurrentProcessSpecification());

            if (process == null)
            {
                process = Process.NewDefaultSalaryPaymentProcess();
            }

            if (process.Status == Status.Created)
            {
                process.Start();
                _processRepository.Add(process);
                _unitOfWork.Commit();
            }
        }
Beispiel #6
0
        void IProcessService.Create(Process process, Guid assignedId)
        {
            process.SetId(assignedId);
            process.ChangeStatus(ProcessStatus.Running);
            //HACK:【重要】创建流程时预先设置调度标识以此作为按流程串行调度依据
            process.SetChargingBy(this._schedulerService.GetChargingBy(assignedId));
            _repository.Add(process);
            //创建流程启动请求
            this._schedulerService.Add(new ProcessStartResumption(process));

            this._log.InfoFormat("用户{0}发起类型为“{1}”的流程“{2}”#{3},参数:{4}"
                                 , process.Originator.UserName
                                 , process.ProcessType.Name
                                 , process.Title
                                 , process.ID
                                 , string.Join("$", process.GetDataFields().Select(o => o.Key + "=" + o.Value)));
        }
        public async Task <IActionResult> AddStep(int userId, StepForCreationDto stepForCreation)
        {
            var creator = await _userRepo.GetUser(userId);

            if (creator.Id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var step = _mapper.Map <Step>(stepForCreation);

            step.User = creator;

            _repo.Add(step);

            if (await _repo.SaveAll())
            {
                var jobToReturn = _mapper.Map <StepForCreationDto>(step);
                return(CreatedAtRoute("GetStep", new { stepNumber = step.StepNumber, deptName = step.deptName, objectiveName = step.objectiveName, userId = userId }, jobToReturn));
            }

            throw new Exception("Creation of Step failed on save");
        }
Beispiel #8
0
        public async Task <IActionResult> AddCommonDifficulty(int userId, CommonDifficultyForCreationDto commonDifficultyForCreation)
        {
            var creator = await _userRepo.GetUser(userId);

            if (creator.Id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var commonDifficulty = _mapper.Map <CommonDifficulty>(commonDifficultyForCreation);

            commonDifficulty.User = creator;

            _repo.Add(commonDifficulty);

            if (await _repo.SaveAll())
            {
                var jobToReturn = _mapper.Map <CommonDifficultyForReturnDto>(commonDifficulty);
                return(CreatedAtRoute("GetCommonDifficulty", new { id = commonDifficulty.Id, userId = userId }, jobToReturn));
            }

            throw new Exception("Creation of Common difficulty failed on save");
        }
        public async Task <IActionResult> AddObjective(int userId, ObjectiveForCreationDto objectiveForCreation)
        {
            var creator = await _userRepo.GetUser(userId);

            if (creator.Id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var objective = _mapper.Map <Objective>(objectiveForCreation);

            objective.User = creator;

            _repo.Add(objective);

            if (await _repo.SaveAll())
            {
                var jobToReturn = _mapper.Map <ObjectiveForCreationDto>(objective);
                return(CreatedAtRoute("GetObjective", new { objectiveName = objective.ObjectiveName, deptName = objective.deptName, userId = userId }, jobToReturn));
            }

            throw new Exception("Creation of Objective failed on save");
        }
        public async Task <IActionResult> AddBestPractice(int userId, BestPracticeForCreationDto bestPracticeForCreation)
        {
            var creator = await _userRepo.GetUser(userId);

            if (creator.Id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var bestPractice = _mapper.Map <BestPractice>(bestPracticeForCreation);

            bestPractice.User = creator;

            _repo.Add(bestPractice);

            if (await _repo.SaveAll())
            {
                var jobToReturn = _mapper.Map <BestPracticeForReturnDto>(bestPractice);
                return(CreatedAtRoute("GetBestPractice", new { id = bestPractice.Id, userId = userId }, jobToReturn));
            }

            throw new Exception("Creation of Best practice failed on save");
        }
 public async Task <IActionResult> Add(ModelProcessDto modelProcessDto)
 {
     return(Ok(await _processRepository.Add(modelProcessDto)));
 }