public async Task <bool> Handle(ExtractCwcVisit request, CancellationToken cancellationToken)
        {
            //Extract
            int found = await _cwcVisitSourceExtractor.Extract(request.Extract, request.DatabaseProtocol);

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

            //Load
            int loaded = await _cwcVisitLoader.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 MnchExtractActivityNotification(request.Extract.Id, new DwhProgress(
                                                        nameof(CwcVisitExtract),
                                                        nameof(ExtractStatus.Loaded),
                                                        found, loaded, rejected, loaded, 0)));

            return(true);
        }
Exemplo n.º 2
0
 public void SetUp()
 {
     _loader    = TestInitializer.ServiceProvider.GetService <ICwcVisitLoader>();
     _extractor = TestInitializer.ServiceProvider.GetService <ICwcVisitSourceExtractor>();
     _extract   = _extracts.First(x => x.Name.IsSameAs(nameof(CwcVisitExtract)));
     _count     = _extractor.Extract(_extract, _protocol).Result;
 }
Exemplo n.º 3
0
        public void should_Extract(string name)
        {
            Assert.False(_extractsContext.TempCwcVisitExtracts.Any());
            var extract = _extracts.First(x => x.Name.IsSameAs(name));

            var count = _extractor.Extract(extract, _protocol).Result;

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