示例#1
0
 public PageService(IImageAnalysisService imageAnalysisService, IMasterPageRepository masterPageRepository, IPageRepository pageRepository, IPageValidator pageValidator, IStorageService storageService)
 {
     _imageAnalysisService = imageAnalysisService;
     _masterPageRepository = masterPageRepository;
     _pageRepository       = pageRepository;
     _pageValidator        = pageValidator;
     _storageService       = storageService;
 }
示例#2
0
 /// <summary>
 /// Constructor sets dependent components.
 /// </summary>
 /// <param name="elementService">For element interactions.</param>
 /// <param name="imageAnalysisService">Used to retrieve image properties from uploaded files and resize images.</param>
 /// <param name="masterPageRepository">Master page repository.</param>
 /// <param name="masterPageService">Master page service.</param>
 /// <param name="pageRepository">Page repository.</param>
 /// <param name="pageValidator">Page validator.</param>
 /// <param name="unitOfWorkFactory">Unit of work factory.</param>
 /// <param name="uploadService">For the management of uploads.</param>
 public PageService(IElementService elementService, IImageAnalysisService imageAnalysisService, IMasterPageRepository masterPageRepository, IMasterPageService masterPageService, IPageRepository pageRepository, IPageValidator pageValidator, IUnitOfWorkFactory unitOfWorkFactory, IUploadService uploadService)
 {
     _elementService       = elementService;
     _imageAnalysisService = imageAnalysisService;
     _masterPageRepository = masterPageRepository;
     _masterPageService    = masterPageService;
     _pageRepository       = pageRepository;
     _pageValidator        = pageValidator;
     _unitOfWorkFactory    = unitOfWorkFactory;
     _uploadService        = uploadService;
 }
示例#3
0
        public Devourer(List<DevourTarget> initialTargets, IProxyProvider proxies, IPageValidator validator = null)
        {
            if (initialTargets == null || initialTargets.Count == 0 /*|| reader == null */ || proxies == null)
                throw new ArgumentException("Bad arguments");

            PreventSimilarTargetDownload = false;
            CookieOptions = CookieOptions.Empty;

            _proxies = proxies;
            _validator = validator;

            _successTargets = new List<Uri>();
            _faultTargets = new List<DevourTarget>();
            _allTargets = new HashSet<string>();

            InitializeStartTargets(initialTargets);

            SubscribeProxyProvider();
        }
示例#4
0
        public Devourer(List <DevourTarget> initialTargets, IProxyProvider proxies, IPageValidator validator = null)
        {
            if (initialTargets == null || initialTargets.Count == 0 /*|| reader == null */ || proxies == null)
            {
                throw new ArgumentException("Bad arguments");
            }

            PreventSimilarTargetDownload = false;
            CookieOptions = CookieOptions.Empty;

            _proxies   = proxies;
            _validator = validator;

            _successTargets = new List <Uri>();
            _faultTargets   = new List <DevourTarget>();
            _allTargets     = new HashSet <string>();

            InitializeStartTargets(initialTargets);

            SubscribeProxyProvider();
        }
示例#5
0
        private bool TryCheckDownloadSpeed(RatedProxy proxy, Uri uri, IPageValidator validator, ref double siteRate, ref double downloadSpeed)
        {
            Stopwatch timer = new Stopwatch();

            for (int i = 0; i < 3; i++)
            {
                DownloaderObj obj = new DownloaderObj(uri, null, true, proxy, CookieOptions.Empty, 1);
                timer.Restart();
                Downloader.DownloadSync(obj);
                timer.Stop();
                string data = obj.DataStr;
                if (data != null)
                {
                    if (validator.Validate(data))
                    {
                        siteRate = (1 - i / 3d);
                        int leng = Encoding.UTF8.GetBytes(data).Length;
                        downloadSpeed = Encoding.UTF8.GetBytes(data).Length / (double)timer.ElapsedMilliseconds; //KB-sec
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#6
0
 //RequestParams _params;
 public Devourer(DevourTarget initialTarget, IProxyProvider proxies, IPageValidator validator = null)
     : this(new List<DevourTarget>(new DevourTarget[] { initialTarget }), proxies, validator)
 {
 }
示例#7
0
 internal void RegisterPageValidator(IPageValidator pageValidator)
 {
   this.pageValidators.Add(pageValidator);
 }
示例#8
0
 private bool TryCheckDownloadSpeed(RatedProxy proxy, Uri uri, IPageValidator validator, ref double siteRate, ref double downloadSpeed)
 {
     Stopwatch timer = new Stopwatch();
     for (int i = 0; i < 3; i++)
     {
         DownloaderObj obj = new DownloaderObj(uri, null, true, proxy, CookieOptions.Empty, 1);
         timer.Restart();
         Downloader.DownloadSync(obj);
         timer.Stop();
         string data = obj.DataStr;
         if (data != null)
         {
             if (validator.Validate(data))
             {
                 siteRate = (1 - i / 3d);
                 int leng = Encoding.UTF8.GetBytes(data).Length;
                 downloadSpeed = Encoding.UTF8.GetBytes(data).Length / (double)timer.ElapsedMilliseconds; //KB-sec
                 return true;
             }
         }
     }
     return false;
 }
示例#9
0
        ConcurrentQueue <DevourTarget> _targets;           /* KEY -- faultCount, VALUE -- targetUri */
        //RequestParams _params;

        public Devourer(DevourTarget initialTarget, IProxyProvider proxies, IPageValidator validator = null)
            : this(new List <DevourTarget>(new DevourTarget[] { initialTarget }), proxies, validator)
        {
        }
示例#10
0
 public AuthorModel(IAuthorRepository repository, IDateValidator dateValidator, IPageValidator pageValidator)
 {
     _repository    = repository;
     _dateValidator = dateValidator;
     _pageValidator = pageValidator;
 }