public async Task Parse()
        {
            try
            {
                var expandedContentBackgroundProcessor = new ExpandedContentBackgroundProcessor(_localization);
                var backgrounds = await expandedContentBackgroundProcessor.Process(_ecBackgroundsFileName, _localization);

                foreach (var background in backgrounds)
                {
                    background.ContentSourceEnum = ContentSource.EC;

                    var backgroundSearchTerm = _globalSearchTermRepository.CreateSearchTerm(background.Name,
                                                                                            GlobalSearchTermType.Background, ContentType.ExpandedContent,
                                                                                            $"/characters/backgrounds/{background.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(backgroundSearchTerm);
                }

                await _tableStorage.AddBatchAsync <Background>($"backgrounds{_localization.Language}", backgrounds,
                                                               new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload EC backgrounds.");
            }
        }
Esempio n. 2
0
        public async Task <List <Power> > Parse()
        {
            var forcePowers = new List <Power>();

            try
            {
                var forcePowersProcessor = new ExpandedContentForcePowersProcessor();
                forcePowers = await forcePowersProcessor.Process(_ecForcePowersFileName, _localization);

                foreach (var forcePower in forcePowers)
                {
                    forcePower.ContentSourceEnum = ContentSource.EC;

                    var forcePowerSearchTerm = _globalSearchTermRepository.CreateSearchTerm(forcePower.Name,
                                                                                            GlobalSearchTermType.ForcePower, ContentType.ExpandedContent,
                                                                                            $"/characters/forcePowers/?search={forcePower.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(forcePowerSearchTerm);
                }

                await _tableStorage.AddBatchAsync <Power>($"powers{_localization.Language}", forcePowers,
                                                          new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload EC force powers.");
            }

            return(forcePowers);
        }
Esempio n. 3
0
        public async Task <List <ReferenceTable> > Parse()
        {
            var tables = await _referenceTableProcessor.Process(_referenceTableFileNames, _localization);

            await _tableStorage.AddBatchAsync <ReferenceTable>($"referenceTables{_localization.Language}", tables,
                                                               new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });

            return(tables);
        }
Esempio n. 4
0
        public async Task Upload()
        {
            var existingSearchTerms = (await _tableStorage.GetAllAsync <GlobalSearchTerm>("searchTerms")).ToList();

            var i = 1;

            Parallel.ForEach(existingSearchTerms, new ParallelOptions {
                MaxDegreeOfParallelism = Environment.ProcessorCount
            }, async existingSearchTerm =>
            {
                await _tableStorage.DeleteAsync("searchTerms", existingSearchTerm);
                Console.WriteLine($"Deleted {i} of {existingSearchTerms.Count} existing search terms.");
                i++;
            });

            foreach (var globalSearchTerm in _globalSearchTermRepository.SearchTerms)
            {
                globalSearchTerm.LanguageEnum = _localization.Language;
            }

            await _tableStorage.AddBatchAsync <GlobalSearchTerm>("searchTerms",
                                                                 _globalSearchTermRepository.SearchTerms.Where(s =>
                                                                                                               s.PartitionKey == ContentType.ExpandedContent.ToString()),
                                                                 new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.Insert });

            await _tableStorage.AddBatchAsync <GlobalSearchTerm>("searchTerms",
                                                                 _globalSearchTermRepository.SearchTerms.Where(s =>
                                                                                                               s.PartitionKey == ContentType.Core.ToString()),
                                                                 new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.Insert });

            var index = await _searchIndexClient.GetIndexAsync("searchterms-index");

            await _searchIndexClient.DeleteIndexAsync("searchterms-index");

            await _searchIndexClient.CreateIndexAsync(index);

            var oldIndexer = await _searchIndexerClient.GetIndexerAsync("searchterms-indexer");

            await _searchIndexerClient.DeleteIndexerAsync(oldIndexer);

            await _searchIndexerClient.CreateIndexerAsync(oldIndexer);

            await _searchIndexerClient.RunIndexerAsync("searchterms-indexer");
        }
        public async Task Parse()
        {
            try
            {
                var enhancedItems = await _expandedContentEnhancedItemsProcessor.Process(_ecEnhancedItemsFileName, _localization);

                foreach (var enhancedItem in enhancedItems)
                {
                    enhancedItem.ContentSourceEnum = ContentSource.EC;

                    var enhancedItemSearchTerm = _globalSearchTermRepository.CreateSearchTerm(enhancedItem.Name, GlobalSearchTermType.EnhancedItem, ContentType.ExpandedContent,
                                                                                              $"/loot/enhancedItems?search={enhancedItem.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(enhancedItemSearchTerm);
                }

                await _tableStorage.AddBatchAsync <EnhancedItem>($"enhancedItems{_localization.Language}", enhancedItems,
                                                                 new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload EC enhanced items.");
            }
        }
        public async Task Parse(List <ReferenceTable> referenceTables = null)
        {
            try
            {
                var rules = await _starshipChapterRulesProcessor.Process(_sotgFilesName, _localization);

                if (referenceTables != null)
                {
                    foreach (var chapterRule in rules)
                    {
                        foreach (var referenceTable in referenceTables)
                        {
                            chapterRule.ContentMarkdown = Regex.Replace(chapterRule.ContentMarkdown,
                                                                        $@"(?<!#\s*){referenceTable.Name}", $"[{referenceTable.Name}](#{Uri.EscapeUriString(referenceTable.Name)})", RegexOptions.IgnoreCase);
                        }
                    }
                }

                await _blobContainerClient.CreateIfNotExistsAsync();

                foreach (var chapterRules in rules)
                {
                    var json       = JsonConvert.SerializeObject(chapterRules);
                    var blobClient = _blobContainerClient.GetBlobClient($"{chapterRules.ChapterName}.json");

                    var content = Encoding.UTF8.GetBytes(json);
                    using (var ms = new MemoryStream(content))
                    {
                        await blobClient.UploadAsync(ms, true);
                    }
                }
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload SOTG rules.");
            }

            try
            {
                var deployments =
                    await _starshipDeploymentProcessor.Process(_sotgFilesName.Where(f => f.Equals("SOTG.sotg_02.txt")).ToList(), _localization);

                foreach (var deployment in deployments)
                {
                    deployment.ContentSourceEnum = ContentSource.SotG;

                    var deploymentSearchTerm = _globalSearchTermRepository.CreateSearchTerm(deployment.Name, GlobalSearchTermType.Deployment, ContentType.Core,
                                                                                            $"/starships/deployments/{deployment.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(deploymentSearchTerm);
                }

                if (referenceTables != null)
                {
                    foreach (var deployment in deployments)
                    {
                        foreach (var referenceTable in referenceTables)
                        {
                            if (deployment.Features != null)
                            {
                                foreach (var deploymentFeature in deployment.Features)
                                {
                                    if (deploymentFeature.Content != null)
                                    {
                                        deploymentFeature.Content = Regex.Replace(deploymentFeature.Content,
                                                                                  $@"(?<!#\s*){referenceTable.Name}", $"[{referenceTable.Name}](#{Uri.EscapeUriString(referenceTable.Name)})",
                                                                                  RegexOptions.IgnoreCase);
                                    }
                                }
                            }
                        }
                    }
                }

                await _tableStorage.AddBatchAsync <StarshipDeployment>($"starshipDeployments{_localization.Language}", deployments,
                                                                       new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload SOTG deployments.");
            }

            try
            {
                var equipment = await _starshipEquipmentProcessor.Process(_sotgFilesName.Where(f => f.Equals("SOTG.sotg_05.txt")).ToList(), _localization);

                if (referenceTables != null)
                {
                    foreach (var starshipEquipment in equipment)
                    {
                        if (starshipEquipment.Description != null)
                        {
                            foreach (var referenceTable in referenceTables)
                            {
                                starshipEquipment.Description = Regex.Replace(starshipEquipment.Description,
                                                                              $@"(?<!#\s*){referenceTable.Name}", $"[{referenceTable.Name}](#{Uri.EscapeUriString(referenceTable.Name)})", RegexOptions.IgnoreCase);
                            }
                        }
                    }
                }

                var dupes = equipment
                            .GroupBy(i => i.RowKey)
                            .Where(g => g.Count() > 1)
                            .Select(g => g.Key);

                foreach (var starshipEquipment in equipment)
                {
                    starshipEquipment.ContentSourceEnum = ContentSource.SotG;

                    switch (starshipEquipment.TypeEnum)
                    {
                    case StarshipEquipmentType.Armor:
                    case StarshipEquipmentType.Shield:
                    case StarshipEquipmentType.Ammunition:
                    case StarshipEquipmentType.Hyperdrive:
                    case StarshipEquipmentType.Navcomputer:
                    case StarshipEquipmentType.PowerCoupling:
                    case StarshipEquipmentType.Reactor:
                        var equipmentSearchTerm = _globalSearchTermRepository.CreateSearchTerm(starshipEquipment.Name, GlobalSearchTermType.StarshipEquipment, ContentType.Core,
                                                                                               $"/starships/equipment?search={starshipEquipment.Name}");
                        _globalSearchTermRepository.SearchTerms.Add(equipmentSearchTerm);
                        break;

                    case StarshipEquipmentType.Weapon:
                        var weaponSearchTerm = _globalSearchTermRepository.CreateSearchTerm(starshipEquipment.Name, GlobalSearchTermType.StarshipWeapon, ContentType.Core,
                                                                                            $"/starships/weapons?search={starshipEquipment.Name}");
                        _globalSearchTermRepository.SearchTerms.Add(weaponSearchTerm);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                await _tableStorage.AddBatchAsync <StarshipEquipment>($"starshipEquipment{_localization.Language}", equipment,
                                                                      new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException e)
            {
                Console.WriteLine("Failed to upload SOTG equipment.");
            }

            try
            {
                var modifications = await _starshipModificationProcessor.Process(_sotgFilesName.Where(f => f.Equals("SOTG.sotg_04.txt")).ToList(), _localization);

                if (referenceTables != null)
                {
                    foreach (var modification in modifications)
                    {
                        if (modification.Content != null)
                        {
                            foreach (var referenceTable in referenceTables)
                            {
                                modification.Content = Regex.Replace(modification.Content,
                                                                     $@"(?<!#\s*){referenceTable.Name}", $"[{referenceTable.Name}](#{Uri.EscapeUriString(referenceTable.Name)})", RegexOptions.IgnoreCase);
                            }
                        }
                    }
                }

                foreach (var modification in modifications)
                {
                    modification.ContentSourceEnum = ContentSource.SotG;

                    var modificationSearchTerm = _globalSearchTermRepository.CreateSearchTerm(modification.Name, GlobalSearchTermType.StarshipModification, ContentType.Core,
                                                                                              $"/starships/modifications?search={modification.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(modificationSearchTerm);
                }

                await _tableStorage.AddBatchAsync <StarshipModification>($"starshipModifications{_localization.Language}", modifications,
                                                                         new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException e)
            {
                Console.WriteLine("Failed to upload SOTG modifications.");
            }

            try
            {
                var sizes = await _starshipSizeProcessor.Process(_sotgFilesName.Where(f => f.Equals("SOTG.sotg_03.txt")).ToList(), _localization);

                foreach (var size in sizes)
                {
                    size.ContentSourceEnum = ContentSource.SotG;

                    var sizeSearchTerm = _globalSearchTermRepository.CreateSearchTerm(size.Name, GlobalSearchTermType.StarshipSize, ContentType.Core,
                                                                                      $"/rules/sotg/starshipSizes/{size.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(sizeSearchTerm);
                }

                await _tableStorage.AddBatchAsync <StarshipBaseSize>($"starshipBaseSizes{_localization.Language}", sizes,
                                                                     new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload SOTG sizes.");
            }

            try
            {
                var ventures = await _starshipVentureProcessor.Process(_sotgFilesName.Where(f => f.Equals("SOTG.sotg_06.txt")).ToList(), _localization);

                foreach (var venture in ventures)
                {
                    venture.ContentSourceEnum = ContentSource.SotG;

                    var sizeSearchTerm = _globalSearchTermRepository.CreateSearchTerm(venture.Name, GlobalSearchTermType.Venture, ContentType.Core,
                                                                                      $"/starships/ventures?search={venture.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(sizeSearchTerm);
                }
                await _tableStorage.AddBatchAsync <StarshipVenture>($"starshipVentures{_localization.Language}", ventures,
                                                                    new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload SOTG ventures.");
            }
        }
Esempio n. 7
0
        public async Task Parse()
        {
            try
            {
                var ecFeats = await _expandedContentCustomizationOptionsFeatProcessor.Process(_ecCustomizationOptionsFileName, _localization);

                foreach (var feat in ecFeats)
                {
                    feat.ContentSourceEnum = ContentSource.EC;

                    var featSearchTerm = _globalSearchTermRepository.CreateSearchTerm(feat.Name, GlobalSearchTermType.Feat, ContentType.ExpandedContent,
                                                                                      $"/characters/feats/?search={feat.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(featSearchTerm);
                }

                await _tableStorage.AddBatchAsync <Feat>($"feats{_localization.Language}", ecFeats,
                                                         new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload EC feats.");
            }

            try
            {
                var expandedContentCustomizationOptionsLightsaberFormsProcessor = new ExpandedContentCustomizationOptionsLightsaberFormsProcessor();

                var ecLightsaberForms =
                    await expandedContentCustomizationOptionsLightsaberFormsProcessor.Process(
                        _ecCustomizationOptionsFileName, _localization, ContentType.ExpandedContent);

                foreach (var lightsaberForm in ecLightsaberForms)
                {
                    lightsaberForm.ContentSourceEnum = ContentSource.EC;

                    var lightsaberFormSearchTerm = _globalSearchTermRepository.CreateSearchTerm(lightsaberForm.Name, GlobalSearchTermType.LightsaberForm, ContentType.ExpandedContent,
                                                                                                $"/characters/lightsaberForms/?search={lightsaberForm.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(lightsaberFormSearchTerm);
                }

                await _tableStorage.AddBatchAsync <LightsaberForm>($"lightsaberForms{_localization.Language}", ecLightsaberForms,
                                                                   new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload EC fighting styles.");
            }

            //try
            //{
            //    var ecFightingStyles =
            //        await _expandedContentCustomizationOptionsFightingStyleProcessor.Process(
            //            _ecCustomizationOptionsFileName, _localization, ContentType.ExpandedContent);

            //    foreach (var fightingStyle in ecFightingStyles)
            //    {
            //        fightingStyle.ContentSourceEnum = ContentSource.EC;

            //        var fightingStyleSearchTerm = _globalSearchTermRepository.CreateSearchTerm(fightingStyle.Name, GlobalSearchTermType.FightingStyle, ContentType.ExpandedContent,
            //            $"/characters/fightingStyles/?search={fightingStyle.Name}");
            //        _globalSearchTermRepository.SearchTerms.Add(fightingStyleSearchTerm);
            //    }

            //    await _tableStorage.AddBatchAsync<FightingStyle>($"fightingStyles{_localization.Language}", ecFightingStyles,
            //        new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            //}
            //catch (StorageException)
            //{
            //    Console.WriteLine("Failed to upload EC fighting styles.");
            //}

            //try
            //{
            //    var ecFightingMasteries =
            //        await _expandedContentCustomizationOptionsFightingMasteryProcessor.Process(
            //            _ecCustomizationOptionsFileName, _localization, ContentType.ExpandedContent);

            //    foreach (var fightingMastery in ecFightingMasteries)
            //    {
            //        fightingMastery.ContentSourceEnum = ContentSource.EC;

            //        var fightingMasterySearchTerm = _globalSearchTermRepository.CreateSearchTerm(fightingMastery.Name, GlobalSearchTermType.FightingMastery, ContentType.ExpandedContent,
            //            $"/characters/fightingMasteries/?search={fightingMastery.Name}");
            //        _globalSearchTermRepository.SearchTerms.Add(fightingMasterySearchTerm);
            //    }

            //    await _tableStorage.AddBatchAsync<FightingStyle>($"fightingMasteries{_localization.Language}", ecFightingMasteries,
            //        new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            //}
            //catch (StorageException)
            //{
            //    Console.WriteLine("Failed to upload EC fighting masteries.");
            //}
        }
Esempio n. 8
0
        public static async Task Parse(IServiceProvider serviceProvider, IAzureTableStorage azureTableStorage,
                                       GlobalSearchTermRepository globalSearchTermRepository, ILocalization localization)
        {
            var playerHandbookManager = new PlayerHandbookManager(serviceProvider, localization);
            var wretchedHivesManager  = new WretchedHivesManager(serviceProvider, localization);
            var starshipManager       = new StarshipsOfTheGalaxyManager(serviceProvider, localization);
            var monsterManualManager  =
                new MonsterManualManager(azureTableStorage, globalSearchTermRepository, localization);
            var extendedContentSpeciesManager =
                new ExpandedContentSpeciesManager(serviceProvider, localization);
            var extendedContentBackgroundManager =
                new ExpandedContentBackgroundsManager(azureTableStorage, globalSearchTermRepository, localization);
            var extendedContentEquipmentManager =
                new ExpandedContentEquipmentManager(azureTableStorage, globalSearchTermRepository, localization);
            var extendedContentArchetypesManager =
                new ExpandedContentArchetypesManager(serviceProvider, localization);
            var extendedContentVariantRulesManager =
                new ExpandedContentVariantRulesManager(serviceProvider, localization);
            var expandedContentManager =
                new ExpandedContentManager(serviceProvider, localization);
            var extendedContentCustomizationOptionsManager =
                new ExpandedContentCustomizationOptionsManager(azureTableStorage, globalSearchTermRepository,
                                                               localization);
            var extendedContentForcePowersManager =
                new ExpandedContentForcePowersManager(azureTableStorage, globalSearchTermRepository, localization);
            var extendedContentTechPowersManager =
                new ExpandedContentTechPowersManager(azureTableStorage, globalSearchTermRepository, localization);
            var referenceTableManager = new ReferenceTableManager(azureTableStorage, localization);
            var creditsManager        = new CreditsManager(serviceProvider, localization);
            var extendedContentEnhancedItemManager =
                new ExpandedContentEnhancedItemsManager(azureTableStorage, globalSearchTermRepository, localization);

            var referenceTables = await referenceTableManager.Parse();

            var powers = await playerHandbookManager.Parse();

            powers.AddRange(await extendedContentTechPowersManager.Parse());
            powers.AddRange(await extendedContentForcePowersManager.Parse());
            await wretchedHivesManager.Parse();

            await starshipManager.Parse(referenceTables);

            await monsterManualManager.Parse(powers);

            await extendedContentSpeciesManager.Parse();

            await extendedContentBackgroundManager.Parse();

            await extendedContentEquipmentManager.Parse();

            await extendedContentArchetypesManager.Parse();

            await extendedContentVariantRulesManager.Parse();

            await expandedContentManager.Parse();

            await extendedContentCustomizationOptionsManager.Parse();

            await creditsManager.Parse();

            await extendedContentEnhancedItemManager.Parse();

            try
            {
                var searchServiceClient = serviceProvider.GetService <SearchIndexClient>();

                if (searchServiceClient != null)
                {
                    var searchManager = new SearchManager(serviceProvider, localization);
                    await searchManager.Upload();
                }
            }
            catch (StorageException)
            {
                var searchTerms = globalSearchTermRepository.SearchTerms;
                var dupes       = searchTerms
                                  .GroupBy(i => i.RowKey)
                                  .Where(g => g.Count() > 1)
                                  .Select(g => g.Key);

                foreach (var dupe in dupes)
                {
                    Console.WriteLine($"Dupe: {dupe}");
                }

                var nonConformingNames = searchTerms.Where(s => Regex.IsMatch(s.RowKey, @"[\\]|[/]|[#]|[?] "));
                foreach (var nonConformingName in nonConformingNames)
                {
                    Console.WriteLine($"Non-conforming: {nonConformingName}");
                }

                Console.WriteLine("Failed to upload search terms.");
            }

            try
            {
                var features        = serviceProvider.GetService <FeatureRepository>()?.Features;
                var sheetOperations = new SheetOperations(serviceProvider);

                if (features != null && serviceProvider.GetService <IConfiguration>()?["FeaturesSheetId"] != null)
                {
                    var featureSheetData = features.Select(c => new List <object> {
                        c.RowKey, c.Level
                    } as IList <object>).ToList();
                    await sheetOperations.UpdateFeatureSheetAsync(featureSheetData);

                    Console.WriteLine("Successfully wrote features to Features Parsed sheet.");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to write features to sheet.");
            }

            try
            {
                var currentVersion =
                    (await azureTableStorage.GetAsync <DataVersion>($"dataVersion{localization.Language}", ContentType.Core.ToString(),
                                                                    "MASTERVERSION"))?.Version;

                var dataNames = new List <string>
                {
                    "MASTERVERSION", "archetypes", "armorProperties", "backgrounds", "classes", "credits",
                    "enhancedItems", "equipment", "feats", "features", "monsters", "powers", "referenceTables", "species", "starshipBaseSizes",
                    "starshipDeployments", "starshipEquipment", "starshipModifications", "starshipVentures", "weaponProperties",
                    "player-handbook-rules", "starships-rules", "variant-rules", "wretched-hives-rules",
                    "characterAdvancementLU", "conditionsLU", "featureDataLU", "featureLevelLU", "skillsLU", "fightingStyle",
                    "fightingMastery", "expanded-content"
                };
                var dataVersions = dataNames.Select(d => new DataVersion
                {
                    LastUpdated  = DateTime.Now,
                    Name         = d,
                    PartitionKey = ContentType.Core.ToString(),
                    RowKey       = d,
                    Version      = currentVersion + 1 ?? 1
                });

                await azureTableStorage.AddBatchAsync <DataVersion>($"dataVersion{localization.Language}", dataVersions,
                                                                    new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to update data versions.");
            }
        }
        public async Task Parse()
        {
            try
            {
                var rules = await _wretchedHivesChapterRulesProcessor.Process(_whFilesName, _localization);

                await _blobContainerClient.CreateIfNotExistsAsync();

                foreach (var chapterRules in rules)
                {
                    var json       = JsonConvert.SerializeObject(chapterRules);
                    var blobClient = _blobContainerClient.GetBlobClient($"{chapterRules.ChapterName}.json");

                    var content = Encoding.UTF8.GetBytes(json);
                    using (var ms = new MemoryStream(content))
                    {
                        await blobClient.UploadAsync(ms, true);
                    }
                }
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload WH rules.");
            }

            try
            {
                var enhancedItemProcessor = new EnhancedItemProcessor(_localization);
                var enhancedItems         = await enhancedItemProcessor.Process(_whFilesName.Where(f => f.Equals("WH.wh_aa.txt")).ToList(), _localization);

                foreach (var enhancedItem in enhancedItems)
                {
                    enhancedItem.ContentSourceEnum = ContentSource.WH;

                    var enhancedItemSearchTerm = _globalSearchTermRepository.CreateSearchTerm(enhancedItem.Name, GlobalSearchTermType.EnhancedItem, ContentType.Core,
                                                                                              $"/loot/enhancedItems?search={enhancedItem.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(enhancedItemSearchTerm);
                }

                await _tableStorage.AddBatchAsync <EnhancedItem>($"enhancedItems{_localization.Language}", enhancedItems,
                                                                 new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload WH enhanced items.");
            }

            try
            {
                var equipment =
                    await _wretchedHivesEquipmentProcessor.Process(new List <string> {
                    "WH.wh_05.txt"
                }, _localization);

                foreach (var equipment1 in equipment)
                {
                    equipment1.ContentSourceEnum = ContentSource.WH;

                    switch (equipment1.EquipmentCategoryEnum)
                    {
                    case EquipmentCategory.Unknown:
                    case EquipmentCategory.Ammunition:
                    case EquipmentCategory.Explosive:
                    case EquipmentCategory.Storage:
                    case EquipmentCategory.AdventurePack:
                    case EquipmentCategory.Communications:
                    case EquipmentCategory.DataRecordingAndStorage:
                    case EquipmentCategory.LifeSupport:
                    case EquipmentCategory.Medical:
                    case EquipmentCategory.WeaponOrArmorAccessory:
                    case EquipmentCategory.Tool:
                    case EquipmentCategory.Mount:
                    case EquipmentCategory.Vehicle:
                    case EquipmentCategory.TradeGood:
                    case EquipmentCategory.Utility:
                    case EquipmentCategory.GamingSet:
                    case EquipmentCategory.MusicalInstrument:
                    case EquipmentCategory.Droid:
                    case EquipmentCategory.Clothing:
                    case EquipmentCategory.AlcoholicBeverage:
                    case EquipmentCategory.Spice:
                    case EquipmentCategory.Kit:
                        var equipmentSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment1.Name,
                                                                                               GlobalSearchTermType.AdventuringGear, ContentType.Core,
                                                                                               $"/loot/adventuringGear/?search={equipment1.Name}");
                        _globalSearchTermRepository.SearchTerms.Add(equipmentSearchTerm);
                        break;

                    case EquipmentCategory.Weapon:
                        var weaponSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment1.Name,
                                                                                            GlobalSearchTermType.Weapon, ContentType.Core,
                                                                                            $"/loot/weapons/?search={equipment1.Name}");
                        _globalSearchTermRepository.SearchTerms.Add(weaponSearchTerm);
                        break;

                    case EquipmentCategory.Armor:
                        var searchTermType = GlobalSearchTermType.Armor;
                        if (equipment1.ArmorClassificationEnum == ArmorClassification.Shield)
                        {
                            searchTermType = GlobalSearchTermType.Shield;
                        }

                        var armorSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment1.Name,
                                                                                           searchTermType, ContentType.Core,
                                                                                           $"/loot/armor/?search={equipment1.Name}");
                        _globalSearchTermRepository.SearchTerms.Add(armorSearchTerm);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                var dupes = equipment
                            .GroupBy(i => i.RowKey)
                            .Where(g => g.Count() > 1)
                            .Select(g => g.Key);

                await _tableStorage.AddBatchAsync <Equipment>($"equipment{_localization.Language}", equipment,
                                                              new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException e)
            {
                Console.WriteLine("Failed to upload WH equipment.");
            }

            try
            {
                var weaponProperties = await _weaponPropertyProcessor.Process(new List <string> {
                    "WH.wh_05.txt"
                }, _localization);

                await _tableStorage.AddBatchAsync <WeaponProperty>($"weaponProperties{_localization.Language}", weaponProperties,
                                                                   new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload WH weapon properties.");
            }

            try
            {
                var armorProperties =
                    await _armorPropertyProcessor.Process(new List <string> {
                    "WH.wh_05.txt"
                }, _localization);

                await _tableStorage.AddBatchAsync <ArmorProperty>($"armorProperties{_localization.Language}", armorProperties,
                                                                  new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload WH armor properties.");
            }

            try
            {
                var playerHandbookFeatProcessor = new PlayerHandbookFeatProcessor(_localization);
                var feats = await playerHandbookFeatProcessor.Process(new List <string> {
                    "WH.wh_06.txt"
                }, _localization);

                foreach (var feat in feats)
                {
                    feat.ContentSourceEnum = ContentSource.WH;

                    var featSearchTerm = _globalSearchTermRepository.CreateSearchTerm(feat.Name, GlobalSearchTermType.Feat, ContentType.Core,
                                                                                      $"/characters/feats/?search={feat.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(featSearchTerm);
                }

                await _tableStorage.AddBatchAsync <Feat>($"feats{_localization.Language}", feats,
                                                         new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload WH feats.");
            }
        }
        public async Task Parse()
        {
            try
            {
                var equipmentProcessor = new ExpandedContentEquipmentProcessor(_localization);
                var equipments         = await equipmentProcessor.Process(_ecEquipmentFileName, _localization);

                foreach (var equipment in equipments)
                {
                    equipment.ContentSourceEnum = ContentSource.EC;

                    switch (equipment.EquipmentCategoryEnum)
                    {
                    case EquipmentCategory.Unknown:
                    case EquipmentCategory.Ammunition:
                    case EquipmentCategory.Explosive:
                    case EquipmentCategory.Storage:
                    case EquipmentCategory.AdventurePack:
                    case EquipmentCategory.Communications:
                    case EquipmentCategory.DataRecordingAndStorage:
                    case EquipmentCategory.LifeSupport:
                    case EquipmentCategory.Medical:
                    case EquipmentCategory.WeaponOrArmorAccessory:
                    case EquipmentCategory.Tool:
                    case EquipmentCategory.Mount:
                    case EquipmentCategory.Vehicle:
                    case EquipmentCategory.TradeGood:
                    case EquipmentCategory.Utility:
                    case EquipmentCategory.GamingSet:
                    case EquipmentCategory.MusicalInstrument:
                    case EquipmentCategory.Droid:
                    case EquipmentCategory.Clothing:
                    case EquipmentCategory.Kit:
                        var equipmentSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment.Name,
                                                                                               GlobalSearchTermType.AdventuringGear, ContentType.ExpandedContent,
                                                                                               $"/loot/adventuringGear/?search={equipment.Name}");
                        _globalSearchTermRepository.SearchTerms.Add(equipmentSearchTerm);
                        break;

                    case EquipmentCategory.Weapon:
                        var weaponSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment.Name,
                                                                                            GlobalSearchTermType.Weapon, ContentType.ExpandedContent,
                                                                                            $"/loot/weapons/?search={equipment.Name}");
                        _globalSearchTermRepository.SearchTerms.Add(weaponSearchTerm);
                        break;

                    case EquipmentCategory.Armor:
                        var searchTermType = GlobalSearchTermType.Armor;
                        if (equipment.ArmorClassificationEnum == ArmorClassification.Shield)
                        {
                            searchTermType = GlobalSearchTermType.Shield;
                        }

                        var armorSearchTerm = _globalSearchTermRepository.CreateSearchTerm(equipment.Name,
                                                                                           searchTermType, ContentType.ExpandedContent,
                                                                                           $"/loot/armor/?search={equipment.Name}");
                        _globalSearchTermRepository.SearchTerms.Add(armorSearchTerm);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

                await _tableStorage.AddBatchAsync <Equipment>($"equipment{_localization.Language}", equipments,
                                                              new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload EC equipment.");
            }
        }