예제 #1
0
        public string RejectProposal(Guid ID, Guid ProfessorID, ProposalComment comment, bool BigChanges = true)
        {
            using (var dbContextTransaction = Context.Database.BeginTransaction())
            {
                try
                {
                    var proposal = Get(ID);
                    if (proposal == null)
                    {
                        dbContextTransaction.Rollback();
                        dbContextTransaction.Dispose();
                        return("اطلاعات پروپوزال اشتباه است");
                    }

                    if (proposal.ProposalStage.Order != 3 && proposal.ProposalStage.Order != 5 && proposal.ProposalStage.Order != 6 && proposal.ProposalStage.Order != 8 && proposal.ProposalStage.Order != 9 && proposal.ProposalStage.Order != 10 && proposal.ProposalStage.Order != 12)
                    {
                        dbContextTransaction.Rollback();
                        dbContextTransaction.Dispose();
                        return("پروپوزال در دست بررسی این کاربر قرار نیست");
                    }


                    var currentStage = StageRepository.Get(proposal.ProposalStageID);
                    if (currentStage != null)
                    {
                        ProposalStage nextStage = null;


                        //5 ==> 4
                        //9 ==> 7
                        //3 ==> 4
                        //6 ==> 7 BigChanges
                        //8 ==> 7
                        //10 ==> 11
                        //12 ==> 11
                        switch (currentStage.Order)
                        {
                        case 3:
                        {
                            if (proposal.FirstJudgeID == ProfessorID)
                            {
                                proposal.FirstJudgeApproved = true;
                            }
                            else if (proposal.SecondJudgeID == ProfessorID)
                            {
                                proposal.SecondJudgeApproved = true;
                            }
                            if (proposal.SecondJudgeApproved && proposal.FirstJudgeApproved)
                            {
                                nextStage = StageRepository.SelectBy(p => p.Order == 4).FirstOrDefault();
                                proposal.FirstJudgeApproved  = false;
                                proposal.SecondJudgeApproved = false;
                                proposal.LatestOperation     = "رد شده توسط داوران";
                            }
                            else
                            {
                                nextStage = currentStage;
                            }
                            break;
                        }

                        case 5:
                        {
                            if (proposal.FirstJudgeID == ProfessorID)
                            {
                                proposal.FirstJudgeApproved = true;
                            }
                            else if (proposal.SecondJudgeID == ProfessorID)
                            {
                                proposal.SecondJudgeApproved = true;
                            }
                            if (proposal.SecondJudgeApproved && proposal.FirstJudgeApproved)
                            {
                                nextStage = StageRepository.SelectBy(p => p.Order == 4).FirstOrDefault();
                                proposal.FirstJudgeApproved  = false;
                                proposal.SecondJudgeApproved = false;
                                proposal.LatestOperation     = "رد شده توسط داوران";
                            }
                            else
                            {
                                nextStage = currentStage;
                            }

                            break;
                        }

                        case 6:
                        {
                            if (proposal.FirstJudgeID == ProfessorID)
                            {
                                proposal.FirstJudgeApproved = true;
                            }
                            else if (proposal.SecondJudgeID == ProfessorID)
                            {
                                proposal.SecondJudgeApproved = true;
                            }
                            if (proposal.SecondJudgeApproved && proposal.FirstJudgeApproved)
                            {
                                nextStage = StageRepository.SelectBy(p => p.Order == 7).FirstOrDefault();
                                proposal.FirstJudgeApproved  = false;
                                proposal.SecondJudgeApproved = false;
                                proposal.BigChangesForJudges = BigChanges;
                                proposal.LatestOperation     = "رد شده توسط داوران در جلسه دفاع";
                            }
                            else
                            {
                                nextStage = currentStage;
                            }

                            break;
                        }

                        case 8:
                        {
                            nextStage = StageRepository.SelectBy(p => p.Order == 7).FirstOrDefault();
                            proposal.LatestOperation = "رد شده توسط استاد راهنما";
                            break;
                        }

                        case 9:
                        {
                            if (proposal.FirstJudgeID == ProfessorID)
                            {
                                proposal.FirstJudgeApproved = true;
                            }
                            else if (proposal.SecondJudgeID == ProfessorID)
                            {
                                proposal.SecondJudgeApproved = true;
                            }
                            if (proposal.SecondJudgeApproved && proposal.FirstJudgeApproved)
                            {
                                nextStage = StageRepository.SelectBy(p => p.Order == 7).FirstOrDefault();
                                proposal.FirstJudgeApproved  = false;
                                proposal.SecondJudgeApproved = false;
                                proposal.LatestOperation     = "رد شده توسط داوران";
                            }
                            else
                            {
                                nextStage = currentStage;
                            }

                            break;
                        }

                        case 10:
                        {
                            nextStage = StageRepository.SelectBy(p => p.Order == 11).FirstOrDefault();
                            proposal.IsFinalApprove  = true;
                            proposal.LatestOperation = "رد شده توسط شورا";
                            break;
                        }

                        case 12:
                        {
                            nextStage = StageRepository.SelectBy(p => p.Order == 11).FirstOrDefault();
                            proposal.LatestOperation = "رد شده توسط استاد راهنما";
                            break;
                        }
                        }
                        if (nextStage != null)
                        {
                            proposal.ProposalStageID = nextStage.ID;
                            //WorkFlow
                            ProposalWorkflowHistory work = new ProposalWorkflowHistory
                            {
                                ID                   = Guid.NewGuid(),
                                OccuranceDate        = DateTime.Now,
                                OccuredByProfessorID = ProfessorID,
                                OccuredByStudentID   = null,
                                ProposalID           = proposal.ID,
                                ProposalOperationID  = Guid.Parse("73142388-9CE9-465A-AC7E-830B5D5F317C")
                            };
                            ProposalWorkflowHistoryRepository.Add(work);
                            //
                            //Comment
                            ProposalComment com = new ProposalComment {
                                ID = Guid.NewGuid(),
                                ImportanceLevel      = comment.ImportanceLevel,
                                Content              = comment.Content,
                                OccuranceDate        = DateTime.Now,
                                OccuredByProfessorID = ProfessorID,
                                OccuredByStudentID   = null,
                                ProposalID           = proposal.ID,
                                ProposalStageID      = currentStage.ID
                            };
                            ProposalCommentRepository.Add(com);
                            //
                        }
                    }


                    Commit();
                    dbContextTransaction.Commit();
                    dbContextTransaction.Dispose();

                    return("");
                }
                catch (Exception e)
                {
                    dbContextTransaction.Rollback();
                    dbContextTransaction.Dispose();
                    return("خطا در سرور");
                }
            }
        }
예제 #2
0
        public string SendProposal(Guid ID) //, ProposalComment comment)
        {
            using (var dbContextTransaction = Context.Database.BeginTransaction())
            {
                try
                {
                    var proposal = Get(ID);
                    if (proposal == null)
                    {
                        dbContextTransaction.Rollback();
                        dbContextTransaction.Dispose();
                        return("اطلاعات پروپوزال اشتباه است");
                    }

                    if (proposal.ProposalStage.Order != 1 && proposal.ProposalStage.Order != 4 && proposal.ProposalStage.Order != 7 && proposal.ProposalStage.Order != 11)
                    {
                        dbContextTransaction.Rollback();
                        dbContextTransaction.Dispose();
                        return("پروپوزال در دست بررسی این کاربر قرار نیست");
                    }


                    var currentStage = StageRepository.Get(proposal.ProposalStageID);
                    if (currentStage != null)
                    {
                        ProposalStage nextStage = null;
                        if (currentStage.Order == 1 || currentStage.Order == 4 || currentStage.Order == 11)
                        {
                            nextStage = StageRepository.SelectBy(p => p.Order == currentStage.Order + 1).FirstOrDefault();
                        }
                        else if (currentStage.Order == 7)
                        {
                            if (proposal.BigChangesForJudges.HasValue && proposal.BigChangesForJudges.Value)
                            {
                                nextStage = StageRepository.SelectBy(p => p.Order == 9).FirstOrDefault();
                            }
                            else
                            {
                                nextStage = StageRepository.SelectBy(p => p.Order == 8).FirstOrDefault();
                            }
                        }

                        if (nextStage != null)
                        {
                            proposal.ProposalStageID = nextStage.ID;
                            proposal.LatestOperation = "ارسال شده توسط دانشجو";
                            //WorkFlow
                            ProposalWorkflowHistory work = new ProposalWorkflowHistory
                            {
                                ID                   = Guid.NewGuid(),
                                OccuranceDate        = DateTime.Now,
                                OccuredByProfessorID = null,
                                OccuredByStudentID   = proposal.StudentID,
                                ProposalID           = proposal.ID,
                                ProposalOperationID  = Guid.Parse("B56DBC09-DDFA-4003-89EC-CED81CD31F7C")
                            };
                            ProposalWorkflowHistoryRepository.Add(work);
                            //
                            //Comment
                            //ProposalComment com = new ProposalComment
                            //{
                            //    ID = Guid.NewGuid(),
                            //    ImportanceLevel = comment.ImportanceLevel,
                            //    Content = comment.Content,
                            //    OccuranceDate = DateTime.Now,
                            //    OccuredByProfessorID = null,
                            //    OccuredByStudentID = proposal.StudentID,
                            //    ProposalID = proposal.ID,
                            //    ProposalStageID = currentStage.ID
                            //};
                            //ProposalCommentRepository.Add(com);
                            //
                        }
                    }


                    Commit();
                    dbContextTransaction.Commit();
                    dbContextTransaction.Dispose();

                    return("");
                }
                catch (Exception e)
                {
                    dbContextTransaction.Rollback();
                    dbContextTransaction.Dispose();
                    return("خطا در سرور");
                }
            }
        }