Exemplo n.º 1
0
        public void DeleteAllErroredFiles()
        {
            if (ActiveScan == null)
            {
                return;
            }
            var files = ActiveErrorFiles.ToList();

            ActiveErrorFiles.Clear();
            HashSet <SVR_AnimeEpisode> episodesToUpdate = new HashSet <SVR_AnimeEpisode>();
            HashSet <SVR_AnimeSeries>  seriesToUpdate   = new HashSet <SVR_AnimeSeries>();

            files.ForEach(file =>
            {
                SVR_VideoLocal_Place place = Repo.Instance.VideoLocal_Place.GetByID(file.VideoLocal_Place_ID);
                place.RemoveAndDeleteFileWithOpenTransaction(episodesToUpdate, seriesToUpdate);
            });
            // update everything we modified
            Repo.Instance.AnimeEpisode.BatchAction(episodesToUpdate, episodesToUpdate.Count, (ep, _) => {
                if (ep.AnimeEpisodeID == 0)
                {
                    ep.PlexContract = null;
                }
                try
                {
                    ep.PlexContract = Helper.GenerateVideoFromAnimeEpisode(ep);
                }
                catch (Exception ex)
                {
                    LogManager.GetCurrentClassLogger().Error(ex, ex.ToString());
                }
            });

            Repo.Instance.ScanFile.Delete(files);
        }
Exemplo n.º 2
0
        public void DeleteAllErroredFiles()
        {
            if (ActiveScan == null)
            {
                return;
            }
            var files = ActiveErrorFiles.ToList();

            ActiveErrorFiles.Clear();
            HashSet <SVR_AnimeEpisode> episodesToUpdate = new HashSet <SVR_AnimeEpisode>();
            HashSet <SVR_AnimeSeries>  seriesToUpdate   = new HashSet <SVR_AnimeSeries>();

            using (var session = DatabaseFactory.SessionFactory.OpenSession())
            {
                files.ForEach(file =>
                {
                    SVR_VideoLocal_Place place = RepoFactory.VideoLocalPlace.GetByID(file.VideoLocal_Place_ID);
                    place.RemoveAndDeleteFileWithOpenTransaction(session, seriesToUpdate);
                });
                // update everything we modified
                foreach (SVR_AnimeSeries ser in seriesToUpdate)
                {
                    ser?.QueueUpdateStats();
                }
            }
            RepoFactory.ScanFile.Delete(files);
        }
Exemplo n.º 3
0
        public void DeleteAllErroredFiles()
        {
            if (ActiveScan == null)
            {
                return;
            }
            var files = ActiveErrorFiles.ToList();

            ActiveErrorFiles.Clear();
            HashSet <SVR_AnimeEpisode> episodesToUpdate = new HashSet <SVR_AnimeEpisode>();
            HashSet <SVR_AnimeSeries>  seriesToUpdate   = new HashSet <SVR_AnimeSeries>();

            using (var session = DatabaseFactory.SessionFactory.OpenSession())
            {
                files.ForEach(file =>
                {
                    SVR_VideoLocal_Place place = RepoFactory.VideoLocalPlace.GetByID(file.VideoLocal_Place_ID);
                    place.RemoveAndDeleteFileWithOpenTransaction(session, episodesToUpdate, seriesToUpdate);
                });
                // update everything we modified
                foreach (SVR_AnimeEpisode ep in episodesToUpdate)
                {
                    if (ep.AnimeEpisodeID == 0)
                    {
                        ep.PlexContract = null;
                        RepoFactory.AnimeEpisode.Save(ep);
                    }
                    try
                    {
                        ep.PlexContract = Helper.GenerateVideoFromAnimeEpisode(ep);
                        RepoFactory.AnimeEpisode.SaveWithOpenTransaction(session, ep);
                    }
                    catch (Exception ex)
                    {
                        LogManager.GetCurrentClassLogger().Error(ex, ex.ToString());
                    }
                }
                foreach (SVR_AnimeSeries ser in seriesToUpdate)
                {
                    ser.QueueUpdateStats();
                }
            }
            RepoFactory.ScanFile.Delete(files);
        }