示例#1
0
        /// <summary>
        /// 结束考试
        /// </summary>
        public static void SubmitTest(Model.Training_TestPlan getTestPlan)
        {
            using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
            {
                ////所有交卷的人员 交卷 并计算分数
                var getTrainingTestRecords = from x in db.Training_TestRecord
                                             where x.TestPlanId == getTestPlan.TestPlanId && (!x.TestEndTime.HasValue || !x.TestScores.HasValue)
                                             select x;
                foreach (var itemRecord in getTrainingTestRecords)
                {
                    itemRecord.TestEndTime = DateTime.Now;
                    itemRecord.TestScores  = db.Training_TestRecordItem.Where(x => x.TestRecordId == itemRecord.TestRecordId).Sum(x => x.SubjectScore) ?? 0;
                    db.SubmitChanges();
                }

                var getTrainingTasks = from x in db.Training_Task
                                       where x.PlanId == getTestPlan.PlanId && (x.States != "2" || x.States == null)
                                       select x;
                foreach (var item in getTrainingTasks)
                {
                    item.States = "2";
                    db.SubmitChanges();
                }

                ////TODO 讲培训计划 考试记录 写入到培训记录
                APITrainRecordService.InsertTrainRecord(getTestPlan);
            }
        }
示例#2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="testPlanId"></param>
 public static void updateAll(string testPlanId)
 {
     using (Model.SUBHSSEDB db = new Model.SUBHSSEDB(Funs.ConnString))
     {
         //// 获取考试计划
         var getTestPlan = db.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == testPlanId);
         if (getTestPlan != null)
         {
             //// 获取参加考试 记录
             var getAllTestRecords = db.Training_TestRecord.Where(x => x.TestPlanId == getTestPlan.TestPlanId);
             if (getAllTestRecords.Count() > 0)
             {
                 /// 参加考试人数
                 int testManCout = getAllTestRecords.Select(x => x.TestManId).Distinct().Count();
                 //// 获取培训计划人员
                 var getAllTrainingTasks = db.Training_Task.Where(x => x.PlanId == getTestPlan.PlanId);
                 //// 考试人数大于等于 培训人数
                 if (testManCout >= getAllTrainingTasks.Count())
                 {
                     ////所有人员 都交卷时 考试计划结束 状态置为3
                     var getAllTestRecord = getAllTestRecords.FirstOrDefault(x => !x.TestEndTime.HasValue);
                     if (getAllTestRecord == null)
                     {
                         var getTrainingTasks = getAllTrainingTasks.Where(x => x.States != "2" || x.States == null);
                         foreach (var item in getTrainingTasks)
                         {
                             item.States = "2";
                             db.SubmitChanges();
                         }
                         getTestPlan.States = "3";
                         db.SubmitChanges();
                         ////TODO 讲培训计划 考试记录 写入到培训记录
                         APITrainRecordService.InsertTrainRecord(getTestPlan);
                     }
                 }
             }
         }
     }
 }