public OmdbApiManager() { Client = InicializeHttpClient(); string apiKey = ConfigReader.GetConfigValue("apiKey"); SearchByIdParameter = $"?apikey={apiKey}&type=movie&i=tt"; }
static void Main(string[] args) { Stopwatch stopwatch = new Stopwatch(); Console.WriteLine("Zadaj: 1 - ulozi filmy z IMDB do databazy, 2 - exportuje filmy z databazy do CSV suboru, 3 - opatovny pokus o ziskanie filmov s exception"); string selectedOption = Console.ReadLine(); Container = DependencyConfiguration.InitializeContainer(); dbProcessor = Container.Resolve <IMovieRepository>(); //TODO: zvacsit timeout pre pracu s API --> ziskat z DB vsetky ID, ktore skoncili v chybe a opatovne spracovat s vacsim timeoutom //TODO: logika pre ziskanie zaznamov z DB s errorom //TODO: prirobit requestovanie podla konkretneho ID stopwatch.Start(); if (selectedOption.Equals("1")) { Console.WriteLine("Prebieha ziskavanie filmov z IMDB a ukladanie do databazy..."); GetMoviesFromImdbToDatabase(); } else if (selectedOption.Equals("2")) { Console.WriteLine("Prebieha export filmov z databazy do CSV suboru..."); ExportMoviesFromDatabaseToCsv(); } else if (selectedOption.Equals("3")) { Console.WriteLine("Prebieha..."); int taskCount = Int32.Parse(ConfigReader.GetConfigValue("taskCount")); int batchSize = Int32.Parse(ConfigReader.GetConfigValue("batchSize")); int selectCount = taskCount * batchSize; List <int> failedMoviesIds = dbProcessor.GetFailedMovieIds(selectCount); //TODO: spracuj } else { Console.WriteLine("Nespravna volba! Program bude ukonceny."); Console.ReadLine(); } stopwatch.Stop(); Logger.Instance.WriteLog($"Total duration: {stopwatch.ElapsedMilliseconds} ms"); }
private static void GetMoviesFromImdbToDatabase() { Stopwatch sw = new Stopwatch(); sw.Start(); List <Movie> movies = new List <Movie>(); MovieManager movieManager = new MovieManager(new TaskManager()); int defaultImdbId = Int32.Parse(ConfigReader.GetConfigValue("defaultImdbId")); //tt0098000 - Nocturne indien (1989) - pociatok ziskavania filmov? int imdbIdLastProcessed = dbProcessor.GetMovieIdForNextProcessing(); int imdbIdForProcessing = imdbIdLastProcessed == 0 ? defaultImdbId : (imdbIdLastProcessed + 1); int batchSize = Int32.Parse(ConfigReader.GetConfigValue("batchSize")); Console.WriteLine($"Data budu ziskavane pre IMDB filmy od ID = {imdbIdForProcessing}"); movies = movieManager.GetMoviesFomImdb(imdbIdForProcessing, batchSize); sw.Restart(); dbProcessor.SaveMoviesToDatabase(movies); sw.Stop(); Logger.Instance.WriteLog($"Save movies to DB - duration: {sw.ElapsedMilliseconds} ms"); }
public TaskManager() { MovieTasks = new List <Task <List <Movie> > >(); MovieGetter = new MovieBatchGetter(); TaskCount = Int32.Parse(ConfigReader.GetConfigValue("taskCount")); }
private Logger() { LogFullPath = ConfigReader.GetConfigValue("logPath") + "MoviesImdbLog_" + Guid.NewGuid().ToString() + ".txt"; }
public MovieExporter() { CsvHeader = ConfigReader.GetConfigValue("csvHeader"); CsvExportPath = ConfigReader.GetConfigValue("csvExportPath"); }