示例#1
0
        /// <summary>
        /// 发送学生的课程学习消息(每个课时的单元学习完成后都要发送消息,进行数据统计)
        /// </summary>
        public void PublishStudyMessage(int courseId, int lessonId, int studentId, int studySeconds, int subjectCount, int getCoins)
        {
            MessageBll bll = new MessageBll();

            CourseStudyMessage msg = new CourseStudyMessage();

            msg.AsOfDate     = DateTime.Now.Date;
            msg.CourseId     = courseId;
            msg.LessonId     = lessonId;
            msg.StudentId    = studentId;
            msg.StudySeconds = studySeconds;
            msg.SubjectCount = subjectCount;
            msg.GetCoins     = getCoins;
            string msgBody = JsonConvert.SerializeObject(msg);

            bll.PublishMessage(MessageChannel.REPORT_CHANNEL, MessageTypeEnum.课程学习, msgBody);
        }
示例#2
0
        public override void Handle()
        {
            CourseStudyMessage       msgObject = JsonConvert.DeserializeObject <CourseStudyMessage>(message);
            SumStudentBll            bll       = new SumStudentBll();
            StudentStudyBll          studyBll  = new StudentStudyBll();
            Yw_StudentCourseProgress progress  = studyBll.GetProgressByStudentCourse(msgObject.StudentId, msgObject.CourseId);

            bool newDay = false;

            if (progress == null)
            {
                throw new AbhsException(ErrorCodeEnum.StudentCourseProgressNotFound, AbhsErrorMsg.ConstStudentCourseProgressNotFound, msgObject.StudentId + "," + msgObject.CourseId);
            }

            Sum_StudyFactDaily daily = bll.GetDailyData(msgObject.StudentId, progress.Yps_ClassId, msgObject.AsOfDate.Date);

            if (daily == null)
            {
                newDay = true;
                daily  = new Sum_StudyFactDaily();
                daily.Ssd_StudentId        = msgObject.StudentId;
                daily.Ssd_SchoolId         = progress.Yps_SchoolId;
                daily.Ssd_ClassId          = progress.Yps_ClassId;
                daily.Ssd_Date             = msgObject.AsOfDate.Date;
                daily.Ssd_UpdateTime       = DateTime.Now;
                daily.Ssd_StudySeconds     = msgObject.StudySeconds;
                daily.Ssd_IncomeCoins      = msgObject.GetCoins;
                daily.Ssd_SubjectCount     = msgObject.SubjectCount;
                daily.Ssd_ExperiencePoints = msgObject.GetCoins;
            }
            else
            {
                daily.Ssd_UpdateTime       = DateTime.Now;
                daily.Ssd_StudySeconds     = daily.Ssd_StudySeconds + msgObject.StudySeconds;
                daily.Ssd_IncomeCoins      = daily.Ssd_IncomeCoins + msgObject.GetCoins;
                daily.Ssd_SubjectCount     = daily.Ssd_SubjectCount + msgObject.SubjectCount;
                daily.Ssd_ExperiencePoints = daily.Ssd_ExperiencePoints + msgObject.GetCoins;
            }
            bll.SaveDailyData(daily);

            Dictionary <DateCycleTypeEnum, Sum_StudyFactDateCycle> dic = bll.FetchOrCreateCycleData(msgObject.StudentId, progress.Yps_ClassId, msgObject.AsOfDate.Date);

            foreach (KeyValuePair <DateCycleTypeEnum, Sum_StudyFactDateCycle> item in dic)
            {
                item.Value.Sdc_StudentId        = msgObject.StudentId;
                item.Value.Sdc_SchoolId         = progress.Yps_SchoolId;
                item.Value.Sdc_ClassId          = progress.Yps_ClassId;
                item.Value.Sdc_UpdateTime       = DateTime.Now;
                item.Value.Sdc_StudySeconds     = item.Value.Sdc_StudySeconds + msgObject.StudySeconds;
                item.Value.Sdc_IncomeCoins      = item.Value.Sdc_IncomeCoins + msgObject.GetCoins;
                item.Value.Sdc_SubjectCount     = item.Value.Sdc_SubjectCount + msgObject.SubjectCount;
                item.Value.Sdc_ExperiencePoints = item.Value.Sdc_ExperiencePoints + msgObject.GetCoins;
                item.Value.Sdc_StudyDayCount    = newDay ? item.Value.Sdc_StudyDayCount + 1 : item.Value.Sdc_StudyDayCount;
                bll.SaveCycleData(item.Value);
            }

            if (newDay)
            {
                int            dayCount = bll.GetStudyDayCountOfStudent(msgObject.StudentId);
                StudentInfoBll infoBll  = new StudentInfoBll();
                infoBll.UpdateStudyDayCountOfStudent(msgObject.StudentId, dayCount);
            }
        }