/// <summary> /// Move all from Input-Directory to Output-Directory, well named. /// Then for each new item, invoke "duplicate" check. For that, hash needs to be calculated first /// </summary> /// <returns></returns> public Task Run() { var fileScannerBlock = BlockCreator.CreateFileScannerBlock(); var hashBlock = this.CreateHashBlock(); // either move to recycle as duplicate var moveToRecycleBin = BlockCreator.CreateMoverAction(this.recycleBin.FullName); var finish = new ActionBlock <PhotoContext>(context => { }); // or continue with the meta data analysis var analysis = BlockCreator.ReadImageMetadataBlock(); var suggestion = BlockCreator.CreateSuggestionBlock(); var mover = BlockCreator.CreateMoverAction(); var batched = new BatchBlock <PhotoContext>(100); var registerMetadata = this.CreateRegisterMetadataBlock(); fileScannerBlock.LinkTo(hashBlock, DataflowLinkOptions); // if hash is known -> move to recycle // if unknown, calculate other metrics and continue processing... var checkDuplicate = this.CreateCheckDuplicateBlock(analysis, moveToRecycleBin); hashBlock.LinkTo(checkDuplicate, DataflowLinkOptions); analysis.LinkTo(suggestion, DataflowLinkOptions); suggestion.LinkTo(mover, DataflowLinkOptions); mover.LinkTo(batched, DataflowLinkOptions); batched.LinkTo(registerMetadata, DataflowLinkOptions); moveToRecycleBin.LinkTo(finish, DataflowLinkOptions); finish.Completion.ContinueWith(task => { Log.Information("Moving to recycle bin completed.."); }); var dbDisposed = registerMetadata.Completion.ContinueWith(task => { Log.Information("Processing of new pictures completed.."); this.db.Dispose(); }); var processContext = new ProcessContext(this.inputDirectoryInfo, this.outputDirectoryInfo); fileScannerBlock.Post(processContext); fileScannerBlock.Complete(); return(Task.WhenAll( dbDisposed, finish.Completion)); }
public Task Run() { var fileScannerBlock = BlockCreator.CreateFileScannerBlock(); var analysis = BlockCreator.ReadImageMetadataBlock(); var filter = BlockCreator.CreateFilterBlock(); var suggestion = BlockCreator.CreateSuggestionBlock(); var mover = BlockCreator.CreateMoverAction(); fileScannerBlock.LinkTo(analysis, DataflowLinkOptions); analysis.LinkTo(filter, DataflowLinkOptions); filter.LinkTo(suggestion, DataflowLinkOptions); suggestion.LinkTo(mover, DataflowLinkOptions); var processContext = new ProcessContext(this.inputDirectoryInfo, this.outputDirectoryInfo); fileScannerBlock.Post(processContext); fileScannerBlock.Complete(); return(mover.Completion); }