Exemplo n.º 1
0
        /// <summary>
        /// Initialises a new instance of the <see cref="CategoryWatcher"/> class.
        /// </summary>
        /// <param name="category">
        /// The category.
        /// </param>
        /// <param name="mediaWikiSiteRepository">
        /// The media Wiki Site Repository.
        /// </param>
        /// <param name="ignoredPagesRepository">
        /// The ignored Pages Repository.
        /// </param>
        /// <param name="logger">
        /// The logger.
        /// </param>
        public CategoryWatcher(
            WatchedCategory category, 
            IMediaWikiSiteRepository mediaWikiSiteRepository, 
            IIgnoredPagesRepository ignoredPagesRepository, 
            ILogger logger)
        {
            this.watchedCategory = category;

            this.logger = logger;

            // look up site id
            string baseWiki = LegacyConfig.Singleton()["baseWiki"];
            MediaWikiSite mediaWikiSite = mediaWikiSiteRepository.GetById(int.Parse(baseWiki));
            this.site = mediaWikiSite;

            this.category = category.Category;
            this.key = category.Keyword;
            this.sleepTime = category.SleepTime;

            this.RegisterInstance();

            this.watcherThread = new Thread(this.WatcherThreadMethod);
            this.watcherThread.Start();

            this.ignoredPagesRepository = ignoredPagesRepository;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initialises a new instance of the <see cref="WatcherController"/> class.
        /// </summary>
        /// <param name="messageService">
        /// The message Service.
        /// </param>
        /// <param name="urlShorteningService">
        /// The url Shortening Service.
        /// </param>
        /// <param name="watchedCategoryRepository">
        /// The watched Category Repository.
        /// </param>
        /// <param name="mediaWikiSiteRepository">
        /// The media Wiki Site Repository.
        /// </param>
        /// <param name="ignoredPagesRepository">
        /// The ignored Pages Repository.
        /// </param>
        /// <param name="logger">
        /// The logger.
        /// </param>
        /// <param name="ircClient">
        /// The IRC Client.
        /// </param>
        /// <param name="legacyDatabase">
        /// The legacy Database.
        /// </param>
        protected WatcherController(
            IMessageService messageService, 
            IUrlShorteningService urlShorteningService, 
            IWatchedCategoryRepository watchedCategoryRepository, 
            IMediaWikiSiteRepository mediaWikiSiteRepository,
            IIgnoredPagesRepository ignoredPagesRepository,
            ILogger logger,
            IIrcClient ircClient,
            ILegacyDatabase legacyDatabase)
        {
            this.messageService = messageService;
            this.urlShorteningService = urlShorteningService;
            this.watchers = new Dictionary<string, CategoryWatcher>();
            this.logger = logger;
            this.ircClient = ircClient;

            foreach (WatchedCategory item in watchedCategoryRepository.Get())
            {
                var categoryWatcher = new CategoryWatcher(
                    item,
                    mediaWikiSiteRepository,
                    ignoredPagesRepository,
                    logger.CreateChildLogger("CategoryWatcher[" + item.Keyword + "]"));
                this.watchers.Add(item.Keyword, categoryWatcher);
                categoryWatcher.CategoryHasItemsEvent += this.CategoryHasItemsEvent;
            }

            this.legacyDatabase = legacyDatabase;
        }