public void TVShowWithNoEndTest()
        {
            IIMDbDataProvider imdbDataProvider = new IMDbScraperDataProvider();
            Production        production       = imdbDataProvider.GetProduction(48861, new FullProductionDataFetchSettings());

            Assert.IsNotNull(production);
            Assert.AreEqual(48861, production.IMDbID);
            Assert.IsTrue(production.ProductionType == ProductionTypeEnum.TVSeries);
            Assert.IsTrue((production as TVSeries).Year != default(int));
            Assert.IsFalse((production as TVSeries).EndYear.HasValue);
        }
        public void DetailedProductionScraping()
        {
            IIMDbDataProvider imdbDataProvider = new IMDbScraperDataProvider();

            foreach (long productionID in productionIDsTotest)
            {
                Production production = imdbDataProvider.GetProduction(productionID, new FullProductionDataFetchSettings());
                Assert.IsNotNull(production);
                Assert.AreEqual(productionID, production.IMDbID);
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{EnvironmentUtilities.GetEnvironmentName()}.json", optional: true, reloadOnChange: true)
                          .AddEnvironmentVariables()
                          .AddCommandLine(args);

            BaseJobConfiguration configuration = builder.Build().Get <BaseJobConfiguration>();

            InitializationHelper.Initialize(configuration);
            var services = new ServiceCollection();

            services.AddOptions();
            var serviceProvider = services.BuildServiceProvider();

            if (configuration.MaxRecordCount == default(int))
            {
                configuration.MaxRecordCount = ConfigurationConstants.PersisterRecordCountPerRun;
            }

            using (JMoviesEntities entities = new JMoviesEntities())
            {
                IIMDbDataProvider imdbDataProvider = new IMDbScraperDataProvider();
                if (configuration.StartRecordID == default(long) || configuration.WorkingType == PersisterWorkingTypeEnum.UpdateInternalData)
                {
                    configuration.StartRecordID = PersisterHelper.DetermineTheStartID(EntityType, DataSource, configuration.WorkingType, configuration.StartRecordID, entities);
                }
                long dataID = configuration.StartRecordID;
                for (int i = 0; i < configuration.MaxRecordCount; i++)
                {
                    if (i != 0)
                    {
                        dataID = PersisterHelper.GetNextID(EntityType, DataSource, configuration.WorkingType, entities, dataID);
                    }

                    if (dataID != default(long))
                    {
                        if (dataID > ConfigurationConstants.IMDBMaxID)
                        {
                            dataID = 1;
                        }

                        try
                        {
                            Production production = imdbDataProvider.GetProduction(dataID, ProductionDataFetchSettings);
                            DbContextOptionsBuilder <JMoviesEntities> dbContextOptionsBuilder = new DbContextOptionsBuilder <JMoviesEntities>();
                            dbContextOptionsBuilder.UseLazyLoadingProxies(true);
                            using (JMoviesEntities productionPersistanceEntities = new JMoviesEntities(dbContextOptionsBuilder.Options))
                            {
                                ProductionPersistanceManager.Persist(productionPersistanceEntities, production);
                            }
                            PersisterHelper.SavePersisterHistory(entities, dataID, DataSource, EntityType, string.Empty);
                        }
                        catch (Exception exception)
                        {
                            PersisterHelper.SavePersisterHistory(entities, dataID, DataSource, EntityType, exception.ToString());
                        }
                        entities.SaveChanges();
                    }
                }
            }
        }