Пример #1
0
        public async Task <bool> IsSigningNotificationPollRequiredAsync(CancellationToken cancellationToken)
        {
            var currentDateTime = _dateTimeProvider.GetNowUtc();

            var latestCollection = await _collectionReferenceDataService.GetLatestFundingClaimsCollectionAsync(cancellationToken, true);

            if (latestCollection == null || currentDateTime >= latestCollection.SignatureCloseDateUtc.GetValueOrDefault().AddDays(1))
            {
                _logger.LogInfo("no available collection which require signin possibly one day elapsed since signature closed");
                return(false);
            }

            if (latestCollection.IsOpenForSubmission)
            {
                _logger.LogInfo("Collection is still open , no feed poll required");
                return(false);
            }

            if (currentDateTime > latestCollection.SubmissionCloseDateUtc && currentDateTime <= latestCollection.SignatureCloseDateUtc.GetValueOrDefault())
            {
                _logger.LogInfo("Collection is still closed and we are between submission close and signature close , feed poll should be called");
                return(true);
            }

            var latestFeedEntry = await _feedRepository.GetLatestSyndicationDataAsync(cancellationToken);

            if (latestFeedEntry != null && latestFeedEntry.DateTimeUpdatedUtc < latestCollection.SignatureCloseDateUtc.GetValueOrDefault().AddHours(1))
            {
                _logger.LogInfo("Collection is closed and signature closed date is passed too, we are in the grace period of one hour, feed poll will be done");
                return(true);
            }

            _logger.LogInfo("Collection is closed and signature closed date is passed too, grace period of one hour is elapsed - No more feed poll required");
            return(false);
        }
        public async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            try
            {
                var latestFeedDetails = await _feedRepository.GetLatestSyndicationDataAsync(cancellationToken);

                var syncResult = await GetNewDataFromFeedAsync(cancellationToken, latestFeedDetails);

                var latestPageNumber = syncResult.OrderByDescending(x => x.PageNumber).FirstOrDefault()?.PageNumber;
                var lastItem         = syncResult.LastOrDefault(x => x.PageNumber == latestPageNumber);

                await _feedRepository.SaveFeedItemAsync(cancellationToken, lastItem);

                await _feedRepository.UpdateSubmissionFileAsync(cancellationToken, syncResult);
            }
            catch (Exception exception)
            {
                _logger.LogError("Funding claims signing notifications Feed retrieval Failed", exception);
                throw;
            }
        }