Exemple #1
0
        public void Update(UpdateSafetyStandardInput input)
        {
            var existing = _standardRepository.Get().Include(u => u.Attachments).Where(u => u.Id == input.Id).FirstOrDefault();
            var standard = input.MapTo <SafetyStandard>();

            _standardRepository.Update(standard, existing, new System.Linq.Expressions.Expression <Func <SafetyStandard, object> >[] { }, false);
        }
Exemple #2
0
        public void Update(UpdateCalendarInput input)
        {
            //修改
            var existing = _calendarRepository.Get().Where(u => u.Id == input.Id).FirstOrDefault();
            var calendar = input.MapTo <Calendar>();

            _calendarRepository.Update(calendar, existing, new Expression <Func <Calendar, object> >[] { }, false);
        }
Exemple #3
0
        public void Update(UpdateProjectTaskInput input)
        {
            var projectId = _ganttRepository.Get().Where(u => u.Tasks.Any(v => v.Id == input.Id)).Select(u => u.ProjectId).FirstOrDefault();

            if (!_projectHelper.HasPermission("项目进度负责人", projectId))
            {
                throw new AppCoreException("项目进度没有权限");
            }
            var task     = input.MapTo <ProjectTask>();
            var existing = _projectTaskRepository.Get().Where(u => u.Id == task.Id).FirstOrDefault();
            int adjacentTaskId;
            var nextSibling = false;
            var targetId    = input.Target;

            _projectTaskRepository.Update(task, new System.Linq.Expressions.Expression <Func <ProjectTask, object> >[] { u => u.GanttId, u => u.SortNo }, false);
            if (!string.IsNullOrEmpty(targetId))
            {
                if (targetId.StartsWith("next:"))
                {
                    targetId    = targetId.Replace("next:", "");
                    nextSibling = true;
                }
                if (!int.TryParse(targetId, out adjacentTaskId))
                {
                    return;
                }
                var adjacentTask = _projectTaskRepository.Get().Where(u => u.Id == adjacentTaskId).Select(u => new ProjectTask {
                    Id = u.Id, SortNo = u.SortNo
                }).FirstOrDefault();
                var sortedOrder = adjacentTask.SortNo;
                if (nextSibling)
                {
                    sortedOrder++;
                }
                List <ProjectTask> updatedList = new List <ProjectTask>();
                updatedList.Add(new ProjectTask {
                    Id = task.Id, SortNo = sortedOrder
                });
                var otherUpdatedList = _projectTaskRepository.Get().Where(u => u.SortNo >= sortedOrder && u.Id != task.Id).Select(u => new ProjectTask {
                    Id = u.Id, SortNo = u.SortNo
                }).ToList();
                otherUpdatedList.ForEach(u => u.SortNo++);
                updatedList.AddRange(otherUpdatedList);
                _projectTaskRepository.BatchUpdate(updatedList, new System.Linq.Expressions.Expression <Func <ProjectTask, object> >[] { u => u.SortNo }, true);
            }
        }
Exemple #4
0
        public void Update(UpdateProjectLinkInput input)
        {
            var projectId = _ganttRepository.Get().Where(u => u.Links.Any(v => v.Id == input.Id)).Select(u => u.ProjectId).FirstOrDefault();

            if (_projectHelper.HasPermission("项目进度负责人", projectId))
            {
                throw new AppCoreException("项目进度没有权限");
            }
            var link = input.MapTo <ProjectLink>();

            _linkRepository.Update(link);
        }
Exemple #5
0
        public void Update(UpdateMonthlyPlanInput input)
        {
            var userId = _authInfoProvider.GetCurrent().User.Id;

            if (!_projectHelper.HasPermission("项目计划负责人", input.ProjectId))//权限设置
            {
                throw new AppCoreException("月计划修改没有权限");
            }
            var plan = input.MapTo <MonthlyPlan>();

            if (plan.RecordDate == null)
            {
                throw new AppCoreException("传入数据的RecordTime不能为空");
            }
            if (plan.ProjectId == 0)
            {
                throw new AppCoreException("传入数据的ProjectId不能为空");
            }
            if (_planRepository.Count(u => u.ProjectId == plan.ProjectId && u.RecordDate == plan.RecordDate && u.Id != plan.Id) > 0)
            {
                throw new EntityException("RecordDate", plan.RecordDate.ToString("y"), "InvestmentMonthlyPlan", "已存在");
            }
            _planRepository.Update(plan);
        }
Exemple #6
0
        /// <summary>
        /// 最后一个审批结束执行
        /// </summary>
        /// <param name="projectInstanceId"></param>
        public void CompleteApproval(int projectInstanceId)
        {
            var project = _problemRepository.Get().Include(u => u.ProblemPhotoSets).Where(u => u.ProcessInstanceId == projectInstanceId).FirstOrDefault();

            if (project == null)
            {
                throw new EntityException("ProjectInstanceId", projectInstanceId, "QualityProblem", "不存在");
            }
            if (project.State == DataState.Creating)
            {
                using (var transaction = _dbContextProvider.BeginTransaction())
                {
                    var temp = JsonConvert.DeserializeObject <QualityProblem>(JsonConvert.SerializeObject(project));
                    temp.State             = DataState.Stable;
                    temp.ProcessInstanceId = null;
                    _problemRepository.Update(temp, new System.Linq.Expressions.Expression <Func <QualityProblem, object> >[] {
                        u => u.State,
                        u => u.ProcessInstanceId
                    }, true);
                    temp       = JsonConvert.DeserializeObject <QualityProblem>(JsonConvert.SerializeObject(project));
                    temp.State = DataState.Created;
                    temp.Id    = 0;
                    temp.Mid   = project.Id;
                    //清空之前附件
                    temp.ProblemPhotoSets.ForEach(u =>
                    {
                        u.Id = 0;
                    });
                    _problemRepository.Add(temp);
                    transaction.Commit();
                }
                AppBaseContext.Instance.Produce("add-project-briefing", JsonConvert.SerializeObject(new
                {
                    TenantId  = _op.TenantId,
                    ProjectId = project.ProjectId
                }));
            }
            else if (project.Mid != null && project.State == DataState.Updating)
            {
                using (var transaction = _dbContextProvider.BeginTransaction())
                {
                    var temp = JsonConvert.DeserializeObject <QualityProblem>(JsonConvert.SerializeObject(project));
                    temp.State = DataState.Updated;
                    _problemRepository.Update(temp, new System.Linq.Expressions.Expression <Func <QualityProblem, object> >[] {
                        u => u.State
                    }, true);
                    temp     = JsonConvert.DeserializeObject <QualityProblem>(JsonConvert.SerializeObject(project));
                    temp.Id  = project.Mid.Value;
                    temp.Mid = null;
                    //清空之前附件
                    temp.ProblemPhotoSets.ForEach(u =>
                    {
                        u.Id = 0;
                    });
                    var existing = _problemRepository.Get().Include(u => u.ProblemPhotoSets).Where(u => u.Id == project.Mid).FirstOrDefault();
                    _problemRepository.Update(temp, existing, new System.Linq.Expressions.Expression <Func <QualityProblem, object> >[] {
                        u => u.ProcessInstanceId,
                        u => u.State,
                        u => u.CompletionTime,      // 整改完成时间
                        u => u.CompletionPhotoSets, // 整改完成图片
                        u => u.RectificationState,  //整改情况
                        u => u.Rectifications       // 整改进展
                    }, false);
                    transaction.Commit();
                }
                AppBaseContext.Instance.Produce("add-project-briefing", JsonConvert.SerializeObject(new
                {
                    TenantId  = _op.TenantId,
                    ProjectId = project.ProjectId
                }));
            }
            else
            {
                throw new AppCoreException("当前数据不再更新状态");
            }
        }
Exemple #7
0
        public void CompleteProcess(int processInstanceId)
        {
            var project = _projectRepository.Get()
                          .Include(u => u.Location)
                          .Include(u => u.Members)
                          .Include(u => u.Units).ThenInclude(u => u.Members)
                          .Include(u => u.Attachments)
                          .Where(u => u.ProcessInstanceId == processInstanceId).FirstOrDefault();

            if (project == null)
            {
                throw new EntityException("ProjectInstanceId", processInstanceId, "Project", "不存在");
            }
            if (project.DataState == DataState.Creating)
            {
                //project.State = DataState.Stable;
                //_projectBaseInfoRepository.Update(project, new System.Linq.Expressions.Expression<Func<ProjectBaseInfo, object>>[] {
                //    u => u.State
                //}, true);
                //using (var transaction = _dbContextProvider.BeginTransaction())
                //{

                var temp = JsonConvert.DeserializeObject <Project>(JsonConvert.SerializeObject(project));
                temp.DataState         = DataState.Stable;
                temp.ProcessInstanceId = null;
                _projectRepository.Update(temp, new System.Linq.Expressions.Expression <Func <Project, object> >[] {
                    u => u.DataState,
                    u => u.ProcessInstanceId
                }, true);

                temp = JsonConvert.DeserializeObject <Project>(JsonConvert.SerializeObject(project));
                temp.Attachments.ForEach(u => u.Id = 0);
                temp.Members.ForEach(u => u.Id     = 0);
                temp.Units.ForEach(u =>
                {
                    u.Id = 0;
                    u.Members.ForEach(v => v.Id = 0);
                });
                if (temp.Location != null)
                {
                    temp.Location.Id        = 0;
                    temp.Location.ProjectId = 0;
                }
                temp.DataState = DataState.Created;
                temp.Id        = 0;
                temp.Mid       = project.Id;
                _projectRepository.Add(temp);
                //    transaction.Commit();
                //}
            }
            else if (project.Mid != null && project.DataState == DataState.Updating)
            {
                using (var transaction = _dbContextProvider.BeginTransaction())
                {
                    var temp = JsonConvert.DeserializeObject <Project>(JsonConvert.SerializeObject(project));
                    temp.DataState = DataState.Updated;
                    _projectRepository.Update(temp, new System.Linq.Expressions.Expression <Func <Project, object> >[] {
                        u => u.DataState
                    }, true);
                    temp     = JsonConvert.DeserializeObject <Project>(JsonConvert.SerializeObject(project));
                    temp.Id  = project.Mid.Value;
                    temp.Mid = null;
                    temp.Attachments.ForEach(u => u.Id = 0);
                    temp.Members.ForEach(u => u.Id     = 0);
                    if (temp.Location != null)
                    {
                        temp.Location.Id = 0;
                    }
                    temp.Units.ForEach(u => {
                        u.Id = 0;
                        u.Members.ForEach(v => v.Id = 0);
                    });
                    var existing = _projectRepository.Get()
                                   .Include(u => u.Location)
                                   .Include(u => u.Members)
                                   .Include(u => u.Attachments)
                                   .Include(u => u.Units).ThenInclude(u => u.Members)
                                   .Where(u => u.Id == temp.Id).FirstOrDefault();
                    _projectRepository.Update(temp, existing, new System.Linq.Expressions.Expression <Func <Project, object> >[] {
                        u => u.ProcessInstanceId,
                        u => u.DataState,
                        u => u.No,
                        u => u.Units
                    }, false);
                    var addedUnits   = temp.Units.Except(existing.Units, u => u.Id).ToList();
                    var deletedUnits = existing.Units.Except(temp.Units, u => u.Id).ToList();
                    var updatedUnits = temp.Units.Intersect(existing.Units, u => u.Id).ToList();
                    foreach (var added in addedUnits)
                    {
                        _projectUnitRepository.Add(added);
                    }
                    foreach (var deleted in deletedUnits)
                    {
                        _projectUnitRepository.Delete(deleted);
                    }
                    foreach (var updated in updatedUnits)
                    {
                        var existed = existing.Units.Where(u => u.Id == updated.Id).FirstOrDefault();
                        _projectUnitRepository.Update(updated, existed, new Expression <Func <ProjectUnit, object> >[] { }, false);
                    }
                    transaction.Commit();
                }
            }
            else
            {
                throw new AppCoreException("当前数据不再更新状态");
            }
        }
Exemple #8
0
        public void CompleteProcess(int processInstanceId)
        {
            var progress = _progressRepository.Get().Include(u => u.Attachments).Where(u => u.ProcessInstanceId == processInstanceId).FirstOrDefault();

            if (progress == null)
            {
                throw new EntityException("WeeklyProgressInstanceId", processInstanceId, "WeeklyProgress", "不存在");
            }
            if (progress.DataState == DataState.Creating)
            {
                //progress.State = DataState.Stable;
                //_progressBaseInfoRepository.Update(progress, new System.Linq.Expressions.Expression<Func<WeeklyProgressBaseInfo, object>>[] {
                //    u => u.State
                //}, true);
                using (var transaction = _dbContextProvider.BeginTransaction())
                {
                    var temp = JsonConvert.DeserializeObject <WeeklyProgress>(JsonConvert.SerializeObject(progress));
                    temp.DataState         = DataState.Stable;
                    temp.ProcessInstanceId = null;
                    _progressRepository.Update(temp, new System.Linq.Expressions.Expression <Func <WeeklyProgress, object> >[] {
                        u => u.DataState,
                        u => u.ProcessInstanceId
                    }, true);
                    temp           = JsonConvert.DeserializeObject <WeeklyProgress>(JsonConvert.SerializeObject(progress));
                    temp.DataState = DataState.Created;
                    temp.Id        = 0;
                    temp.Mid       = progress.Id;
                    //清空之前附件
                    temp.Attachments.ForEach(u =>
                    {
                        u.Id = 0;
                    });
                    _progressRepository.Add(temp);
                    transaction.Commit();
                }

                AppBaseContext.Instance.Produce("add-project-briefing", JsonConvert.SerializeObject(new {
                    TenantId  = _op.TenantId,
                    ProjectId = progress.ProjectId
                }));
            }
            else if (progress.Mid != null && progress.DataState == DataState.Updating)
            {
                using (var transaction = _dbContextProvider.BeginTransaction())
                {
                    var temp = JsonConvert.DeserializeObject <WeeklyProgress>(JsonConvert.SerializeObject(progress));
                    temp.DataState = DataState.Updated;
                    _progressRepository.Update(temp, new System.Linq.Expressions.Expression <Func <WeeklyProgress, object> >[] {
                        u => u.DataState
                    }, true);
                    temp     = JsonConvert.DeserializeObject <WeeklyProgress>(JsonConvert.SerializeObject(progress));
                    temp.Id  = progress.Mid.Value;
                    temp.Mid = null;
                    //清空之前附件
                    temp.Attachments.ForEach(u =>
                    {
                        u.Id = 0;
                    });
                    var existing = _progressRepository.Get().Include(u => u.Attachments)
                                   .Where(u => u.Id == temp.Id).FirstOrDefault();
                    _progressRepository.Update(temp, existing, new System.Linq.Expressions.Expression <Func <WeeklyProgress, object> >[] {
                        u => u.ProcessInstanceId,
                        u => u.DataState,
                    }, false);
                    transaction.Commit();
                }
            }
            else
            {
                throw new AppCoreException("当前数据不再更新状态");
            }
        }
Exemple #9
0
        public void CompleteProcess(int processInstanceId)
        {
            var record = _recordRepository.Get()
                         .Include(u => u.Attachments)
                         .Where(u => u.ProcessInstanceId == processInstanceId).FirstOrDefault();

            if (record == null)
            {
                throw new EntityException("RecordInstanceId", processInstanceId, "Record", "不存在");
            }
            if (record.DataState == DataState.Creating)
            {
                //record.State = DataState.Stable;
                //_recordBaseInfoRepository.Update(record, new System.Linq.Expressions.Expression<Func<RecordBaseInfo, object>>[] {
                //    u => u.State
                //}, true);
                using (var transaction = _dbContextProvider.BeginTransaction())
                {
                    var temp = JsonConvert.DeserializeObject <Record>(JsonConvert.SerializeObject(record));
                    temp.DataState         = DataState.Stable;
                    temp.ProcessInstanceId = null;
                    _recordRepository.Update(temp, new System.Linq.Expressions.Expression <Func <Record, object> >[] {
                        u => u.DataState,
                        u => u.ProcessInstanceId
                    }, true);
                    temp = JsonConvert.DeserializeObject <Record>(JsonConvert.SerializeObject(record));
                    temp.Attachments.ForEach(u => u.Id = 0);
                    temp.DataState = DataState.Created;
                    temp.Id        = 0;
                    temp.Mid       = record.Id;
                    _recordRepository.Add(temp);
                    transaction.Commit();
                }
            }
            else if (record.Mid != null && record.DataState == DataState.Updating)
            {
                using (var transaction = _dbContextProvider.BeginTransaction())
                {
                    var temp = JsonConvert.DeserializeObject <Record>(JsonConvert.SerializeObject(record));
                    temp.DataState = DataState.Updated;
                    _recordRepository.Update(temp, new System.Linq.Expressions.Expression <Func <Record, object> >[] {
                        u => u.DataState
                    }, true);
                    temp    = JsonConvert.DeserializeObject <Record>(JsonConvert.SerializeObject(record));
                    temp.Id = record.Mid.Value;
                    temp.Attachments.ForEach(u => u.Id = 0);
                    temp.Mid = null;
                    var existing = _recordRepository.Get()
                                   .Include(u => u.Attachments)
                                   .Where(u => u.Id == temp.Id).FirstOrDefault();
                    _recordRepository.Update(temp, existing, new System.Linq.Expressions.Expression <Func <Record, object> >[] {
                        u => u.RecordTypeId,
                        u => u.RecordName,
                        u => u.Description,
                        u => u.Attachments
                    }, true);
                    transaction.Commit();
                }
            }
            else
            {
                throw new AppCoreException("当前数据不再更新状态");
            }
        }
Exemple #10
0
        /// <summary>
        /// 最后一个审批结束执行
        /// </summary>
        /// <param name="projectInstanceId"></param>
        public void CompleteApproval(int projectInstanceId)
        {
            var project = _earlyStageRepository.Get().Include(u => u.Attachments).Where(u => u.ProcessInstanceId == projectInstanceId).FirstOrDefault();

            if (project == null)
            {
                throw new EntityException("ProjectInstanceId", projectInstanceId, "EarlyStage", "不存在");
            }
            if (project.State == DataState.Creating)
            {
                using (var transaction = _dbContextProvider.BeginTransaction())
                {
                    var temp = JsonConvert.DeserializeObject <EarlyStage>(JsonConvert.SerializeObject(project));
                    temp.State             = DataState.Stable;
                    temp.ProcessInstanceId = null;
                    _earlyStageRepository.Update(temp, new System.Linq.Expressions.Expression <Func <EarlyStage, object> >[] {
                        u => u.State,
                        u => u.ProcessInstanceId
                    }, true);
                    temp       = JsonConvert.DeserializeObject <EarlyStage>(JsonConvert.SerializeObject(project));
                    temp.State = DataState.Created;
                    temp.Id    = 0;
                    temp.Mid   = project.Id;
                    //清空之前附件
                    temp.Attachments.ForEach(u =>
                    {
                        u.Id = 0;
                    });
                    _earlyStageRepository.Add(temp);
                    transaction.Commit();
                }
            }
            else if (project.Mid != null && project.State == DataState.Updating)
            {
                using (var transaction = _dbContextProvider.BeginTransaction())
                {
                    var temp = JsonConvert.DeserializeObject <EarlyStage>(JsonConvert.SerializeObject(project));
                    temp.State = DataState.Updated;
                    _earlyStageRepository.Update(temp, new System.Linq.Expressions.Expression <Func <EarlyStage, object> >[] {
                        u => u.State
                    }, true);
                    temp     = JsonConvert.DeserializeObject <EarlyStage>(JsonConvert.SerializeObject(project));
                    temp.Id  = project.Mid.Value;
                    temp.Mid = null;
                    //清空之前附件
                    temp.Attachments.ForEach(u =>
                    {
                        u.Id = 0;
                    });
                    var existing = _earlyStageRepository.Get().Include(u => u.Attachments).Where(u => u.Id == project.Mid).FirstOrDefault();
                    _earlyStageRepository.Update(temp, existing, new System.Linq.Expressions.Expression <Func <EarlyStage, object> >[] {
                        u => u.ProcessInstanceId,
                        u => u.State
                    }, false);
                    transaction.Commit();
                }
            }
            else
            {
                throw new AppCoreException("当前数据不再更新状态");
            }
        }
Exemple #11
0
        /// <summary>
        /// 最后一个审批结束执行
        /// </summary>
        /// <param name="projectInstanceId"></param>
        public void CompleteApproval(int projectInstanceId)
        {
            var project = _recordRepository.Get().Include(u => u.Attachments).Where(u => u.ProcessInstanceId == projectInstanceId).FirstOrDefault();

            if (project == null)
            {
                throw new EntityException("ProjectInstanceId", projectInstanceId, "MemorabiliaRecord", "不存在");
            }
            if (project.State == DataState.Creating)
            {
                //project.State = DataState.Stable;
                //_supplierRepository.Update(project, new System.Linq.Expressions.Expression<Func<Supplier, object>>[] {
                //    u => u.State
                //}, true);
                using (var transaction = _dbContextProvider.BeginTransaction())
                {
                    var temp = JsonConvert.DeserializeObject <MemorabiliaRecord>(JsonConvert.SerializeObject(project));
                    temp.State             = DataState.Stable;
                    temp.ProcessInstanceId = null;
                    _recordRepository.Update(temp, new System.Linq.Expressions.Expression <Func <MemorabiliaRecord, object> >[] {
                        u => u.State,
                        u => u.ProcessInstanceId
                    }, true);
                    temp       = JsonConvert.DeserializeObject <MemorabiliaRecord>(JsonConvert.SerializeObject(project));
                    temp.State = DataState.Created;
                    temp.Id    = 0;
                    temp.Mid   = project.Id;
                    //清空之前附件
                    temp.Attachments.ForEach(u =>
                    {
                        u.Id = 0;
                    });
                    _recordRepository.Add(temp);
                    transaction.Commit();
                }
                //foreach (var resposiblePersonId in project.ResposiblePersonIdList)
                //{
                //    _messagingProvider.CreateNotice(resposiblePersonId.ToString(), $"与您有关的项目【{project.Name}已经创建完成");
                //}
            }
            else if (project.Mid != null && project.State == DataState.Updating)
            {
                using (var transaction = _dbContextProvider.BeginTransaction())
                {
                    var temp = JsonConvert.DeserializeObject <MemorabiliaRecord>(JsonConvert.SerializeObject(project));
                    temp.State = DataState.Updated;
                    _recordRepository.Update(temp, new System.Linq.Expressions.Expression <Func <MemorabiliaRecord, object> >[] {
                        u => u.State
                    }, true);
                    temp     = JsonConvert.DeserializeObject <MemorabiliaRecord>(JsonConvert.SerializeObject(project));
                    temp.Id  = project.Mid.Value;
                    temp.Mid = null;
                    //清空之前附件
                    temp.Attachments.ForEach(u =>
                    {
                        u.Id = 0;
                    });
                    var existing = _recordRepository.Get().Include(u => u.Attachments).Where(u => u.Id == project.Mid).FirstOrDefault();
                    _recordRepository.Update(temp, existing, new System.Linq.Expressions.Expression <Func <MemorabiliaRecord, object> >[] {
                        u => u.ProcessInstanceId,
                        u => u.State
                    }, false);
                    transaction.Commit();
                }
                //foreach (var resposiblePersonId in project.ResposiblePersonIdList)
                //{
                //    _messagingProvider.CreateNotice(resposiblePersonId.ToString(), $"与您有关的项目【{project.Name}已经更新完成");
                //}
            }
            else
            {
                throw new AppCoreException("当前数据不再更新状态");
            }
        }