Ejemplo n.º 1
0
        public void parseNames(ConcThreadJobMaster sender)
        {
            // get parsed movie data;
            ConcurrentImdbMovieParser parser = sender as ConcurrentImdbMovieParser;
            this.movie = new Movie(parser.movieData);

            List<uint> IDsToTest = new List<uint>();

            SQLiteConnector.db.beginTransaction();

            IDsToTest.AddRange(movie.imdbMovie.directors);
            IDsToTest.AddRange(movie.imdbMovie.writers);
            foreach (Tuple<uint, string> cur in movie.imdbMovie.roles) {
                    IDsToTest.Add(cur.Item1);
            }
            foreach (Award a in movie.imdbMovie.awards) {
                IDsToTest.AddRange(a.persons);
            }
            bool[] contains =SQLiteConnector.db.testAndSetPersons(IDsToTest);
            int i = 0;
            foreach (uint id in IDsToTest) {
                if (!contains[i]) {
                    startParse(id);
                }
                i++;
            }
            SQLiteConnector.db.updateMovieData(this.movie);
            SQLiteConnector.db.endTransaction();
        }
Ejemplo n.º 2
0
 public void addJobMasters(ConcThreadJobMaster[] masters)
 {
     Monitor.Enter(lockvar);
     foreach(ConcThreadJobMaster m in masters) {
         jobMaster.AddLast(m);
         Controller.controller.setProgressIndicator(true);
     }
     Monitor.Exit(lockvar);
 }
Ejemplo n.º 3
0
 public void addJobMaster(ConcThreadJobMaster master)
 {
     if (master != null) {
         Monitor.Enter(lockvar);
         jobMaster.AddLast(master);
         Monitor.Exit(lockvar);
         Controller.controller.setProgressIndicator(true);
     }
 }
Ejemplo n.º 4
0
 private void actionButton_Click(object sender, RoutedEventArgs e)
 {
     if (lastParser != null) {
         if (lastParser is ConcurrentIMDBNameParser) {
             controller.insertPersonInDB((ConcurrentIMDBNameParser)lastParser);
         } else if (lastParser is ConcurrentImdbMovieParser) {
             controller.insertMovieInDB(IMDBUtil.getTitleIdFromUrl(lastURL));
         }
     }
     lastParser = null;
 }
Ejemplo n.º 5
0
        private void imdbWebBrowser_Navigating(object sender, NavigatingCancelEventArgs e)
        {
            string url = e.Uri.ToString();
            if (!Regex.Match(url, @"imdb\.com").Success) {
                imdbWebBrowser.Navigate(lastURL);
                return;
            }
            setButton("add", false);
            lastParser = null;
            lastURL = url;

            if (IMDBUtil.isMovieUrl(url)) {
                ConcurrentImdbMovieParser parser = new ConcurrentImdbMovieParser(IMDBUtil.getTitleIdFromUrl(url));
                parser.setFinalizeFunction(this.updateActionButton);
                ThreadsMaster.getInstance().addVeryVeryImportantThreadMaster(parser);
            } else if (IMDBUtil.isNameURL(url)) {
                ConcurrentIMDBNameParser parser = new ConcurrentIMDBNameParser(IMDBUtil.getNameIdFromUrl(url));
                parser.setFinalizeFunction(this.updateActionButton);
                ThreadsMaster.getInstance().addVeryVeryImportantThreadMaster(parser);
            } else {
                updateActionButton(null);
            }
        }
Ejemplo n.º 6
0
 public void func(ConcThreadJobMaster sender)
 {
     ((ConcurrentImdbMovieParser)sender).movieData.printToConsole();
 }
Ejemplo n.º 7
0
 private void updateActionButton(ConcThreadJobMaster sender)
 {
     if (sender != null) {
         if (sender is ConcurrentIMDBNameParser) {
             setButton("Add '" + ((ConcurrentIMDBNameParser)sender).person.name + "' to Database", true);
         } else if (sender is ConcurrentImdbMovieParser) {
             setButton("Add '" + ((ConcurrentImdbMovieParser)sender).movieData.title + "' to Database", true);
         }
         lastParser = sender;
     } else {
         setButton("add", false);
     }
 }
Ejemplo n.º 8
0
 public void parseFinished(ConcThreadJobMaster sender)
 {
     ConcurrentIMDBNameParser p = sender as ConcurrentIMDBNameParser;
     SQLiteConnector.db.updateImdbPerson(p.person);
 }
Ejemplo n.º 9
0
 public void imdbParseFinished(ConcThreadJobMaster sender)
 {
     ConcurrentImdbMovieParser parser = (ConcurrentImdbMovieParser)sender;
     this.imdbMovie = parser.movieData;
 }
Ejemplo n.º 10
0
 public void addVeryVeryImportantThreadMaster(ConcThreadJobMaster master)
 {
     Monitor.Enter(lockvar);
     jobMaster.AddFirst(master);
     Monitor.Exit(lockvar);
 }
Ejemplo n.º 11
0
 public void hasFinished(ConcThreadJobMaster master)
 {
     Monitor.Enter(lockvar);
     jobMaster.Remove(master);
     Monitor.Exit(lockvar);
     master.finalize();
     if (jobMaster.Count == 0) {
         Controller.controller.setProgressIndicator(false);
     }
 }