コード例 #1
0
        /// <summary>
        /// 保存考生信息
        /// </summary>
        /// <param name="testRecord">考试计划记录</param>
        public static Model.TestRecordItem SaveTestRecord(Model.TestRecordItem testRecord)
        {
            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                var getTestPlan = db.Test_TestPlan.FirstOrDefault(x => x.TestPlanId == testRecord.TestPlanId);
                if (getTestPlan != null)
                {
                    testRecord.TestPlanName      = getTestPlan.PlanName;
                    testRecord.TestPlanStartTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", getTestPlan.TestStartTime);
                    testRecord.TestPlanEndTime   = string.Format("{0:yyyy-MM-dd HH:mm:ss}", getTestPlan.TestEndTime);
                    Model.Test_TestRecord newTestRecord = new Model.Test_TestRecord
                    {
                        TestPlanId   = testRecord.TestPlanId,
                        TestManId    = testRecord.TestManId,
                        TestManName  = testRecord.TestManName,
                        IdentityCard = testRecord.IdentityCard,
                        Telephone    = testRecord.Telephone,
                        ManType      = testRecord.UserType,
                        Duration     = getTestPlan.Duration,
                    };
                    if (!string.IsNullOrEmpty(testRecord.UnitId))
                    {
                        newTestRecord.UnitId = testRecord.UnitId;
                    }
                    if (!string.IsNullOrEmpty(testRecord.DepartId))
                    {
                        newTestRecord.DepartId = testRecord.DepartId;
                    }
                    if (!string.IsNullOrEmpty(testRecord.WorkPostId))
                    {
                        newTestRecord.WorkPostId = testRecord.WorkPostId;
                    }
                    if (!string.IsNullOrEmpty(testRecord.ProjectId))
                    {
                        newTestRecord.ProjectId = testRecord.ProjectId;
                    }

                    if (string.IsNullOrEmpty(newTestRecord.ManType))
                    {
                        if (testRecord.TestManId == Const.sedinId)
                        {
                            newTestRecord.ManType = "2";
                        }
                        else if (UserService.GetUserByUserId(testRecord.TestManId) != null)
                        {
                            newTestRecord.ManType = "1";
                        }
                        else
                        {
                            newTestRecord.ManType = "3";
                        }
                    }

                    Model.Test_TestRecord getUpdateTestRecord = new Model.Test_TestRecord();
                    ;                   getUpdateTestRecord = db.Test_TestRecord.FirstOrDefault(x => x.TestRecordId == testRecord.TestRecordId);
                    if (getUpdateTestRecord == null)
                    {
                        getUpdateTestRecord = db.Test_TestRecord.FirstOrDefault(x => x.TestPlanId == testRecord.TestPlanId && x.IdentityCard == testRecord.IdentityCard);
                    }
                    if (getUpdateTestRecord != null)
                    {
                        testRecord.TestRecordId  = getUpdateTestRecord.TestRecordId;
                        testRecord.TestEndTime   = string.Format("{0:yyyy-MM:dd HH:mm:ss}", getUpdateTestRecord.TestEndTime);
                        testRecord.TestStartTime = string.Format("{0:yyyy-MM:dd HH:mm:ss}", getUpdateTestRecord.TestStartTime);
                        testRecord.TestScores    = getUpdateTestRecord.TestScores ?? 0;

                        if (string.IsNullOrEmpty(getUpdateTestRecord.ManType))
                        {
                            getUpdateTestRecord.ManType = newTestRecord.ManType;
                        }
                        if (!getUpdateTestRecord.TestEndTime.HasValue && getTestPlan.TestEndTime < DateTime.Now)
                        {
                            getUpdateTestRecord.DepartId     = newTestRecord.DepartId;
                            getUpdateTestRecord.TestManName  = newTestRecord.TestManName;
                            getUpdateTestRecord.IdentityCard = newTestRecord.IdentityCard;
                            getUpdateTestRecord.Telephone    = newTestRecord.Telephone;
                            db.SubmitChanges();
                        }
                    }
                    else
                    {
                        if (getTestPlan.TestEndTime > DateTime.Now)
                        {
                            var getTestPlanTraining = db.Test_TestPlanTraining.Where(x => x.TestPlanId == getTestPlan.TestPlanId && x.UserType == testRecord.UserType);
                            if (getTestPlanTraining.Count() > 0)
                            {
                                int cout1 = getTestPlanTraining.Sum(x => x.TestType1Count ?? 0);
                                int cout2 = getTestPlanTraining.Sum(x => x.TestType2Count ?? 0);
                                int cout3 = getTestPlanTraining.Sum(x => x.TestType3Count ?? 0);
                                newTestRecord.QuestionCount = cout1 + cout2 + cout3;
                                newTestRecord.TotalScore    = (getTestPlan.SValue ?? 0) * cout1 + (getTestPlan.MValue ?? 0) * cout2 + (getTestPlan.JValue ?? 0) * cout3;
                            }

                            testRecord.TestRecordId = newTestRecord.TestRecordId = SQLHelper.GetNewID();
                            db.Test_TestRecord.InsertOnSubmit(newTestRecord);
                            db.SubmitChanges();
                        }
                    }

                    if (!string.IsNullOrEmpty(testRecord.TestEndTime))
                    {
                        testRecord.TestStates = "3";
                    }
                    else if (getTestPlan.States == Const.State_2 && getTestPlan.TestEndTime >= DateTime.Now)
                    {
                        testRecord.TestStates = "2";
                    }
                    else if (getTestPlan.States != Const.State_2 || getTestPlan.TestStartTime < DateTime.Now)
                    {
                        testRecord.TestStates = "1";
                    }
                    else if (getTestPlan.TestEndTime < DateTime.Now)
                    {
                        testRecord.TestStates = "0";
                    }
                }
            }
            return(testRecord);
        }
コード例 #2
0
 /// <summary>
 /// 获取考生信息
 /// </summary>
 /// <param name="testPlanId"></param>
 /// <param name="testManId"></param>
 /// <param name="userType"></param>
 /// <param name="identityCard"></param>
 /// <returns></returns>
 public static Model.TestRecordItem getTestRecordInfo(string testPlanId, string testManId, string userType, string identityCard)
 {
     using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
     {
         Model.TestRecordItem newTestRecord = new Model.TestRecordItem();
         var getTestPlan = db.Test_TestPlan.FirstOrDefault(x => x.TestPlanId == testPlanId);
         if (getTestPlan != null)
         {
             newTestRecord.TestPlanName      = getTestPlan.PlanName;
             newTestRecord.TestPlanId        = testPlanId;
             newTestRecord.TestPlanStartTime = string.Format("{0:yyyy-MM-dd HH:mm:ss}", getTestPlan.TestStartTime);
             newTestRecord.TestPlanEndTime   = string.Format("{0:yyyy-MM-dd HH:mm:ss}", getTestPlan.TestEndTime);
             newTestRecord.TestManId         = testManId;
             newTestRecord.UserType          = userType;
             var getUpdateTestRecord = db.Test_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.IdentityCard == identityCard);
             if (getUpdateTestRecord == null && userType != "2")
             {
                 getUpdateTestRecord = db.Test_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TestManId == testManId);
             }
             if (getUpdateTestRecord != null)
             {
                 newTestRecord.TestRecordId = getUpdateTestRecord.TestRecordId;
                 newTestRecord.DepartId     = getUpdateTestRecord.DepartId;
                 newTestRecord.UnitId       = getUpdateTestRecord.UnitId;
                 newTestRecord.ProjectId    = getUpdateTestRecord.ProjectId;
                 newTestRecord.TestManName  = getUpdateTestRecord.TestManName;
                 newTestRecord.Telephone    = getUpdateTestRecord.Telephone;
                 newTestRecord.IdentityCard = getUpdateTestRecord.IdentityCard;
                 newTestRecord.TestScores   = getUpdateTestRecord.TestScores ?? 0;
             }
             else
             {
                 if (userType == "1")
                 {
                     var getUser = db.Sys_User.FirstOrDefault(x => x.UserId == testManId);
                     if (getUser != null)
                     {
                         newTestRecord.TestManName  = getUser.UserName;
                         newTestRecord.UnitId       = getUser.UnitId;
                         newTestRecord.DepartId     = getUser.DepartId;
                         newTestRecord.IdentityCard = getUser.IdentityCard;
                         newTestRecord.Telephone    = getUser.Telephone;
                     }
                 }
                 else if (userType == "3")
                 {
                     var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == testManId);
                     if (getPerson != null)
                     {
                         newTestRecord.TestManName  = getPerson.PersonName;
                         newTestRecord.ProjectId    = getPerson.ProjectId;
                         newTestRecord.UnitId       = getPerson.UnitId;
                         newTestRecord.WorkPostId   = getPerson.WorkPostId;
                         newTestRecord.IdentityCard = getPerson.IdentityCard;
                         newTestRecord.Telephone    = getPerson.Telephone;
                     }
                 }
                 else
                 {
                     newTestRecord.UnitId = newTestRecord.UnitId = CommonService.GetIsThisUnitId();
                 }
             }
             newTestRecord.DepartName  = DepartService.getDepartNameById(newTestRecord.DepartId);
             newTestRecord.UnitName    = UnitService.GetUnitNameByUnitId(newTestRecord.UnitId);
             newTestRecord.ProjectName = ProjectService.GetProjectNameByProjectId(newTestRecord.ProjectId);
             newTestRecord.IsThiUnit   = CommonService.GetIsThisUnit(newTestRecord.UnitId);
         }
         return(newTestRecord);
     }
 }