public async Task Upload()
        {
            var existingSearchTerms = (await _tableStorage.GetAllAsync <GlobalSearchTerm>("searchTerms")).ToList();

            foreach (var existingSearchTerm in existingSearchTerms.Where(e => !e.IsDeleted))
            {
                existingSearchTerm.IsDeleted = true;
            }

            await _tableStorage.AddBatchAsync <GlobalSearchTerm>("searchTerms",
                                                                 existingSearchTerms.Where(e => e.PartitionKey == ContentType.ExpandedContent.ToString()),
                                                                 new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });

            await _tableStorage.AddBatchAsync <GlobalSearchTerm>("searchTerms",
                                                                 existingSearchTerms.Where(e => e.PartitionKey == ContentType.Core.ToString()),
                                                                 new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });

            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 });
        }
Esempio n. 2
0
        public async Task Parse()
        {
            try
            {
                var classImageLus = await _tableStorage.GetAllAsync <ClassImageLU>("classImageLU");

                var casterRatioLus = await _tableStorage.GetAllAsync <CasterRatioLU>("casterRatioLU");

                var classes = await _tableStorage.GetAllAsync <Class>($"classes{_localization.Language}");

                var archetypeProcessor = new ExpandedContentArchetypeProcessor(classImageLus.ToList(), casterRatioLus.ToList(), classes.ToList());
                var archetypes         = await archetypeProcessor.Process(_ecArchetypesFileName, _localization);

                foreach (var archetype in archetypes)
                {
                    archetype.ContentSourceEnum = ContentSource.EC;

                    var archetypeSearchTerm = _globalSearchTermRepository.CreateSearchTerm(archetype.Name,
                                                                                           GlobalSearchTermType.Archetype, ContentType.ExpandedContent,
                                                                                           $"/characters/archetypes/{Uri.EscapeDataString(archetype.Name)}");
                    _globalSearchTermRepository.SearchTerms.Add(archetypeSearchTerm);
                }

                try
                {
                    var archetypeFeatures = archetypes.SelectMany(f => f.Features).ToList();

                    var featureLevels = (await _tableStorage.GetAllAsync <FeatureDataLU>("featureDataLU")).ToList();

                    foreach (var archetypeFeature in archetypeFeatures)
                    {
                        var featureLevel = featureLevels.SingleOrDefault(f => f.FeatureRowKey == archetypeFeature.RowKey);
                        if (featureLevel != null)
                        {
                            archetypeFeature.Level = featureLevel.Level;
                        }
                    }

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

                    await _tableStorage.AddBatchAsync <Feature>($"features{_localization.Language}", archetypeFeatures,
                                                                new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
                }
                catch (StorageException se)
                {
                    Console.WriteLine($"Failed to upload EC archetype features: {se}");
                }

                await _tableStorage.AddBatchAsync <Archetype>($"archetypes{_localization.Language}", archetypes,
                                                              new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
            }
            catch (StorageException e)
            {
                Console.WriteLine($"Failed to upload EC archetypes: {e.Message}");
            }
        }
        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. 4
0
        public async Task <List <Power> > Parse()
        {
            var techPowers = new List <Power>();

            try
            {
                var techPowersProcessor = new ExpandedContentTechPowersProcessor();
                techPowers = await techPowersProcessor.Process(_ecTechPowersFileName, _localization);

                foreach (var techPower in techPowers)
                {
                    techPower.ContentSourceEnum = ContentSource.EC;

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

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

            return(techPowers);
        }
        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 async Task Parse()
        {
            try
            {
                var monsters = await _monsterProcessor.Process(_mmFileName, _localization);

                foreach (var monster in monsters)
                {
                    monster.ContentSourceEnum = ContentSource.SnV;

                    var monsterSearchTerm = _globalSearchTermRepository.CreateSearchTerm(monster.Name,
                                                                                         GlobalSearchTermType.Monster, ContentType.Core, $"/rules/snv/monsters/{monster.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(monsterSearchTerm);
                }

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

            foreach (var monsterChapterName in SectionNames.MonsterChapterNames)
            {
                var monsterChapterSearchTerm = _globalSearchTermRepository.CreateSearchTerm(monsterChapterName.name,
                                                                                            monsterChapterName.globalSearchTermType, ContentType.Core, monsterChapterName.pathOverride);
                _globalSearchTermRepository.SearchTerms.Add(monsterChapterSearchTerm);
            }
        }
        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. 8
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 _searchServiceClient.Indexes.GetAsync("searchterms-index");

            await _searchServiceClient.Indexes.DeleteAsync("searchterms-index");

            await _searchServiceClient.Indexes.CreateAsync(index);

            await _searchServiceClient.Indexers.RunAsync("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()
        {
            try
            {
                var ecFeats = await _expandedContentCustomizationOptionsProcessor.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.");
            }
        }
        public async Task Parse()
        {
            try
            {
                var equipment =
                    await _playerHandbookEquipmentProcessor.Process(_phbFilesNames
                                                                    .Where(p => p.Equals("PHB.phb_05.txt")).ToList(), _localization);

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

                    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.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();
                    }
                }

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

            try
            {
                var backgrounds =
                    await _playerHandbookBackgroundsProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_04.txt"))
                                                                      .ToList(), _localization);

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

                    var backgroundSearchTerm = _globalSearchTermRepository.CreateSearchTerm(background.Name, GlobalSearchTermType.Background, ContentType.Core,
                                                                                            $"/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 PHB backgrounds.");
            }

            try
            {
                var speciesImageUrlsLus = await _tableStorage.GetAllAsync <SpeciesImageUrlLU>("speciesImageUrlsLU");

                var playerHandbookSpeciesProcessor = new PlayerHandbookSpeciesProcessor(speciesImageUrlsLus.ToList());

                var species =
                    await playerHandbookSpeciesProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_02.txt"))
                                                                 .ToList(), _localization);

                foreach (var specie in species)
                {
                    specie.ContentSourceEnum = ContentSource.PHB;

                    var specieSearchTerm = _globalSearchTermRepository.CreateSearchTerm(specie.Name, GlobalSearchTermType.Species, ContentType.Core,
                                                                                        $"/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 PHB species.");
            }

            try
            {
                var featureLevels = (await _tableStorage.GetAllAsync <FeatureDataLU>("featureLevelLU")).ToList();

                var classImageLus = await _tableStorage.GetAllAsync <ClassImageLU>("classImageLU");

                var casterRatioLus = await _tableStorage.GetAllAsync <CasterRatioLU>("casterRatioLU");

                var multiclassProficiencyLus =
                    await _tableStorage.GetAllAsync <MulticlassProficiencyLU>("multiclassProficiencyLU");

                var playerHandbookClassProcessor = new PlayerHandbookClassProcessor(classImageLus.ToList(), casterRatioLus.ToList(), multiclassProficiencyLus.ToList());

                var classes =
                    await playerHandbookClassProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_03.txt"))
                                                               .ToList(), _localization);

                foreach (var swClass in classes)
                {
                    swClass.ContentSourceEnum = ContentSource.PHB;

                    var classSearchTerm = _globalSearchTermRepository.CreateSearchTerm(swClass.Name, GlobalSearchTermType.Class, ContentType.Core,
                                                                                       $"/characters/classes/{swClass.Name}");
                    _globalSearchTermRepository.SearchTerms.Add(classSearchTerm);
                }

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

                try
                {
                    var archetypes = classes.SelectMany(s => s.Archetypes).ToList();

                    foreach (var archetype in archetypes)
                    {
                        archetype.ContentSourceEnum = ContentSource.PHB;

                        var archetypeSearchTerm = _globalSearchTermRepository.CreateSearchTerm(archetype.Name, GlobalSearchTermType.Archetype, ContentType.Core,
                                                                                               $"/characters/archetypes/{archetype.Name}");
                        _globalSearchTermRepository.SearchTerms.Add(archetypeSearchTerm);
                    }

                    try
                    {
                        var archetypeFeatures = archetypes.SelectMany(f => f.Features).ToList();

                        foreach (var archetypeFeature in archetypeFeatures)
                        {
                            var featureLevel = featureLevels.SingleOrDefault(f => f.FeatureRowKey == archetypeFeature.RowKey);
                            if (featureLevel != null)
                            {
                                archetypeFeature.Level = featureLevel.Level;
                            }
                        }

                        await _tableStorage.AddBatchAsync <Feature>($"features{_localization.Language}", archetypeFeatures,
                                                                    new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
                    }
                    catch (StorageException se)
                    {
                        Console.WriteLine($"Failed to upload PHB archetype features: {se}");
                    }

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

                    await _tableStorage.AddBatchAsync <Archetype>($"archetypes{_localization.Language}", archetypes,
                                                                  new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
                }
                catch (StorageException se)
                {
                    Console.WriteLine($"Failed to upload PHB archetypes: {se}");
                }

                try
                {
                    var classFeatures = classes.SelectMany(f => f.Features).ToList();

                    foreach (var classFeature in classFeatures)
                    {
                        var featureLevel = featureLevels.SingleOrDefault(f => f.FeatureRowKey == classFeature.RowKey);
                        if (featureLevel != null)
                        {
                            classFeature.Level = featureLevel.Level;
                        }
                    }

                    await _tableStorage.AddBatchAsync <Feature>($"features{_localization.Language}", classFeatures,
                                                                new BatchOperationOptions { BatchInsertMethod = BatchInsertMethod.InsertOrReplace });
                }
                catch (StorageException se)
                {
                    Console.WriteLine($"Failed to upload PHB class features: {se}");
                }
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload PHB classes.");
            }

            try
            {
                var playerHandbookPowersProcessor = new PlayerHandbookPowersProcessor(_localization);

                var powers =
                    await playerHandbookPowersProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_11.txt") || p.Equals("PHB.phb_12.txt"))
                                                                .ToList(), _localization);

                foreach (var power in powers)
                {
                    power.ContentSourceEnum = ContentSource.PHB;

                    switch (power.PowerTypeEnum)
                    {
                    case PowerType.None:
                        break;

                    case PowerType.Force:
                        var forcePowerSearchTerm = _globalSearchTermRepository.CreateSearchTerm(power.Name, GlobalSearchTermType.ForcePower, ContentType.Core,
                                                                                                $"/characters/forcePowers/?search={power.Name}");
                        _globalSearchTermRepository.SearchTerms.Add(forcePowerSearchTerm);
                        break;

                    case PowerType.Tech:
                        var techPowerSearchTerm = _globalSearchTermRepository.CreateSearchTerm(power.Name, GlobalSearchTermType.TechPower, ContentType.Core,
                                                                                               $"/characters/techPowers/?search={power.Name}");
                        _globalSearchTermRepository.SearchTerms.Add(techPowerSearchTerm);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }

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

            try
            {
                var feats = await _playerHandbookFeatProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_06.txt"))
                                                                       .ToList(), _localization);

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

                    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 PHB feats.");
            }

            try
            {
                var rules =
                    await _playerHandbookChapterRulesProcessor.Process(_phbFilesNames, _localization);

                await _cloudBlobContainer.CreateIfNotExistsAsync(BlobContainerPublicAccessType.Off, null, null);

                foreach (var chapterRules in rules)
                {
                    var json = JsonConvert.SerializeObject(chapterRules);
                    var blob = _cloudBlobContainer.GetBlockBlobReference($"{chapterRules.ChapterName}.json");

                    await blob.UploadTextAsync(json);
                }
            }
            catch (StorageException)
            {
                Console.WriteLine("Failed to upload PHB rules.");
            }

            try
            {
                var weaponProperties =
                    await _weaponPropertyProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_05.txt")).ToList(), _localization);

                var specialProperty = weaponProperties.SingleOrDefault(w => w.Name == "Special");
                if (specialProperty != null)
                {
                    specialProperty.Content =
                        "#### Special\r\nA weapon with the special property has unusual rules governing its use, explained in the weapon's description.";
                }

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

            try
            {
                var armorProperties =
                    await _armorPropertyProcessor.Process(_phbFilesNames.Where(p => p.Equals("PHB.phb_05.txt")).ToList(), _localization);

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

            foreach (var referenceName in SectionNames.ReferenceNames)
            {
                var referenceSearchTerm = _globalSearchTermRepository.CreateSearchTerm(referenceName.name, referenceName.globalSearchTermType, ContentType.Core,
                                                                                       referenceName.pathOverride);
                _globalSearchTermRepository.SearchTerms.Add(referenceSearchTerm);
            }

            foreach (var variantRuleName in SectionNames.VariantRuleNames)
            {
                var variantRuleSearchTerm = _globalSearchTermRepository.CreateSearchTerm(variantRuleName.name, variantRuleName.globalSearchTermType, ContentType.Core,
                                                                                         variantRuleName.pathOverride);
                _globalSearchTermRepository.SearchTerms.Add(variantRuleSearchTerm);
            }
        }
Esempio n. 12
0
        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 _cloudBlobContainer.CreateIfNotExistsAsync(BlobContainerPublicAccessType.Off, null, null);

                foreach (var chapterRules in rules)
                {
                    var json = JsonConvert.SerializeObject(chapterRules);
                    var blob = _cloudBlobContainer.GetBlockBlobReference($"{chapterRules.ChapterName}.json");

                    await blob.UploadTextAsync(json);
                }
            }
            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);
                            }
                        }
                    }
                }

                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:
                        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)
            {
                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)
            {
                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. 13
0
        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.");
            }
        }
Esempio n. 14
0
        public async Task Parse()
        {
            try
            {
                var rules = await _wretchedHivesChapterRulesProcessor.Process(_whFilesName, _localization);

                await _cloudBlobContainer.CreateIfNotExistsAsync(BlobContainerPublicAccessType.Off, null, null);

                foreach (var chapterRules in rules)
                {
                    var json = JsonConvert.SerializeObject(chapterRules);
                    var blob = _cloudBlobContainer.GetBlockBlobReference($"{chapterRules.ChapterName}.json");

                    await blob.UploadTextAsync(json);
                }
            }
            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.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 weapon 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 PHB feats.");
            }
        }
        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. 16
0
        public static async Task Parse(ITableStorage azureTableStorage, CloudStorageAccount cloudStorageAccount,
                                       GlobalSearchTermRepository globalSearchTermRepository, ILocalization localization)
        {
            var starshipManager = new StarshipsOfTheGalaxyManager(azureTableStorage, cloudStorageAccount,
                                                                  globalSearchTermRepository, localization);
            var monsterManualManager =
                new MonsterManualManager(azureTableStorage, globalSearchTermRepository, localization);
            var extendedContentSpeciesManager =
                new ExpandedContentSpeciesManager(azureTableStorage, globalSearchTermRepository, localization);
            var extendedContentBackgroundManager =
                new ExpandedContentBackgroundsManager(azureTableStorage, globalSearchTermRepository, localization);
            var extendedContentEquipmentManager =
                new ExpandedContentEquipmentManager(azureTableStorage, globalSearchTermRepository, localization);
            var extendedContentArchetypesManager =
                new ExpandedContentArchetypesManager(azureTableStorage, globalSearchTermRepository, localization);
            var extendedContentVariantRulesManager =
                new ExpandedContentVariantRulesManager(cloudStorageAccount, localization);
            var extendedContentCustomizationOptionsManager =
                new ExpandedContentCustomizationOptionsManager(azureTableStorage, globalSearchTermRepository,
                                                               localization);
            var extendedContentForcePowersManager =
                new ExpandedContentForcePowersManager(azureTableStorage, globalSearchTermRepository, localization);
            var extendedContentTechPowersManager =
                new ExpandedContentTechPowersManager(azureTableStorage, globalSearchTermRepository, localization);
            var playerHandbookManager = new PlayerHandbookManager(azureTableStorage, cloudStorageAccount,
                                                                  globalSearchTermRepository, localization);
            var referenceTableManager = new ReferenceTableManager(azureTableStorage, localization);
            var wretchedHivesManager  = new WretchedHivesManager(azureTableStorage, cloudStorageAccount,
                                                                 globalSearchTermRepository, localization);
            var creditsManager = new CreditsManager(cloudStorageAccount, localization);
            var extendedContentEnhancedItemManager =
                new ExpandedContentEnhancedItemsManager(azureTableStorage, globalSearchTermRepository, localization);

            var referenceTables = await referenceTableManager.Parse();

            await starshipManager.Parse(referenceTables);

            await monsterManualManager.Parse();

            await extendedContentSpeciesManager.Parse();

            await extendedContentBackgroundManager.Parse();

            await extendedContentEquipmentManager.Parse();

            await extendedContentArchetypesManager.Parse();

            await extendedContentVariantRulesManager.Parse();

            await extendedContentCustomizationOptionsManager.Parse();

            await extendedContentTechPowersManager.Parse();

            await extendedContentForcePowersManager.Parse();

            await wretchedHivesManager.Parse();

            await playerHandbookManager.Parse();

            await creditsManager.Parse();

            await extendedContentEnhancedItemManager.Parse();

            try
            {
                var searchManager = new SearchManager(azureTableStorage, globalSearchTermRepository);
                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 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"
                };
                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.");
            }
        }