public MainWindow()
        {
            InitializeComponent();
            Bpr.Beep1of2();

            themeSelector1.ApplyTheme = ApplyTheme;
        }
Пример #2
0
        async Task <int> onLoadList_(object ___notUsed___)
        {
            Bpr.Beep1of2();

            var sw = Stopwatch.StartNew();

            Task <int> task = Task.Run(() => { _db.MediaUnits.Take(7).Load(); return(_db.MediaUnits.Local.Count()); }); //{ Task.Delay(3333); return DateTime .Now.Millisecond; });

            await task.ContinueWith(_ =>
            {
                PlayList.ClearAddRange(_db.MediaUnits.Local);
                if (PlayList.Count() > 0)
                {
                    CurMediaUnit = PlayList[0];
                    onTglPlayPause(___notUsed___);
                }

                TopLefttInfo = $"{PlayList.Count()} songs loaded in {.001 * sw.ElapsedMilliseconds:N1} sec. ";
                Bpr.Beep2of2();
            }, TaskScheduler.FromCurrentSynchronizationContext());

            int ttlRows = await task;

            TopLefttInfo = $"{PlayList.Count()} songs loaded in {.001 * sw.ElapsedMilliseconds:N1} sec. ";

            //await _db.MediaUnits.Take(7).LoadAsync();


            return(ttlRows);
        }
Пример #3
0
 void onRefreshFeeds(object dgF)
 {
     Bpr.Beep1of2();
     ((DataGrid)dgF).Items.Refresh();
     InfoApnd =
         $"{"Feed:Db/Lcl, DnLd:Db/Lcl"}  {Db.Feeds.Count()}/{Db.Feeds. Count()},   {Db.DnLds.Count()}/{Db.DnLds. Count()},   filt.dnld: {CurrentDnLds.Count}";
     Bpr.Beep2of2();
 }
Пример #4
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());
        }
Пример #5
0
 void onRefreshDgH(object dgH)
 {
     Bpr.Beep1of2();
     Debug.WriteLine("::> {1}, {2},   {3}, {4}, filt.dnld: {5}", "", Db.Feeds.Count(), Db.Feeds.Count(), Db.DnLds.Count(), Db.DnLds.Count(), CurrentDnLds.Count);
     ((DataGrid)dgH).Items.Refresh();
     Debug.WriteLine("::> {1}, {2},   {3}, {4}, filt.dnld: {5}", "", Db.Feeds.Count(), Db.Feeds.Count(), Db.DnLds.Count(), Db.DnLds.Count(), CurrentDnLds.Count);
     InfoApnd =
         $"{"Feed:Db/Lcl, DnLd:Db/Lcl"}  {Db.Feeds.Count()}/{Db.Feeds. Count()},   {Db.DnLds.Count()}/{Db.DnLds. Count()},   filt.dnld: {CurrentDnLds.Count}";
     Bpr.Beep2of2();
 }
Пример #6
0
        void onChkSelectFeed(object pnl1)
        {
            Bpr.Beep1of2();

            var dgF = ((Grid)pnl1).FindName("dgF") as DataGrid;
            var dgD = ((Grid)pnl1).FindName("dgD") as DataGrid;

            CheckFeedSynch(((DataGrid)dgF), SelectedFeed);
            //((DataGrid)dg).Items.Refresh();

            //Db.DnLds.Where(r => r.ReDownload || (r.DownloadedAt == null && r.PublishedAt > new DateTime(2013, 11, 22) && string.Compare(r.Feed.HostMachineId , Environment.MachineName, true) == 0)).OrderByDescending(r => r.PublishedAt).Load();
            //			refilterLoaclToFiltered();
            Bpr.Beep2of2();
        }
Пример #7
0
        async Task <int> onLoadList__(object ___notUsed___)
        {
            Bpr.Beep1of2();
            var sw      = Stopwatch.StartNew();
            int ttlRows = await Task.Run(() => { _db.MediaUnits.Take(7).Load(); return(_db.MediaUnits.Local.Count()); }); //{ Task.Delay(3333); return DateTime .Now.Millisecond; });

            PlayList.ClearAddRange(_db.MediaUnits.Local);
            if (PlayList.Count() > 0)
            {
                CurMediaUnit = PlayList[0];
            }

            TopLefttInfo = $"{PlayList.Count()} songs loaded in {.001 * sw.ElapsedMilliseconds:N1} sec. ";
            Bpr.Beep2of2();

            return(ttlRows);
        }
Пример #8
0
        public async Task <int> LoadLkus()
        {
            Bpr.Beep1of2();
            var sw          = Stopwatch.StartNew();
            int genresCount = await Task.Run(() => { _db.LkuGenres.Load(); return(_db.LkuGenres.Local.Count()); });

            Genres.ClearAddRange(_db.LkuGenres.Local);
            if (Genres.Count() > 0)
            {
                CurGenre = _db.LkuGenres.First(r => r.Name == "All");
            }

            TopLefttInfo = $"{Genres.Count()} genres loaded in {.001 * sw.ElapsedMilliseconds:N1} sec. ";

            var ttlMU = await LoadList();

            Bpr.Beep2of2();
            return(genresCount);
        }
Пример #9
0
 async Task onDnldCast(object x)
 {
     Bpr.Beep1of2(); canDnldCast = false; await Task.Delay(9); /*Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri)); */ Bpr.Beep2of2(); canDnldCast = true;
 }
Пример #10
0
 async Task onGenerateAnonces(object x)
 {
     Bpr.Beep1of2(); canGenerateAnoncesProp = false; await PostDnldHelper.GenerateAllAndFolderAnons(Db, MiscHelper.DirPlr2); Bpr.Beep2of2(); canGenerateAnoncesProp = true;
 }
        async Task migrate(A0DbMdl db)
        {
            Bpr.Beep1of2();
            var obsVm = JsonFileSerializer.Load <ObsMainVM>(MainVM.MainVmJsonFile) as ObsMainVM;

            if (obsVm == null)
            {
                MessageBox.Show("No Go");
            }
            else
            {
                var srFromJsonWithNote = obsVm.SnRts.Where(r => !string.IsNullOrEmpty(r.Notes));

                try
                {
                    if (db.SessionResults.Any(r => r.Note != null && (r.Note == "zz" || r.Note.StartsWith("from fs at"))))
                    {
                        db.SessionResults.Where(r => r.Note != null && (r.Note == "zz" || r.Note.StartsWith("from fs at"))).ToList().ForEach(r => r.Note = "");
                    }

                    tbInfo.Text = $"Json: \t{obsVm.SnRts.Length} total runs incl-g {srFromJsonWithNote.Count()} with note;\r\nDB: \t{db.SessionResults.Count()} \r\n";
                    Debug.WriteLine($"::>{tbInfo.Text}");

                    await Task.Yield();

                    Bpr.BeepClk();

                    int brandNew = 0, noMatchesInDb = 0, alreadySame = 0, updated = 0;

                    foreach (var srjs in obsVm.SnRts)
                    {
                        var srdb0 = db.SessionResults.FirstOrDefault(d =>
                                                                     d.UserId == srjs.UserId &&
                                                                     d.Duration == srjs.Duration /*drn(srjs.Duration)*/ &&
                                                                     d.ExcerciseName == srjs.ExcerciseName &&
                                                                     d.PokedIn == srjs.PokedIn &&
                                                                     Math.Abs((d.DoneAt - srjs.DoneAt.DateTime.AddMinutes(srjs.DoneAt.OffsetMinutes)).TotalSeconds) < 5);
                        if (srdb0 == null)
                        {
                            db.SessionResults.Add(new SessionResult
                            {
                                DoneAt        = srjs.DoneAt.DateTime.AddMinutes(srjs.DoneAt.OffsetMinutes),
                                UserId        = srjs.UserId,
                                Duration      = srjs.Duration /*drn(srjs.Duration)*/,
                                ExcerciseName = srjs.ExcerciseName,
                                PokedIn       = srjs.PokedIn,
                                Note          = srjs.Notes
                            });
                            brandNew++;
                        }
                    }

                    try
                    {
                        foreach (var srjs in srFromJsonWithNote)
                        {
                            var srdb2 = db.SessionResults.FirstOrDefault(d => Math.Abs((d.DoneAt - srjs.DoneAt.DateTime.AddMinutes(srjs.DoneAt.OffsetMinutes)).TotalSeconds) < 5);
                            if (srdb2 == null)
                            {
                                db.SessionResults.Add(new SessionResult
                                {
                                    DoneAt        = srjs.DoneAt.DateTime.AddMinutes(srjs.DoneAt.OffsetMinutes),
                                    UserId        = srjs.UserId,
                                    Duration      = srjs.Duration /*drn(srjs.Duration)*/,
                                    ExcerciseName = srjs.ExcerciseName,
                                    PokedIn       = srjs.PokedIn,
                                    Note          = srjs.Notes
                                });
                                noMatchesInDb++;
                            }
                            else
                            {
                                if (srjs.Notes.Equals(srdb2.Note))
                                {
                                    alreadySame++;
                                }
                                else
                                {
                                    updated++;
                                    srdb2.Note = srjs.Notes;
                                }
                            }
                        }
                    }
                    catch (Exception ex) { Debug.WriteLine(ex); }


                    tbInfo.Text += $" brandNew {brandNew}, notFoundInDb {noMatchesInDb }, alreadySame {alreadySame }, updated {updated}\n";
                    Debug.WriteLine($"::>{tbInfo.Text}");

                    var rv = await db.TrySaveReportAsync();

                    tbInfo.Text += $" {rv}";
                    Bpr.Beep2of2();
                }
                catch (Exception ex) { tbEror.Text = ex.Log(); }
                finally { new DbExplorer2().Show(); }
            }
        }
Пример #12
0
 async void onDbSave(object sender, RoutedEventArgs e)
 {
     Bpr.Beep1of2(); tbInfo.Text = (await _db.TrySaveReportAsync()).report; Bpr.Beep2of2();
 }