Esempio n. 1
0
        private ThreadWatcher(SiteHelper siteHelper, ThreadWatcherConfig config)
        {
            SiteHelper               = siteHelper;
            PageUrl                  = config.PageUrl;
            PageHost                 = new Uri(PageUrl).Host;
            GlobalThreadID           = config.GlobalThreadID;
            AddedOn                  = config.AddedOn;
            BaseDownloadDirectory    = Settings.AbsoluteDownloadDirectory;
            PageBaseFileName         = config.PageBaseFileName;
            UseOriginalFileNames     = config.UseOriginalFileNames;
            MinCheckIntervalSeconds  = siteHelper.MinCheckIntervalSeconds;
            _pageAuth                = config.PageAuth;
            _imageAuth               = config.ImageAuth;
            _oneTimeDownload         = config.OneTimeDownload;
            _checkIntervalSeconds    = Math.Max(config.CheckIntervalSeconds, MinCheckIntervalSeconds);
            _description             = config.Description;
            _lastImageOn             = config.LastImageOn;
            _threadDownloadDirectory = config.RelativeDownloadDirectory != null?
                                       General.GetAbsoluteDirectoryPath(config.RelativeDownloadDirectory, BaseDownloadDirectory) :
                                           GetDesiredThreadDownloadDirectory();

            if (config.StopReason != null)
            {
                Stop(config.StopReason.Value);
            }
        }
Esempio n. 2
0
        public static ThreadWatcher Create(SiteHelper siteHelper, string pageUrl, string pageAuth, string imageAuth, bool oneTimeDownload, int checkIntervalSeconds, string description = null)
        {
            string globalThreadID      = siteHelper.GetGlobalThreadID();
            ThreadWatcherConfig config = new ThreadWatcherConfig {
                PageUrl              = pageUrl,
                GlobalThreadID       = globalThreadID,
                AddedOn              = DateTime.UtcNow,
                PageAuth             = pageAuth,
                ImageAuth            = imageAuth,
                UseOriginalFileNames = Settings.UseOriginalFileNames,
                OneTimeDownload      = oneTimeDownload,
                CheckIntervalSeconds = checkIntervalSeconds,
                PageBaseFileName     = General.CleanFileName(siteHelper.GetThreadName()),
                Description          = description ?? globalThreadID
            };

            return(new ThreadWatcher(siteHelper, config));
        }
Esempio n. 3
0
        public static ThreadWatcher Create(ThreadWatcherConfig config)
        {
            SiteHelper siteHelper = SiteHelper.CreateByUrl(config.PageUrl);

            return(new ThreadWatcher(siteHelper, config));
        }