Ejemplo n.º 1
0
        public int Add(StartProcessInput <AddRecordInput> input)
        {
            NullableHelper.SetNull(input.Data);
            var variables = new Dictionary <string, object>();
            var userId    = _authInfoProvider.GetCurrent().User.Id;

            variables.Add("starter", userId.ToString());
            int processInstanceId = _runtimeProvider.StartProcessInstanceByName(
                input.ProcessDefinitionName,
                $"{input.ProcessDefinitionName}-{input.Data.RecordName}",
                variables);
            var tasks = _taskProvider.GetByProcessInstance(processInstanceId);

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

            record.ProcessInstanceId = processInstanceId;
            record.DataState         = DataState.Creating;
            record.Mid = null;
            _recordRepository.Add(record);
            var task = tasks[0];

            if (!input.PreventCommit)
            {
                _taskProvider.Complete(task.Id);
            }
            return(record.Id);
        }
Ejemplo n.º 2
0
        public int Add(StartProcessInput <AddProjectInput> input)
        {
            NullableHelper.SetNull(input.Data);
            var variables = new Dictionary <string, object>();
            var userId    = _authInfoProvider.GetCurrent().User.Id;

            variables.Add("starter", userId.ToString());
            int processInstanceId = _runtimeProvider.StartProcessInstanceByName(
                input.ProcessDefinitionName,
                $"{input.ProcessDefinitionName}-{input.Data.Name}",
                variables);
            var tasks = _taskProvider.GetByProcessInstance(processInstanceId);

            if (tasks.Count == 0)
            {
                throw new AppCoreException("任务未创建成功!");
            }
            var project = input.Data.MapTo <Project>();
            var count   = ProjectContext.Instance.GetProjectBaseInfoNoCount(() => _projectRepository.Count(u => u.CreateTime.Value.Year == DateTime.Now.Year && (u.DataState == DataState.Stable || u.DataState == DataState.Creating)));

            project.ProcessInstanceId = processInstanceId;
            project.DataState         = DataState.Creating;
            project.No  = $"{DateTime.Now.Year}{count.ToString("0000")}";
            project.Mid = null;
            _projectRepository.Add(project);
            var task = tasks[0];

            if (!input.PreventCommit)
            {
                _taskProvider.Complete(task.Id);
            }
            return(project.Id);
        }
Ejemplo n.º 3
0
        public int Add(StartProcessInput <AddConstructionUnitInput> input)
        {
            if (input.Data.Name == null)
            {
                throw new AppCoreException("单位名称不能为空");
            }
            var variables = new Dictionary <string, object>();
            var userId    = _authInfoProvider.GetCurrent().User.Id;

            variables.Add("starter", userId.ToString());
            int processInstanceId = _runtimeProvider.StartProcessInstanceByName(
                input.ProcessDefinitionName,
                $"{input.ProcessDefinitionName}-{input.Data.Name}",
                variables);
            var tasks = _taskProvider.GetByProcessInstance(processInstanceId);

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

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

            _taskProvider.Complete(task.Id);
            return(constructionUnit.Id);
        }
Ejemplo n.º 4
0
        public int Add(StartProcessInput <AddWeeklyProgressInput> input)
        {
            NullableHelper.SetNull(input.Data);
            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.AddDate}",
                variables);
            var tasks = _taskProvider.GetByProcessInstance(processInstanceId);

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

            if (progress.ProjectId == 0)
            {
                throw new AppCoreException("传入数据的ProjectId不能为空");
            }
            //if(_progressRepository.Count(u=>u.ProjectId == progress.ProjectId && u.Week == progress.Week && u.Year == progress.Year) > 0)
            //{
            //    throw new EntityException("Week", progress.Week, "PmWeeklyReport", "已存在");
            //}
            progress.ProcessInstanceId = processInstanceId;
            progress.DataState         = DataState.Creating;
            progress.Mid = null;
            _progressRepository.Add(progress);
            var task = tasks[0];

            if (!input.PreventCommit)
            {
                _taskProvider.Complete(task.Id);
            }
            return(progress.Id);
        }
Ejemplo n.º 5
0
        public int Add(StartProcessInput <AddContractPaymentInput> input)
        {
            if (input.Data.ContractId == 0)
            {
                throw new AppCoreException("合同id不能为0");
            }
            var variables = new Dictionary <string, object>();
            var userId    = _authInfoProvider.GetCurrent().User.Id;

            variables.Add("starter", userId.ToString());
            int processInstanceId = _runtimeProvider.StartProcessInstanceByName(
                input.ProcessDefinitionName,
                $"{input.ProcessDefinitionName}",//-{input.Data.Title}
                variables);
            var tasks = _taskProvider.GetByProcessInstance(processInstanceId);

            if (tasks.Count == 0)
            {
                throw new AppCoreException("任务未创建成功!");
            }

            var contractPayment = input.Data.MapTo <ContractPayment>();

            // var count = AppSampleContext.Instance.GetSupplierNoCount(() => _supplierRepository.Count(u => u.CreateTime.Value.Year == DateTime.Now.Year && (u.State == DataState.Stable || u.State == DataState.Creating)));
            contractPayment.ProcessInstanceId = processInstanceId;
            contractPayment.State             = DataState.Creating;
            // memorabiliaRecord.SupplierNo = $"{DateTime.Now.Year}{count.ToString("000000")}";
            var paymentNumberPrefix = $"CP{DateTime.Now.ToString("yyyyMMdd")}";
            var count = _contractPaymentRepository.Count(u => u.PaymentNumber.Contains(paymentNumberPrefix) && (u.State == DataState.Stable || u.State == DataState.Creating));

            contractPayment.PaymentNumber = $"{paymentNumberPrefix}{count.ToString("00")}";
            contractPayment.Mid           = null;
            _contractPaymentRepository.Add(contractPayment);
            var task = tasks[0];

            if (!input.PreventCommit)
            {
                _taskProvider.Complete(task.Id);
            }
            return(contractPayment.Id);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public int Add(StartProcessInput <AddEarlyStageInput> input)
        {
            if (input.Data.ReplyNumber == null)
            {
                throw new AppCoreException("批复文号不能为空");
            }
            var variables = new Dictionary <string, object>();
            var userId    = _authInfoProvider.GetCurrent().User.Id;

            variables.Add("starter", userId.ToString());
            int processInstanceId = _runtimeProvider.StartProcessInstanceByName(
                input.ProcessDefinitionName,
                $"{input.ProcessDefinitionName}-{input.Data.ReplyNumber}",
                variables);
            var tasks = _taskProvider.GetByProcessInstance(processInstanceId);

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

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

            if (!input.PreventCommit)
            {
                _taskProvider.Complete(task.Id);
            }
            return(earlyStage.Id);
        }