Example #1
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);
        }
        public void FlightDataFlow_PostFile_CopiedToRawFolder()
        {
            var bufferBlock             = dataFlow.GetReadFileBufferBlock();
            DataflowLinkOptions options = new DataflowLinkOptions {
                PropagateCompletion = true
            };
            var readBlock = dataFlow.ReadDeserializeJsonfiles(RAWFolder);

            bufferBlock.Post(new List <string>(Directory.GetFiles(InputFolder)));
            bufferBlock.LinkTo(readBlock, options);
            bufferBlock.Complete();
            bufferBlock.Completion.ContinueWith(delegate { readBlock.Complete(); });
            readBlock.Completion.Wait(5000);

            var inputFilesCount = Directory.GetFiles(InputFolder).Length;
            var rawFilesCount   = Directory.GetFiles(RAWFolder).Length;

            Directory.GetFiles(RAWFolder).ToList().ForEach(file => File.Delete(file));
            Assert.AreEqual(inputFilesCount, rawFilesCount);
        }