Example #1
0
        //void changeLevelForTest()
        //{
        //    this.ViewModel.CurrentIndex = null;
        //    readLevel();
        //    calcQuestion();
        //}

        private void readLevel()
        {
            CRWLog log = Client.Common.StaticInfo.InnerSQLiteDB.CRW_rLog(PageGamesList.Game_User, this.ViewModel.CRWTypeID);

            if (log.NextLevel.HasValue)
            {
                // var now = WebDateTime.Now;
                var now   = DateTime.Now;
                var today = now.Date;

                var toAdd = new CRWLog()
                {
                    UserID            = log.UserID,
                    CRWTypeID         = this.ViewModel.CRWTypeID,
                    Level             = log.NextLevel.Value,
                    DateValue         = today.Ticks,
                    DateDisplay       = today.ToString("yyyy-MM-dd"),
                    UpdateTimeValue   = now.Ticks,
                    UpdateTimeDisplay = now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                    Percentage        = null,
                    NextLevel         = null,
                    UseTime           = log.UseTime,
                    UseTimeDisplay    = log.UseTimeDisplay
                };

                Client.Common.StaticInfo.InnerSQLiteDB.CRW_cLog(toAdd);

                // 再次获取
                log = Client.Common.StaticInfo.InnerSQLiteDB.CRW_rLog(PageGamesList.Game_User, this.ViewModel.CRWTypeID);
            }

            CRW_Level level = new CRW_Level(log.Level, this.ViewModel.CRWTypeID);

            this.ViewModel.Level = level;

            #region 听力溯算 根据难度调整语速

            if (
                this.ViewModel.CRWTypeID == 2 &&
                this.ViewModel.Level != null
                )
            {
                App.TTS.SetSpeechRateSilent(this.ViewModel.Level.SpeechRate);
            }

            #endregion
        }
Example #2
0
        public PageMain(int selectedCRWTypeID)
        {
            InitializeComponent();
            initUI();

            this.mBll = new CRWBll();
            this.initEvent();
            this.ViewModel      = new PageMainViewModel();
            this.BindingContext = this.ViewModel;

            this.ViewModel.CRWTypeID = selectedCRWTypeID;

            #region 数据库锻炼时间赋值

            CRWLog log = Client.Common.StaticInfo.InnerSQLiteDB.CRW_rLog(PageGamesList.Game_User, this.ViewModel.CRWTypeID);
            this.ViewModel.DB_Today_CRWUseTimeInfo = TimeSpan.FromTicks(log.UseTime.Value);

            #endregion

            readLevel();
            calcQuestion();
            showStopWatch();
        }
Example #3
0
        private void readNextQuestion()
        {
            var r = mBll.ReadNextQuestion(this.ViewModel.CurrentIndex, this.ViewModel.Level, this.ViewModel.QuestionList);

            this.ViewModel.RememberQuestion = r.Item2;
            this.ViewModel.AnswerQuestion   = r.Item3;

            #region 听力溯算 播放题目内容

            if (
                this.ViewModel.CRWTypeID == 2 &&
                this.ViewModel.RememberQuestion != null &&
                this.ViewModel.RememberQuestion.TTSMsg.IsNullOrWhiteSpace() == false
                )
            {
                App.TTS.Play(this.ViewModel.RememberQuestion.TTSMsg);
            }

            #endregion

            #region 答题完毕

            if (this.ViewModel.RememberQuestion == null && this.ViewModel.AnswerQuestion == null)
            {
                this.ViewModel.swCRW_UseTime.Stop();

                this.ViewModel.CurrentIndex = null;

                decimal correctPercentage = mBll.CheckCorrectPercentage(this.ViewModel.QuestionList);
                var     result            = mBll.CalcLevel(this.ViewModel.Level, this.ViewModel.QuestionList);

                System.Diagnostics.Debug.WriteLine(result.Item2);
                App.Output.Info(Tag, result.Item2);

                var lastestLog = Client.Common.StaticInfo.InnerSQLiteDB.CRW_rLog(PageGamesList.Game_User, this.ViewModel.CRWTypeID);
                lastestLog.NextLevel      = result.Item1.LevelNo;
                lastestLog.Percentage     = Convert.ToInt32(correctPercentage);
                lastestLog.UseTime        = this.ViewModel.swCRW_UseTime.ElapsedTicks;
                lastestLog.UseTimeDisplay = this.ViewModel.CRW_UseTimeInfo;

                Client.Common.StaticInfo.InnerSQLiteDB.CRW_uLog(lastestLog);

                // 设置新的等级, 计算新的题目
                this.ViewModel.Level = result.Item1;
                this.calcQuestion();
                // 播放检测正确率动画, 播放完毕后执行, readNextQuestion()

                // var now = WebDateTime.Now; // DateTime.Now;
                var now   = DateTime.Now;
                var today = now.Date;

                var toAdd = new CRWLog()
                {
                    UserID            = PageGamesList.Game_User.ID,
                    CRWTypeID         = 1,
                    Level             = this.ViewModel.Level.LevelNo,
                    DateValue         = today.Ticks,
                    DateDisplay       = today.ToString("yyyy-MM-dd"),
                    UpdateTimeValue   = now.Ticks,
                    UpdateTimeDisplay = now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                    Percentage        = null,
                    NextLevel         = null,
                    UseTime           = this.ViewModel.DB_Today_CRWUseTimeInfo.Ticks + this.ViewModel.swCRW_UseTime.ElapsedTicks, // 数据库记录的使用时间 + 当前计时器的使用时间
                    UseTimeDisplay    = this.ViewModel.CRW_UseTimeInfo
                };

                Client.Common.StaticInfo.InnerSQLiteDB.CRW_cLog(toAdd);

                this.playNextLevelVideo(result.Item2);
                return;
            }

            #endregion

            // 继续回答下一题
            mCurrentStep = 0;
            this.ViewModel.swCRW_UseTime.Start();
            calcTimeOut_BgWorker_Start();
            this.ViewModel.CurrentIndex = r.Item1;
        }