Ejemplo n.º 1
0
        async Task addUPdate_SetIdrFlag(Feed feed, List <RssDnldInfo> rdis)
        {
            try
            {
                feed.RunTimeNote  = $"{rdis.Count:N0} casts in RSS. ";
                feed.NewCastCount = 0;
                foreach (var rdi in rdis.OrderByDescending(r => r.Published))
                {
                    var dnld = await dnLd_AddOrUpdate(feed, rdi);

                    if (dnld != null)
                    {
                        dnld.ReDownload = PodCatcherViewModel.IsDownloadRequiredWrpr(dnld);
                        if (dnld.ReDownload)
                        {
                            feed.NewCastCount++;
                        }
                    }
                    Val2++;//Appender += "·";          Bpr.BeepFD(14000, 55);
                }
                feed.CastQntNew = feed.NewCastCount;
                feed.CastQntTtl = rdis.Count;
                feed.StatusInfo = $"{feed.NewCastCount} / {rdis.Count}"; //update feed with counts of new casts
            }
            catch (Exception ex) { ex.Log(); throw; }
        }
Ejemplo n.º 2
0
        async Task <DnLd> dnLd_AddOrUpdate(Feed feed, RssDnldInfo rss)
        {
            //await Task.Delay(3); //todo: resolve:   A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context. Any instance members are not guaranteed to be thread safe.
            try
            {
                var existingLcRow = await _db.DnLds.FirstOrDefaultAsync(r => string.Compare(r.CastUrl, rss.OrgSrcUrl, true) == 0); // ??        _db.DnLds.FirstOrDefault(r => string.Compare(r.CastUrl, rss.OrgSrcUrl, true) == 0);    //cast url is unique in DB (as of Jan 2015)

                if (existingLcRow == null)
                {
                    var dnld = new DnLd
                    {
                        CastFileLength  = rss.CastFileLen,
                        CastFilenameExt = rss.CasFilename,
                        CastSummary     = PodCatcherViewModel.safeLen(rss.CastSumry, 2048).Replace("\n\n", Environment.NewLine), // string.IsNullOrEmpty(rss.CastSumry) ? "" : rss.CastSumry.Length >= 1023 ? rss.CastSumry.Substring(0, 1023) : rss.CastSumry,
                        CastTitle       = rss.CastTitle,
                        CastUrl         = rss.OrgSrcUrl,
                        DnldStatusId    = "N",
                        FeedId          = feed.Id,
                        Feed            = feed,
                        IsDownloading   = false,
                        PublishedAt     = rss.Published,
                        ModifiedAt      = _crlnTS,
                        RowAddedAt      = _crlnTS,
                        RowAddedByPC    = Environment.MachineName,
                        ErrLog          = PodCatcherViewModel.safeLen(string.IsNullOrWhiteSpace(rss.AltSrcUrl) ? "" :
                                                                      $"{rss.AltSrcUrl} :alt|org: \r\n{rss.OrignLink}", 1000),
                        DurationMin       = rss.TtlMinuts,
                        TrgFileSortPrefix = "",
                        AvailableLastDate = DateTime.Today,
                        IsStillOnline     = true,
                        DownloadedAt      = null,
                        RunTimeNote       = "New  DnLd row",
                    };

                    _db.DnLds.Add(dnld);

                    return(dnld);
                }
                else
                {
                    PodCatcherViewModel.UpdateDbRowWhereChanged(rss, existingLcRow);
                    return(existingLcRow);
                }
            }
            catch (Exception ex) { ex.Log(); }
            return(null);
        }