public async Task <State> LoadSingleAsync(WRLDCWarehouseDbContext _context, ILogger _log, StateForeign stateForeign, EntityWriteOption opt) { // check if entity already exists State existingState = await _context.States.SingleOrDefaultAsync(r => r.WebUatId == stateForeign.WebUatId); // check if we should not modify existing entities if (opt == EntityWriteOption.DontReplace && existingState != null) { return(existingState); } // find the region of the state via the region WebUatId int regionWebUatId = stateForeign.RegionWebUatId; Region stateRegion = await _context.Regions.SingleOrDefaultAsync(r => r.WebUatId == regionWebUatId); // if region doesnot exist, skip the import. Ideally, there should not be such case if (stateRegion == null) { _log.LogCritical($"Unable to find region with webUatId {regionWebUatId} while inserting state with webUatId {stateForeign.WebUatId} and name {stateForeign.FullName}"); return(null); } // check if we have to replace the entity completely if (opt == EntityWriteOption.Replace && existingState != null) { _context.States.Remove(existingState); } // if region is not present, then insert or check if we have to replace the entity completely if (existingState == null || (opt == EntityWriteOption.Replace && existingState != null)) { State newState = new State(); newState.FullName = stateForeign.FullName; newState.ShortName = stateForeign.ShortName; newState.RegionId = stateRegion.RegionId; newState.WebUatId = stateForeign.WebUatId; _context.States.Add(newState); await _context.SaveChangesAsync(); return(newState); } // check if we have to modify the entity if (opt == EntityWriteOption.Modify && existingState != null) { existingState.FullName = stateForeign.FullName; existingState.ShortName = stateForeign.ShortName; existingState.RegionId = stateRegion.RegionId; await _context.SaveChangesAsync(); return(existingState); } return(null); }
public async Task ImportForeignSsVoltage(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { VolSubStationExtract volExtract = new VolSubStationExtract(); List <VoltageForeign> ssVoltageList = volExtract.ExtractSubStationVoltages(oracleConnStr); LoadSsVoltage loadSsVoltage = new LoadSsVoltage(); foreach (VoltageForeign voltageForeign in ssVoltageList) { Voltage insertedVoltage = await loadSsVoltage.LoadSingleAsync(_context, _log, stateForeign, opt); } }
public async Task ImportForeignBusReactorOwners(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { BusReactorOwnerExtract brOwnerExtract = new BusReactorOwnerExtract(); List <BusReactorOwnerForeign> brOwnersForeign = brOwnerExtract.ExtractBusReactorOwnersForeign(oracleConnStr); LoadBusReactorOwner loadBrOwner = new LoadBusReactorOwner(); foreach (BusReactorOwnerForeign brOwnerForeign in brOwnersForeign) { BusReactorOwner insertedBrOwner = await loadBrOwner.LoadSingleAsync(_context, _log, brOwnerForeign, opt); } }
public async Task ImportForeignLineReactorOwners(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { LineReactorOwnerExtract lrOwnerExtract = new LineReactorOwnerExtract(); List <LineReactorOwnerForeign> lrOwnersForeign = lrOwnerExtract.ExtractLineReactorOwnersForeign(oracleConnStr); LoadLineReactorOwner loadLrOwner = new LoadLineReactorOwner(); foreach (LineReactorOwnerForeign lrOwnerForeign in lrOwnersForeign) { LineReactorOwner insertedLrOwner = await loadLrOwner.LoadSingleAsync(_context, _log, lrOwnerForeign, opt); } }
public async Task ImportForeignTransformerTypes(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { TransformerTypeExtract transTypeExtract = new TransformerTypeExtract(); List <TransformerType> transTypes = transTypeExtract.ExtractTransformerTypes(oracleConnStr); LoadTransformerType loadTrType = new LoadTransformerType(); foreach (TransformerType trType in transTypes) { TransformerType insertedTrType = await loadTrType.LoadSingleAsync(_context, _log, trType, opt); } }
public async Task ImportForeignGenerationTypes(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { GenerationTypeExtract genTypeExtract = new GenerationTypeExtract(); List <GenerationType> genTypes = genTypeExtract.ExtractGenTypes(oracleConnStr); LoadGenerationType loadGenType = new LoadGenerationType(); foreach (GenerationType genType in genTypes) { GenerationType insertedGenType = await loadGenType.LoadSingleAsync(_context, _log, genType, opt); } }
public async Task ImportForeignGenClassifications(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { GeneratorClassificationExtract genClassificationExtract = new GeneratorClassificationExtract(); List <GeneratorClassification> genClassifications = genClassificationExtract.ExtractGeneratorClassifications(oracleConnStr); LoadGeneratorClassification loadGenClassification = new LoadGeneratorClassification(); foreach (GeneratorClassification genClassification in genClassifications) { GeneratorClassification insertedGenClassification = await loadGenClassification.LoadSingleAsync(_context, _log, genClassification, opt); } }
public async Task ImportForeignHvdcPoles(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { HvdcPoleExtract hvdcPoleExtract = new HvdcPoleExtract(); List <HvdcPoleForeign> hvdcPoleForeignList = hvdcPoleExtract.ExtractHvdcPoleForeign(oracleConnStr); LoadHvdcPole loadHvdcPole = new LoadHvdcPole(); foreach (HvdcPoleForeign lineForeign in hvdcPoleForeignList) { HvdcPole insertedPole = await loadHvdcPole.LoadSingleAsync(_context, _log, lineForeign, opt); } }
public async Task ImportForeignBuses(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { BusExtract busExtract = new BusExtract(); List <BusForeign> busForeigns = busExtract.ExtractBusesForeign(oracleConnStr); LoadBus loadBus = new LoadBus(); foreach (BusForeign busForeign in busForeigns) { Bus insertedBus = await loadBus.LoadSingleAsync(_context, _log, busForeign, opt); } }
public async Task ImportForeignMajorSubstations(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { MajorSubstationExtract majorSSExtract = new MajorSubstationExtract(); List <MajorSubstationForeign> majorSSForeigns = majorSSExtract.ExtractMajorSubstationsForeign(oracleConnStr); LoadMajorSubstation loadMajorSS = new LoadMajorSubstation(); foreach (MajorSubstationForeign majorSSForeign in majorSSForeigns) { MajorSubstation insertedMajorSS = await loadMajorSS.LoadSingleAsync(_context, _log, majorSSForeign, opt); } }
public async Task ImportForeignFilterBanks(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { FilterBankExtract fbExtract = new FilterBankExtract(); List <FilterBankForeign> fbForeignList = fbExtract.ExtractFilterBanksForeign(oracleConnStr); LoadFilterBank loadFb = new LoadFilterBank(); foreach (FilterBankForeign fbForeign in fbForeignList) { FilterBank insertedSS = await loadFb.LoadSingleAsync(_context, _log, fbForeign, opt); } }
public async Task ImportForeignSubstations(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { SubstationExtract ssExtract = new SubstationExtract(); List <SubstationForeign> ssForeignList = ssExtract.ExtractSubstationsForeign(oracleConnStr); LoadSubstation loadSS = new LoadSubstation(); foreach (SubstationForeign ssForeign in ssForeignList) { Substation insertedSS = await loadSS.LoadSingleAsync(_context, _log, ssForeign, opt); } }
public async Task ImportForeignStates(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { StateExtract stateExtract = new StateExtract(); List <StateForeign> stateForeigns = stateExtract.ExtractStatesForeign(oracleConnStr); LoadState loadState = new LoadState(); foreach (StateForeign stateForeign in stateForeigns) { State insertedState = await loadState.LoadSingleAsync(_context, _log, stateForeign, opt); } }
public async Task ImportForeignAcTransLineCktOwners(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { AcTransLineCktOwnerExtract acCktOwnerExtract = new AcTransLineCktOwnerExtract(); List <AcTransmissionLineCircuitOwnerForeign> acCktOwnersForeign = acCktOwnerExtract.ExtractAcTransLineCktOwnersForeign(oracleConnStr); LoadAcTransCktOwner loadAcCktOwner = new LoadAcTransCktOwner(); foreach (AcTransmissionLineCircuitOwnerForeign acCktOwnerForeign in acCktOwnersForeign) { AcTransLineCktOwner insertedAcCktOwner = await loadAcCktOwner.LoadSingleAsync(_context, _log, acCktOwnerForeign, opt); } }
public async Task ImportForeignFilterBankOwners(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { FilterBankOwnerExtract fbOwnerExtract = new FilterBankOwnerExtract(); List <FilterBankOwnerForeign> fbOwnersForeign = fbOwnerExtract.ExtractFilterBankOwnersForeign(oracleConnStr); LoadFilterBankOwner loadFbOwner = new LoadFilterBankOwner(); foreach (FilterBankOwnerForeign fbOwnerForeign in fbOwnersForeign) { FilterBankOwner insertedFbOwner = await loadFbOwner.LoadSingleAsync(_context, _log, fbOwnerForeign, opt); } }
public async Task ImportForeignOwners(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { OwnerExtract ownerExtract = new OwnerExtract(); List <Owner> owners = ownerExtract.ExtractOwners(oracleConnStr); LoadOwner loadOwner = new LoadOwner(); foreach (Owner owner in owners) { Owner insertedOwner = await loadOwner.LoadSingleAsync(_context, _log, owner, opt); } }
public async Task ImportForeignRegions(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { RegionExtract regionExtract = new RegionExtract(); List <Region> regions = regionExtract.ExtractRegions(oracleConnStr); LoadRegion loadRegion = new LoadRegion(); foreach (Region region in regions) { Region insertedRegion = await loadRegion.LoadSingleAsync(_context, _log, region, opt); } }
public async Task ImportForeignSubstationOwners(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { SubstationOwnerExtract ssOwnerExtract = new SubstationOwnerExtract(); List <SubstationOwnerForeign> ssOwnersForeign = ssOwnerExtract.ExtractSubstationOwnersForeign(oracleConnStr); LoadSubstationOwner loadSSOwner = new LoadSubstationOwner(); foreach (SubstationOwnerForeign ssOwnerForeign in ssOwnersForeign) { SubstationOwner insertedSSOwner = await loadSSOwner.LoadSingleAsync(_context, _log, ssOwnerForeign, opt); } }
public async Task ImportForeignBayTypes(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { BayTypeExtract bayTypeExtract = new BayTypeExtract(); List <BayType> bayTypes = bayTypeExtract.ExtractBays(oracleConnStr); LoadBayType loadBayType = new LoadBayType(); foreach (BayType bayType in bayTypes) { BayType insertedBayType = await loadBayType.LoadSingleAsync(_context, _log, bayType, opt); } }
public async Task ImportForeignFscs(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { FscExtract fscExtract = new FscExtract(); List <FscForeign> fscForeignList = fscExtract.ExtractFscForeign(oracleConnStr); LoadFsc loadFsc = new LoadFsc(); foreach (FscForeign fscForeign in fscForeignList) { Fsc insertedFsc = await loadFsc.LoadSingleAsync(_context, _log, fscForeign, opt); } }
public async Task ImportForeignTransformers(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { TransformerExtract trExtract = new TransformerExtract(); List <TransformerForeign> trForeignList = trExtract.ExtractTransformersForeign(oracleConnStr); LoadTransformer loadTr = new LoadTransformer(); foreach (TransformerForeign trForeign in trForeignList) { Transformer insertedTr = await loadTr.LoadSingleAsync(_context, _log, trForeign, opt); } }
public async Task ImportForeignAcTransLineCktCondTypes(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { AcTransLineCircuitCondTypeExtract acTransLineCktCondExtract = new AcTransLineCircuitCondTypeExtract(); List <AcTransLineCktCondTypeForeign> acTransLineCktCondTypesForeign = acTransLineCktCondExtract.ExtractAcTransLineCktCondTypeForeign(oracleConnStr); LoadAcTransLineCktCondType loadAcTransLineCktCond = new LoadAcTransLineCktCondType(); foreach (AcTransLineCktCondTypeForeign acTransLineCktCondTypeForeign in acTransLineCktCondTypesForeign) { AcTransLineCkt insertedAcTransLineCkt = await loadAcTransLineCktCond.LoadSingleAsync(_context, _log, acTransLineCktCondTypeForeign, opt); } }
public async Task ImportForeignVoltageLevels(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { VoltLevelExtract voltLevelExtract = new VoltLevelExtract(); List <VoltLevel> voltLevels = voltLevelExtract.ExtractVoltageLevels(oracleConnStr); LoadVoltageLevel loadVoltageLevel = new LoadVoltageLevel(); foreach (VoltLevel voltLevel in voltLevels) { VoltLevel insertedVolt = await loadVoltageLevel.LoadSingleAsync(_context, _log, voltLevel, opt); } }
public async Task ImportForeignBays(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { BayExtract bayExtract = new BayExtract(); List <BayForeign> bayForeigns = bayExtract.ExtractBaysForeign(oracleConnStr); LoadBay loadBay = new LoadBay(); foreach (BayForeign bayForeign in bayForeigns) { Bay insertedBay = await loadBay.LoadSingleAsync(_context, _log, bayForeign, opt); } }
public async Task ImportForeignHvdcLineCktOwners(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { HvdcLineCktOwnerExtract hvdcLineCktOwnerExtract = new HvdcLineCktOwnerExtract(); List <HvdcLineCktOwnerForeign> hvdcLineCktOwnerForeignList = hvdcLineCktOwnerExtract.ExtractHvdcLineCktOwnersForeign(oracleConnStr); LoadHvdcLineCktOwner loadHvdcLineCktOwner = new LoadHvdcLineCktOwner(); foreach (HvdcLineCktOwnerForeign cktOwnerForeign in hvdcLineCktOwnerForeignList) { HvdcLineCktOwner insertedCktOwner = await loadHvdcLineCktOwner.LoadSingleAsync(_context, _log, cktOwnerForeign, opt); } }
public async Task ImportForeignFuels(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { FuelExtract fuelExtract = new FuelExtract(); List <Fuel> fuels = fuelExtract.ExtractFuels(oracleConnStr); LoadFuel loadFuel = new LoadFuel(); foreach (Fuel fuel in fuels) { Fuel insertedFuel = await loadFuel.LoadSingleAsync(_context, _log, fuel, opt); } }
public async Task ImportForeignGeneratorUnits(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { GeneratorUnitExtract genUnitExtract = new GeneratorUnitExtract(); List <GeneratorUnitForeign> genUnitsForeign = genUnitExtract.ExtractGeneratorUnitsForeign(oracleConnStr); LoadGeneratorUnit loadGenUnit = new LoadGeneratorUnit(); foreach (GeneratorUnitForeign genUnitForeign in genUnitsForeign) { GeneratorUnit insertedGenUnit = await loadGenUnit.LoadSingleAsync(_context, _log, genUnitForeign, opt); } }
public async Task ImportForeignCompensators(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { CompensatorExtract compensatorExtract = new CompensatorExtract(); List <CompensatorForeign> compensatorForeignList = compensatorExtract.ExtractCompensatorForeign(oracleConnStr); LoadCompensator loadCompensator = new LoadCompensator(); foreach (CompensatorForeign compensatorForeign in compensatorForeignList) { Compensator insertedCompensator = await loadCompensator.LoadSingleAsync(_context, _log, compensatorForeign, opt); } }
public async Task ImportForeignCompensatorTypes(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { CompensatorTypeExtract compensatorTypeExtract = new CompensatorTypeExtract(); List <CompensatorType> compensatorTypes = compensatorTypeExtract.ExtractCompensatorTypes(oracleConnStr); LoadCompensatorType loadCompensatorType = new LoadCompensatorType(); foreach (CompensatorType compensatorType in compensatorTypes) { CompensatorType insertedCompensatorType = await loadCompensatorType.LoadSingleAsync(_context, _log, compensatorType, opt); } }
public async Task <GeneratorStage> LoadSingleAsync(WRLDCWarehouseDbContext _context, ILogger _log, GeneratorStageForeign genStageForeign, EntityWriteOption opt) { // check if entity already exists GeneratorStage existingGenStage = await _context.GeneratorStages.SingleOrDefaultAsync(r => r.WebUatId == genStageForeign.WebUatId); // check if we should not modify existing entities if (opt == EntityWriteOption.DontReplace && existingGenStage != null) { return(existingGenStage); } // find the GeneratingStation of the state via the region WebUatId int generatingStationWebUatId = genStageForeign.GeneratingStationWebUatId; GeneratingStation genStation = await _context.GeneratingStations.SingleOrDefaultAsync(r => r.WebUatId == generatingStationWebUatId); // if genStation doesnot exist, skip the import. Ideally, there should not be such case if (genStation == null) { _log.LogCritical($"Could not find GeneratingStation with WebUatId {generatingStationWebUatId} in warehouse while creating GeneratorStage with WebUat Id {genStageForeign.WebUatId} and name {genStageForeign.Name}"); return(null); } // check if we have to replace the entity completely if (opt == EntityWriteOption.Replace && existingGenStage != null) { _context.GeneratorStages.Remove(existingGenStage); } // if entity is not present, then insert or check if we have to replace the entity completely if (existingGenStage == null || (opt == EntityWriteOption.Replace && existingGenStage != null)) { GeneratorStage newGenStage = new GeneratorStage(); newGenStage.Name = genStageForeign.Name; newGenStage.GeneratingStationId = genStation.GeneratingStationId; newGenStage.WebUatId = genStageForeign.WebUatId; _context.GeneratorStages.Add(newGenStage); await _context.SaveChangesAsync(); return(newGenStage); } // check if we have to modify the entity if (opt == EntityWriteOption.Modify && existingGenStage != null) { existingGenStage.Name = genStageForeign.Name; existingGenStage.GeneratingStationId = genStation.GeneratingStationId; await _context.SaveChangesAsync(); return(existingGenStage); } return(null); }