Exemple #1
0
        void saveNewCastsToDb(Feed feed, RssHelper rssFeed)
        {
            int newCasts = 0;

            foreach (var rss in rssFeed.RssDnldInfos)
            {
                //Application.Current.Dispatcher.BeginInvoke(new Action(() =>  { // new Func<bool>(() => //tu: new Action(() =>

                DnLd dl;
                if (SaveToDnldRow_IsDnldRequired(feed, rss, out dl))
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        if (!CurrentDnLds.Contains(dl))
                        {
                            CurrentDnLds.Add(dl);
                        }
                    }));

                    newCasts++;

                    //? better wait for all feeds check to finish and then move on to dnlding: if (IsAutoNextStep) Dh.StartDownload(db, dl, dgD);					//Dh.LaunchIfDownloadRequiredMvvm(dl, ((DataGrid)dgD));
                }
                //}));
            }
            feed.CastQntNew    = newCasts;
            feed.CastQntTtl    = rssFeed.RssDnldInfos.Count;
            feed.StatusInfo    = $"{newCasts} / {rssFeed.RssDnldInfos.Count}"; //update feed with counts of new casts
            feed.LastCheckedAt = _now;
        }
Exemple #2
0
        void refilterLoaclToFiltered()
        {
            var sw      = Stopwatch.StartNew();
            var matches = Db.DnLds.Local
                          .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)
                          .Take(_maxRows);

            Debug.WriteLine($"{"Dnlds filtered"} - Loaded in {sw.Elapsed:s\\.f} sec, matches {matches.Count()}");

            CurrentDnLds.ClearAddRangeAuto(matches);
        }
Exemple #3
0
        void onDnldOne(object dgD)
        {
            Bpr.BeepOk();

            SelectedDnLd.ReDownload = true;

            //Application.Current.Dispatcher.BeginInvoke(new Action(() =>			{
            if (!CurrentDnLds.Contains(SelectedDnLd))
            {
                CurrentDnLds.Add(SelectedDnLd);
            }
            //}));

            onStartDnlds(dgD);             // StartDownload(SelectedDnLd, ((DataGrid)dgD));
        }
Exemple #4
0
        void CheckFeedAsync(DataGrid dgF, Feed feed, DataGrid dgD)
        {
            Task.Run(() =>
            {
                lock (thisLock) { var i = TtlFeedsToCheck; Interlocked.Increment(ref i); TtlFeedsToCheck = i; }
                CheckFeedSynch(dgF, feed);
            }).ContinueWith(_ =>
            {
                lock (thisLock) { var i = TtlFeedsToCheck; Interlocked.Decrement(ref i); TtlFeedsToCheck = i; }

                if (dgF != null)
                {
                    dgF.Items.Refresh();
                }

                if (TtlFeedsToCheck == 0)
                {
                    onSaveChanges(null);

                    var unavail = Db.DnLds.Where(r => r.AvailableLastDate != DateTime.Today);
                    InfoApnd    =
                        $"Check of all feeds has finished. loaded {Db.DnLds. Count()} download rows; {unavail.Count()} unavailable; {Db.DnLds. Count() - unavail.Count()} available";
                    unavail.ToList().ForEach(r => r.IsStillOnline = false);

                    Task.Delay(10000);

                    if (IsAutoNextStep)
                    {
                        if (CurrentDnLds.Count() > 0)
                        {
                            InfoApnd = $"{DateTime.Now:ddd HH:mm}			Starting {CurrentDnLds.Count()} downloads now.";
                            onStartDnlds(dgD);
                        }
                        else
                        {
                            InfoApnd = $"{DateTime.Now:ddd HH:mm}			Ready to be closed.";
                        }
                    }
                    else
                    {
                        InfoApnd =
                            $"Check of all feeds has finished; found {CurrentDnLds.Count()} downloads to do. Downloading needs to be started manually!";
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Exemple #5
0
        void onLoadExistingAudioFiles(object notUsed)
        {
            if (!Directory.Exists(MiscHelper.DirPlyr))
            {
                Directory.CreateDirectory(MiscHelper.DirPlyr);
            }

            foreach (var file in Directory.GetFiles(MiscHelper.DirPlyr))
            {
                if (!".m4a.mp3.wma.wav".Contains(Path.GetExtension(file).ToLower()))
                {
                    continue;
                }

                Debug.WriteLine(file, "Load FS exist-g");

                if (CurrentDnLds.FirstOrDefault(r => file.Contains(r.CastFilenameExt)) != null)
                {
                    continue;                                                                                             // already there
                }
                var t = Db.DnLds.FirstOrDefault(r => file.Contains(r.CastFilenameExt));
                if (t == null)
                {
                    Db.DnLds.Where(r => file.Contains(r.CastFilenameExt)).OrderByDescending(r => r.PublishedAt).Load();

                    t = Db.DnLds.FirstOrDefault(r => file.Contains(r.CastFilenameExt));
                    if (t == null)
                    {
                        t = Db.DnLds.FirstOrDefault(r => file.Contains(r.CastFilenameExt));
                    }
                    if (t == null)
                    {
                        Debug.WriteLine("   not in _db yet; strange.");
                    }
                }

                if (t != null)
                {
                    CurrentDnLds.Add(t);
                }
            }

            Bpr.BeepOk();
        }
Exemple #6
0
        void onDeleteOne(object dgH)
        {
            Bpr.BeepOk();

            //Application.Current.Dispatcher.BeginInvoke(new Action(() =>			{
            if (CurrentDnLds.Contains(SelectedDnLd))
            {
                CurrentDnLds.Remove(SelectedDnLd);
            }

            var td = db.DnLds.FirstOrDefault(r => r.Id == SelectedDnLd.Id);

            if (td != null)
            {
                db.DnLds.Remove(td);
            }

            SelectedDnLd = null;
            //}));
        }