コード例 #1
0
        public bool EditProposal(Guid ProposalID, Guid FileID, string com)
        {
            using (var transaction = Context.Database.BeginTransaction())
            {
                try
                {
                    var proposal = Get(ProposalID);
                    var file     = ProposalFileRepository.Get(FileID);
                    if (file == null || proposal == null)
                    {
                        return(false);
                    }

                    file.ProposalID = ProposalID;

                    ProposalWorkflowHistory w = new ProposalWorkflowHistory()
                    {
                        ID = Guid.NewGuid(),
                        OccuredByProfessorID = null,
                        OccuredByStudentID   = proposal.StudentID,
                        OccuranceDate        = DateTime.Now,
                        ProposalID           = proposal.ID,
                        ProposalOperationID  = Guid.Parse("bf63e692-e4f9-4e7e-bf3d-1dc2c8189078")
                    };
                    ProposalWorkflowHistoryRepository.Add(w);

                    ProposalComment c = new ProposalComment()
                    {
                        ID = Guid.NewGuid(),
                        OccuredByProfessorID = null,
                        OccuredByStudentID   = proposal.StudentID,
                        OccuranceDate        = DateTime.Now,
                        Content         = com,
                        ProposalID      = proposal.ID,
                        ImportanceLevel = null,
                        ProposalStageID = proposal.ProposalStageID
                    };
                    ProposalCommentRepository.Add(c);

                    Commit();
                    transaction.Commit();
                    transaction.Dispose();
                    return(true);
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    transaction.Dispose();
                    return(false);
                }
            }
        }
コード例 #2
0
        public bool SubmitProposal(ProposalGeneralInfoJSON ProposalJSON, string Username)
        {
            using (var dbContextTransaction = Context.Database.BeginTransaction())
            {
                try
                {
                    bool result = true;

                    Student s = StudentRepository.Value.SelectBy(q => q.SocialSecurityNumber == Username).FirstOrDefault();
                    if (s == null)
                    {
                        return(false);
                    }

                    Proposal p = new Proposal();
                    p.ID                  = Guid.NewGuid();
                    p.CreateDate          = DateTime.Now;
                    p.IsFinalApprove      = false;
                    p.LatestOperation     = "ثبت شده توسط دانشجو";
                    p.LatinName           = ProposalJSON.LatinName;
                    p.Name                = ProposalJSON.Name;
                    p.ResearchTypeID      = ProposalJSON.ReseachTypeID;
                    p.ProposalStageID     = StageRepository.SelectBy(w => w.Order == 1).FirstOrDefault().ID;
                    p.ProposalStatusID    = StatusRepository.SelectBy(e => e.IsDefault).FirstOrDefault().ID;
                    p.StudentID           = s.ID;
                    p.FirstJudgeApproved  = false;
                    p.SecondJudgeApproved = false;

                    Add(p);

                    result &= KeywordRepository.AddProposalKeyword(ProposalJSON.keywords, p.ID);

                    //WorkFlow
                    ProposalWorkflowHistory work = new ProposalWorkflowHistory {
                        ID                   = Guid.NewGuid(),
                        OccuranceDate        = DateTime.Now,
                        OccuredByProfessorID = null,
                        OccuredByStudentID   = s.ID,
                        ProposalID           = p.ID,
                        ProposalOperationID  = Guid.Parse("4aaaa946-53ce-45c8-a317-20eba03867e0")
                    };
                    ProposalWorkflowHistoryRepository.Add(work);
                    //

                    ProposalFile pf = ProposalFileRepository.Get(ProposalJSON.FileID);
                    if (pf == null)
                    {
                        return(false);
                    }
                    else
                    {
                        pf.ProposalID = p.ID;
                    }


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

                    return(result);
                }
                catch (Exception e)
                {
                    dbContextTransaction.Rollback();
                    dbContextTransaction.Dispose();
                    return(false);
                }
            }
        }
コード例 #3
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("خطا در سرور");
                }
            }
        }
コード例 #4
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("خطا در سرور");
                }
            }
        }