Exemplo n.º 1
0
        /// <summary>
        /// Generatate unsorted list.
        /// </summary>
        /// <param name="progress"></param>
        public static void GeneratateUnsortedList(Progress progress)
        {
            mediaPathTvUnsorted.Clear();
            mediaPathMoviesUnsorted.Clear();


            var count = 0;

            try
            {
                foreach (MediaPathModel mediaPath in MediaPathDB)
                {
                    for (int index = 0; index < mediaPath.FileCollection.Count; index++)
                    {
                        progress.Message = string.Format("Processing {0}", mediaPath.FileCollection[index].PathAndFileName);

                        MediaPathFileModel filePath = mediaPath.FileCollection[index];

                        if (filePath.Type == MediaPathFileModel.MediaPathFileType.Movie)
                        {
                            if (new System.IO.FileInfo(filePath.PathAndFileName).Length > Get.InOutCollection.MinimumMovieSize)
                            {
                                if (!MasterMediaDBFactory.MovieDatabaseContains(filePath.PathAndFileName))
                                {
                                    mediaPathMoviesUnsorted.Add(filePath);
                                }
                            }
                        }

                        if (filePath.Type == MediaPathFileModel.MediaPathFileType.TV)
                        {
                            if (!MasterMediaDBFactory.TvDatabaseContains(filePath.PathAndFileName))
                            {
                                mediaPathTvUnsorted.Add(filePath);
                            }
                        }

                        count++;

                        var total = (long)MediaPathDB.Sum(pathColletion => pathColletion.FileCollection.Count);

                        progress.Percent = Convert.ToInt32((long)count * 100 / total);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "Could not Generated Unsorted List", ex.Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Generatate unsorted list.
        /// </summary>
        public static void GeneratateUnsortedList()
        {
            mediaPathTvUnsorted.Clear();
            mediaPathMoviesUnsorted.Clear();

            try
            {
                foreach (MediaPathModel mediaPath in MediaPathDB)
                {
                    for (int index = 0; index < mediaPath.FileCollection.Count; index++)
                    {
                        MediaPathFileModel filePath = mediaPath.FileCollection[index];

                        if (filePath.Type == MediaPathFileModel.MediaPathFileType.Movie)
                        {
                            if (new System.IO.FileInfo(filePath.PathAndFileName).Length > Get.InOutCollection.MinimumMovieSize)
                            {
                                if (!MasterMediaDBFactory.MovieDatabaseContains(filePath.PathAndFileName))
                                {
                                    mediaPathMoviesUnsorted.Add(filePath);
                                }
                            }
                        }

                        if (filePath.Type == MediaPathFileModel.MediaPathFileType.TV)
                        {
                            if (!MasterMediaDBFactory.TvDatabaseContains(filePath.PathAndFileName))
                            {
                                mediaPathTvUnsorted.Add(filePath);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, 0, "Could not Generated Unsorted List", ex.Message);
            }
        }
Exemplo n.º 3
0
        /// <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();
        }