/// <summary> /// Initialize the specified outputDirectory and type. /// </summary> /// <param name="outputDirectory">Output directory.</param> /// <param name="type">Type.</param> public void Initialize(string outputDirectory, SearchOutputType type) { _waiter.Reset(); if (_initialized) throw new NotSupportedException("This instance has already been initialized."); if (outputDirectory == null) throw new ArgumentNullException("outputDirectory"); if (!_directory.Exists(outputDirectory)) throw new DirectoryNotFoundException(string.Format("Output directory '{0}' doesn't exists.", _directory)); _outputDirectory = outputDirectory; _type = type; _initialized = true; _waiter.Set(); }
/// <summary> /// Searchs a media according some criterias. /// </summary> /// <returns>A task that represents the search operation.</returns> /// <param name="directory">Directory where to search.</param> /// <param name="outputType">The output where notify found result.</param> /// <param name="outputDirectory">Directory where result goes if the output type is Copy, Move or Link.</param> /// <param name="criteria">Criteria where to search. If no criteria specified, search on all known criteria.</param> /// <param name="dateFrom">Date from.</param> /// <param name="dateTo">Date to.</param> /// <param name="keywords">Keywords.</param> public async Task SearchMediaAsync( string directory, SearchOutputType outputType, string outputDirectory, SearchCriteria criteria, DateTime? dateFrom, DateTime? dateTo, string keywords) { if (directory == null) throw new ArgumentNullException("directory"); if (!_directory.Exists(directory)) throw new DirectoryNotFoundException(string.Format("Search directory '{0}' doesn't exists.", directory)); var tasks = _fileSystemHelper.ProcessForEachFilesAsync( new[] { directory }, true, FileFilterProvider.TagFileMatcher, (f, cts) => { Log.D("Check if file '{0}' is match to given criterias.", f); return Task.FromResult(0); }); await Task.WhenAll(tasks); // ISearchOutput output; // if (outputType.In(SearchOutputType.Copy, SearchOutputType.Move, SearchOutputType.Link)) // //outputDirectory = _path.Combine(Environment.CurrentDirectory, "SearchResult_" + DateTime.Now.ToString(FileSystemHelper.DATETIME_FILE_FORMAT)); // output = _fileOutput; // else // output = _consoleOutput; // Log.D("Search output is: {0}", output); }