Exemple #1
0
        void onShowChart(object mode)
        {
            string f;

            switch ((string)mode)
            {
            case "Full": f = "MMM-dd"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.OrderByDescending(r => r.DoneAt)); break;

            case "Mont": f = "MMM-dd"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.Where(r => r.DoneAt > DateTime.Now.AddMonths(-1)).OrderByDescending(r => r.DoneAt)); break;

            case "Week": f = "MMM-dd"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.Where(r => r.DoneAt > DateTime.Now.AddDays(-7)).OrderByDescending(r => r.DoneAt)); break;

            case "1Day": f = "H:mm"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.Where(r => r.DoneAt > DateTime.Now.AddDays(-1)).OrderByDescending(r => r.DoneAt)); break;

            case "PreX": f = "H:mm"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.OrderByDescending(r => r.DoneAt).Take(10)); break;

            case "Pre5": f = "h:mm:ss"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.OrderByDescending(r => r.DoneAt).Take(05)); break;

            case null:
            default: f = "MMM-dd"; break;
            }

            _chartUC.AxisX.First().LabelFormatter = value => DateTime.FromOADate(value).ToString(f);
        }
Exemple #2
0
        void onShowChart(object mode)
        {
            string f;

            switch ((string)mode)
            {
            case "Full": f = "y-M-d"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.OrderByDescending(r => r.DoneAt)); break;

            case "Year": f = "MMM d"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.Where(r => r.DoneAt > DateTime.Now.AddYears(-1)).OrderByDescending(r => r.DoneAt)); break;

            case "3Mon": f = "ddd d"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.Where(r => r.DoneAt > DateTime.Now.AddMonths(-3)).OrderByDescending(r => r.DoneAt)); break;

            case "Mont": f = "ddd d"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.Where(r => r.DoneAt > DateTime.Now.AddMonths(-1)).OrderByDescending(r => r.DoneAt)); break;

            case "Week": f = "ddd H:mm"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.Where(r => r.DoneAt > DateTime.Now.AddDays(-7)).OrderByDescending(r => r.DoneAt)); break;

            case "PreX": f = "ddd H:mm"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.OrderByDescending(r => r.DoneAt).Take(10)); break;

            case "Pre5": f = "H:mm"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.OrderByDescending(r => r.DoneAt).Take(05)); break;

            case "24hr": f = "H:mm"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.Where(r => r.DoneAt > DateTime.Now.AddDays(-1)).OrderByDescending(r => r.DoneAt)); break;

            case "1Day": f = "H:mm"; /**/ _chartUC.LoadDataToChart(CurUserCurExcrsRsltLst.Where(r => r.DoneAt > DateTime.Today).OrderByDescending(r => r.DoneAt)); break;

            case null:
            default: f = "MMM-dd"; break;
            }

            _chartUC.AxisX.First().LabelFormatter = value => DateTime.FromOADate(value).ToString(f);
        }

        void onDeleteSR(object x)
        {
            if (SelectSnRt == null)
            {
                return;
            }

            synth.SpeakAsyncCancelAll(); synth.SpeakFaF($"Are you sure?");
            if (MessageBox.Show($"{SelectSnRt.DoneAt:MMM-dd HH:mm} \r\n\n{SelectSnRt.CpM} cpm\r\n\n{(SelectSnRt.IsRecord == true ? "It's a Record!!" : "")}", "Are you sure?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                DeleteSaveSsnRsltToDb(SelectSnRt, A0DbMdl.GetA0DbMdlAzureDb);
            }
        }

        void promptSample()
        {
            /*
             * var ps = new PromptStyle
             * {
             * Emphasis = PromptEmphasis.Strong,
             * Volume = PromptVolume.ExtraLoud
             * };
             *
             * var pb = new PromptBuilder();
             * pb.StartStyle(ps);
             * pb.StartParagraph();
             *
             * pb.StartVoice(VoiceGender.Female, VoiceAge.Child);
             * pb.StartSentence();
             * pb.AppendText($"Female Child", PromptRate.Medium);
             * pb.AppendBreak(TimeSpan.FromSeconds(.3));
             * pb.EndSentence();
             * pb.EndVoice();
             *
             * pb.StartVoice(VoiceGender.Female, VoiceAge.Senior);
             * pb.StartSentence();
             * pb.AppendText($"Female Senior", PromptRate.Medium);
             * pb.AppendBreak(TimeSpan.FromSeconds(.3));
             * pb.EndSentence();
             * pb.EndVoice();
             *
             * pb.StartVoice(VoiceGender.Male, VoiceAge.Senior);
             * pb.StartSentence();
             * pb.AppendText($"Male Senior", PromptRate.Medium);
             * pb.AppendBreak(TimeSpan.FromSeconds(.3));
             * pb.EndSentence();
             * pb.EndVoice();
             *
             * pb.StartVoice(VoiceGender.Male, VoiceAge.Child);
             * pb.StartSentence();
             * pb.AppendText($"Male Child", PromptRate.Medium);
             * pb.AppendBreak(TimeSpan.FromSeconds(.3));
             * pb.EndSentence();
             * pb.EndVoice();
             *
             * pb.EndParagraph();
             * pb.EndStyle();
             * synth.SpeakAsyncCancelAll(); synth.SpeakFaF(pb);
             */
        }

        async void prepLessonType(string x, bool doF1 = true)
        {
            SubLesnId = x.Split('-').Last();

            switch (x[0])
            {
            case 'A':
            case 'D': LesnTyp = LessonType.DrillsInFile; break;

            case 'B': LesnTyp = LessonType.BasicLessons; break;

            case 'C': LesnTyp = LessonType.Combinations; break;

            case 'N': LesnTyp = LessonType.NumerSymbols; break;

            case 'F': LesnTyp = LessonType.EditableFile; break;

            case 'S': LesnTyp = LessonType.SpecialDrill; break;

            case 'P': LesnTyp = LessonType.PhrasesRandm; break;

            case 'X': LesnTyp = LessonType.Experimental; break;

            default: break;
            }

            var(lessonTxt, lessonLen) = LessonHelper.GetLesson(LesnTyp, SubLesnId);
            LessonText = lessonTxt;
            LessonLen  = lessonLen;

            if (doF1)
            {
                using (var db = A0DbMdl.GetA0DbMdlAzureDb)
                {
                    loadListsFromDB(DashName, SelectUser, db);
                    await updateDoneTodo(SelectUser, synth, db);
                }
            }

            CurInfo = $"{(LesnTyp)} - {SubLesnId:N0}  ";// ({DashName})";
        }

        async Task updateDoneTodo(string selectUser, SpeechSynthesizer synth, A0DbMdl db)
        {
            int doneToday = -1, sinceRcrd = -1, todoToday = -1;

            try
            {
                doneToday = db.SessionResults.Count(r => r.UserId.Equals(selectUser, StringComparison.OrdinalIgnoreCase) && r.DoneAt > DateTime.Today);

                //if (!db.SessionResults.Any(r => r.UserId.Equals(selectUser, StringComparison.OrdinalIgnoreCase)))
                //{
                //  sinceRcrd = 0;
                //  todoToday = _planPerDay - doneToday;
                //}
                //else
                {
                    var latestGlobalRecordDate = await getLatestGlobalRecordDate(selectUser, db);

                    sinceRcrd = db.SessionResults.Count(r => r.UserId == selectUser && r.DoneAt > latestGlobalRecordDate);
                    todoToday =
                        ((DateTime.Today < latestGlobalRecordDate)) ? 0 : // if done a record today ==> 0 left
                        ((DateTime.Today - latestGlobalRecordDate).Days + 1) * _planPerDay - sinceRcrd;
                }

                if (todoToday < 0)
                {
                    todoToday = _planPerDay - doneToday;
                }
            }
            catch (Exception ex) { ex.Log(); synth.SpeakAsyncCancelAll(); synth.SpeakFaF($"Something is not right: {ex.Message}. Talk to you later"); }

            DoneToday = doneToday;
            ExrzeRuns = sinceRcrd;
            TodoToday = todoToday;
        }