/// <summary> /// Initializes a new instance of the <see cref="FrmEditMediaPath"/> class. /// </summary> public FrmEditMediaPath(MediaPathActionType type, MediaPathModel mediaPathModel) { this.InitializeComponent(); this.actionType = type; this.editingMediaPathModel = mediaPathModel; this.SetupBindings(); }
/// <summary> /// The copy to. /// </summary> /// <param name="currentMediaPath"> /// The current media path. /// </param> public void CopyTo(MediaPathModel currentMediaPath) { currentMediaPath.MediaPath = this.mediaPath; currentMediaPath.LastScannedTime = this.lastScannedTime; currentMediaPath.FoundFiles = this.foundFiles; currentMediaPath.RecursiveScan = this.recursiveScan; currentMediaPath.ScraperGroup = this.scraperGroup; currentMediaPath.DefaultSource = this.defaultSource; currentMediaPath.ContainsTv = this.containsTv; currentMediaPath.ContainsMovies = this.containsMovies; currentMediaPath.ImportUsingFileName = this.importUsingFileName; currentMediaPath.ImportUsingParentFolderName = this.importUsingParentFolderName; }
/// <summary> /// Scans the media path. /// </summary> /// <param name="mediaPathModel"> /// The media path model. /// </param> public static void ScanMediaPath(MediaPathModel mediaPathModel) { var bgw = new BackgroundWorker(); bgw.DoWork += BgwDoWork; bgw.RunWorkerCompleted += BgwRunWorkerCompleted; importInProgress = true; bgw.RunWorkerAsync(mediaPathModel); do { Thread.Sleep(50); } while (importInProgress); }
/// <summary> /// Create clone of MediaPathModel /// </summary> /// <returns> /// Clone of MediaPathModel /// </returns> public MediaPathModel Copy() { var newMediaPath = new MediaPathModel { MediaPath = this.mediaPath, LastScannedTime = this.lastScannedTime, FoundFiles = this.foundFiles, RecursiveScan = this.recursiveScan, ScraperGroup = this.scraperGroup, DefaultSource = this.defaultSource, ContainsMovies = this.containsMovies, ContainsTv = this.containsTv, ImportUsingFileName = this.importUsingFileName, importUsingParentFolderName = this.importUsingParentFolderName }; return(newMediaPath); }
/// <summary> /// Adds the new entries. /// </summary> /// <param name="mediaPathModel"> /// The media path model. /// </param> /// <param name="files"> /// The files. /// </param> private static void AddNewEntries(MediaPathModel mediaPathModel, string[] files) { if (files == null) { return; } foreach (string f in files) { MediaPathFileModel.MediaPathFileType type = DetectType.FindType( f, mediaPathModel.ContainsTv, mediaPathModel.ContainsMovies); AddFolderType importType; if (type == MediaPathFileModel.MediaPathFileType.Movie) { importType = mediaPathModel.NameFileBy; } else { importType = AddFolderType.NotApplicable; } MediaPathFileModel obj = MediaPathFileModel.Add( f, type, importType, mediaPathModel.ScraperGroup, mediaPathModel.DefaultSource); string f1 = f; try { var check = mediaPathModel.FileCollection.Any(file => file.PathAndFileName == f1); if (!check) { mediaPathModel.FileCollection.Add(obj); } } catch { } } }
/// <summary> /// Remove a MediaPathModel from the MediaPathDB /// </summary> /// <param name="mediaPathModel">The media path model.</param> public static void RemoveFromDatabase(MediaPathModel mediaPathModel) { EnsureMediaPathDatabaseExists(); // Remove movies from db for (int index = 0; index < mediaPathModel.FileCollection.Count; index++) { MediaPathFileModel filePath = mediaPathModel.FileCollection[index]; if (filePath.Type == MediaPathFileModel.MediaPathFileType.Movie) { string p = filePath.Path.TrimEnd('\\'); if (! MovieDBFactory.MovieDatabase.Remove( (from m in MovieDBFactory.MovieDatabase where m.GetBaseFilePath == p select m). SingleOrDefault()) ) { MovieDBFactory.HiddenMovieDatabase.Remove( (from m in MovieDBFactory.HiddenMovieDatabase where m.GetBaseFilePath == p select m). SingleOrDefault()); } } if (filePath.Type == MediaPathFileModel.MediaPathFileType.TV) { if (MasterMediaDBFactory.TvDatabaseContains(filePath.PathAndFileName)) { MasterMediaDBFactory.MasterTvMediaDatabase.Remove(filePath.PathAndFileName); } } } // Remove media path MediaPathDB.Remove(mediaPathModel); // Update master MasterMediaDBFactory.PopulateMasterMovieMediaDatabase(); }
/// <summary> /// The copy to. /// </summary> /// <param name="currentMediaPath"> /// The current media path. /// </param> public void CopyTo(MediaPathModel currentMediaPath) { currentMediaPath.MediaPath = this.mediaPath; currentMediaPath.LastScannedTime = this.lastScannedTime; currentMediaPath.FoundFiles = this.foundFiles; currentMediaPath.RecursiveScan = this.recursiveScan; currentMediaPath.ScraperGroup = this.scraperGroup; currentMediaPath.DefaultSource = this.defaultSource; currentMediaPath.ContainsTv = this.containsTv; currentMediaPath.ContainsMovies = this.containsMovies; currentMediaPath.ImportUsingFileName = this.importUsingFileName; currentMediaPath.ImportUsingParentFolderName = this.importUsingParentFolderName; }
/// <summary> /// Create clone of MediaPathModel /// </summary> /// <returns> /// Clone of MediaPathModel /// </returns> public MediaPathModel Copy() { var newMediaPath = new MediaPathModel { MediaPath = this.mediaPath, LastScannedTime = this.lastScannedTime, FoundFiles = this.foundFiles, RecursiveScan = this.recursiveScan, ScraperGroup = this.scraperGroup, DefaultSource = this.defaultSource, ContainsMovies = this.containsMovies, ContainsTv = this.containsTv, ImportUsingFileName = this.importUsingFileName, importUsingParentFolderName = this.importUsingParentFolderName }; return newMediaPath; }