예제 #1
0
        public static void FillDatabaseInfo(ActorScraper scraper)
        {
            Console.WriteLine("\r\nTransfering to database...", ProfileManager.InfoColor);

            foreach (var actor in scraper.UniqueActors)
            {
                AddActorToDb(actor.Name, actor.Surname, actor.Born);
            }

            foreach (var movie in scraper.UniqueFilms)
            {
                AddMovieToDb(movie.Name, movie.Rating, movie.Genre, movie.Year);
            }

            Console.WriteLine("Starting actors and films query...", ProfileManager.InfoColor);
            foreach (var actor in scraper.UniqueActors)
            {
                var actorId = SelectActorId(actor.Name, actor.Surname);
                foreach (var film in actor.Films)
                {
                    var movieId = SelectFilmId(film.Name);
                    SelectActorFilmId(actorId, movieId);
                }
            }
        }
예제 #2
0
        static void Main()
        {
            var profile   = ProfileManager.GetProfile();
            var actorDict = EnterActors();

            var scraper = new ActorScraper(profile);

            scraper.ScrapeActors(actorDict);

            SqlQueries.ActorObjList = scraper.UniqueActors.ToList();

            Database.FillDatabaseInfo(scraper);
            Console.WriteLine("Data transfer complete.", ProfileManager.SuccessColor);
            Console.Write("\r\nActor with most films: ", ProfileManager.ResultColor);
            Database.GetActorWithMostFilms();
            Console.Write("\r\nActor with biggest film rating: ", ProfileManager.ResultColor);
            Database.GetFilmWithBiggestRating();

            if (SqlQueries.ActorObjList.Count > 1)
            {
                Console.WriteLine($"\r\nThe {SqlQueries.ActorObjList.Count} actors Co-Star in all these films:", ProfileManager.ResultColor);
                Database.ActorsAndMovies(SqlQueries.UniversalString());

                if (SqlQueries.ActorObjList.Count > 2)
                {
                    Database.ActorsAndMovies(SqlQueries.CoStarMethod());
                }
            }

            Database.CloseConnections();

            Console.WriteLine("\r\nPress any key to exit...", ProfileManager.InfoColor);
            Console.ReadKey();
        }
예제 #3
0
            new ObservableCollection <Film>(); //{new Film("Test Film", 10, "2017", "Cool genre")};

        //TODO: Make this threaded
        public static void SearchActors()
        {
            // Get a dict of actors
            var actorDict = new Dictionary <string, string>();

            foreach (Actor actor in SelectedActors)
            {
                var pair = actorNameToIdPair(actor.Fullname);
                actorDict.Add(pair.Key, pair.Value);
            }

            // Scrape
            var scraper = new ActorScraper();

            scraper.ScrapeActors(actorDict);

            // Update FilmsResult
            FilmsResult.Clear();
            foreach (var film in scraper.GetFilmsInCommon())
            {
                FilmsResult.Add(film);
            }
        }