Example #1
0
        public async Task <bool> Handle(ExtractEnhancedAdherenceCounselling request, CancellationToken cancellationToken)
        {
            //Extract
            int found = await _EnhancedAdherenceCounsellingSourceExtractor.Extract(request.Extract, request.DatabaseProtocol);

            //Validate
            await _extractValidator.Validate(request.Extract.Id, found, nameof(EnhancedAdherenceCounsellingExtract), $"{nameof(TempEnhancedAdherenceCounsellingExtract)}s");

            //Load
            int loaded = await _EnhancedAdherenceCounsellingLoader.Load(request.Extract.Id, found, request.DatabaseProtocol.SupportsDifferential);

            int rejected =
                _extractHistoryRepository.ProcessRejected(request.Extract.Id, found - loaded, request.Extract);


            _extractHistoryRepository.ProcessExcluded(request.Extract.Id, rejected, request.Extract);

            //notify loaded
            DomainEvents.Dispatch(
                new ExtractActivityNotification(request.Extract.Id, new DwhProgress(
                                                    nameof(EnhancedAdherenceCounsellingExtract),
                                                    nameof(ExtractStatus.Loaded),
                                                    found, loaded, rejected, loaded, 0)));

            return(true);
        }
        public void should_Load()
        {
            Assert.True(_count > 0);
            Assert.False(_extractsContext.EnhancedAdherenceCounsellingExtracts.Any());

            var count = _loader.Load(_extract.Id, _count, false).Result;

            Assert.True(count > 0);
            _extractsContext = TestInitializer.ServiceProvider.GetService <ExtractsContext>();
            Assert.AreEqual(count, _extractsContext.EnhancedAdherenceCounsellingExtracts.Count());
            Log.Debug($"Temp {_count} Main {_extractsContext.EnhancedAdherenceCounsellingExtracts.Count()}");
        }