Exemple #1
0
        public ResultEntity <int> StartProjectPhase(int ProjectId)
        {
            ResultEntity <int> result;

            try
            {
                var dt     = DateTime.Now;
                int IntRet = 1;

                var project = new ProjectBLL().GetDataById(ProjectId);
                var list    = new TemplatePhaseBLL().GetTemplatePhaseListByTemplateId(project.TemplateId);

                if (list.Count > 0)  //添加项目下一阶段
                {
                    var firstTemplatPhase = list[0];
                    var repResult         = InsertProjectPhase(new ProjectPhase
                    {
                        ProjectId       = ProjectId,
                        TemplatePhaseId = firstTemplatPhase.Id,
                        StartTime       = dt,
                        Status          = 1,
                        CreateBy        = "",
                        CreateTime      = dt
                    });

                    new ProjectBLL().UpdatePhaseStatus(ProjectId, 1, firstTemplatPhase.Name);
                }


                if (IntRet > 0)
                {
                    result = new ResultEntity <int>(true, ConstantDefine.TipSaveSuccess, IntRet);
                }
                else
                {
                    result = new ResultEntity <int>(ConstantDefine.TipSaveFail);
                }
            }
            catch (Exception ex)
            {
                Loger.LogErr(ex);
                result = new ResultEntity <int>(ex.Message);
            }

            return(result);
        }
Exemple #2
0
        public ResultEntity <int> CompletePhase(int PhaseId, int Status)
        {
            ResultEntity <int> result;

            try
            {
                var dt = DateTime.Now;

                //下一阶段
                var projectPhase = dal.GetDataById <ProjectPhase>(PhaseId);
                //对当前是否满足完成条件进行判断
                var templatePhaseId = projectPhase.TemplatePhaseId;

                /* 验证必要内容必要的是否全部上传
                 * //var attachmentList = new ProjectAttachmentBLL().GetView_ProjectAttachmentByPhaseId(PhaseId, templatePhaseId);
                 *
                 * //var ok = true;
                 * //ok = !attachmentList.Exists(x => x.TemplateMustContentId.HasValue && x.TemplateMustContentId != 0 && x.IsMust == 1 && x.Id == 0); //必要内容都已经上传
                 *
                 * //if(!ok)
                 * //{
                 * //    result = new ResultEntity<int>("必要内容未全部上传,不能完成阶段");
                 * //    return result;
                 * //}
                 */

                int IntRet    = 0;
                var repResult = dal.Update <ProjectPhase>(new { EndTime = dt, Status = Status }, it => it.Id == PhaseId);

                var templatePhase = new TemplatePhaseBLL().GetDataById(projectPhase.TemplatePhaseId);
                var list          = new TemplatePhaseBLL().GetTemplatePhaseListByTemplateId(templatePhase.TemplateId);
                int index         = list.FindIndex(x => x.Id == projectPhase.TemplatePhaseId);

                if (index < list.Count - 1)  //添加项目下一阶段
                {
                    var nextTemplatPhase = list[index + 1];
                    InsertProjectPhase(new ProjectPhase {
                        ProjectId       = projectPhase.ProjectId,
                        TemplatePhaseId = nextTemplatPhase.Id,
                        StartTime       = DateTime.Now,
                        Status          = 1,
                        CreateBy        = "",
                        CreateTime      = dt
                    });

                    new ProjectBLL().UpdatePhaseStatus(projectPhase.ProjectId, 1, nextTemplatPhase.Name);
                }
                else  //当前已经是最后一个阶段
                {
                    new ProjectBLL().UpdatePhaseStatus(projectPhase.ProjectId, 2, null);
                }

                if (repResult)
                {
                    IntRet = 1;
                }

                if (IntRet > 0)
                {
                    result = new ResultEntity <int>(true, ConstantDefine.TipSaveSuccess, IntRet);
                }
                else
                {
                    result = new ResultEntity <int>(ConstantDefine.TipSaveFail);
                }
            }
            catch (Exception ex)
            {
                Loger.LogErr(ex);
                result = new ResultEntity <int>(ex.Message);
            }

            return(result);
        }