public async Task <object> Add(IJournalMeta entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } var dbmodel = this.MapContractToModel(entity); await this.Collection.InsertOneAsync(dbmodel); return(dbmodel); }
public async Task <object> Update(IJournalMeta entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } var dbmodel = this.MapContractToModel(entity); var id = dbmodel.GetIdValue <BsonIdAttribute>(); var filter = this.GetFilterById(id); var result = await this.Collection.ReplaceOneAsync(filter, dbmodel); return(result); }
public DirectoryProcessor(string direcoryName, IJournalMeta journalMeta, IProcessorFactory processorFactory) { if (journalMeta == null) { throw new ArgumentNullException(nameof(journalMeta)); } if (processorFactory == null) { throw new ArgumentNullException(nameof(processorFactory)); } this.DirectoryName = direcoryName; this.journalMeta = journalMeta; this.processorFactory = processorFactory; }
public FileProcessor( string fileName, IJournalMeta journalMeta, IDocumentFactory documentFactory, IXmlFileContentDataService fileManager, IArticleMetaHarvester articleMetaHarvester, IModelFactory modelFactory, ILogger logger) { this.FileName = fileName; this.journalMeta = journalMeta ?? throw new ArgumentNullException(nameof(journalMeta)); this.documentFactory = documentFactory ?? throw new ArgumentNullException(nameof(documentFactory)); this.fileManager = fileManager ?? throw new ArgumentNullException(nameof(fileManager)); this.articleMetaHarvester = articleMetaHarvester ?? throw new ArgumentNullException(nameof(articleMetaHarvester)); this.modelFactory = modelFactory ?? throw new ArgumentNullException(nameof(modelFactory)); this.logger = logger; }
private void ProcessDirectories(string[] args, IJournalMeta journalMeta) { var directories = args.Where(this.FilterNonDashedOption) .Select(this.SelectDirectoryName) .Where(d => !string.IsNullOrWhiteSpace(d)) .ToArray(); foreach (var directoryName in directories) { this.logger?.Log(directoryName); var direcoryProcessor = this.processorFactory.CreateDirectoryProcessor(directoryName, journalMeta); // Processing of each should be executed strictly sequential // due to the changes of the current location. direcoryProcessor.Process().Wait(); } }
public async Task Run(params string[] args) { int numberOfDoubleDashedArguments = args.Count(this.FilterDoubleDashedOption); if (numberOfDoubleDashedArguments != 1) { await this.helpProvider.GetHelp(); return; } var journalId = args.Single(this.FilterDoubleDashedOption).Substring(2); IJournalMeta journalMeta = (await this.journalsMetaService.GetAllJournalsMeta()) .FirstOrDefault(j => j.Permalink == journalId); if (journalMeta == null) { this.logger?.Log(LogType.Error, "Journal not found"); return; } this.ProcessDirectories(args, journalMeta); }