public WorldSource() { BlueprintReader = new BlueprintResource(); BlueprintReader.OverrideVersionMap(this.versionMap, this.componentMap); WorldDefinitionReader = new WorldDefinitionResource(); WorldDefinitionReader.OverrideVersionMap(this.versionMap, this.componentMap); ClusterReader = new ClusterDefinitionResource(); ClusterReader.OverrideVersionMap(this.versionMap, this.componentMap); }
protected override void CustomFileExport(ExportParameters exportParameters) { var Blueprint = BlueprintResource.Create(); Blueprint.InitFromRecord(exportParameters.BagStream, exportParameters.FileRecord); var outputPath = Path.GetFullPath(Path.Combine(exportParameters.OutputDirectory, exportParameters.FileRecord.Name + exportParameters.FileExtension)); var text = JsonConvert.SerializeObject(Blueprint, Formatting.Indented); File.WriteAllText(outputPath, text); exportParameters.OnProgressReport?.Invoke(exportParameters.FileRecord, 0); }
private static async Task SeedCurrentBlueprintResources(EveEchoesPlanetaryProductionApiDbContext dbContext, ILogger logger, string[] lineArgs, string[] csvValues) { var resourceTasks = new List <ValueTask <EntityEntry <BlueprintResource> > >(); var name = lineArgs[0]; var blueprintName = $"{name} Blueprint"; var blueprint = await dbContext.Blueprints.FirstOrDefaultAsync(b => b.BlueprintItem.Name.Equals(blueprintName)); if (blueprint is null) { logger.LogError($"Can't find blueprint with name: {name}"); } for (var i = 3; i < 49; i++) { var itemName = csvValues[i]; var itemQuantitySuccess = long.TryParse(lineArgs[i], out var itemQuantity); var item = await dbContext.Items.Where(i => i.Name.Equals(itemName)).FirstOrDefaultAsync(); if (!itemQuantitySuccess || item is null) { logger.LogError("Can't parse blueprint resource"); logger.LogError($"Resource: {itemName}, quantity: {itemQuantity}"); continue; } if (itemQuantity == 0) { continue; } var blueprintResource = new BlueprintResource() { Blueprint = blueprint, Item = item, Quantity = itemQuantity, }; resourceTasks.Add(dbContext.BlueprintsResources.AddAsync(blueprintResource)); } var tasks = resourceTasks.Select(vt => vt.AsTask()).ToArray(); await Task.WhenAll(tasks); await dbContext.SaveChangesAsync(); }