Пример #1
0
        public PodCatcherViewModel(bool countDown = true)
        {
            Bpr.Beep1of2();

            CurVer = VerHelper.CurVerStr(A0DbContext.SqlEnv); //bool isDay0; if (bool.TryParse(MiscDataHelper.GetSetting("daq", "IsDay0", "True", "Directive flag to run all tasks in Full or Daily/Delta mode.").SValue, out isDay0))IsDay0 = isDay0;

            IsAutoNextStep = countDown;

            Task.Run(() => Thread.Sleep(1))
            .ContinueWith(async _ => await reLoad(), TaskScheduler.FromCurrentSynchronizationContext())
            .ContinueWith(_ =>
            {
#if !SkipCountDown
                if (IsAutoNextStep)
                {
                    Bpr.BeepOkB();
                }
                Thread.Sleep(1000);
                if (IsAutoNextStep)
                {
                    Bpr.BeepFD(9000, 200);
                }
                Thread.Sleep(1000);
                if (IsAutoNextStep)
                {
                    Bpr.BeepFD(8600, 200);
                }
                Thread.Sleep(1000);
                if (IsAutoNextStep)
                {
                    Bpr.BeepFD(8300, 200);
                }
                Thread.Sleep(1000);
                if (IsAutoNextStep)
                {
                    Bpr.BeepFD(8000, 600);
                }
                Thread.Sleep(1000);
                if (IsAutoNextStep)
                {
                    Bpr.BeepFD(7000, 200);
                }
                Thread.Sleep(5);
                if (IsAutoNextStep)
                {
                    Bpr.BeepFD(7000, 200);
                }
#endif
            })
            .ContinueWith(_ => { if (IsAutoNextStep)
                                 {
                                     onDoAll(null);
                                 }
                          }, TaskScheduler.FromCurrentSynchronizationContext())
            .ContinueWith(_ => Bpr.Beep2of2(), TaskScheduler.FromCurrentSynchronizationContext());
        }
        async Task filterStart(string csvFilterString)
        {
            if (!_loaded)
            {
                return;
            }

            Debug.WriteLine($"■■■ filterStart()");

            App.Synth.SpeakAsyncCancelAll();
            Bpr.BeepFD(12000, 33); // wake monitor speakers

            await reLoadTxCore();

            if (string.IsNullOrEmpty(csvFilterString))
            {
                App.Synth.SpeakAsync("Clear!");
                filterTxns(csvFilterString, _txCatgry);
            }
            else
            {
                var ta = csvFilterString.Split(new[] { '`', '>', '\\', '/' });
                if (ta.Length > 1)
                {
                    App.Synth.SpeakAsync($"{ta.Length}-part filter");

                    if (string.IsNullOrEmpty(ta[0]) && string.IsNullOrEmpty(ta[1]))
                    {
                        App.Synth.SpeakAsync("Still Empty."); return;
                    }
                    if (!string.IsNullOrEmpty(ta[0]))
                    {
                        if (!decimal.TryParse(ta[0], out var amt))
                        {
                            App.Synth.SpeakAsync("1st must be number."); return;
                        }

                        if (!decimal.TryParse(tRng.Text, out var rng))
                        {
                            tRng.Text = (rng = 0m).ToString();
                        }
                        //App.Synth.SpeakAsync("Multi.");
                        filterTxns(csvFilterString.Substring(ta[0].Length + 1), _txCatgry, amt, rng);
                    }
                    else if (!string.IsNullOrEmpty(ta[1])) // explicit by string
                    {
                        //App.Synth.SpeakAsync("Filter by text.");
                        filterTxns(ta[1], _txCatgry);
                    }
                }
                else // == 1
                {
                    if (decimal.TryParse(csvFilterString, out var amt))
                    {
                        if (!decimal.TryParse(tRng.Text, out var rng))
                        {
                            tRng.Text = (rng = 0m).ToString();
                        }
                        //App.Synth.SpeakAsync("Filter by money.");
                        filterTxns("", _txCatgry, amt, rng);
                    }
                    else
                    {
                        //App.Synth.SpeakAsync("Filter by text.");
                        filterTxns(csvFilterString, _txCatgry);
                    }
                }
            }

            _txCoreV2_Root_VwSrc.Source = _core;

            if (chkInfer.IsChecked == true)
            {
                var catIds = _core.Select(r => r.TxCategory.Id).Distinct().Where(r => r != 3); // Debug.WriteLine($"catIds.Count() = {catIds.Count()}");
                filterCategoryByIdList(catIds);
            }

            updateTitle();
            Bpr.OkFaF();
        }