private void WireUpRelicIds(TransformResultsContainer transformResults) { foreach (LegendMateria lm in transformResults.LegendMaterias) { if (!String.IsNullOrWhiteSpace(lm.RelicName)) { string realmName = GetNameOfTypeListItem <RealmList>(lm.Realm); lm.RelicId = transformResults.Relics.Where(r => (lm.RelicName == $"{r.RelicName} ({realmName})") && r.Realm == lm.Realm && lm.CharacterName == r.CharacterName).Select(r => r.Id).SingleOrDefault(); _logger.LogDebug("wired up RelicId {RelicId} to LegendMateria {LegendMateria}", lm.RelicId, lm.Description); } } foreach (SoulBreak sb in transformResults.SoulBreaks) { if (!String.IsNullOrWhiteSpace(sb.RelicName)) { string realmName = GetNameOfTypeListItem <RealmList>(sb.Realm); sb.RelicId = transformResults.Relics.Where(r => (sb.RelicName == $"{r.RelicName} ({realmName})") && r.Realm == sb.Realm && sb.CharacterName == r.CharacterName).Select(r => r.Id).SingleOrDefault(); _logger.LogDebug("wired up RelicId {RelicId} to SoulBreak {SoulBreak}", sb.RelicId, sb.Description); } } }
public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestMessage req, [Inject] ITransformStorageProvider transformStorageProvider, [Inject] ILogger <ITransformStorageProvider> logger) { logger.LogInformation("Azure Function StoreTransform processed a request."); try { // parse query parameter - can be null string formattedDateString = req.GetQueryNameValuePairs() .FirstOrDefault(q => string.Compare(q.Key, "formattedDateString", true) == 0) .Value; // Get request body dynamic data = await req.Content.ReadAsAsync <object>(); string datastring = data.ToString(); //this data had better be serializable to TransformResultsContainer TransformResultsContainer trc = JsonConvert.DeserializeObject <TransformResultsContainer>(datastring); string filePath = transformStorageProvider.StoreTransformResults(trc, formattedDateString); var response = req.CreateResponse(HttpStatusCode.OK, filePath); return(response); } catch (System.Exception ex) { logger.LogError(ex, $"Error in Azure Function StoreTransform : {ex.Message}"); var response = req.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); return(response); } }
private TransformResultsContainer ExecuteTransform(ImportResultsContainer importResults) { TransformResultsContainer transformResultsContainer = new TransformResultsContainer(); transformResultsContainer.Events = _eventRowTransformer.Transform(importResults.EventRows); _logger.LogInformation("finished transforming EventRows to Events"); transformResultsContainer.Missions = _missionRowTransformer.Transform(importResults.MissionRows); _logger.LogInformation("finished transforming MissionRows to Missions"); transformResultsContainer.Experiences = _experienceRowTransformer.Transform(importResults.ExperienceRows); _logger.LogInformation("finished transforming ExperienceRows to a single Experience object in a list"); //transformResultsContainer.Dungeons = _dungeonRowTransformer.Transform(importResults.DungeonRows); //_logger.LogInformation("finished transforming DungeonRows to Dungeons"); transformResultsContainer.MagiciteSkills = _magiciteSkillRowTransformer.Transform(importResults.MagiciteSkillRows.Where(ms => !String.IsNullOrWhiteSpace(ms.Name))); _logger.LogInformation("finished transforming MagiciteSkillRows to MagiciteSkills"); transformResultsContainer.Magicites = _magiciteRowTransformer.Transform(importResults.MagiciteRows); _logger.LogInformation("finished transforming MagiciteRows to Magicites"); transformResultsContainer.Statuses = _statusRowTransformer.Transform(importResults.StatusRows); _logger.LogInformation("finished transforming StatusRows to Statuses"); transformResultsContainer.Others = _otherRowTransformer.Transform(importResults.OtherRows); _logger.LogInformation("finished transforming OtherRows to Others"); transformResultsContainer.Commands = _commandRowTransformer.Transform(importResults.CommandRows); _logger.LogInformation("finished transforming CommandRows to Commands"); transformResultsContainer.BraveActions = _braveActionRowTransformer.Transform(importResults.BraveActionRows); _logger.LogInformation("finished transforming BraveActionRows to BraveActions"); transformResultsContainer.SoulBreaks = _soulBreakRowTransformer.Transform(importResults.SoulBreakRows); _logger.LogInformation("finished transforming SoulBreakRows to SoulBreaks"); transformResultsContainer.Relics = _relicRowTransformer.Transform(importResults.RelicRows); _logger.LogInformation("finished transforming RelicRows to Relics"); transformResultsContainer.Abilities = _abilityRowTransformer.Transform(importResults.AbilityRows); _logger.LogInformation("finished transforming AbilityRows to Abilities"); transformResultsContainer.LegendMaterias = _legendMateriaRowTransformer.Transform(importResults.LegendMateriaRows); _logger.LogInformation("finished transforming LegendMateriaRows to LegendMaterias"); transformResultsContainer.RecordMaterias = _recordMateriaRowTransformer.Transform(importResults.RecordMateriaRows); _logger.LogInformation("finished transforming RecordMateriaRows to RecordMaterias"); transformResultsContainer.RecordSpheres = _recordSphereRowTransformer.Transform(importResults.RecordSphereRows); _logger.LogInformation("finished transforming RecordMateriaRows to RecordMaterias"); transformResultsContainer.LegendSpheres = _legendSphereRowTransformer.Transform(importResults.LegendSphereRows); _logger.LogInformation("finished transforming LegendSphereRows to LegendSpheres"); transformResultsContainer.Characters = _characterRowTransformer.Transform(importResults.CharacterRows); _logger.LogInformation("finished transforming CharacterRows to Characters"); return(transformResultsContainer); }
private void WireUpSoulBreakIds(TransformResultsContainer transformResults) { foreach (Command command in transformResults.Commands) { command.SourceSoulBreakId = transformResults.SoulBreaks.Where(sb => sb.SoulBreakName == command.SourceSoulBreakName && sb.CharacterName.Trim() == command.CharacterName.Trim()).Select(e => e.Id).SingleOrDefault(); _logger.LogDebug("wired up SoulBreakId {SoulBreakId} to Command {Command}", command.SourceSoulBreakId, command.Description); } foreach (BraveAction braveAction in transformResults.BraveActions) { braveAction.SourceSoulBreakId = transformResults.SoulBreaks.Where(sb => sb.SoulBreakName == braveAction.SourceSoulBreakName && sb.CharacterName.Trim() == braveAction.CharacterName.Trim()).Select(e => e.Id).SingleOrDefault(); _logger.LogDebug("wired up SoulBreakId {SoulBreakId} to BraveAction {BraveAction}", braveAction.SourceSoulBreakId, braveAction.Description); } foreach (Relic relic in transformResults.Relics) { string realmName = GetNameOfTypeListItem <RealmList>(relic.Realm); relic.SoulBreakId = transformResults.SoulBreaks.Where(sb => sb.SoulBreakName.Trim() == relic.SoulBreakName.Trim() && (sb.CharacterName.Trim() == relic.CharacterName.Trim()) && (sb.RelicName == $"{relic.RelicName} ({realmName})") && relic.Realm == sb.Realm).Select(e => e.Id).SingleOrDefault(); _logger.LogDebug("wired up SoulBreakId {SoulBreakId} to Relic {Relic}", relic.SoulBreakId, relic.Description); } }
public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestMessage req, [Inject] IMergeManager mergeManager, [Inject] ILogger <IMergeManager> logger) { logger.LogInformation("Azure Function ExecuteMerge processed a request."); try { dynamic data = await req.Content.ReadAsAsync <object>(); string datastring = data.ToString(); //this data had better be serializable to TranformResultsContainer TransformResultsContainer trc = JsonConvert.DeserializeObject <TransformResultsContainer>(datastring); MergeResultsContainer mrc = mergeManager.MergeAll(trc); var response = req.CreateResponse(HttpStatusCode.OK, mrc); return(response); } catch (System.Exception ex) { logger.LogError(ex, $"Error in Azure Function ExecuteMerge : {ex.Message}"); var response = req.CreateResponse(HttpStatusCode.InternalServerError, ex.Message); return(response); } }
public TransformResultsContainer RetrieveTransformResults(string path) { string fileContents = RetrieveSerializedData(path); TransformResultsContainer transformResultsContainer = JsonConvert.DeserializeObject <TransformResultsContainer>(fileContents); return(transformResultsContainer); }
public string StoreTransformResults(TransformResultsContainer transformResultsContainer, string formattedDateString) { string serializedTransformResults = JsonConvert.SerializeObject(transformResultsContainer); string datedFilePath = StoreSerializedData(serializedTransformResults, formattedDateString, _fileTransformStorageOptions.TransformResultsStoragePath); return(datedFilePath); }
public string StoreTransformResults(TransformResultsContainer transformResultsContainer, string formattedDateString) { string serializedTransformResults = JsonConvert.SerializeObject(transformResultsContainer); string datedFilePath = StoreTextAsBlob(_azureBlobStorageOptions.TransformResultsStoragePath, serializedTransformResults, formattedDateString); return(datedFilePath); //this is the identifier of the blob }
public TransformResultsContainer RetrieveTransformResults() { string fileContents = RetrieveSerializedData(_fileTransformStorageOptions.TransformResultsStoragePath, TransformResultFileFilterExpression); TransformResultsContainer transformResultsContainer = JsonConvert.DeserializeObject <TransformResultsContainer>(fileContents); return(transformResultsContainer); }
public TransformResultsContainer RetrieveTransformResults() { string fileContents = RetrieveLatestBlobContents(_azureBlobStorageOptions.TransformResultsStoragePath); TransformResultsContainer transformResultsContainer = JsonConvert.DeserializeObject <TransformResultsContainer>(fileContents); return(transformResultsContainer); }
private void WireUpOthers(TransformResultsContainer transformResults) { foreach (SoulBreak soulBreak in transformResults.SoulBreaks) { soulBreak.OtherEffects = transformResults.Others.Where(o => soulBreak.Effects.Contains(o.SourceName)).ToList(); _logger.LogDebug("wired up {OtherEffectsCount} OtherEffects to SoulBreak {SoulBreak}", soulBreak.OtherEffects.Count(), soulBreak.Description); } }
private void WireUpBraveActions(TransformResultsContainer transformResults) { foreach (SoulBreak soulBreak in transformResults.SoulBreaks) { soulBreak.BraveActions = transformResults.BraveActions.Where(c => c.SourceSoulBreakName == soulBreak.SoulBreakName).ToList(); _logger.LogDebug("wired up {BraveActionsCount} BraveActions to SoulBreak {SoulBreak}", soulBreak.BraveActions.Count(), soulBreak.Description); } }
private void WireUpLegendMaterias(TransformResultsContainer transformResults) { foreach (Character character in transformResults.Characters) { character.LegendMaterias = transformResults.LegendMaterias.Where(lm => lm.CharacterName == character.CharacterName).ToList(); _logger.LogDebug("wired up {LegendMateriasCount} LegendMaterias to Character {Character}", character.LegendMaterias.Count(), character.Description); } }
private void WireUpRelics(TransformResultsContainer transformResults) { foreach (Character character in transformResults.Characters) { character.Relics = transformResults.Relics.Where(r => r.CharacterName == character.CharacterName).ToList(); _logger.LogDebug("wired up {RelicsCount} Relics to Character {Character}", character.Relics.Count(), character.Description); } }
private void WireUpMagiciteSkills(TransformResultsContainer transformResults) { foreach (Magicite magicite in transformResults.Magicites) { string realmName = GetNameOfTypeListItem <RealmList>(magicite.Realm); magicite.MagiciteSkills = transformResults.MagiciteSkills.Where(s => s.MagiciteName == $"{magicite.MagiciteName} ({realmName})").ToList(); _logger.LogDebug("wired up {MagiciteSkillsCount} MagiciteSkills to Magicite {Magicite}", magicite.MagiciteSkills.Count(), magicite.Description); } }
private void WireUpSoulBreaks(TransformResultsContainer transformResults) { foreach (Relic relic in transformResults.Relics) { string realmName = GetNameOfTypeListItem <RealmList>(relic.Realm); relic.SoulBreak = transformResults.SoulBreaks.SingleOrDefault(sb => sb.SoulBreakName.Trim() == relic.SoulBreakName.Trim() && (sb.CharacterName.Trim() == relic.CharacterName.Trim()) && (sb.RelicName == $"{relic.RelicName} ({realmName})") && relic.Realm == sb.Realm); _logger.LogDebug("wired up {SoulBreak} SoulBreak to Relic {Relic}", relic.SoulBreak?.Description, relic?.Description); } }
public TransformResultsContainer RetrieveTransformResults(string path) { TransformResultsContainer transformResultsContainer = new TransformResultsContainer(); CloudBlockBlob blockBlob = _container.GetBlockBlobReference(path); string fileContents = blockBlob.DownloadTextAsync().Result; transformResultsContainer = JsonConvert.DeserializeObject <TransformResultsContainer>(fileContents); return(transformResultsContainer); }
private void WireUpLegendMateriaIds(TransformResultsContainer transformResults) { foreach (Relic relic in transformResults.Relics) { if (!String.IsNullOrWhiteSpace(relic.LegendMateriaName)) { relic.LegendMateriaId = transformResults.LegendMaterias.Where(lm => (lm.LegendMateriaName == relic.LegendMateriaName) && (lm.Realm == relic.Realm)).Select(lm => lm.Id).SingleOrDefault(); _logger.LogDebug("wired up LegendMateriaId {LegendMateriaId} to Relic {Relic}", relic.CharacterId, relic.Description); } } }
private void WireUpStatuses(TransformResultsContainer transformResults) { foreach (SoulBreak soulBreak in transformResults.SoulBreaks) { IList <Status> potentialMatches = transformResults.Statuses.Where(s => !String.IsNullOrWhiteSpace(s.CommonName) && soulBreak.Effects.Contains(s.CommonName)).ToList(); IList <Status> processedMatches = ProcessStatusesToRemoveSuperfluousQuickCasts(potentialMatches); soulBreak.Statuses = processedMatches; _logger.LogDebug("wired up {StatusesCount} Statuses to SoulBreak {SoulBreak}", soulBreak.Statuses.Count(), soulBreak.Description); } }
public TransformResultsContainer TransformAll(ImportResultsContainer importResultsContainer) { try { TransformResultsContainer transformResultsContainer = ExecuteTransform(importResultsContainer); return(transformResultsContainer); } catch (Exception ex) { _logger.LogError(ex, ex.Message); _logger.LogInformation("Error in TransformManager TransformAll method - transform was NOT completed."); throw; } }
public MergeResultsContainer MergeAll(TransformResultsContainer transformResultsContainer) { try { MergeResultsContainer mergeResultsContainer = ExecuteMerge(transformResultsContainer); _logger.LogInformation("MergeManager MergeAll method successfully completed."); return(mergeResultsContainer); } catch (Exception ex) { _logger.LogError(ex, ex.Message); _logger.LogInformation("Error in MergeManager MergeAll method - Merge was NOT completed."); throw; } }
private void WireUpEventIds(TransformResultsContainer transformResults) { //foreach (Dungeon dungeon in transformResults.Dungeons) //{ // dungeon.IntroducingEventId = transformResults.Events.Where(e => e.EventName == dungeon.IntroducingEvent).Select(e => e.Id).SingleOrDefault(); // _logger.LogDebug("wired up EventId {EventId} to Dungeon {Dungeon}", dungeon.IntroducingEventId, dungeon.Description); //} foreach (Magicite magicite in transformResults.Magicites) { magicite.IntroducingEventId = transformResults.Events.Where(e => e.EventName == magicite.IntroducingEventName).Select(e => e.Id).Single(); _logger.LogDebug("wired up EventId {EventId} to Magicite {Magicite}", magicite.IntroducingEventId, magicite.Description); } foreach (Character character in transformResults.Characters) { foreach (StatsByLevelInfo info in character.StatsByLevelInfos) { info.IntroducingEventId = transformResults.Events.Where(e => e.EventName == info.IntroducingEvent).Select(e => e.Id).SingleOrDefault(); _logger.LogDebug("wired up EventId {EventId} to StatsByLevelInfo for Character {Character}", info.IntroducingEventId, character.Description); } character.StatIncrementsForRecordSpheres.IntroducingEventId = transformResults.Events.Where(e => e.EventName == character.StatIncrementsForRecordSpheres.IntroducingEvent).Select(e => e.Id).SingleOrDefault(); _logger.LogDebug("wired up EventId {EventId} to StatIncrementsForRecordSpheres for Character {Character}", character.StatIncrementsForRecordSpheres.IntroducingEventId, character.Description); character.StatIncrementsForLegendSpheres.IntroducingEventId = transformResults.Events.Where(e => e.EventName == character.StatIncrementsForLegendSpheres.IntroducingEvent).Select(e => e.Id).SingleOrDefault(); _logger.LogDebug("wired up EventId {EventId} to StatIncrementsForLegendSpheres for Character {Character}", character.StatIncrementsForLegendSpheres.IntroducingEventId, character.Description); } foreach (Ability ability in transformResults.Abilities) { ability.IntroducingEventId = transformResults.Events.Where(e => e.EventName == ability.IntroducingEventName).Select(e => e.Id).SingleOrDefault(); _logger.LogDebug("wired up EventId {EventId} to Ability {Ability}", ability.IntroducingEventId, ability.Description); } foreach (Mission mission in transformResults.Missions) { mission.AssociatedEventId = transformResults.Events.Where(e => e.EventName == mission.AssociatedEvent).Select(e => e.Id).SingleOrDefault(); _logger.LogDebug("wired up EventId {EventId} to Mission {Mission}", mission.AssociatedEventId, mission.Description); } }
public TransformResultsContainer TransformAll(string importFilePath) { try { ImportResultsContainer importResults = _importStorageProvider.RetrieveImportResults(importFilePath); TransformResultsContainer transformResultsContainer = ExecuteTransform(importResults); return(transformResultsContainer); } catch (Exception ex) { _logger.LogError(ex, ex.Message); _logger.LogInformation("Error in TransformManager TransformAll method - transform was NOT completed."); throw; } }
public MergeResultsContainer MergeAll(string transformFilePath) { try { TransformResultsContainer transformResults = _transformStorageProvider.RetrieveTransformResults(transformFilePath); MergeResultsContainer mergeResultsContainer = ExecuteMerge(transformResults); _logger.LogInformation("MergeManager MergeAll method successfully completed."); return(mergeResultsContainer); } catch (Exception ex) { _logger.LogError(ex, ex.Message); _logger.LogInformation("Error in MergeManager MergeAll method - Merge was NOT completed."); throw; } }
private void CalculateLegendSphereTier(TransformResultsContainer transformResults) { foreach (Character character in transformResults.Characters) { if (character.LegendSpheres.Any()) { IList <LegendSphere> legendSpheres = character.LegendSpheres.OrderBy(s => s.Id).ToList(); int legendSphereCount = legendSpheres.Count; for (int index = 0; index < legendSphereCount; index++) { legendSpheres[index].Tier = index + 1; } _logger.LogDebug("calculated up LegendSpheres Tiers for Character {Character}", character.Description); } } }
private void WireUpMagiciteIds(TransformResultsContainer transformResults) { foreach (MagiciteSkill ms in transformResults.MagiciteSkills) { if (!String.IsNullOrWhiteSpace(ms.MagiciteName)) { Magicite parentMagicite = transformResults.Magicites.FirstOrDefault( m => $"{m.MagiciteName} ({GetNameOfTypeListItem<RealmList>(m.Realm)})" == ms.MagiciteName); if (parentMagicite != null) { ms.MagiciteId = parentMagicite.Id; } else { ms.MagiciteId = 0; //couldn't match } _logger.LogDebug("wired up MagiciteId {MagiciteId} to MagiciteSkill {MagiciteSkill}", ms.MagiciteId, ms.Description); } } }
public void Run() { try { Stopwatch stopwatchFull = Stopwatch.StartNew(); _logger.LogInformation($"{nameof(Application)}.{nameof(Run)} execution invoked"); _importValidator = _serviceProvider.GetService <IImportValidator>(); _typeListValidator = _serviceProvider.GetService <ITypeListValidator>(); _importManager = _serviceProvider.GetService <IImportManager>(); _importStorageProvider = _serviceProvider.GetService <IImportStorageProvider>(); _transformManager = _serviceProvider.GetService <ITransformManager>(); _transformStorageProvider = _serviceProvider.GetService <ITransformStorageProvider>(); _mergeManager = _serviceProvider.GetService <IMergeManager>(); _mergeStorageProvider = _serviceProvider.GetService <IMergeStorageProvider>(); //uncomment below to actually run import and transform stages - file based string formattedDateString = DateTime.UtcNow.ToString(DateFormatSpecifier); //Import Stopwatch stopwatchImport = Stopwatch.StartNew(); string failureInfo; //Before we take the overhead of downloading all the import data, check that the data has the right overall structure bool isDataSourceValid = _importValidator.TryValidateDataSource(out failureInfo); if (!isDataSourceValid) { _logger.LogWarning("Enlir Import Data not in Expected Format: \n" + failureInfo); throw new ValidationException("Enlir Import Data not in Expected Format: \n" + failureInfo); } ImportResultsContainer importResultsContainer = _importManager.ImportAll(); string importStoragePath = _importStorageProvider.StoreImportResults(importResultsContainer, formattedDateString); stopwatchImport.Stop(); //cheat data setup for testing - comment out when doing full run for real //string importStoragePath = @"D:\Temp\FFRKApi\ImportResults-2018-12-21_09-48-46.json"; //string transformStoragePath = @"D:\Docs\Personal\FFRKLinqQuery\TransformResults-Latest.json"; //string formattedDateString = "2018-12-21_09-48-46"; //string importContents = File.ReadAllText(importStoragePath); //ImportResultsContainer importResultsContainer = JsonConvert.DeserializeObject<ImportResultsContainer>(importContents); ////Now that we have the import data, we need to check whether our TypeLists (used to convert staring data into ids) ////is still accurate. If the source data has changed their list of values for each type, we need to stop and correct the TypeLists IEnumerable <TypeListDifferences> typeListDifferences = _typeListValidator.TryValidateTypeLists(importResultsContainer); if (typeListDifferences.Any(t => t.IsIdListDifferentFromSource)) { _logger.LogWarning("Enlir TypeList Data differs from coded TypeLists."); //write validation failure data to log for easy perusal string typeListDifferencesLogPath = $"{AppContext.BaseDirectory}\\TypeListDifferencesLog.json"; string typeListDifferencesLogContents = JsonConvert.SerializeObject(typeListDifferences); File.WriteAllText(typeListDifferencesLogPath, typeListDifferencesLogContents); _logger.LogWarning("Enlir TypeList differences written to file: " + typeListDifferencesLogPath); throw new ValidationException("Enlir Type List Data differs from coded TypeLists"); } //Transform Stopwatch stopwatchTransform = Stopwatch.StartNew(); TransformResultsContainer transformResultsContainer = _transformManager.TransformAll(importStoragePath); string transformStoragePath = _transformStorageProvider.StoreTransformResults(transformResultsContainer, formattedDateString); stopwatchTransform.Stop(); //Merge Stopwatch stopwatchMerge = Stopwatch.StartNew(); MergeResultsContainer mergeResultsContainer = _mergeManager.MergeAll(transformStoragePath); string mergeStoragePath = _mergeStorageProvider.StoreMergeResults(mergeResultsContainer, formattedDateString); stopwatchMerge.Stop(); //test merge storage MergeResultsContainer testMergeResultsContainer = _mergeStorageProvider.RetrieveMergeResults(mergeStoragePath); stopwatchFull.Stop(); _logger.LogInformation("Import Completed in {ImportTime} seconds", stopwatchImport.Elapsed.Seconds); _logger.LogInformation("Transform Completed in {TransformTime} seconds", stopwatchTransform.Elapsed.Seconds); _logger.LogInformation("Merge Completed in {MergeTime} seconds", stopwatchMerge.Elapsed.Seconds); _logger.LogInformation("Full Run Completed in {FullRunTime} seconds", stopwatchFull.Elapsed.Seconds); int aggregateTime = stopwatchImport.Elapsed.Seconds + stopwatchMerge.Elapsed.Seconds + stopwatchFull.Elapsed.Seconds; _logger.LogInformation("Full Run Aggregate Time in {AggregateTime} seconds", aggregateTime); } catch (Exception ex) { _logger.LogError(ex, ex.Message); _logger.LogInformation("Error in Top Level Application execution. Validate, Import, Transform, and Merge operations were NOT successfully completed. Previously existing data is unchanged"); throw; } }
private void WireUpCharacterIds(TransformResultsContainer transformResults) { foreach (RecordSphere rs in transformResults.RecordSpheres) { if (!String.IsNullOrWhiteSpace(rs.CharacterName)) { rs.CharacterId = transformResults.Characters.Where(c => c.CharacterName == rs.CharacterName).Select(c => c.Id).SingleOrDefault(); _logger.LogDebug("wired up CharacterId {CharacterId} to RecordSphere {RecordSphere}", rs.CharacterId, rs.Description); } } foreach (LegendSphere ls in transformResults.LegendSpheres) { if (!String.IsNullOrWhiteSpace(ls.CharacterName)) { ls.CharacterId = transformResults.Characters.Where(c => c.CharacterName == ls.CharacterName).Select(c => c.Id).SingleOrDefault(); _logger.LogDebug("wired up CharacterId {CharacterId} to LegendSphere {LegendSphere}", ls.CharacterId, ls.Description); } } foreach (RecordMateria rm in transformResults.RecordMaterias) { if (!String.IsNullOrWhiteSpace(rm.CharacterName)) { rm.CharacterId = transformResults.Characters.Where(c => c.CharacterName == rm.CharacterName).Select(c => c.Id).SingleOrDefault(); _logger.LogDebug("wired up CharacterId {CharacterId} to RecordMateria {RecordMateria}", rm.CharacterId, rm.Description); } } foreach (LegendMateria lm in transformResults.LegendMaterias) { if (!String.IsNullOrWhiteSpace(lm.CharacterName)) { lm.CharacterId = transformResults.Characters.Where(c => c.CharacterName == lm.CharacterName).Select(c => c.Id).SingleOrDefault(); _logger.LogDebug("wired up CharacterId {CharacterId} to LegendMateria {LegendMateria}", lm.CharacterId, lm.Description); } } foreach (Relic relic in transformResults.Relics) { if (!String.IsNullOrWhiteSpace(relic.CharacterName)) { relic.CharacterId = transformResults.Characters.Where(c => c.CharacterName == relic.CharacterName).Select(c => c.Id).SingleOrDefault(); _logger.LogDebug("wired up CharacterId {CharacterId} to Relic {Relic}", relic.CharacterId, relic.Description); } } foreach (Command command in transformResults.Commands) { if (!String.IsNullOrWhiteSpace(command.CharacterName)) { command.CharacterId = transformResults.Characters.Where(c => c.CharacterName == command.CharacterName).Select(c => c.Id).SingleOrDefault(); _logger.LogDebug("wired up CharacterId {CharacterId} to Command {Command}", command.CharacterId, command.Description); } } foreach (BraveAction braveAction in transformResults.BraveActions) { if (!String.IsNullOrWhiteSpace(braveAction.CharacterName)) { braveAction.CharacterId = transformResults.Characters.Where(c => c.CharacterName == braveAction.CharacterName).Select(c => c.Id).SingleOrDefault(); _logger.LogDebug("wired up CharacterId {CharacterId} to BraveAction {BraveAction}", braveAction.CharacterId, braveAction.Description); } } foreach (SoulBreak soulbreak in transformResults.SoulBreaks) { if (!String.IsNullOrWhiteSpace(soulbreak.CharacterName)) { soulbreak.CharacterId = transformResults.Characters.Where(c => c.CharacterName == soulbreak.CharacterName).Select(c => c.Id).SingleOrDefault(); _logger.LogDebug("wired up CharacterId {CharacterId} to SoulBreak {SoulBreak}", soulbreak.CharacterId, soulbreak.Description); } } }
private void WireUpOtherSourceInfo(TransformResultsContainer transformResults) { foreach (Other other in transformResults.Others) { //first check statuses for match Status relatedStatus = transformResults.Statuses.SingleOrDefault(s => s.CommonName.Trim() == other.SourceName.Trim()); if (relatedStatus != null) //this is the match { other.SourceId = relatedStatus.Id; other.SourceType = nameof(Status); _logger.LogDebug("wired up SourceId {SourceId} and SourceType {SourceType} to Other {Other}", other.SourceId, other.SourceType, other.Description); continue; } //next check soul breaks for match SoulBreak relatedSoulBreak = transformResults.SoulBreaks.SingleOrDefault(s => s.SoulBreakName.Trim() == other.SourceName.Trim() && (s.CharacterName.Trim() == other.CharacterName.Trim())); if (relatedSoulBreak != null) //this is the match { other.SourceId = relatedSoulBreak.Id; other.SourceType = nameof(SoulBreak); _logger.LogDebug("wired up SourceId {SourceId} and SourceType {SourceType} to Other {Other}", other.SourceId, other.SourceType, other.Description); continue; } RecordMateria relatedRecordMateria = transformResults.RecordMaterias.SingleOrDefault(r => r.RecordMateriaName.Trim() == other.SourceName.Trim()); if (relatedRecordMateria != null) //this is the match { other.SourceId = relatedRecordMateria.Id; other.SourceType = nameof(RecordMateria); _logger.LogDebug("wired up SourceId {SourceId} and SourceType {SourceType} to Other {Other}", other.SourceId, other.SourceType, other.Description); continue; } Relic relatedRelic = transformResults.Relics.SingleOrDefault(r => r.RelicName.Trim() == other.SourceName.Trim()); if (relatedRelic != null) //this is the match { other.SourceId = relatedRelic.Id; other.SourceType = nameof(Relic); _logger.LogDebug("wired up SourceId {SourceId} and SourceType {SourceType} to Other {Other}", other.SourceId, other.SourceType, other.Description); continue; } Command relatedCommand = transformResults.Commands.SingleOrDefault(c => c.CommandName.Trim() == other.SourceName.Trim()); if (relatedCommand != null) //this is the match { other.SourceId = relatedCommand.Id; other.SourceType = nameof(Command); _logger.LogDebug("wired up SourceId {SourceId} and SourceType {SourceType} to Other {Other}", other.SourceId, other.SourceType, other.Description); continue; } IList <LegendMateria> relatedLegendMateria = transformResults.LegendMaterias.Where(l => l.LegendMateriaName == other.SourceName).ToList(); if (relatedLegendMateria != null && relatedLegendMateria.Count == 1) //this is the match { other.SourceId = relatedLegendMateria.First().Id; other.SourceType = nameof(LegendMateria); _logger.LogDebug("wired up SourceId {SourceId} and SourceType {SourceType} to Other {Other}", other.SourceId, other.SourceType, other.Description); continue; } _logger.LogWarning("FAILED to wire up SourceId and SourceType to Other {Other}", other.Description); } }
private MergeResultsContainer ExecuteMerge(TransformResultsContainer transformResults) { MergeResultsContainer mergeResultsContainer = new MergeResultsContainer(); //Id Wireup WireUpLegendMateriaIds(transformResults); _logger.LogInformation("Finished wiring up LegendMateriaIds"); WireUpCharacterIds(transformResults); _logger.LogInformation("Finished wiring up CharacterIds"); WireUpSoulBreakIds(transformResults); _logger.LogInformation("Finished wiring up SoulBreakIds"); WireUpRelicIds(transformResults); _logger.LogInformation("Finished wiring up RelicIds"); WireUpMagiciteIds(transformResults); _logger.LogInformation("Finished wiring up MagiciteIds"); WireUpEventIds(transformResults); _logger.LogInformation("Finished wiring up EventIds"); WireUpOtherSourceInfo(transformResults); _logger.LogInformation("Finished wiring up OtherSourceInfo"); //Object Wireup WireUpMagiciteSkills(transformResults); _logger.LogInformation("Finished wiring up MagiciteSkills"); WireUpRecordSpheres(transformResults); _logger.LogInformation("Finished wiring up RecordSpheres"); WireUpLegendSpheres(transformResults); _logger.LogInformation("Finished wiring up LegendSpheres"); WireUpRecordMaterias(transformResults); _logger.LogInformation("Finished wiring up RecordMaterias"); WireUpLegendMaterias(transformResults); _logger.LogInformation("Finished wiring up LegendMaterias"); WireUpCommands(transformResults); _logger.LogInformation("Finished wiring up Commands"); WireUpBraveActions(transformResults); _logger.LogInformation("Finished wiring up BraveActions"); WireUpStatuses(transformResults); _logger.LogInformation("Finished wiring up Statuses"); WireUpOthers(transformResults); _logger.LogInformation("Finished wiring up Others"); WireUpSoulBreaks(transformResults); _logger.LogInformation("Finished wiring up SoulBreaks"); WireUpRelics(transformResults); _logger.LogInformation("Finished wiring up Relics"); //Value Wireup/Calculation CalculateLegendSphereTier(transformResults); _logger.LogInformation("Finished calculating up LegendSphereTier"); _logger.LogInformation("Finished MergeAll Operation"); //copy data from transformResults container to merge results container mergeResultsContainer.Abilities = transformResults.Abilities; mergeResultsContainer.Characters = transformResults.Characters; mergeResultsContainer.Commands = transformResults.Commands; mergeResultsContainer.BraveActions = transformResults.BraveActions; //mergeResultsContainer.Dungeons = transformResults.Dungeons; mergeResultsContainer.Events = transformResults.Events; mergeResultsContainer.Experiences = transformResults.Experiences; mergeResultsContainer.LegendMaterias = transformResults.LegendMaterias; mergeResultsContainer.LegendSpheres = transformResults.LegendSpheres; mergeResultsContainer.MagiciteSkills = transformResults.MagiciteSkills; mergeResultsContainer.Magicites = transformResults.Magicites; mergeResultsContainer.Missions = transformResults.Missions; mergeResultsContainer.Others = transformResults.Others; mergeResultsContainer.RecordMaterias = transformResults.RecordMaterias; mergeResultsContainer.RecordSpheres = transformResults.RecordSpheres; mergeResultsContainer.Relics = transformResults.Relics; mergeResultsContainer.SoulBreaks = transformResults.SoulBreaks; mergeResultsContainer.Statuses = transformResults.Statuses; //now add in list members mergeResultsContainer.AbilityTypeList = new AbilityTypeList().TypeList; mergeResultsContainer.AutoTargetTypeList = new AutoTargetTypeList().TypeList; mergeResultsContainer.DamageFormulaTypeList = new DamageFormulaTypeList().TypeList; mergeResultsContainer.ElementList = new ElementList().TypeList; mergeResultsContainer.EquipmentTypeList = new EquipmentTypeList().TypeList; mergeResultsContainer.EventTypeList = new EventTypeList().TypeList; mergeResultsContainer.MissionTypeList = new MissionTypeList().TypeList; mergeResultsContainer.OrbTypeList = new OrbTypeList().TypeList; mergeResultsContainer.RealmList = new RealmList().TypeList; mergeResultsContainer.RelicTypeList = new RelicTypeList().TypeList; mergeResultsContainer.SchoolList = new SchoolList().TypeList; mergeResultsContainer.StatSetTypeList = new StatSetTypeList().TypeList; mergeResultsContainer.StatTypeList = new StatTypeList().TypeList; mergeResultsContainer.SoulBreakTierList = new SoulBreakTierList().TypeList; mergeResultsContainer.TargetTypeList = new TargetTypeList().TypeList; //now add in model lookup lists mergeResultsContainer.EventIdList = mergeResultsContainer.Events.Select(i => new KeyValuePair <int, string>(i.Id, i.EventName)).ToList(); mergeResultsContainer.MissionList = mergeResultsContainer.Missions.Select(i => new KeyValuePair <int, string>(i.Id, i.Description)).ToList(); mergeResultsContainer.ExperienceIdList = mergeResultsContainer.Experiences.Select(i => new KeyValuePair <int, string>(i.Id, i.Description)).ToList(); //mergeResultsContainer.DungeonIdList = mergeResultsContainer.Dungeons.Select(i => new KeyValuePair<int, string>(i.Id, i.DungeonName)).ToList(); mergeResultsContainer.MagiciteSkillIdList = mergeResultsContainer.MagiciteSkills.Select(i => new KeyValuePair <int, string>(i.Id, i.Description)).ToList(); mergeResultsContainer.MagiciteIdList = mergeResultsContainer.Magicites.Select(i => new KeyValuePair <int, string>(i.Id, i.MagiciteName)).ToList(); mergeResultsContainer.StatusIdList = mergeResultsContainer.Statuses.Select(i => new KeyValuePair <int, string>(i.Id, i.CommonName)).ToList(); mergeResultsContainer.OtherIdList = mergeResultsContainer.Others.Select(i => new KeyValuePair <int, string>(i.Id, i.Name)).ToList(); mergeResultsContainer.CommandIdList = mergeResultsContainer.Commands.Select(i => new KeyValuePair <int, string>(i.Id, i.Description)).ToList(); mergeResultsContainer.BraveActionIdList = mergeResultsContainer.BraveActions.Select(i => new KeyValuePair <int, string>(i.Id, i.Description)).ToList(); mergeResultsContainer.SoulBreakIdList = mergeResultsContainer.SoulBreaks.Select(i => new KeyValuePair <int, string>(i.Id, i.SoulBreakName)).ToList(); mergeResultsContainer.RelicIdList = mergeResultsContainer.Relics.Select(i => new KeyValuePair <int, string>(i.Id, i.Description)).ToList(); mergeResultsContainer.AbilityIdList = mergeResultsContainer.Abilities.Select(i => new KeyValuePair <int, string>(i.Id, i.AbilityName)).ToList(); mergeResultsContainer.LegendMateriaIdList = mergeResultsContainer.LegendMaterias.Select(i => new KeyValuePair <int, string>(i.Id, i.Description)).ToList(); mergeResultsContainer.RecordMateriaIdList = mergeResultsContainer.RecordMaterias.Select(i => new KeyValuePair <int, string>(i.Id, i.Description)).ToList(); mergeResultsContainer.RecordSphereIdList = mergeResultsContainer.RecordSpheres.Select(i => new KeyValuePair <int, string>(i.Id, i.Description)).ToList(); mergeResultsContainer.LegendSphereIdList = mergeResultsContainer.LegendSpheres.Select(i => new KeyValuePair <int, string>(i.Id, i.Description)).ToList(); mergeResultsContainer.CharacterIdList = mergeResultsContainer.Characters.Select(i => new KeyValuePair <int, string>(i.Id, i.CharacterName)).ToList(); return(mergeResultsContainer); }