Example #1
0
        public int Add(StartProcessInput <AddHousekeepingProblemInput> input)
        {
            if (input.Data.ProjectId == 0)
            {
                throw new AppCoreException("文明施工所在项目不能为0");
            }
            var variables = new Dictionary <string, object>();
            var userId    = _authInfoProvider.GetCurrent().User.Id;

            // var list = _projectRepository.Get().Where(u => u.Id == input.Data.ProjectId).SelectMany(u => u.Members).Where(u => u.ProjectRole == "文明施工负责人").Select(u => u.UserId).ToList();
            if (!_projectHelper.HasPermission("文明施工负责人", input.Data.ProjectId))//权限设置
            {
                throw new AppCoreException("文明施工发布没有权限");
            }
            variables.Add("starter", userId.ToString());
            int processInstanceId = _runtimeProvider.StartProcessInstanceByName(
                input.ProcessDefinitionName,
                $"{input.ProcessDefinitionName}-{input.Data.Content}",
                variables);
            var tasks = _taskProvider.GetByProcessInstance(processInstanceId);

            if (tasks.Count == 0)
            {
                throw new AppCoreException("任务未创建成功!");
            }
            var problem = input.Data.MapTo <HousekeepingProblem>();

            // var count = AppSampleContext.Instance.GetSupplierNoCount(() => _supplierRepository.Count(u => u.CreateTime.Value.Year == DateTime.Now.Year && (u.State == DataState.Stable || u.State == DataState.Creating)));
            problem.ProcessInstanceId = processInstanceId;
            problem.State             = DataState.Creating;
            // memorabiliaRecord.SupplierNo = $"{DateTime.Now.Year}{count.ToString("000000")}";
            problem.Mid = null;
            _problemRepository.Add(problem);
            var task = tasks[0];

            if (!input.PreventCommit)
            {
                _taskProvider.Complete(task.Id);
            }
            return(problem.Id);
        }
Example #2
0
        public int Add(StartProcessInput <AddQualityProblemInput> input)
        {
            if (input.Data.Source == null)
            {
                throw new AppCoreException("质量问题来源不能为空");
            }
            var variables = new Dictionary <string, object>();
            var userId    = _authInfoProvider.GetCurrent().User.Id;

            if (!_projectHelper.HasPermission("质量信息负责人", input.Data.ProjectId))//权限设置
            {
                throw new AppCoreException("质量问题发布没有权限");
            }
            variables.Add("starter", userId.ToString());
            int processInstanceId = _runtimeProvider.StartProcessInstanceByName(
                input.ProcessDefinitionName,
                $"{input.ProcessDefinitionName}-{input.Data.Source}",
                variables);
            var tasks = _taskProvider.GetByProcessInstance(processInstanceId);

            if (tasks.Count == 0)
            {
                throw new AppCoreException("任务未创建成功!");
            }
            var qualityProblem = input.Data.MapTo <QualityProblem>();

            // var count = AppSampleContext.Instance.GetSupplierNoCount(() => _supplierRepository.Count(u => u.CreateTime.Value.Year == DateTime.Now.Year && (u.State == DataState.Stable || u.State == DataState.Creating)));
            qualityProblem.ProcessInstanceId = processInstanceId;
            qualityProblem.State             = DataState.Creating;
            // memorabiliaRecord.SupplierNo = $"{DateTime.Now.Year}{count.ToString("000000")}";
            qualityProblem.Mid = null;
            _problemRepository.Add(qualityProblem);
            var task = tasks[0];

            if (!input.PreventCommit)
            {
                _taskProvider.Complete(task.Id);
            }
            return(qualityProblem.Id);
        }
Example #3
0
 public List <CurrentMemberPermission> GetCurrentPermission(List <int> projectIdList, string projectRole)
 {
     return(_projectHelper.HasPermission(projectRole, projectIdList));
 }