Beispiel #1
0
        private void ChargerDossiersPao(ITaskObserver observer)
        {
            observer.NotifyIsIndeterminate(this);

            var dossiers = Directory.GetDirectories(_racinePao, "*.*",
                                                    SearchOption.TopDirectoryOnly);

            observer.NotifyProgress(this, 0);

            var dossiersParutions =
                (from dossier in observer.InSlice(0, 10).EnumerableProgressTracker(this, dossiers)
                 let parution = Parution(dossier)
                                where parution != null
                                select new { Parution = parution, Dossier = dossier }).ToList();


            _dossiersParutions = dossiersParutions.ToLookup(dp => dp.Parution, dp => dp.Dossier);

            var cabs =
                from dossierParution in observer.InSlice(15, 100).EnumerableProgressTracker(this, dossiersParutions)
                let fi = ExtraireCabFileInfo(dossierParution.Dossier, dossierParution.Parution)
                         where fi != null
                         let cab = CréerCab(fi, dossierParution.Parution)
                                   where cab != null
                                   select cab;

            _listeDonnéesCab = new List <ICab>(cabs);

            observer.NotifyProgress(this, 100);
        }
Beispiel #2
0
        private IEnumerable <ICab> CabsPourCompte(CompteCab compte, ITaskObserver observer)
        {
            observer.NotifyProgress(this, 0);
            var cabs = new List <ICab>();

            string pageRacine = OuvrirPage(RequêteDossierRacine(compte), observer.InSlice(0, 7));

            cabs.AddRange(CabsPourPage(pageRacine, compte.Editeur, observer.InSlice(7, 10)));

            ITaskObserver loopObs = observer.InSlice(10, 100);
            var           matches = _RegexDossier.Matches(pageRacine);
            var           slices  = loopObs.GetSlices(matches.Count).GetEnumerator();

            foreach (Match mDossier in matches)
            {
                ITaskObserver sliceObs = loopObs.InSlice(slices.Current);
                var           gDossier = mDossier.Groups["url_rep"];
                if (gDossier != null && !String.IsNullOrEmpty(gDossier.Value))
                {
                    string dossier     = gDossier.Value;
                    string pageDossier = OuvrirPage(RequêteDossier(compte, dossier), sliceObs.InSlice(0, 70));
                    if (!String.IsNullOrEmpty(pageDossier))
                    {
                        cabs.AddRange(CabsPourPage(pageDossier, compte.Editeur, sliceObs.InSlice(70, 100)));
                    }
                }
                slices.MoveNext();
            }
            observer.NotifyProgress(this, 100);
            return(cabs);
        }