Exemplo n.º 1
0
        /// <summary>
        /// Handles the Tick event of the tmr control.
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.
        /// </param>
        private static void tmr_Tick(object sender, EventArgs e)
        {
            frmSavingDB.SetMovieValue(SavingMovieValue);
            frmSavingDB.SetMovieDBMax(SavingMovieMax);
            frmSavingDB.SetTVDBValue(SavingTVDBValue);
            frmSavingDB.SetTVDBMax(SavingTVDBMax);

            if (SavingMovieValue == SavingMovieMax - 1)
            {
                frmSavingDB.MovieDBFinished();
            }

            if (SavingTVDBValue == SavingTVDBMax)
            {
                frmSavingDB.TvDBFinished();
            }
        }
Exemplo n.º 2
0
        private static void SaveMovies(BindingList <MovieModel> database)
        {
            int max = database.Count;

            if (max == 0)
            {
                return;
            }

            SavingMovieMax += database.Count - 1;
            var parallelOptions = new ParallelOptions {
                MaxDegreeOfParallelism = 6
            };

            Parallel.ForEach(
                database,
                parallelOptions,
                movie =>
            {
                SavingCount++;

                var path = Get.FileSystemPaths.PathDatabases + OutputName.MovieDb + Path.DirectorySeparatorChar;

                var title = FileNaming.RemoveIllegalChars(movie.Title);

                string writePath;

                if (movie.Hidden)
                {
                    writePath = path + title + ".hiddenmovie";
                }
                else
                {
                    writePath = path + title + ".movie";
                }

                movie.DatabaseSaved = true;
                var json            = JsonConvert.SerializeObject(movie);
                Gzip.CompressString(json, writePath + ".gz");

                var posterPath = path + title + ".poster.jpg";
                var fanartPath = path + title + ".fanart.jpg";

                if (movie.SmallPoster != null)
                {
                    movie.SmallPoster.Save(posterPath);
                }

                if (movie.SmallFanart != null)
                {
                    movie.SmallFanart.Save(fanartPath);
                }

                Application.DoEvents();

                SavingMovieValue++;
            });

            frmSavingDB.MovieDBFinished();

            SavingMovieDB = false;
        }