/// <summary> /// 自动结束考试 /// </summary> public static void UpdateTestPlanStates() { Model.SUBHSSEDB db = Funs.DB; var getTestPlans = from x in db.Training_TestPlan where x.States == Const.State_2 && x.TestEndTime.AddMinutes(x.Duration) < DateTime.Now select x; if (getTestPlans.Count() > 0) { foreach (var item in getTestPlans) { APITestPlanService.SubmitTest(item); item.States = "3"; db.SubmitChanges(); } } var getTrainingTestRecords = from x in db.Training_TestRecord where x.TestStartTime.Value.AddMinutes(x.Duration) < DateTime.Now && (!x.TestEndTime.HasValue || !x.TestScores.HasValue) select x; foreach (var itemRecord in getTrainingTestRecords) { itemRecord.TestEndTime = itemRecord.TestStartTime.Value.AddMinutes(itemRecord.Duration); itemRecord.TestScores = db.Training_TestRecordItem.Where(x => x.TestRecordId == itemRecord.TestRecordId).Sum(x => x.SubjectScore) ?? 0; TestRecordService.UpdateTestRecord(itemRecord); } }
/// <summary> /// 新增 考试人员明细 /// </summary> public static void AddTrainingTestRecord(List <Model.TestRecordItem> testRecords, Model.Training_TestPlan newTestPlan) { foreach (var item in testRecords) { var person = PersonService.GetPersonById(item.TestManId); if (person != null) { Model.Training_TestRecord newTrainDetail = new Model.Training_TestRecord { TestRecordId = SQLHelper.GetNewID(), ProjectId = newTestPlan.ProjectId, TestPlanId = newTestPlan.TestPlanId, TestManId = item.TestManId, TestType = item.TestType, Duration = newTestPlan.Duration, }; TestRecordService.AddTestRecord(newTrainDetail); } } }