/// <summary> /// 如果检测到该课程已学习完成,将更新用户课程完成数量 /// </summary> public override void Execute() { Validate(); var state = State as CourseStudyFinishedCheckEventState; //获取课程下的所有章节状态信息 var courseChapters = ChapterAccessor.GetChaptersAllFor(state.CoureseId); //有效的课程章节 var enableChapters = courseChapters.Where(p => p.Status == (int)ChapterStatus.ENABLED); //有效的课程章节ID集合 var enabledChapterIds = enableChapters.Select(p => p.ChapterId); //有效的课程章节数 var enabledCount = enableChapters != null?enableChapters.Count() : 0; //获取用户当前课程学习过的章节信息 var studiedChapters = StudyRecordAccessor.GetChapterIdsFor(state.StudentId, state.CoureseId); //已学习过的课程章节数 var studiedCount = studiedChapters.Count(p => enabledChapterIds.Contains(p)); //如果:课程中开启的章节数均已学习完成,则更新用户课程完成数 if (enabledCount == studiedCount) { UserStudyAccessor.UpdateReadedCourse(state.StudentId, 1); } }
public override void Execute() { Validate(); var state = State as UserStudingPlansStatisticsEventState; //学习中的计划状态,指:未开始,学习中的状态 var status = EnumUtility.GetEnumValues(typeof(UserStudyPlanStatus)).ToList(); //排除已学习完成的 status.Remove((int)UserStudyPlanStatus.COMPLETE); status.TrimExcess(); //学员 学习计划数量 int count = UserStudyPlanAccessor.GetPlansCount(state.UserId, status); //更新仓储数据 UserStudyAccessor.UpdateStudyPlans(state.UserId, count); }
/// <summary> /// 增加学习时间 /// </summary> public void AddStudingTime() { ThrowExceptionIfValidateFailure(); //计算本次上报后新增的学习时间 if (LastReportStudyTime >= ReceivedTime) { return; } //时间差 TimeSpan timespan = ReceivedTime.Subtract(LastReportStudyTime); //具体相差的总分钟数 int totalMinutes = unchecked ((int)Math.Floor(timespan.TotalMinutes)); //更新到数据库 UserStudyAccessor.UpdateStudyTime(StudentId, totalMinutes); }