示例#1
0
        public Yw_SubjectProcess GetNextProcess(
            int subjectId,
            int currentUser,
            SubjectStatusEnum nextStatus,
            SubjectActionEnum action)
        {
            if (currentUser < 10000)
            {
                throw new ArgumentException(nameof(currentUser));
            }
            Yw_SubjectProcess nextProcess = new Yw_SubjectProcess();

            nextProcess.Ysp_Action     = (int)action;
            nextProcess.Ysp_CreateTime = DateTime.Now;
            nextProcess.Ysp_Id         = 0;
            nextProcess.Ysp_Mark       = "";
            nextProcess.Ysp_Operator   = currentUser;
            nextProcess.Ysp_Remark     = "";
            nextProcess.Ysp_Status     = (int)nextStatus;
            nextProcess.Ysp_SubjectId  = subjectId;
            if (subjectId >= 10000)
            {
                Yw_SubjectProcess currentProcess = SubjectProcessService.GetCurrentProcess(
                    subjectId);
                if (currentProcess != null)
                {
                    nextProcess.Ysp_Mark   = currentProcess.Ysp_Mark;
                    nextProcess.Ysp_Remark = currentProcess.Ysp_Remark;
                }
            }
            return(nextProcess);
        }
示例#2
0
        public ActionResult ReEdit(int subjectId)
        {
            SubjectBll        bll     = new SubjectBll();
            Yw_SubjectProcess process = bll.GetNextProcess(
                subjectId,
                CurrentUserID,
                SubjectStatusEnum.编辑中,
                SubjectActionEnum.重新编辑);

            bll.ReEdit(process);

            return(Json(new SuccessJsonResponse()));
        }
示例#3
0
        public void MoveToNext(Yw_SubjectProcess process)
        {
            SubjectProcessService.Insert(process);

            IEnumerable <Yw_SubjectIndex> subjectIdnexes =
                SubjectIndexService.GetSubjectIndexBySubject(process.Ysp_SubjectId);

            foreach (var item in subjectIdnexes)
            {
                item.EnableAudit();
                item.Ysi_Status = process.Ysp_Status;
                SubjectIndexService.Update(item);
            }
        }
示例#4
0
 public void Approve(Yw_Subject subject, Yw_SubjectProcess process)
 {
     using (TransactionScope scope = new TransactionScope())
     {
         try
         {
             UpdateSubject(subject);
             MoveToNext(process);
             scope.Complete();
         }
         catch
         {
             RollbackTran();
             throw;
         }
     }
 }
示例#5
0
        public void SubjectRepository_Insert_ShouldSuccess()
        {
            SubjectProcessRepository repository = new SubjectProcessRepository();
            DateTime          now         = DateTime.Now;
            Yw_SubjectProcess addedEntity = repository.Insert(new Yw_SubjectProcess()
            {
                Ysp_Id         = 0,
                Ysp_CreateTime = now,
                Ysp_Status     = (int)SubjectStatusEnum.编辑中,
                Ysp_Mark       = "mark-zhcy",
                Ysp_Action     = (int)SubjectActionEnum.提交,
                Ysp_Operator   = 10000,
                Ysp_Remark     = "Remark-zhcy",
                Ysp_SubjectId  = 10005
            });

            Assert.IsNotNull(addedEntity);
            Assert.IsTrue(addedEntity.Ysp_Id > 0);
            Assert.AreEqual(10005, addedEntity.Ysp_SubjectId);
        }
        public ActionResult Approve(ApproveInputModel approve)
        {
            SubjectBll        bll           = new SubjectBll();
            var               subjectEntity = bll.GetSubject(approve.SubjectId);
            Yw_SubjectProcess nextProcess   = new Yw_SubjectProcess();

            nextProcess.Ysp_Action     = (int)SubjectActionEnum.审批;
            nextProcess.Ysp_CreateTime = DateTime.Now;
            nextProcess.Ysp_Id         = 0;
            nextProcess.Ysp_Operator   = CurrentUserID;
            nextProcess.Ysp_Remark     = "";
            nextProcess.Ysp_Status     = (int)approve.NextStatus;
            nextProcess.Ysp_SubjectId  = approve.SubjectId;
            subjectEntity.Ysj_Status   = nextProcess.Ysp_Status;
            if (approve.Mark != null && approve.Mark.Count > 0)
            {
                string mark = string.Join(",", approve.Mark);
                nextProcess.Ysp_Mark = mark;
            }
            bll.Approve(subjectEntity, nextProcess);
            return(Json(new SuccessJsonResponse()));
        }
示例#7
0
        public void ReEdit(Yw_SubjectProcess process)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    Yw_Subject subject = SubjectService.Get(process.Ysp_SubjectId);
                    subject.EnableAudit();
                    subject.Ysj_Status = process.Ysp_Status;
                    SubjectService.Update(subject);

                    MoveToNext(process);

                    scope.Complete();
                }
                catch
                {
                    RollbackTran();
                    throw;
                }
            }
        }
示例#8
0
        public void SubmitSubject(
            Yw_Subject subject,
            Yw_SubjectContent content,
            IEnumerable <Yw_SubjectIndex> subjectIndexToAdd,
            IEnumerable <int> subjectIndexToDelete,
            Yw_SubjectKnowledge mainKnowledge,
            IEnumerable <Yw_SubjectKnowledge> knowledgesToAdd,
            IEnumerable <int> knowledgesToDelete,
            Yw_SubjectProcess subjectProcess)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    if (!Saved(subject.Ysj_Id))
                    {
                        //SaveSubject(
                        //    subject,
                        //    content,
                        //    subjectIndexToAdd,
                        //    subjectIndexToDelete,
                        //    mainKnowledge,
                        //    knowledgesToAdd,
                        //    knowledgesToDelete);
                    }

                    subjectProcess.Ysp_SubjectId = subject.Ysj_Id;
                    MoveSubjectProcessToNext(subjectProcess);

                    scope.Complete();
                }
                catch
                {
                    RollbackTran();
                    throw;
                }
            }
        }
        protected int SaveSubject(QuestionInputModel subject)
        {
            SubjectBll bll = new SubjectBll();

            //题目信息
            Yw_Subject          subjectEntity     = null;
            Action <Yw_Subject> saveSubjectMethod =
                SubjectFetcher.Fetch(subject, bll, CurrentUserID, out subjectEntity);

            //题目内容
            Yw_SubjectContent          content           = null;
            ContentFetcher             fetcher           = GetContentFetcher();
            Action <Yw_SubjectContent> saveContentMethod = fetcher.Fetch(
                subject,
                bll,
                CurrentUserID,
                out content);

            //要删除的关键词
            IList <int> keywordIdsToDelete = null;
            //要添加的关键词
            IList <Yw_SubjectIndex> keywordsToAdd = KeywordFetcher.Fetch(
                subject,
                bll,
                CurrentUserID,
                out keywordIdsToDelete);

            //主知识点
            Yw_SubjectKnowledge          mainKnowledgeEntity = null;
            Action <Yw_SubjectKnowledge> saveKnowledgeMethod = MainKnowledgeFetcher.Fetch(
                subject,
                bll,
                CurrentUserID,
                out mainKnowledgeEntity);

            //次级知识点
            //需要删除的次级知识点
            IEnumerable <int> idsOfknowledgeToDelete = null;
            //需要添加的次级知识点
            IEnumerable <Yw_SubjectKnowledge> knowledgesToAdd =
                SecondaryKnowledgeFetcher.Fetch(
                    subject,
                    bll,
                    CurrentUserID,
                    out idsOfknowledgeToDelete);

            Yw_SubjectProcess process = null;

            if (subject.Button == FormSubmitButton.Submit)
            {
                process = bll.GetNextProcess(
                    subject.Id,
                    CurrentUserID,
                    subject.NextStatus,
                    SubjectActionEnum.提交);
                subjectEntity.Ysj_Status = process.Ysp_Status;
            }

            return(bll.SaveSubject(saveSubjectMethod, subjectEntity,
                                   saveContentMethod, content,
                                   saveKnowledgeMethod, mainKnowledgeEntity,
                                   keywordsToAdd, keywordIdsToDelete,
                                   knowledgesToAdd, idsOfknowledgeToDelete,
                                   process, subject.Button));
        }
示例#10
0
 private void MoveSubjectProcessToNext(Yw_SubjectProcess entity)
 {
     SubjectProcessService.Insert(entity);
 }
示例#11
0
        public int SaveSubject(
            Action <Yw_Subject> saveSubject, Yw_Subject subject,
            Action <Yw_SubjectContent> saveContent, Yw_SubjectContent content,
            Action <Yw_SubjectKnowledge> saveKnowledge, Yw_SubjectKnowledge knowledge,
            IEnumerable <Yw_SubjectIndex> keywordsToAdd, IEnumerable <int> keywordIdsToDelete,
            IEnumerable <Yw_SubjectKnowledge> knowledgesToAdd,
            IEnumerable <int> idsOfknowledgeToDelete,
            Yw_SubjectProcess process,
            FormSubmitButton button)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    Check.IfNull(saveSubject, nameof(saveSubject));
                    Check.IfNull(saveContent, nameof(saveContent));
                    Check.IfNull(saveKnowledge, nameof(saveKnowledge));

                    //题目
                    saveSubject(subject);

                    //题目的内容
                    content.Ysc_SubjectId = subject.Ysj_Id;
                    saveContent(content);

                    //主知识点
                    if (knowledge != null)
                    {
                        knowledge.Ysw_SubjectId = subject.Ysj_Id;
                        saveKnowledge(knowledge);
                    }

                    //关键词
                    if (keywordsToAdd != null)
                    {
                        for (int i = 0; i < keywordsToAdd.Count(); i++)
                        {
                            var k = keywordsToAdd.ElementAt(i);
                            k.Ysi_SubjectId = subject.Ysj_Id;
                        }
                    }
                    InsertKeywords(keywordsToAdd);
                    DeleteKeywords(keywordIdsToDelete);

                    //次级知识点
                    if (knowledgesToAdd != null)
                    {
                        for (int i = 0; i < knowledgesToAdd.Count(); i++)
                        {
                            var k = knowledgesToAdd.ElementAt(i);
                            k.Ysw_SubjectId = subject.Ysj_Id;
                        }
                    }
                    InsertSecondaryKnowledges(knowledgesToAdd);
                    DeleteSecondaryKnowledges(idsOfknowledgeToDelete);

                    //如果是提交操作,进入审批流程
                    if (button == FormSubmitButton.Submit)
                    {
                        process.Ysp_SubjectId = subject.Ysj_Id;
                        MoveToNext(process);
                    }

                    scope.Complete();
                    return(subject.Ysj_Id);
                }
                catch
                {
                    RollbackTran();
                    throw;
                }
            }
        }