public void HandleAsync(ProviderAddedEvent <IApplication> message) { var appDefinition = (ApplicationDefinition)message.Definition; if (appDefinition.Enable) { var app = _applicationsFactory.GetInstance(appDefinition); var indexers = _indexerFactory.Enabled().Select(i => (IndexerDefinition)i.Definition).ToList(); SyncIndexers(new List <IApplication> { app }, indexers); } }
public override HealthCheck Check() { var enabled = _indexerFactory.Enabled(false); var expiringProviders = new List <IIndexer>(); var expiredProviders = new List <IIndexer>(); foreach (var provider in enabled) { var settingsType = provider.Definition.Settings.GetType(); var vipProp = settingsType.GetProperty("VipExpiration"); if (vipProp == null) { continue; } var expiration = (string)vipProp.GetValue(provider.Definition.Settings); if (expiration.IsNullOrWhiteSpace()) { continue; } if (DateTime.Parse(expiration).Before(DateTime.Now)) { expiredProviders.Add(provider); } if (DateTime.Parse(expiration).Between(DateTime.Now, DateTime.Now.AddDays(7))) { expiringProviders.Add(provider); } } if (!expiringProviders.Empty()) { return(new HealthCheck(GetType(), HealthCheckResult.Warning, string.Format(_localizationService.GetLocalizedString("IndexerVipCheckExpiringClientMessage"), string.Join(", ", expiringProviders.Select(v => v.Definition.Name))), "#indexer-vip-expiring")); } if (!expiredProviders.Empty()) { return(new HealthCheck(GetType(), HealthCheckResult.Warning, string.Format(_localizationService.GetLocalizedString("IndexerVipCheckExpiredClientMessage"), string.Join(", ", expiredProviders.Select(v => v.Definition.Name))), "#indexer-vip-expired")); } return(new HealthCheck(GetType())); }
public override HealthCheck Check() { var enabled = _indexerFactory.Enabled(false); if (enabled.Empty()) { return(new HealthCheck(GetType(), HealthCheckResult.Error, _localizationService.GetLocalizedString("IndexerHealthCheckNoIndexers"))); } return(new HealthCheck(GetType())); }
private async Task <List <ReleaseInfo> > Dispatch(Func <IIndexer, Task <IndexerPageableQueryResult> > searchAction, SearchCriteriaBase criteriaBase) { var indexers = _indexerFactory.Enabled(); if (criteriaBase.IndexerIds != null && criteriaBase.IndexerIds.Count > 0) { indexers = indexers.Where(i => criteriaBase.IndexerIds.Contains(i.Definition.Id) || (criteriaBase.IndexerIds.Contains(-1) && i.Protocol == DownloadProtocol.Usenet) || (criteriaBase.IndexerIds.Contains(-2) && i.Protocol == DownloadProtocol.Torrent)) .ToList(); } _logger.ProgressInfo("Searching indexer(s): [{0}] for {1}", string.Join(", ", indexers.Select(i => i.Definition.Name).ToList()), criteriaBase.ToString()); var tasks = indexers.Select(x => DispatchIndexer(searchAction, x, criteriaBase)); var batch = await Task.WhenAll(tasks); var reports = batch.SelectMany(x => x).ToList(); _logger.Debug("Total of {0} reports were found for {1} from {2} indexer(s)", reports.Count, criteriaBase, indexers.Count); return(reports); }