Example #1
0
        public ActionResult AddMovie(MovieAddEditModel model)
        {
            model.MovieName.LanguageID = ParseHelper.ToInt32(model.NameLanguageID);
            model.MovieName.IsDefault  = true;

            //model.MovieArchive.ArchiveID = Parse.ToInt32(model.ArchiveID);
            //model.MovieArchive.Resolution = model.ArchiveResolution;
            //model.MovieArchive.FileExtension = model.ArchiveFileExtension;
            //model.MovieArchive.UserID = model.

            //insert movie first and get inserted id
            int movieId = MovieBL.Save(model.Movie, UserID);

            //save the name
            model.MovieName.MovieID = movieId;
            MovieNameBL.Save(model.MovieName, UserID);
            //if (model.ArchiveExists == true)
            //{
            //    //save the archive
            //    model.MovieArchive.MovieID = movieId;
            //    MovieArchiveBL.Save(model.MovieArchive, UserID);
            //}

            switch (model.Submit)
            {
            case "SubmitAndNavigateToMovie":
                return(RedirectToAction("DetailView", "Movie", new { id = movieId }));

            case "SubmitAndClearForm":
            default:
                return(RedirectToAction("AddMovie"));
            }
        }
Example #2
0
        public ActionResult EditMovie(int id)
        {
            MovieAddEditModel model = new MovieAddEditModel();

            model.Movie     = MovieBL.GetMovie(id);
            model.MovieName = MovieNameBL.GetAllDOByMovieID(id).SingleOrDefault(q => q.IsDefault == true);
            //model.MovieArchive = MovieArchiveBL.GetAllDOByMovieID(id).SingleOrDefault();

            model.Languages.ToList().ForEach(q => q.Selected = false);
            model.Languages.Single(q => q.Value == model.MovieName.LanguageID.ToString()).Selected = true;

            //if (model.MovieArchive != null)
            //{
            //    model.ArchiveExists = true;

            //    model.ResolutionList.ToList().ForEach(q => q.Selected = false);
            //    model.ResolutionList.Single(q => q.Value == model.MovieArchive.Resolution).Selected = true;

            //    model.FileExtensionList.ToList().ForEach(q => q.Selected = false);
            //    model.FileExtensionList.Single(q => q.Value == model.MovieArchive.FileExtension).Selected = true;

            //    model.Archives.ToList().ForEach(q => q.Selected = false);
            //    model.Archives.Single(q => q.Value == model.MovieArchive.ArchiveID.ToString()).Selected = true;
            //}

            return(View(model));
        }
Example #3
0
        public ActionResult EditMovie(MovieAddEditModel model)
        {
            int movieId = model.MovieId;

            MovieDO     _movie     = MovieBL.GetMovie(movieId);
            MovieNameDO _movieName = MovieNameBL.GetAllDOByMovieID(movieId).SingleOrDefault(q => q.IsDefault == true);

            //MovieArchiveDO _movieArchive = MovieArchiveBL.GetAllDOByMovieID(movieId).SingleOrDefault();
            //if (_movieArchive == null) _movieArchive = new MovieArchiveDO() { MovieID = movieId };

            _movieName.LanguageID = ParseHelper.ToInt32(model.NameLanguageID);
            _movieName.Name       = model.MovieName.Name;

            //_movieArchive.ArchiveID = Parse.ToInt32(model.ArchiveID);
            //_movieArchive.Resolution = model.ArchiveResolution;
            //_movieArchive.FileExtension = model.ArchiveFileExtension;
            //_movieArchive.Path = model.MovieArchive.Path;

            //if imdbid is changed, we need to reset imdb things first.
            string previousImdbId = _movie.ImdbID;

            if (string.IsNullOrEmpty(previousImdbId) == false && model.Movie.ImdbID != previousImdbId)
            {
                MovieBL.ResetImdbInformation(model.MovieId);
                _movie        = MovieBL.GetMovie(movieId);
                _movie.ImdbID = model.Movie.ImdbID;
            }

            //save movie
            MovieBL.Save(_movie, UserID);
            //save the name
            MovieNameBL.Save(_movieName, UserID);
            //if (model.ArchiveExists == true)
            //{
            //    //save the archive
            //    MovieArchiveBL.Save(_movieArchive, UserID);
            //}

            switch (model.Submit)
            {
            case "SubmitAndNavigateToMovie":
                return(RedirectToAction("DetailView", "Movie", new { id = movieId }));

            case "SubmitAndClearForm":
            default:
                return(RedirectToAction("AddMovie"));
            }
        }
Example #4
0
        private void parseMovies( )
        {
            string logPath = string.Format(Application.StartupPath + @"\_log\{0}{1}{2}_{3}_{4}_{5}\",
                                           DateTime.Now.Year.ToString( ),
                                           DateTime.Now.Month.ToString( ).PadLeft(2, '0'),
                                           DateTime.Now.Day.ToString( ).PadLeft(2, '0'),
                                           DateTime.Now.Hour.ToString( ).PadLeft(2, '0'),
                                           DateTime.Now.Minute.ToString( ).PadLeft(2, '0'),
                                           DateTime.Now.Second.ToString( ).PadLeft(2, '0'));

            Directory.CreateDirectory(logPath);

            TextWriter twSum = new StreamWriter(logPath + logHelper.createLogFileName("_summary"));

            twSum.WriteLine(string.Format("{0}\tThread started for {1} movies",
                                          DateTime.Now.ToString( ),
                                          mCount.ToString( )));

            foreach (var item in mListCurrent)
            {
                string movieName = MovieNameBL.GetOriginalNameOfMovie(item.ID);
                if (!string.IsNullOrEmpty(item.ImdbID))
                {
                    string imdbId = item.ImdbID;

                    TextWriter tw    = new StreamWriter(logPath + logHelper.createLogFileName(String.Format("{0} ({1})", movieName, imdbId)));
                    DateTime   start = DateTime.Now;
                    //TODO: Stopwatch olarak geliştirirsek daha bi güzel olur aslında
                    Stopwatch sw = new Stopwatch( );
                    sw.Start( );
                    tw.WriteLine(" GET BY ID ");
                    tw.WriteLine("Start : " + start.ToString( ));

                    getMovieInfoByIdAndSave(imdbId, item, tw, start);

                    TimeSpan processTime = sw.Elapsed;
                    sw.Stop( );

                    tw.WriteLine("End : " + DateTime.Now.ToString( ));
                    tw.WriteLine( );
                    tw.WriteLine(String.Format("Total elapsed time: {0} minutes {1} seconds {2} miliseconds",
                                               processTime.Minutes.ToString( ),
                                               processTime.Seconds.ToString( ),
                                               processTime.Milliseconds.ToString( )));
                    tw.Close( );
                }
                else if (!String.IsNullOrEmpty(movieName))
                {
                    bool skipSearchForNow = true;
                    if (skipSearchForNow == false)
                    {
                        string search   = movieName;
                        string imdbId   = "";
                        String tempHtml = "";

                        TextWriter tw    = new StreamWriter(logPath + logHelper.createLogFileName(String.Format("{0}", movieName)));
                        DateTime   start = DateTime.Now;
                        Stopwatch  sw    = new Stopwatch( );
                        sw.Start( );
                        logHelper.logLine(tw, " GET BY SEARCH ");
                        logHelper.logLine(tw, "Search started");

                        try {
                            tempHtml = WebRequestHelper.CallPage("http://www.imdb.com/find?tt=all&q=" + search.Replace(" ", "+"));
                        } catch (Exception ex) { logHelper.logException(tw, ex); }

                        logHelper.logLine(tw, "Query ran successfully");

                        System.Text.RegularExpressions.Regex rgx;

                        if (tempHtml != "")
                        {
                            string temp = "";

                            //check if this is the search page
                            //or if we've been redirected to the movie's page
                            rgx = new System.Text.RegularExpressions.Regex(@"<title>IMDb Title Search</title>");

                            if (rgx.Matches(tempHtml).Count == 1)
                            {
                                //arama sayfasına gelmişiz

                                logHelper.logLine(tw, "We are at search result page");

                                //we'll parse all movies in this page and show the user the list to select from
                                //if there is only 1 exact title result, we will take it as the single result
                                if (tempHtml.Contains("<b>Popular Titles</b>"))
                                {
                                    logHelper.logLine(tw, "Our movie is in the Popular Titles!");

                                    //popüler sonuçlarda bulduk, onu alalım
                                    temp   = tempHtml.Substring(tempHtml.IndexOf("<b>Popular Titles</b>"));
                                    temp   = temp.Substring(temp.IndexOf("<a href=\"/title/tt") + 16);
                                    imdbId = temp.Remove(temp.IndexOf("/"));
                                }
                                else
                                {
                                    logHelper.logLine(tw, "Movie is not so Popular. Not checking now. Sent to waiting queue.");
                                    //popülerde yoksa, şimdilik salla, sonra bakalım ama - - -!!!
                                    copyItemToList(mListCurrent, mListWaiting, item.ID);
                                }
                            }
                            else
                            {
                                //sayfayı bulmuşuz

                                logHelper.logLine(tw, "We are at the movie page");

                                if (tempHtml.Contains("<link href=\"http://www.imdb.com/title/"))
                                {
                                    temp = tempHtml.Substring(tempHtml.IndexOf("<link href=\"http://www.imdb.com/title/") + 38);
                                }
                                else if (tempHtml.Contains("<link rel=\"canonical\" href=\"http://www.imdb.com/title/"))
                                {
                                    temp = tempHtml.Substring(tempHtml.IndexOf("<link rel=\"canonical\" href=\"http://www.imdb.com/title/") + 54);
                                }
                                imdbId = temp.Remove(temp.IndexOf("/"));
                            }
                            if (!String.IsNullOrEmpty(imdbId))
                            {
                                logHelper.logLine(tw, "Got the ID: " + imdbId);
                                getMovieInfoByIdAndSave(imdbId, item, tw, start);
                            }
                        }
                        else
                        {
                            logHelper.logLine(tw, "Error while connecting to IMDB. Aborting.");

                            copyItemToList(mListCurrent, mListWaiting, item.ID);
                        }

                        tw.Close( );
                    }
                }
                else
                {
                    //movie is f****d up. forget about it..
                    //removeItemFromMovieList ( mListCurrent, item.movieId );
                }

                setProgressBarValue(parseStatus, parseStatus.Value + 1);
            }
            twSum.WriteLine(string.Format("{0}\tThread finished with {1} movies waiting in queue",
                                          DateTime.Now.ToString( ),
                                          mListWaiting.Count.ToString( )));
            twSum.Close( );

            MessageBox.Show(string.Format("{0}\tThread finished with {1} movies waiting in queue",
                                          DateTime.Now.ToString( ),
                                          mListWaiting.Count.ToString( )));

            setButtonEnabled(btnStart, true);
        }