예제 #1
0
        public DbSystemInserter(BodyDbContext ctx)
        {
            Context = ctx;

            string syscmdtext  = "INSERT INTO Systems (ModSystemAddress, X, Y, Z, RegionId, SizeClass, Mid3, Mid2, Mid1b, Mid1a, Sequence, EdsmId, EdsmLastModifiedSeconds)";
            string syscmdtext2 = " VALUES (@ModSystemAddress, @X, @Y, @Z, @RegionId, @SizeClass, @Mid3, @Mid2, @Mid1b, @Mid1a, @Sequence, @EdsmId, @EdsmLastModifiedSeconds)";

            execsyscmd = ctx.GetInsertIdentity(ref syscmdtext, ref syscmdtext2);

            if (execsyscmd == null)
            {
                return;
            }

            syscmdtext += syscmdtext2;

            if (ctx.Database.Connection.State != ConnectionState.Open)
            {
                ctx.Database.Connection.Open();
            }

            try
            {
                syscmd                = ctx.Database.Connection.CreateCommand();
                syscmd.CommandText    = syscmdtext;
                syscmd.CommandType    = CommandType.Text;
                paramSysaddr          = syscmd.AddParameter("@ModSystemAddress", DbType.Int64);
                paramX                = syscmd.AddParameter("@X", DbType.Int32);
                paramY                = syscmd.AddParameter("@Y", DbType.Int32);
                paramZ                = syscmd.AddParameter("@Z", DbType.Int32);
                paramRegionId         = syscmd.AddParameter("@RegionId", DbType.Int16);
                paramSizeClass        = syscmd.AddParameter("@SizeClass", DbType.Byte);
                paramMid3             = syscmd.AddParameter("@Mid3", DbType.Byte);
                paramMid2             = syscmd.AddParameter("@Mid2", DbType.Byte);
                paramMid1b            = syscmd.AddParameter("@Mid1b", DbType.Byte);
                paramMid1a            = syscmd.AddParameter("@Mid1a", DbType.Byte);
                paramSequence         = syscmd.AddParameter("@Sequence", DbType.Int16);
                paramEdsmId           = syscmd.AddParameter("@EdsmId", DbType.Int32);
                paramEdsmLastModified = syscmd.AddParameter("@EdsmLastModifiedSeconds", DbType.Int32);

                namecmd             = ctx.Database.Connection.CreateCommand();
                namecmd.CommandText = "INSERT INTO SystemCustomNames (Id, SystemAddress, CustomName) VALUES (@Id, @SystemAddress, @CustomName)";
                paramNameId         = namecmd.AddParameter("@Id", DbType.Int32);
                paramNameSysAddr    = namecmd.AddParameter("@SystemAddress", DbType.Int64);
                paramCustomName     = namecmd.AddParameter("@CustomName", DbType.String);
            }
            catch
            {
                Dispose();
                throw;
            }
        }
        public DbScanHeaderInserter(BodyDbContext ctx)
        {
            Context = ctx;

            string scancmdtext  = "INSERT INTO EDDNJournalScans (BodyScanId, GatewayTimestampTicks, ScanTimestampSeconds, SoftwareVersionId, ScanTypeId, DistanceFromArrivalLS, HasSystemAddress, HasBodyID, HasParents, HasComposition, HasAxialTilt, HasLuminosity, IsMaterialsDict, IsBasicScan, IsPos3SigFig, HasAtmosphereType, HasAtmosphereComposition)";
            string scancmdtext2 = " VALUES (@BodyScanId, @GatewayTimestampTicks, @ScanTimestampSeconds, @SoftwareVersionId, @ScanTypeId, @DistanceFromArrivalLS, @HasSystemAddress, @HasBodyID, @HasParents, @HasComposition, @HasAxialTilt, @HasLuminosity, @IsMaterialsDict, @IsBasicScan, @IsPos3SigFig, @HasAtmosphereType, @HasAtmosphereComposition)";

            execscancmd = ctx.GetInsertIdentity(ref scancmdtext, ref scancmdtext2);

            if (execscancmd == null)
            {
                return;
            }

            scancmdtext += scancmdtext2;

            if (ctx.Database.Connection.State != ConnectionState.Open)
            {
                ctx.Database.Connection.Open();
            }

            cmd                             = ctx.Database.Connection.CreateCommand();
            cmd.CommandText                 = scancmdtext;
            cmd.CommandType                 = CommandType.Text;
            paramBodyScanId                 = cmd.AddParameter("@BodyScanId", DbType.Int32);
            paramGatewayTimestamp           = cmd.AddParameter("@GatewayTimestampTicks", DbType.Int64);
            paramScanTimestamp              = cmd.AddParameter("@ScanTimestampSeconds", DbType.Int32);
            paramSoftwareVersionId          = cmd.AddParameter("@SoftwareVersionId", DbType.Int16);
            paramDistFromArrival            = cmd.AddParameter("@DistanceFromArrivalLS", DbType.Single);
            paramScanTypeId                 = cmd.AddParameter("@ScanTypeId", DbType.Byte);
            paramHasSystemAddress           = cmd.AddParameter("@HasSystemAddress", DbType.Boolean);
            paramHasBodyID                  = cmd.AddParameter("@HasBodyID", DbType.Boolean);
            paramHasParents                 = cmd.AddParameter("@HasParents", DbType.Boolean);
            paramHasComposition             = cmd.AddParameter("@HasComposition", DbType.Boolean);
            paramHasAxialTilt               = cmd.AddParameter("@HasAxialTilt", DbType.Boolean);
            paramHasLuminosity              = cmd.AddParameter("@HasLuminosity", DbType.Boolean);
            paramIsMaterialsDict            = cmd.AddParameter("@IsMaterialsDict", DbType.Boolean);
            paramIsBasicScan                = cmd.AddParameter("@IsBasicScan", DbType.Boolean);
            paramIsPos3SigFig               = cmd.AddParameter("@IsPos3SigFig", DbType.Boolean);
            paramHasAtmosphereType          = cmd.AddParameter("@HasAtmosphereType", DbType.Boolean);
            paramHasAtmosphereComposition   = cmd.AddParameter("@HasAtmosphereComposition", DbType.Boolean);
            paramGatewayTimestamp.Precision = 6;

            cmdJsonExtra             = ctx.Database.Connection.CreateCommand();
            cmdJsonExtra.CommandText = "INSERT INTO EDDNJournalScanJsonExtras (Id, JsonExtra) VALUES (@Id, @JsonExtra)";
            cmdJsonExtra.CommandType = CommandType.Text;
            paramJsonExtraId         = cmdJsonExtra.AddParameter("@Id", DbType.Int32);
            paramJsonExtra           = cmdJsonExtra.AddParameter("@JsonExtra", DbType.String);
        }
        public DbBodyInserter(BodyDbContext ctx)
        {
            Context = ctx;

            string bodycmdtext  = "INSERT INTO SystemBodies (SystemId, BodyID, Stars, Planet, Moon1, Moon2, Moon3, IsBelt, ScanBaseHash, CustomNameId)";
            string bodycmdtext2 = " VALUES (@SystemId, @BodyID, @Stars, @Planet, @Moon1, @Moon2, @Moon3, @IsBelt, @ScanBaseHash, @CustomNameId)";

            execbodycmd = ctx.GetInsertIdentity(ref bodycmdtext, ref bodycmdtext2);

            if (execbodycmd == null)
            {
                return;
            }

            bodycmdtext += bodycmdtext2;

            if (ctx.Database.Connection.State != ConnectionState.Open)
            {
                ctx.Database.Connection.Open();
            }

            try
            {
                bodycmd             = ctx.Database.Connection.CreateCommand();
                bodycmd.CommandText = bodycmdtext;
                paramSystemId       = bodycmd.AddParameter("@SystemId", DbType.Int32);
                paramBodyID         = bodycmd.AddParameter("@BodyID", DbType.Int16);
                paramStars          = bodycmd.AddParameter("@Stars", DbType.Byte);
                paramIsBelt         = bodycmd.AddParameter("@IsBelt", DbType.Boolean);
                paramPlanet         = bodycmd.AddParameter("@Planet", DbType.Byte);
                paramMoon1          = bodycmd.AddParameter("@Moon1", DbType.Byte);
                paramMoon2          = bodycmd.AddParameter("@Moon2", DbType.Byte);
                paramMoon3          = bodycmd.AddParameter("@Moon3", DbType.Byte);
                paramScanBaseHash   = bodycmd.AddParameter("@ScanBaseHash", DbType.Int32);
                paramCustomNameId   = bodycmd.AddParameter("@CustomNameId", DbType.Int16);

                namecmd             = ctx.Database.Connection.CreateCommand();
                namecmd.CommandText = "INSERT INTO SystemBodyCustomNames (Id, SystemId, BodyID, CustomName) VALUES (@Id, @SystemId, @BodyID, @CustomName)";
                paramNameId         = namecmd.AddParameter("@Id", DbType.Int32);
                paramNameSystemId   = namecmd.AddParameter("@SystemId", DbType.Int32);
                paramNameBodyID     = namecmd.AddParameter("@BodyID", DbType.Int16);
                paramCustomName     = namecmd.AddParameter("@CustomName", DbType.String);
            }
            catch
            {
                Dispose();
                throw;
            }
        }
예제 #4
0
        public DbScanUpdater(BodyDbContext ctx)
        {
            Context = ctx;

            if (ctx.Database.Connection.State != ConnectionState.Open)
            {
                ctx.Database.Connection.Open();
            }

            cmdUpdateBody             = ctx.Database.Connection.CreateCommand();
            cmdUpdateBody.CommandText = "UPDATE SystemBodies SET BodyID = @BodyID WHERE Id = @Id";
            cmdUpdateBody.CommandType = CommandType.Text;

            paramUpdateBodyId     = cmdUpdateBody.AddParameter("@Id", DbType.Int32);
            paramUpdateBodyBodyID = cmdUpdateBody.AddParameter("@BodyID", DbType.Int16);

            cmdUpdateScan             = ctx.Database.Connection.CreateCommand();
            cmdUpdateScan.CommandText =
                "UPDATE BodyScans SET " +
                "ParentSetId = @ParentSetId, TidalLock = @TidalLock, " +
                "AxialTilt = @AxialTilt, ReserveLevelId = @ReserveLevelId " +
                "WHERE Id = @Id";
            cmdUpdateScan.CommandType = CommandType.Text;

            paramUpdateScanId           = cmdUpdateScan.AddParameter("@Id", DbType.Int32);
            paramUpdateScanTidalLock    = cmdUpdateScan.AddParameter("@TidalLock", DbType.Boolean);
            paramUpdateScanAxialTilt    = cmdUpdateScan.AddParameter("@AxialTilt", DbType.Single);
            paramUpdateScanParents      = cmdUpdateScan.AddParameter("@ParentSetId", DbType.Int32);
            paramUpdateScanReserveLevel = cmdUpdateScan.AddParameter("@ReserveLevelId", DbType.Byte);

            cmdUpdatePlanet             = ctx.Database.Connection.CreateCommand();
            cmdUpdatePlanet.CommandText =
                "UPDATE BodyScanPlanets SET " +
                "VolcanismId = @VolcanismId, VolcanismMajor = @VolcanismMajor, VolcanismMinor = @VolcanismMinor, " +
                "IsLandable = @IsLandable, TerraformStateId = @TerraformStateId, HasComposition = @HasComposition, " +
                "CompositionMetal = @CompositionMetal, CompositionRock = @CompositionRock, CompositionIce = @CompositionIce " +
                "WHERE Id = @Id";
            cmdUpdatePlanet.CommandType = CommandType.Text;

            paramUpdatePlanetScanId         = cmdUpdatePlanet.AddParameter("@Id", DbType.Int32);
            paramUpdatePlanetVolcanismId    = cmdUpdatePlanet.AddParameter("@VolcanismId", DbType.Byte);
            paramUpdatePlanetVolcanismMajor = cmdUpdatePlanet.AddParameter("@VolcanismMajor", DbType.Boolean);
            paramUpdatePlanetVolcanismMinor = cmdUpdatePlanet.AddParameter("@VolcanismMinor", DbType.Boolean);
            paramUpdatePlanetLandable       = cmdUpdatePlanet.AddParameter("@IsLandable", DbType.Boolean);
            paramUpdatePlanetComposMetal    = cmdUpdatePlanet.AddParameter("@CompositionMetal", DbType.Single);
            paramUpdatePlanetComposRock     = cmdUpdatePlanet.AddParameter("@CompositionRock", DbType.Single);
            paramUpdatePlanetComposIce      = cmdUpdatePlanet.AddParameter("@CompositionIce", DbType.Single);
            paramUpdatePlanetHasCompos      = cmdUpdatePlanet.AddParameter("@HasComposition", DbType.Boolean);
            paramUpdatePlanetTerraformState = cmdUpdatePlanet.AddParameter("@TerraformStateId", DbType.Byte);

            cmdUpdateStar             = ctx.Database.Connection.CreateCommand();
            cmdUpdateStar.CommandText = "UPDATE BodyScanStars SET LuminosityId = @LuminosityId WHERE Id = @Id";
            cmdUpdateStar.CommandType = CommandType.Text;

            paramUpdateStarScanId     = cmdUpdateStar.AddParameter("@Id", DbType.Int32);
            paramUpdateStarLuminosity = cmdUpdateStar.AddParameter("@LuminosityId", DbType.Byte);

            cmdUpdateAtmos             = ctx.Database.Connection.CreateCommand();
            cmdUpdateAtmos.CommandText =
                "UPDATE BodyScanAtmospheres SET " +
                "AtmosphereTypeId = @AtmosphereTypeId, " +
                "AtmosphereComponent1Id = @AtmosphereComponent1Id, AtmosphereComponent1Amt = @AtmosphereComponent1Amt, " +
                "AtmosphereComponent2Id = @AtmosphereComponent2Id, AtmosphereComponent2Amt = @AtmosphereComponent2Amt, " +
                "AtmosphereComponent3Id = @AtmosphereComponent3Id, AtmosphereComponent3Amt = @AtmosphereComponent3Amt " +
                "WHERE Id = @Id";
            cmdUpdateAtmos.CommandType = CommandType.Text;

            paramAtmosUpdateScanId   = cmdUpdateAtmos.AddParameter("@Id", DbType.Int32);
            paramAtmosUpdateComp1Id  = cmdUpdateAtmos.AddParameter("@AtmosphereComponent1Id", DbType.Byte);
            paramAtmosUpdateComp1Amt = cmdUpdateAtmos.AddParameter("@AtmosphereComponent1Amt", DbType.Single);
            paramAtmosUpdateComp2Id  = cmdUpdateAtmos.AddParameter("@AtmosphereComponent2Id", DbType.Byte);
            paramAtmosUpdateComp2Amt = cmdUpdateAtmos.AddParameter("@AtmosphereComponent2Amt", DbType.Single);
            paramAtmosUpdateComp3Id  = cmdUpdateAtmos.AddParameter("@AtmosphereComponent3Id", DbType.Byte);
            paramAtmosUpdateComp3Amt = cmdUpdateAtmos.AddParameter("@AtmosphereComponent3Amt", DbType.Single);
            paramAtmosUpdateTypeId   = cmdUpdateAtmos.AddParameter("@AtmosphereTypeId", DbType.Byte);

            cmdInsertRings             = ctx.Database.Connection.CreateCommand();
            cmdInsertRings.CommandText =
                "INSERT INTO BodyScanRings (ScanId, RingNum, ClassId, InnerRad, OuterRad, MassMT, IsBelt) " +
                "VALUES (@ScanId, @RingNum, @ClassId, @InnerRad, @OuterRad, @MassMT, @IsBelt)";
            cmdInsertRings.CommandType = CommandType.Text;

            paramRingScanId   = cmdInsertRings.AddParameter("@ScanId", DbType.Int32);
            paramRingNum      = cmdInsertRings.AddParameter("@RingNum", DbType.Byte);
            paramRingClass    = cmdInsertRings.AddParameter("@ClassId", DbType.Byte);
            paramRingName     = cmdInsertRings.AddParameter("@Name", DbType.String);
            paramRingInnerRad = cmdInsertRings.AddParameter("@InnerRad", DbType.Single);
            paramRingOuterRad = cmdInsertRings.AddParameter("@OuterRad", DbType.Single);
            paramRingMassMT   = cmdInsertRings.AddParameter("@MassMT", DbType.Single);
            paramRingIsBelt   = cmdInsertRings.AddParameter("@IsBelt", DbType.Boolean);

            cmdInsertRingName             = ctx.Database.Connection.CreateCommand();
            cmdInsertRingName.CommandText = "INSERT INTO BodyScanRingCustomNames (ScanId, RingNum, Name) VALUES (@ScanId, @RingNum, @Name)";
            cmdInsertRingName.CommandType = CommandType.Text;

            paramRingNameScanId = cmdInsertRingName.AddParameter("@ScanId", DbType.Int32);
            paramRingNameNum    = cmdInsertRingName.AddParameter("@RingNum", DbType.Byte);
            paramRingName       = cmdInsertRingName.AddParameter("@Name", DbType.String);

            cmdInsertMats             = ctx.Database.Connection.CreateCommand();
            cmdInsertMats.CommandText =
                "INSERT INTO BodyScanMaterials (Id, MaterialCarbon, MaterialIron, MaterialNickel, MaterialPhosphorus, MaterialSulphur, Material1Id, Material1Amt, Material2Id, Material2Amt, Material3Id, Material3Amt, Material4Id, Material4Amt, Material5Id, Material5Amt, Material6Id, Material6Amt) VALUES " +
                "(@Id, @MaterialCarbon, @MaterialIron, @MaterialNickel, @MaterialPhosphorus, @MaterialSulphur, @Material1Id, @Material1Amt, @Material2Id, @Material2Amt, @Material3Id, @Material3Amt, @Material4Id, @Material4Amt, @Material5Id, @Material5Amt, @Material6Id, @Material6Amt)";
            cmdInsertMats.CommandType = CommandType.Text;

            paramMatsId         = cmdInsertMats.AddParameter("@Id", DbType.Int32);
            paramMatsCarbon     = cmdInsertMats.AddParameter("@MaterialCarbon", DbType.Single);
            paramMatsIron       = cmdInsertMats.AddParameter("@MaterialIron", DbType.Single);
            paramMatsNickel     = cmdInsertMats.AddParameter("@MaterialNickel", DbType.Single);
            paramMatsPhosphorus = cmdInsertMats.AddParameter("@MaterialPhosphorus", DbType.Single);
            paramMatsSulphur    = cmdInsertMats.AddParameter("@MaterialSulphur", DbType.Single);
            paramMat1Id         = cmdInsertMats.AddParameter("@Material1Id", DbType.Byte);
            paramMat1Amt        = cmdInsertMats.AddParameter("@Material1Amt", DbType.Single);
            paramMat2Id         = cmdInsertMats.AddParameter("@Material2Id", DbType.Byte);
            paramMat2Amt        = cmdInsertMats.AddParameter("@Material2Amt", DbType.Single);
            paramMat3Id         = cmdInsertMats.AddParameter("@Material3Id", DbType.Byte);
            paramMat3Amt        = cmdInsertMats.AddParameter("@Material3Amt", DbType.Single);
            paramMat4Id         = cmdInsertMats.AddParameter("@Material4Id", DbType.Byte);
            paramMat4Amt        = cmdInsertMats.AddParameter("@Material4Amt", DbType.Single);
            paramMat5Id         = cmdInsertMats.AddParameter("@Material5Id", DbType.Byte);
            paramMat5Amt        = cmdInsertMats.AddParameter("@Material5Amt", DbType.Single);
            paramMat6Id         = cmdInsertMats.AddParameter("@Material6Id", DbType.Byte);
            paramMat6Amt        = cmdInsertMats.AddParameter("@Material6Amt", DbType.Single);

            cmdInsertAtmos             = ctx.Database.Connection.CreateCommand();
            cmdInsertAtmos.CommandText =
                "INSERT INTO BodyScanAtmospheres (Id, SurfacePressure, AtmosphereComponent1Id, AtmosphereComponent1Amt, AtmosphereComponent2Id, AtmosphereComponent2Amt, AtmosphereComponent3Id, AtmosphereComponent3Amt, AtmosphereId, AtmosphereTypeId, AtmosphereHot, AtmosphereThin, AtmosphereThick) VALUES " +
                "(@Id, @SurfacePressure, @AtmosphereComponent1Id, @AtmosphereComponent1Amt, @AtmosphereComponent2Id, @AtmosphereComponent2Amt, @AtmosphereComponent3Id, @AtmosphereComponent3Amt, @AtmosphereId, @AtmosphereTypeId, @AtmosphereHot, @AtmosphereThin, @AtmosphereThick)";
            cmdInsertAtmos.CommandType = CommandType.Text;

            paramAtmosScanId     = cmdInsertAtmos.AddParameter("@Id", DbType.Int32);
            paramSurfacePressure = cmdInsertAtmos.AddParameter("@SurfacePressure", DbType.Single);
            paramAtmosComp1Id    = cmdInsertAtmos.AddParameter("@AtmosphereComponent1Id", DbType.Byte);
            paramAtmosComp1Amt   = cmdInsertAtmos.AddParameter("@AtmosphereComponent1Amt", DbType.Single);
            paramAtmosComp2Id    = cmdInsertAtmos.AddParameter("@AtmosphereComponent2Id", DbType.Byte);
            paramAtmosComp2Amt   = cmdInsertAtmos.AddParameter("@AtmosphereComponent2Amt", DbType.Single);
            paramAtmosComp3Id    = cmdInsertAtmos.AddParameter("@AtmosphereComponent3Id", DbType.Byte);
            paramAtmosComp3Amt   = cmdInsertAtmos.AddParameter("@AtmosphereComponent3Amt", DbType.Single);
            paramAtmosNameId     = cmdInsertAtmos.AddParameter("@AtmosphereId", DbType.Byte);
            paramAtmosTypeId     = cmdInsertAtmos.AddParameter("@AtmosphereTypeId", DbType.Byte);
            paramAtmosHot        = cmdInsertAtmos.AddParameter("@AtmosphereHot", DbType.Boolean);
            paramAtmosThin       = cmdInsertAtmos.AddParameter("@AtmosphereThin", DbType.Boolean);
            paramAtmosThick      = cmdInsertAtmos.AddParameter("@AtmosphereThick", DbType.Boolean);
        }
예제 #5
0
        public DbScanInserter(BodyDbContext ctx)
        {
            Context = ctx;

            string scancmdtext  = "INSERT INTO BodyScans (SystemBodyId, ParentSetId, ScanBaseHash, AxialTilt, Eccentricity, OrbitalInclination, Periapsis, SemiMajorAxis, OrbitalPeriod, Radius, RotationPeriod, SurfaceTemperature, HasOrbit, TidalLock, ReserveLevelId)";
            string scancmdtext2 = " VALUES (@SystemBodyId, @ParentSetId, @ScanBaseHash, @AxialTilt, @Eccentricity, @OrbitalInclination, @Periapsis, @SemiMajorAxis, @OrbitalPeriod, @Radius, @RotationPeriod, @SurfaceTemperature, @HasOrbit, @TidalLock, @ReserveLevel)";

            execscancmd = ctx.GetInsertIdentity(ref scancmdtext, ref scancmdtext2);

            if (execscancmd == null)
            {
                return;
            }

            scancmdtext += scancmdtext2;

            if (ctx.Database.Connection.State != ConnectionState.Open)
            {
                ctx.Database.Connection.Open();
            }

            try
            {
                cmdScan             = ctx.Database.Connection.CreateCommand();
                cmdScan.CommandText = scancmdtext;
                cmdScan.CommandType = CommandType.Text;

                paramSystemBodyId       = cmdScan.AddParameter("@SystemBodyId", DbType.Int32);
                paramParentSetId        = cmdScan.AddParameter("@ParentSetId", DbType.Int32);
                paramScanBaseHash       = cmdScan.AddParameter("@ScanBaseHash", DbType.Int32);
                paramAxialTilt          = cmdScan.AddParameter("@AxialTilt", DbType.Single);
                paramEccentricity       = cmdScan.AddParameter("@Eccentricity", DbType.Single);
                paramOrbitalInclination = cmdScan.AddParameter("@OrbitalInclination", DbType.Single);
                paramPeriapsis          = cmdScan.AddParameter("@Periapsis", DbType.Single);
                paramSemiMajorAxis      = cmdScan.AddParameter("@SemiMajorAxis", DbType.Single);
                paramOrbitalPeriod      = cmdScan.AddParameter("@OrbitalPeriod", DbType.Single);
                paramRadius             = cmdScan.AddParameter("@Radius", DbType.Single);
                paramRotationPeriod     = cmdScan.AddParameter("@RotationPeriod", DbType.Single);
                paramSurfaceTemperature = cmdScan.AddParameter("@SurfaceTemperature", DbType.Single);
                paramHasOrbit           = cmdScan.AddParameter("@HasOrbit", DbType.Boolean);
                paramTidalLock          = cmdScan.AddParameter("@TidalLock", DbType.Boolean);
                paramReserveLevel       = cmdScan.AddParameter("@ReserveLevel", DbType.Byte);

                cmdRing             = ctx.Database.Connection.CreateCommand();
                cmdRing.CommandText =
                    "INSERT INTO BodyScanRings (ScanId, RingNum, ClassId, InnerRad, OuterRad, MassMT, IsBelt) " +
                    "VALUES (@ScanId, @RingNum, @ClassId, @InnerRad, @OuterRad, @MassMT, @IsBelt)";
                cmdRing.CommandType = CommandType.Text;

                paramRingScanId   = cmdRing.AddParameter("@ScanId", DbType.Int32);
                paramRingNum      = cmdRing.AddParameter("@RingNum", DbType.Byte);
                paramRingClass    = cmdRing.AddParameter("@ClassId", DbType.Byte);
                paramRingInnerRad = cmdRing.AddParameter("@InnerRad", DbType.Single);
                paramRingOuterRad = cmdRing.AddParameter("@OuterRad", DbType.Single);
                paramRingMassMT   = cmdRing.AddParameter("@MassMT", DbType.Single);
                paramRingIsBelt   = cmdRing.AddParameter("@IsBelt", DbType.Boolean);

                cmdRingName             = ctx.Database.Connection.CreateCommand();
                cmdRingName.CommandText = "INSERT INTO BodyScanRingCustomNames (ScanId, RingNum, Name) VALUES (@ScanId, @RingNum, @Name)";
                cmdRingName.CommandType = CommandType.Text;

                paramRingNameScanId = cmdRingName.AddParameter("@ScanId", DbType.Int32);
                paramRingNameNum    = cmdRingName.AddParameter("@RingNum", DbType.Byte);
                paramRingName       = cmdRingName.AddParameter("@Name", DbType.String);

                cmdStar             = ctx.Database.Connection.CreateCommand();
                cmdStar.CommandText =
                    "INSERT INTO BodyScanStars (Id, AbsoluteMagnitude, StellarMass, Age_MY, StarTypeId, LuminosityId) VALUES " +
                    "(@Id, @AbsoluteMagnitude, @StellarMass, @Age_MY, @StarTypeId, @LuminosityId)";
                cmdStar.CommandType = CommandType.Text;

                paramStarId            = cmdStar.AddParameter("@Id", DbType.Int32);
                paramAbsoluteMagnitude = cmdStar.AddParameter("@AbsoluteMagnitude", DbType.Single);
                paramStellarMass       = cmdStar.AddParameter("@StellarMass", DbType.Single);
                paramAgeMY             = cmdStar.AddParameter("@Age_MY", DbType.Int16);
                paramStarTypeId        = cmdStar.AddParameter("@StarTypeId", DbType.Byte);
                paramLuminosityId      = cmdStar.AddParameter("@LuminosityId", DbType.Byte);

                cmdPlanet             = ctx.Database.Connection.CreateCommand();
                cmdPlanet.CommandText =
                    "INSERT INTO BodyScanPlanets (Id, PlanetClassId, CompositionMetal, CompositionRock, CompositionIce, HasComposition, MassEM, SurfaceGravity, VolcanismId, VolcanismMinor, VolcanismMajor, IsLandable) VALUES " +
                    "(@Id, @PlanetClassId, @CompositionMetal, @CompositionRock, @CompositionIce, @HasComposition, @MassEM, @SurfaceGravity, @VolcanismId, @VolcanismMinor, @VolcanismMajor, @IsLandable)";
                cmdPlanet.CommandType = CommandType.Text;

                paramPlanetId             = cmdPlanet.AddParameter("@Id", DbType.Int32);
                paramPlanetClass          = cmdPlanet.AddParameter("@PlanetClassId", DbType.Byte);
                paramCompositionMetal     = cmdPlanet.AddParameter("@CompositionMetal", DbType.Single);
                paramCompositionRock      = cmdPlanet.AddParameter("@CompositionRock", DbType.Single);
                paramCompositionIce       = cmdPlanet.AddParameter("@CompositionIce", DbType.Single);
                paramPlanetHasComposition = cmdPlanet.AddParameter("@HasComposition", DbType.Boolean);
                paramPlanetMassEM         = cmdPlanet.AddParameter("@MassEM", DbType.Single);
                paramSurfaceGravity       = cmdPlanet.AddParameter("@SurfaceGravity", DbType.Single);
                paramVolcanismId          = cmdPlanet.AddParameter("@VolcanismId", DbType.Byte);
                paramVolcanismMinor       = cmdPlanet.AddParameter("@VolcanismMinor", DbType.Boolean);
                paramVolcanismMajor       = cmdPlanet.AddParameter("@VolcanismMajor", DbType.Boolean);
                paramIsLandable           = cmdPlanet.AddParameter("@IsLandable", DbType.Boolean);

                cmdMats             = ctx.Database.Connection.CreateCommand();
                cmdMats.CommandText =
                    "INSERT INTO BodyScanMaterials (Id, MaterialCarbon, MaterialIron, MaterialNickel, MaterialPhosphorus, MaterialSulphur, Material1Id, Material1Amt, Material2Id, Material2Amt, Material3Id, Material3Amt, Material4Id, Material4Amt, Material5Id, Material5Amt, Material6Id, Material6Amt) VALUES " +
                    "(@Id, @MaterialCarbon, @MaterialIron, @MaterialNickel, @MaterialPhosphorus, @MaterialSulphur, @Material1Id, @Material1Amt, @Material2Id, @Material2Amt, @Material3Id, @Material3Amt, @Material4Id, @Material4Amt, @Material5Id, @Material5Amt, @Material6Id, @Material6Amt)";
                cmdMats.CommandType = CommandType.Text;

                paramMatsId         = cmdMats.AddParameter("@Id", DbType.Int32);
                paramMatsCarbon     = cmdMats.AddParameter("@MaterialCarbon", DbType.Single);
                paramMatsIron       = cmdMats.AddParameter("@MaterialIron", DbType.Single);
                paramMatsNickel     = cmdMats.AddParameter("@MaterialNickel", DbType.Single);
                paramMatsPhosphorus = cmdMats.AddParameter("@MaterialPhosphorus", DbType.Single);
                paramMatsSulphur    = cmdMats.AddParameter("@MaterialSulphur", DbType.Single);
                paramMat1Id         = cmdMats.AddParameter("@Material1Id", DbType.Byte);
                paramMat1Amt        = cmdMats.AddParameter("@Material1Amt", DbType.Single);
                paramMat2Id         = cmdMats.AddParameter("@Material2Id", DbType.Byte);
                paramMat2Amt        = cmdMats.AddParameter("@Material2Amt", DbType.Single);
                paramMat3Id         = cmdMats.AddParameter("@Material3Id", DbType.Byte);
                paramMat3Amt        = cmdMats.AddParameter("@Material3Amt", DbType.Single);
                paramMat4Id         = cmdMats.AddParameter("@Material4Id", DbType.Byte);
                paramMat4Amt        = cmdMats.AddParameter("@Material4Amt", DbType.Single);
                paramMat5Id         = cmdMats.AddParameter("@Material5Id", DbType.Byte);
                paramMat5Amt        = cmdMats.AddParameter("@Material5Amt", DbType.Single);
                paramMat6Id         = cmdMats.AddParameter("@Material6Id", DbType.Byte);
                paramMat6Amt        = cmdMats.AddParameter("@Material6Amt", DbType.Single);

                cmdAtmos             = ctx.Database.Connection.CreateCommand();
                cmdAtmos.CommandText =
                    "INSERT INTO BodyScanAtmospheres (Id, SurfacePressure, AtmosphereComponent1Id, AtmosphereComponent1Amt, AtmosphereComponent2Id, AtmosphereComponent2Amt, AtmosphereComponent3Id, AtmosphereComponent3Amt, AtmosphereId, AtmosphereTypeId, AtmosphereHot, AtmosphereThin, AtmosphereThick) VALUES " +
                    "(@Id, @SurfacePressure, @AtmosphereComponent1Id, @AtmosphereComponent1Amt, @AtmosphereComponent2Id, @AtmosphereComponent2Amt, @AtmosphereComponent3Id, @AtmosphereComponent3Amt, @AtmosphereId, @AtmosphereTypeId, @AtmosphereHot, @AtmosphereThin, @AtmosphereThick)";
                cmdAtmos.CommandType = CommandType.Text;

                paramAtmosScanId     = cmdAtmos.AddParameter("@Id", DbType.Int32);
                paramSurfacePressure = cmdAtmos.AddParameter("@SurfacePressure", DbType.Single);
                paramAtmosComp1Id    = cmdAtmos.AddParameter("@AtmosphereComponent1Id", DbType.Byte);
                paramAtmosComp1Amt   = cmdAtmos.AddParameter("@AtmosphereComponent1Amt", DbType.Single);
                paramAtmosComp2Id    = cmdAtmos.AddParameter("@AtmosphereComponent2Id", DbType.Byte);
                paramAtmosComp2Amt   = cmdAtmos.AddParameter("@AtmosphereComponent2Amt", DbType.Single);
                paramAtmosComp3Id    = cmdAtmos.AddParameter("@AtmosphereComponent3Id", DbType.Byte);
                paramAtmosComp3Amt   = cmdAtmos.AddParameter("@AtmosphereComponent3Amt", DbType.Single);
                paramAtmosNameId     = cmdAtmos.AddParameter("@AtmosphereId", DbType.Byte);
                paramAtmosTypeId     = cmdAtmos.AddParameter("@AtmosphereTypeId", DbType.Byte);
                paramAtmosHot        = cmdAtmos.AddParameter("@AtmosphereHot", DbType.Boolean);
                paramAtmosThin       = cmdAtmos.AddParameter("@AtmosphereThin", DbType.Boolean);
                paramAtmosThick      = cmdAtmos.AddParameter("@AtmosphereThick", DbType.Boolean);
            }
            catch
            {
                Dispose();
                throw;
            }
        }