Ejemplo n.º 1
0
        internal void DownloadChapters()
        {
            Object locker = new Object();

            try
            {
                Merge <Chapter> merge = (catc, newc) =>
                {
                    catc.URL = newc.URL;
                };

                Crawler.DownloadChapters(this, (progress, result) =>
                {
                    lock (locker)
                    {
                        if (progress == 100)
                        {
                            if (!ChaptersDownloadedFirstTime)
                            {
                                result.ForEach(ch => ch.Visited = true);
                            }

                            EliminateDoubles(result.ToList());
                            m_chapters.ReplaceInnerCollection(result, ChaptersDownloadedFirstTime, c => c.Title, merge);
                        }

                        DownloadProgress = progress;
                    }
                });

                State = SerieState.Downloaded;
            }
            catch (ObjectDisposedException)
            {
            }
            catch (Exception ex1)
            {
                State = SerieState.Error;

                Loggers.MangaCrawler.Error(
                    String.Format("Exception #1, serie: {0} state: {1}", this, State), ex1);

                try
                {
                    DownloadManager.Instance.DownloadSeries(Server, true);
                }
                catch (Exception ex2)
                {
                    Loggers.MangaCrawler.Error(
                        String.Format("Exception #2, serie: {0} state: {1}", this, State), ex2);
                }
            }

            ChaptersDownloadedFirstTime = true;
            Catalog.Save(this);
            m_check_date_time = DateTime.Now;
        }
Ejemplo n.º 2
0
        internal void DownloadSeries()
        {
            Object locker = new Object();

            try
            {
                Crawler.DownloadSeries(this, (progress, result) =>
                {
                    lock (locker)
                    {
                        Merge <Serie> merge = (cats, news) =>
                        {
                            cats.URL = news.URL;
                        };

                        if (progress == 100)
                        {
                            result = EliminateDoubles(result.ToList());
                            m_series.ReplaceInnerCollection(result, SeriesDownloadedFirstTime, s => s.Title, merge);
                        }

                        DownloadProgress = progress;
                    }
                });

                DownloadManager.Instance.Bookmarks.RemoveNotExisted();
                State = ServerState.Downloaded;
            }
            catch (ObjectDisposedException)
            {
            }
            catch (Exception ex)
            {
                Loggers.MangaCrawler.Error(String.Format(
                                               "Exception, server: {0} state: {1}", this, State), ex);
                State = ServerState.Error;
            }

            SeriesDownloadedFirstTime = true;
            Catalog.Save(this);
            m_check_date_time = DateTime.Now;
        }