public async Task Parse() { try { var speciesImageUrlsLU = await _tableStorage.GetAllAsync<SpeciesImageUrlLU>("speciesImageUrlsLU"); var speciesProcessor = new ExpandedContentSpeciesProcessor(_localization, speciesImageUrlsLU.ToList()); var species = await speciesProcessor.Process(_ecSpeciesFileName, _localization); foreach (var specie in species) { specie.ContentSourceEnum = ContentSource.EC; var specieSearchTerm = _globalSearchTermRepository.CreateSearchTerm(specie.Name, GlobalSearchTermType.Species, ContentType.ExpandedContent, $"/characters/species/{specie.Name}"); _globalSearchTermRepository.SearchTerms.Add(specieSearchTerm); } await _tableStorage.AddBatchAsync<Species>($"species{_localization.Language}", species, new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace }); } catch (StorageException) { Console.WriteLine("Failed to upload EC species."); } }
public override Task <List <Species> > FindBlocks(List <string> lines) { var species = new List <Species>(); for (var i = 0; i < lines.Count; i++) { if (!lines[i].StartsWith("> ## ") && !lines[i].StartsWith(">## ")) { continue; } var speciesEndIndex = lines.FindIndex(i + 1, f => f.StartsWith("> ## ") || f.StartsWith(">## ")); var speciesLines = lines.Skip(i).ToList(); if (speciesEndIndex != -1) { speciesLines = lines.Skip(i).Take(speciesEndIndex - i).CleanListOfStrings().ToList(); } var expandedContentSpeciesProcessor = new ExpandedContentSpeciesProcessor(Localization, _speciesImageUrlLus); species.Add(expandedContentSpeciesProcessor.ParseSpecies(speciesLines, ContentType.Core)); } return(Task.FromResult(species)); }