Beispiel #1
0
        protected virtual IHqSourceManager GetLibrary(string url, out List <Hq> library, out List <string> lethers, double timeCache)
        {
            lock (_lockThis5) {
                CoreEventHub.OnProcessingStart(this, new ProcessingEventArgs(DateTime.Now));
                var lib = new LibraryPage();
                var lt  = new List <string>();
                lib = _cacheManager.CacheManagement(url, _hqSource.GetLibrary, timeCache);
                if (lib != null)
                {
                    NextPage      = lib.NextPage;
                    FinalizedPage = lib.FinalizedPage;
                    if (lib.Letras != null && lib.Letras.Count > 0)
                    {
                        Lethers = lib.Letras;
                        foreach (var kv in Lethers)
                        {
                            lt.Add(kv.Key);
                        }
                    }
                    lethers = lt;
                    library = lib.Hqs;
                }
                else
                {
                    lethers = new List <string>();
                    library = new List <Hq>();
                }

                CoreEventHub.OnProcessingEnd(this, new ProcessingEventArgs(DateTime.Now));
                GC.Collect();
                GC.WaitForPendingFinalizers();
                return(this);
            }
        }
Beispiel #2
0
 public override IHqSourceManager Search(string hqTitle, out List <Hq> result)
 {
     CoreEventHub.OnProcessingStart(this, new ProcessingEventArgs(DateTime.Now));
     result = _hqSource.Search(UpdatePage, hqTitle);
     CoreEventHub.OnProcessingEnd(this, new ProcessingEventArgs(DateTime.Now));
     return(this);
 }
        public List <Page> GetPages(string location)
        {
            CoreEventHub.OnProcessingStart(this, null);
            CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, "Buscando Páginas"));
            var pages = new List <Page>();

            if (!string.IsNullOrEmpty(location))
            {
                var dir    = new DirectoryInfo(location);
                var images = dir.GetFiles();
                foreach (var image in images)
                {
                    var resultString = Regex.Match(image.Name, @"\d+").Value;
                    var number       = Int32.Parse(resultString);
                    CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, $"Adicionando página {number}"));
                    var pg = new Page {
                        Number = number, Source = image.FullName
                    };
                    pages.Add(pg);
                }
            }

            CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, "Tudo Pronto!"));
            CoreEventHub.OnProcessingEnd(this, null);
            return(pages);
        }
Beispiel #4
0
 public virtual IHqSourceManager GetUpdates(out List <Update> updates, double timeCache)
 {
     lock (_lockThis3) {
         CoreEventHub.OnProcessingStart(this, new ProcessingEventArgs(DateTime.Now));
         updates = _cacheManager.CacheManagement(UpdatePage, _hqSource.GetUpdates, timeCache);
         CoreEventHub.OnProcessingEnd(this, new ProcessingEventArgs(DateTime.Now));
         GC.Collect();
         GC.WaitForPendingFinalizers();
         return(this);
     }
 }
Beispiel #5
0
 public virtual IHqSourceManager GetInfo <U>(string url, out U model, double timeCache, bool withoutCache) where U : ModelBase
 {
     lock (_lockThis2) {
         CoreEventHub.OnProcessingStart(this, new ProcessingEventArgs(DateTime.Now));
         model = _cacheManager.ModelCache <U>(url, GetInfoFromSite <U>, timeCache, withoutCache);
         CoreEventHub.OnProcessingEnd(this, new ProcessingEventArgs(DateTime.Now));
         GC.Collect();
         GC.WaitForPendingFinalizers();
         return(this);
     }
 }
        public List <DownloadedHq> GetDownloads()
        {
            //_downloadContext.DownloadLocation.Save(new DownloadLocation { Location = "D:\\Mangas" });
            CoreEventHub.OnProcessingStart(this, null);
            var list = new List <DownloadedHq>();

            CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, "Buscando Locais"));
            var locais = _downloadContext.DownloadLocation.FindAll();

            if (locais != null && locais.Count() > 0)
            {
                CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, "Buscando Hqs"));
                foreach (var local in locais)
                {
                    var directory = new DirectoryInfo(local.Location);
                    var mangas    = directory.GetDirectories();
                    foreach (var manga in mangas)
                    {
                        DownloadedHq downloadedHq = new DownloadedHq();
                        var          json         = manga.GetFiles("*.json").FirstOrDefault();
                        if (json != null)
                        {
                            using (StreamReader file = json.OpenText()) {
                                JsonSerializer serializer = new JsonSerializer();
                                downloadedHq = serializer.Deserialize(file, typeof(DownloadedHq)) as DownloadedHq;
                            }
                        }
                        if (downloadedHq != null)
                        {
                            list.Add(downloadedHq);
                        }
                    }
                }
            }

            CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, "Tudo Pronto!"));
            CoreEventHub.OnProcessingEnd(this, null);
            return(list);
        }
        public List <DownloadedChapter> GetChapters(DownloadedHq downloadedHq)
        {
            CoreEventHub.OnProcessingStart(this, null);
            var chapters = new List <DownloadedChapter>();
            var dir      = new DirectoryInfo(downloadedHq.Location);
            var paths    = dir.GetDirectories();

            CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, $"Buscando Capitulos de {downloadedHq.Hq.Title}"));
            foreach (var path in paths)
            {
                CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, $"Adicioandn capitulo {path.Name}"));
                var title = path.Name;
                var fisrt = false;
                title = Regex.Replace(title, @"\b(\d+)", new MatchEvaluator((match) => {
                    var m = match.Value;
                    if (!fisrt)
                    {
                        m     = m.PadLeft(3, '0');
                        fisrt = true;
                    }
                    return(m);
                }));
                var chap = new Chapter {
                    Title = title
                };
                var downlodeadChapter = new DownloadedChapter {
                    Date = path.CreationTime, Location = path.FullName, Chapter = chap
                };
                chapters.Add(downlodeadChapter);
            }

            chapters = chapters.OrderBy(x => x.Chapter.Title).ToList <DownloadedChapter>();
            CoreEventHub.OnProcessingProgress(this, new ProcessingEventArgs(DateTime.Now, "Tudo Pronto!"));
            CoreEventHub.OnProcessingEnd(this, null);
            return(chapters);
        }
Beispiel #8
0
 protected void OnProcessingEnd(ProcessingEventArgs e) =>
 CoreEventHub.OnProcessingEnd(this, e);