public void FlightDataFLow__PostFile_FileReadConvertedWrittenToDestination()
        {
            var bufferBlock             = dataFlow.GetReadFileBufferBlock();
            DataflowLinkOptions options = new DataflowLinkOptions {
                PropagateCompletion = true
            };
            var readBlock      = dataFlow.ReadDeserializeJsonfiles(RAWFolder);
            var transformBLock = dataFlow.TransformEventsData(CuratedFolder, ExceptionFolder);

            bufferBlock.LinkTo(readBlock, options);
            readBlock.LinkTo(transformBLock, options);

            bufferBlock.Post(new List <string>(Directory.GetFiles(InputFolder)));
            bufferBlock.Complete();

            bufferBlock.Completion.ContinueWith(delegate { readBlock.Complete(); });
            readBlock.Completion.ContinueWith(delegate { transformBLock.Complete(); });

            transformBLock.Completion.Wait(5000);

            var allTransformedFilesCount = Directory.GetFiles(CuratedFolder, "*.json", SearchOption.AllDirectories).Count() +
                                           Directory.GetFiles(ExceptionFolder, "*.json", SearchOption.AllDirectories).Count();

            Assert.AreNotEqual(0, allTransformedFilesCount);

            Directory.GetFiles(CuratedFolder, "*.json", SearchOption.AllDirectories).ToList().ForEach(file => File.Delete(file));
            Directory.GetFiles(ExceptionFolder, "*.json", SearchOption.AllDirectories).ToList().ForEach(file => File.Delete(file));
            Directory.GetFiles(RAWFolder).ToList().ForEach(file => File.Delete(file));
        }
Example #2
0
        public async Task <ActionBlock <IList <RootData> > > Process(BufferBlock <IList <string> > batchBlock)
        {
            var linkOptions = new DataflowLinkOptions {
                PropagateCompletion = true
            };

            var readDataContentBlock      = dataFlowBlockProvider.ReadDeserializeJsonfiles(PathUtility.RawFolder);
            var transformDataContentBlock = dataFlowBlockProvider.TransformEventsData(PathUtility.CuratedFolder, PathUtility.ExceptionFolder);

            while (await batchBlock.OutputAvailableAsync())
            {
                readDataContentBlock.Post(batchBlock.Receive());
            }

            batchBlock.LinkTo(readDataContentBlock, linkOptions);


            readDataContentBlock.LinkTo(transformDataContentBlock, linkOptions);


            await batchBlock.Completion.ContinueWith(delegate { readDataContentBlock.Complete(); });

            await readDataContentBlock.Completion.ContinueWith(delegate { transformDataContentBlock.Complete(); });

            return(transformDataContentBlock);
        }