示例#1
0
 public void SaveDailyData(Sum_StudyFactDaily daily)
 {
     if (daily.Ssd_Id > 0)
     {
         StudentDailyRepository.Update(daily);
     }
     else
     {
         StudentDailyRepository.Add(daily);
     }
 }
示例#2
0
        public override void Handle()
        {
            CourseStudyPractiseMessage msgObject = JsonConvert.DeserializeObject <CourseStudyPractiseMessage>(message);
            SumStudentBll            bll         = new SumStudentBll();
            StudentStudyBll          studyBll    = new StudentStudyBll();
            Yw_StudentCourseProgress progress    = studyBll.GetProgressByStudentCourse(msgObject.StudentId, msgObject.CourseId);

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

            bool newDay = false;

            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_PracticeCount    = 1;
                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_PracticeCount    = daily.Ssd_PracticeCount + 1;
                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_PracticeCount    = item.Value.Sdc_PracticeCount + 1;
                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);
            }
        }
示例#3
0
 public void UpdateDailyData(Sum_StudyFactDaily daily)
 {
     StudentDailyRepository.Update(daily);
 }
示例#4
0
        public Sum_StudyFactDaily GetDailyData(int studentId, int classId, DateTime asOfDate)
        {
            Sum_StudyFactDaily daily = StudentDailyRepository.GetByStudentDate(studentId, classId, asOfDate);

            return(daily);
        }