Пример #1
0
 public void DeleteFileFromMyList(int fileID)
 {
     CommandRequest_DeleteFileFromMyList cmd = new CommandRequest_DeleteFileFromMyList(fileID);
     cmd.Save();
 }
Пример #2
0
        /// <summary>
        /// Delets the VideoLocal record and the associated physical file
        /// </summary>
        /// <param name="videoLocalID"></param>
        /// <returns></returns>
        public string DeleteVideoLocalAndFile(int videoLocalID)
        {
            try
            {
                VideoLocalRepository repVids = new VideoLocalRepository();
                VideoLocal vid = repVids.GetByID(videoLocalID);
                if (vid == null) return "Database entry does not exist";

                logger.Info("Deleting video local record and file: {0}", vid.FullServerPath);
                if (File.Exists(vid.FullServerPath))
                {
                    try
                    {
                        File.Delete(vid.FullServerPath);
                    }
                    catch { }
                }

                AnimeSeries ser = null;
                List<AnimeEpisode> animeEpisodes = vid.GetAnimeEpisodes();
                if (animeEpisodes.Count > 0)
                    ser = animeEpisodes[0].GetAnimeSeries();

                CommandRequest_DeleteFileFromMyList cmdDel = new CommandRequest_DeleteFileFromMyList(vid.Hash, vid.FileSize);
                cmdDel.Save();

                repVids.Delete(videoLocalID);

                if (ser != null)
                {
                    ser.QueueUpdateStats();
                    //StatsCache.Instance.UpdateUsingSeries(ser.AnimeSeriesID);
                }

                // For deletion of files from Trakt, we will rely on the Daily sync

                return "";
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return ex.Message;
            }
        }
Пример #3
0
        /// <summary>
        /// Delete a series, and everything underneath it (episodes, files)
        /// </summary>
        /// <param name="animeSeriesID"></param>
        /// <param name="deleteFiles">also delete the physical files</param>
        /// <returns></returns>
        public string DeleteAnimeSeries(int animeSeriesID, bool deleteFiles, bool deleteParentGroup)
        {
            try
            {
                AnimeEpisodeRepository repEps = new AnimeEpisodeRepository();
                AnimeSeriesRepository repAnimeSer = new AnimeSeriesRepository();
                VideoLocalRepository repVids = new VideoLocalRepository();
                AnimeGroupRepository repGroups = new AnimeGroupRepository();

                AnimeSeries ser = repAnimeSer.GetByID(animeSeriesID);
                if (ser == null) return "Series does not exist";

                int animeGroupID = ser.AnimeGroupID;

                foreach (AnimeEpisode ep in ser.GetAnimeEpisodes())
                {
                    foreach (VideoLocal vid in ep.GetVideoLocals())
                    {
                        if (deleteFiles)
                        {
                            logger.Info("Deleting video local record and file: {0}", vid.FullServerPath);
                            if (!File.Exists(vid.FullServerPath)) return "File could not be found";
                            File.Delete(vid.FullServerPath);
                        }
                        CommandRequest_DeleteFileFromMyList cmdDel = new CommandRequest_DeleteFileFromMyList(vid.Hash, vid.FileSize);
                        cmdDel.Save();

                        repVids.Delete(vid.VideoLocalID);
                    }

                    repEps.Delete(ep.AnimeEpisodeID);
                }
                repAnimeSer.Delete(ser.AnimeSeriesID);

                // finally update stats
                AnimeGroup grp = repGroups.GetByID(animeGroupID);
                if (grp != null)
                {
                    if (grp.GetAllSeries().Count == 0)
                    {
                        DeleteAnimeGroup(grp.AnimeGroupID, false);
                    }
                    else
                    {
                        grp.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
                        StatsCache.Instance.UpdateUsingGroup(grp.TopLevelAnimeGroup.AnimeGroupID);
                    }
                }

                return "";

            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return ex.Message;
            }
        }
Пример #4
0
        public void RemoveMissingMyListFiles(List<Contract_MissingFile> myListFiles)
        {
            foreach (Contract_MissingFile missingFile in myListFiles)
            {
                CommandRequest_DeleteFileFromMyList cmd = new CommandRequest_DeleteFileFromMyList(missingFile.FileID);
                cmd.Save();

                // For deletion of files from Trakt, we will rely on the Daily sync
                // lets also try removing from the users trakt collecion

            }
        }
Пример #5
0
		public void RemoveMissingMyListFiles(List<Contract_MissingFile> myListFiles)
		{
			foreach (Contract_MissingFile missingFile in myListFiles)
			{
				CommandRequest_DeleteFileFromMyList cmd = new CommandRequest_DeleteFileFromMyList(missingFile.FileID);
				cmd.Save();
			}
		}
        /// <summary>
        /// Delets the VideoLocal record and the associated physical file
        /// </summary>
        /// <param name="videoLocalID"></param>
        /// <returns></returns>
        public string DeleteVideoLocalPlaceAndFile(int videolocalplaceid)
        {
            try
            {
                VideoLocal_Place place = RepoFactory.VideoLocalPlace.GetByID(videolocalplaceid);
                if ((place==null) || (place.VideoLocal==null))
                    return "Database entry does not exist";
                VideoLocal vid = place.VideoLocal;
                logger.Info("Deleting video local record and file: {0}", place.FullServerPath);

                IFileSystem fileSystem = place.ImportFolder.FileSystem;
                if (fileSystem == null)
                {
                    logger.Error("Unable to delete file, filesystem not found");
                    return "Unable to delete file, filesystem not found";
                }
                FileSystemResult<IObject> fr = fileSystem.Resolve(place.FullServerPath);
                if (fr == null || !fr.IsOk)
                {
                    logger.Error($"Unable to find file '{place.FullServerPath}'");
                    return $"Unable to find file '{place.FullServerPath}'";
                }
                IFile file = fr.Result as IFile;
                if (file == null)
                {
                    logger.Error($"Seems '{place.FullServerPath}' is a directory");
                    return $"Seems '{place.FullServerPath}' is a directory";

                }
                FileSystemResult fs = file.Delete(true);
                if (fs == null || !fs.IsOk)
                {
                    logger.Error($"Unable to delete file '{place.FullServerPath}'");
                    return $"Unable to delete file '{place.FullServerPath}'";
                }
                if (place.VideoLocal.Places.Count > 1)
                    return "";
                AnimeSeries ser = null;
                List<AnimeEpisode> animeEpisodes = vid.GetAnimeEpisodes();
                if (animeEpisodes.Count > 0)
                    ser = animeEpisodes[0].GetAnimeSeries();

                CommandRequest_DeleteFileFromMyList cmdDel = new CommandRequest_DeleteFileFromMyList(vid.Hash, vid.FileSize);
                cmdDel.Save();
                RepoFactory.VideoLocalPlace.Delete(place.VideoLocal_Place_ID);
                RepoFactory.VideoLocal.Delete(vid.VideoLocalID);
                if (ser != null)
                {
                    ser.QueueUpdateStats();
                }

                // For deletion of files from Trakt, we will rely on the Daily sync

                return "";
            }
            catch (Exception ex)
            {
                logger.Error( ex,ex.ToString());
                return ex.Message;
            }
        }
        /// <summary>
        /// Delete a series, and everything underneath it (episodes, files)
        /// </summary>
        /// <param name="animeSeriesID"></param>
        /// <param name="deleteFiles">also delete the physical files</param>
        /// <returns></returns>
        public string DeleteAnimeSeries(int animeSeriesID, bool deleteFiles, bool deleteParentGroup)
        {
            try
            {
                AnimeSeries ser = RepoFactory.AnimeSeries.GetByID(animeSeriesID);
                if (ser == null) return "Series does not exist";

                int animeGroupID = ser.AnimeGroupID;

                foreach (AnimeEpisode ep in ser.GetAnimeEpisodes())
                {
                    foreach (VideoLocal vid in ep.GetVideoLocals())
                    {
                        foreach (VideoLocal_Place place in vid.Places)
                        {
                            if (deleteFiles)
                            {
                                logger.Info("Deleting video local record and file: {0}", place.FullServerPath);
                                IFileSystem fileSystem = place.ImportFolder.FileSystem;
                                if (fileSystem == null)
                                {
                                    logger.Error("Unable to delete file, filesystem not found");
                                    return "Unable to delete file, filesystem not found";
                                }
                                FileSystemResult<IObject> fr = fileSystem.Resolve(place.FullServerPath);
                                if (fr == null || !fr.IsOk)
                                {
                                    logger.Error($"Unable to find file '{place.FullServerPath}'");
                                    return $"Unable to find file '{place.FullServerPath}'";
                                }
                                IFile file = fr.Result as IFile;
                                if (file == null)
                                {
                                    logger.Error($"Seems '{place.FullServerPath}' is a directory");
                                    return $"Seems '{place.FullServerPath}' is a directory";

                                }
                                FileSystemResult fs = file.Delete(true);
                                if (fs == null || !fs.IsOk)
                                {
                                    logger.Error($"Unable to delete file '{place.FullServerPath}'");
                                    return $"Unable to delete file '{place.FullServerPath}'";
                                }
                            }
                            RepoFactory.VideoLocalPlace.Delete(place.VideoLocal_Place_ID);
                        }
                        CommandRequest_DeleteFileFromMyList cmdDel = new CommandRequest_DeleteFileFromMyList(vid.Hash, vid.FileSize);
                        cmdDel.Save();
                        RepoFactory.VideoLocal.Delete(vid.VideoLocalID);
                    }
                    RepoFactory.AnimeEpisode.Delete(ep.AnimeEpisodeID);
                }
                RepoFactory.AnimeSeries.Delete(ser.AnimeSeriesID);

                // finally update stats
                AnimeGroup grp = RepoFactory.AnimeGroup.GetByID(animeGroupID);
                if (grp != null)
                {
                    if (grp.GetAllSeries().Count == 0)
                    {
                        DeleteAnimeGroup(grp.AnimeGroupID, false);
                    }
                    else
                    {
                        grp.TopLevelAnimeGroup.UpdateStatsFromTopLevel(true, true, true);
                        //StatsCache.Instance.UpdateUsingGroup(grp.TopLevelAnimeGroup.AnimeGroupID);
                    }
                }

                return "";
            }
            catch (Exception ex)
            {
                logger.Error( ex,ex.ToString());
                return ex.Message;
            }
        }
Пример #8
0
		public static void RemoveRecordsWithoutPhysicalFiles()
		{
			VideoLocalRepository repVidLocals = new VideoLocalRepository();
			CrossRef_File_EpisodeRepository repXRefs = new CrossRef_File_EpisodeRepository();

			// get a full list of files
			List<VideoLocal> filesAll = repVidLocals.GetAll();
			foreach (VideoLocal vl in filesAll)
			{
				if (!File.Exists(vl.FullServerPath))
				{
					// delete video local record
					logger.Info("RemoveRecordsWithoutPhysicalFiles : {0}", vl.FullServerPath);
					repVidLocals.Delete(vl.VideoLocalID);

					CommandRequest_DeleteFileFromMyList cmdDel = new CommandRequest_DeleteFileFromMyList(vl.Hash, vl.FileSize);
					cmdDel.Save();
				}
			}

			UpdateAllStats();
		}
Пример #9
0
        public static void RemoveRecordsWithoutPhysicalFiles()
        {
            // get a full list of files
            Dictionary<ImportFolder, List<VideoLocal_Place>> filesAll = RepoFactory.VideoLocalPlace.GetAll().GroupBy(a => a.ImportFolder).ToDictionary(a => a.Key, a => a.ToList());
            foreach (ImportFolder folder in filesAll.Keys)
            {
                IFileSystem fs = folder.FileSystem;

                foreach (VideoLocal_Place vl in filesAll[folder])
                {
                    FileSystemResult<IObject> obj = fs.Resolve(vl.FullServerPath);
                    if (!obj.IsOk || obj.Result is IDirectory)
                    {
                        VideoLocal v = vl.VideoLocal;
                        // delete video local record
                        logger.Info("RemoveRecordsWithoutPhysicalFiles : {0}", vl.FullServerPath);
                        if (v.Places.Count == 1)
                        {
                            RepoFactory.VideoLocalPlace.Delete(vl.VideoLocal_Place_ID);
                            RepoFactory.VideoLocal.Delete(v.VideoLocalID);
                            CommandRequest_DeleteFileFromMyList cmdDel = new CommandRequest_DeleteFileFromMyList(v.Hash, v.FileSize);
                            cmdDel.Save();
                        }
                        else
                            RepoFactory.VideoLocalPlace.Delete(vl.VideoLocal_Place_ID);
                    }
                }
            }

            UpdateAllStats();
        }