示例#1
0
        public async Task Run([CosmosDBTrigger(
                                   DatabaseName,
                                   CollectionName,
                                   ConnectionStringSetting = ConnectionString,
                                   LeaseCollectionName = LeaseCollectionName,
                                   //LeaseCollectionPrefix = LeaseCollectionPrefix,
                                   CreateLeaseCollectionIfNotExists = true
                                   )]
                              IReadOnlyList <Document> documents,
                              ILogger log,
                              [Inject] ReportGenerationServiceResolver reportGenerationServiceResolver,
                              [Inject] ICourseAuditService courseAuditService)
        {
            try
            {
                var reportGenerationService = reportGenerationServiceResolver(Models.ProcessType.Apprenticeship);

                // Index documents
                log.LogInformation("Entered ApprenticeshipChangeFeedTrigger");

                // Audit changes to documents
                // Generate report data
                foreach (string UKPRN in documents.Select(d => d.GetPropertyValue <string>("ProviderUKPRN"))
                         .Distinct())
                {
                    log.LogInformation($"Generating report data for provider {UKPRN}");
                    await reportGenerationService.UpdateReport(int.Parse(UKPRN));
                }
            }
            catch (Exception e)
            {
                log.LogError(e, "Indexing error in ApprenticeshipChangeFeedTrigger");
            }
        }
示例#2
0
 public static Task Run(
     [TimerTrigger("0 0 0 */1 * *")] TimerInfo timer,
     ILogger log,
     [Inject] ICourseAuditService courseAuditService)
 {
     return(courseAuditService.RepopulateSearchIndex(log));
 }
示例#3
0
        public async Task Run([CosmosDBTrigger(
                                   DatabaseName,
                                   CollectionName,
                                   ConnectionStringSetting = ConnectionString,
                                   LeaseCollectionName = LeaseCollectionName,
                                   //LeaseCollectionPrefix = LeaseCollectionPrefix,
                                   CreateLeaseCollectionIfNotExists = true
                                   )]
                              IReadOnlyList <Document> documents,
                              ILogger log,
                              [Inject] ReportGenerationServiceResolver reportGenerationServiceResolver,
                              [Inject] ICourseAuditService courseAuditService)
        {
            try
            {
                var reportGenerationService = reportGenerationServiceResolver(ProcessType.Course);

                // Index documents
                log.LogInformation("Entered FindACourseSearchCosmosTrigger");
                log.LogInformation($"Processing {documents.Count} documents for indexing to Azure search");
                IEnumerable <IndexingResult> results = await courseAuditService.UploadCoursesToSearch(log, documents);

                // Audit changes to documents
                CourseAudit ca = null;
                log.LogInformation($"Auditing changes to {documents.Count} documents");
                foreach (var document in documents)
                {
                    ca = await courseAuditService.Audit(log, document);
                }

                // Generate report data
                foreach (string UKPRN in documents.Select(d => d.GetPropertyValue <string>("ProviderUKPRN"))
                         .Distinct())
                {
                    log.LogInformation($"Generating report data for provider {UKPRN}");
                    await reportGenerationService.UpdateReport(int.Parse(UKPRN));
                }
            } catch (Exception e) {
                log.LogError(e, "Indexing error in FindACourseSearchCosmosTrigger");
            }
        }