/// <summary> /// The update erection sequence. /// </summary> /// <param name="factory"> /// The factory. /// </param> /// <param name="project"> /// The project. /// </param> /// <param name="erectionSequenceList"> /// The erection sequence list. /// </param> /// <returns> /// The System.Boolean. /// </returns> public bool UpdateErectionSequence( string factory, string project, List<KeyValuePair<int, int>> erectionSequenceList ) { project = project.PadLeft( 12 ); List<string> statementList = new List<string>( erectionSequenceList.Count ); using( var database = new ImpactDatabase() ) { var allIdArray = erectionSequenceList.Select( x => (object)x.Key ).ToArray(); ImpactQuery query = new ImpactQuery { Select = { ImpModelPlanning.ElementId }, From = { ImpModelPlanning.As( "T1" ) }, Where = { ImpModelPlanning.Factory.Equal( factory ), ImpModelPlanning.Project.Equal( project ), ImpModelPlanning.ElementId.In( allIdArray ), }, }; string statement = query.ToString(); var existingPlanningList = database.GetAll( statement, column => column[0].Cast<int>() ); var groupedByInsertUpdate = erectionSequenceList.GroupBy( x => existingPlanningList.Remove( x.Key ) ).ToList(); var updateList = groupedByInsertUpdate.Find( x => x.Key ); var insertList = groupedByInsertUpdate.Find( x => !x.Key ); if( null != updateList ) { foreach( var item in updateList ) { var update = new ImpactUpdate( ImpModelPlanning.Instance ) { Columns = { { ImpModelPlanning.ErectionSequenceNo, item.Value } }, Where = { ImpModelPlanning.Factory.Equal( factory ), ImpModelPlanning.Project.Equal( project ), ImpModelPlanning.ElementId.Equal( item.Key ), } }; statementList.Add( update.ToString() ); } } if( null != insertList ) { foreach( var item in insertList ) { var insert = new ImpactInsert( ImpModelPlanning.Instance ) { Columns = { { ImpModelPlanning.Factory, factory }, { ImpModelPlanning.Project, project }, { ImpModelPlanning.ElementId, item.Key }, { ImpModelPlanning.ErectionSequenceNo, item.Value }, }, }; statementList.Add( insert.ToString() ); } } int result = database.ExecuteNonQuery( statementList.ToArray() ); return result > 0; } }
/// <summary> /// Insert the specified record into the database. /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public int InsertProductionFormStrandStd( RecProductionFormStrandStd record ) { var insert = new ImpactInsert( ImpProductionFormStrandStd.Instance ) { Columns = { { ImpProductionFormStrandStd.Factory, record.Factory }, { ImpProductionFormStrandStd.Project, record.Factory }, { ImpProductionFormStrandStd.Name, record.Name }, //Form name ?? { ImpProductionFormStrandStd.StrandPos, record.StrandPos }, { ImpProductionFormStrandStd.StrandX, record.StrandX }, { ImpProductionFormStrandStd.StrandY, record.StrandY }, { ImpProductionFormStrandStd.StrandQuality, record.StrandQuality }, { ImpProductionFormStrandStd.StrandDimension, record.StrandDimension }, { ImpProductionFormStrandStd.StrandPrestressing, record.StrandPrestressing }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Insert the specified record into the database. /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public int InsertSectionStyleStd( RecSectionStyleStd record ) { var insert = new ImpactInsert( ImpSectionStyleStd.Instance ) { Columns = { { ImpSectionStyleStd.Factory, record.Factory }, { ImpSectionStyleStd.Project, record.Project }, { ImpSectionStyleStd.ElementType, record.ElementType }, { ImpSectionStyleStd.Name, record.Name }, { ImpSectionStyleStd.SectionType, record.SectionType }, { ImpSectionStyleStd.Description, record.Description }, { ImpSectionStyleStd.Width, record.Width }, { ImpSectionStyleStd.WidthTolerance, record.WidthTolerance }, { ImpSectionStyleStd.DiffBottomTop, record.DiffBottomTop }, { ImpSectionStyleStd.Height, record.Height }, { ImpSectionStyleStd.Endcap, record.Endcap }, { ImpSectionStyleStd.Strandptn, record.Strandptn }, { ImpSectionStyleStd.RcTemplate, record.RcTemplate }, { ImpSectionStyleStd.Material, record.Material }, { ImpSectionStyleStd.ProductionLine, record.ProductionLine }, { ImpSectionStyleStd.CutType, record.CutType }, { ImpSectionStyleStd.UseCutZone, record.UseCutZone }, { ImpSectionStyleStd.LiftMethod, record.LiftMethod }, { ImpSectionStyleStd.LiftRotation1, record.LiftRotation1 }, { ImpSectionStyleStd.LiftRotation2, record.LiftRotation2 }, { ImpSectionStyleStd.LiftPlacingLs, record.LiftPlacingLs }, { ImpSectionStyleStd.LiftParameterLs, record.LiftParameterLs }, { ImpSectionStyleStd.LiftPlacingSs, record.LiftPlacingSs }, { ImpSectionStyleStd.LiftParameterSs, record.LiftParameterSs }, { ImpSectionStyleStd.LiftCores, record.LiftCores }, { ImpSectionStyleStd.LiftCoreLength, record.LiftCoreLength }, { ImpSectionStyleStd.LiftCoreDisplayMode, record.LiftCoreDisplayMode }, { ImpSectionStyleStd.LiftDistanceMax, record.LiftDistanceMax }, { ImpSectionStyleStd.LiftDistanceMin, record.LiftDistanceMin }, { ImpSectionStyleStd.LiftSpacing, record.LiftSpacing }, { ImpSectionStyleStd.LiftType, record.LiftType }, { ImpSectionStyleStd.SectionViewDimStrandGrp, record.SectionViewDimStrandGrp }, { ImpSectionStyleStd.SectionViewTxtStrandGrp, record.SectionViewTxtStrandGrp }, { ImpSectionStyleStd.SectionViewNbrCores, record.SectionViewNbrCores }, { ImpSectionStyleStd.SectionViewScale, record.SectionViewScale }, { ImpSectionStyleStd.UseSectionViewSymbol, record.UseSectionViewSymbol }, { ImpSectionStyleStd.SectionViewFilename, record.SectionViewFilename }, { ImpSectionStyleStd.ChamferDistance, record.ChamferDistance }, { ImpSectionStyleStd.ChamferText, record.ChamferText }, { ImpSectionStyleStd.ChamferVisibility, record.ChamferVisibility }, { ImpSectionStyleStd.RcCoverCut1, record.RcCoverCut1 }, { ImpSectionStyleStd.RcCoverCut2, record.RcCoverCut2 }, { ImpSectionStyleStd.ElementGrp, record.ElementGrp }, { ImpSectionStyleStd.ProductPrefix, record.ProductPrefix }, { ImpSectionStyleStd.Product, record.Product }, { ImpSectionStyleStd.ElementMarkPrefix, record.ElementMarkPrefix }, { ImpSectionStyleStd.DrawingNamePrefix, record.DrawingNamePrefix }, { ImpSectionStyleStd.DrawingType, record.DrawingType }, { ImpSectionStyleStd.DrawingTemplate, record.DrawingTemplate }, { ImpSectionStyleStd.CreatedBy, record.CreatedBy }, { ImpSectionStyleStd.CreatedDate, record.CreatedDate }, { ImpSectionStyleStd.ChangedBy, record.ChangedBy }, { ImpSectionStyleStd.ChangedDate, record.ChangedDate }, { ImpSectionStyleStd.LiftHolePosition, record.LiftHolePosition }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Insert of Transport Vehicle Standard items /// </summary> /// <param name="vehicle"></param> /// <returns></returns> public int InsertTransportVehicleStd( RecTransportVehicleStd record ) { if( record == null ) { throw new ArgumentNullException( "TransportVehicleStd" ); } var insert = new ImpactInsert( ImpTransportVehicleStd.Instance ) { Columns = { { ImpTransportVehicleStd.Factory, record.Factory }, { ImpTransportVehicleStd.Project, record.Factory }, //Std use, Factory, Factory { ImpTransportVehicleStd.Name, record.Name }, { ImpTransportVehicleStd.Division, record.Division }, { ImpTransportVehicleStd.Description, record.Description }, { ImpTransportVehicleStd.VehicleType, record.VehicleType }, { ImpTransportVehicleStd.TransportType, record.TransportType }, { ImpTransportVehicleStd.Length, record.Length }, { ImpTransportVehicleStd.Width, record.Width }, { ImpTransportVehicleStd.Height, record.Height }, { ImpTransportVehicleStd.Mass, record.Mass }, { ImpTransportVehicleStd.MaxLength, record.MaxLength }, { ImpTransportVehicleStd.MaxWidth, record.MaxWidth }, { ImpTransportVehicleStd.MaxHeight, record.MaxHeight }, { ImpTransportVehicleStd.MaxMass, record.MaxMass }, { ImpTransportVehicleStd.CreatedBy, record.Created_By }, { ImpTransportVehicleStd.CreatedDate, record.Created_Date }, //{ ImpTransportVehicleStd.ChangedBy, record.Created_By }, //{ ImpTransportVehicleStd.ChangedDate, record.Created_Date }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
private int InsertProductionFormStrand ( RecProductionFormStrandStd record ) { var insert = new ImpactInsert( ImpProductionFormStrand.Instance ) { Columns = { { ImpProductionFormStrand.Factory, record.Factory }, { ImpProductionFormStrand.Project, record.Factory },// (factory, factory) { ImpProductionFormStrand.Form, record.Name }, { ImpProductionFormStrand.Strand, record.StrandPos.ToString() }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Insert the specified record into the database. /// Actually we copy std stack info into a new db-record /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public int InsertTransportVehicleStack( RecTransportVehicleStackStd record ) { // !!! Sorry, NumberGenerator is not used for this Id !!! //NumberGenerator ng = new NumberGenerator(); //string company = NumberGenerator.GetCompany( record.Factory ); //record.StackId = ng.GetNextNumber( company, company, RecNumberGenerator.CMP_NG_STACK_ID ); //Now let's use the slow, unsecure and bad unique id's using max, what a mess :( record.StackId = GetMaxStacktId( record ) + 1; var insert = new ImpactInsert( ImpTransportStack.Instance ) { Columns = { { ImpTransportStack.Factory, record.Factory }, { ImpTransportStack.Project, record.Project }, { ImpTransportStack.TransportId, record.TransportId }, { ImpTransportStack.VehicleId, record.VehicleId }, { ImpTransportStack.StackId, record.StackId }, { ImpTransportStack.Rack, record.Rack }, { ImpTransportStack.StackX, record.StackX }, { ImpTransportStack.StackY, record.StackY }, { ImpTransportStack.StackZ, record.StackZ }, { ImpTransportStack.StackRotation, record.StackRotation }, { ImpTransportStack.Description, record.Description }, { ImpTransportStack.StackType, record.StackType }, { ImpTransportStack.StackPosition, record.StackPosition }, { ImpTransportStack.MaxLength, record.MaxLength }, { ImpTransportStack.MaxWidth, record.MaxWidth }, { ImpTransportStack.MaxHeight, record.MaxHeight }, { ImpTransportStack.MaxMass, record.MaxMass }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return record.StackId; }
/// <summary> /// Insert the specified record into the database. /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public int InsertProductionCastStrand(RecProductionCastStrand record, RecProductionFormStd form, BedFilter filter) { if (null == record) { return -1; } int castId = record.CastId; if (castId <= 0) { if (null == form || null == filter) { return -1; } var cast = new RecProductionCast { Factory = record.Factory, Project = record.Project, CastType = form.FormType, Description = "", Shift = filter.Shift, StartDate = filter.StartDateFrom, EndDate = filter.StartDateFrom, Form = form.Name, Tolerance = form.Tolerance, ElementType = form.ElementType, Style = form.Style, Strandptn = form.Strandptn, CastStatus = 0, CastDivision = "" }; var svc = new ProjectManager(); var newCast = svc.InsertProductionCast(cast); castId = newCast.CastId; } var insert = new ImpactInsert( ImpProductionCastStrand.Instance ) { Columns = { { ImpProductionCastStrand.Factory, record.Factory }, { ImpProductionCastStrand.Project, record.Factory },// Factory, Factory for productionCast & ProductionCastStrand { ImpProductionCastStrand.CastId, castId }, { ImpProductionCastStrand.StrandPos, record.StrandPos }, { ImpProductionCastStrand.StrandX, record.StrandX }, { ImpProductionCastStrand.StrandY, record.StrandY }, { ImpProductionCastStrand.StrandQuality, record.StrandQuality }, { ImpProductionCastStrand.StrandDimension, record.StrandDimension }, { ImpProductionCastStrand.StrandPrestressing, record.StrandPrestressing }, } }; string statement = insert.ToString(); int result; using( var database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Insert the specified record into the database. /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public int InsertTransportStack( RecTransportStack record ) { var insert = new ImpactInsert( ImpTransportStack.Instance ) { Columns = { { ImpTransportStack.Factory, record.Factory }, { ImpTransportStack.Project, record.Project }, { ImpTransportStack.TransportId, record.TransportId }, { ImpTransportStack.VehicleId, record.VehicleId }, { ImpTransportStack.StackId, record.StackId }, { ImpTransportStack.Rack, record.Rack }, { ImpTransportStack.StackX, record.StackX }, { ImpTransportStack.StackY, record.StackY }, { ImpTransportStack.StackZ, record.StackZ }, { ImpTransportStack.StackRotation, record.StackRotation }, { ImpTransportStack.Description, record.Description }, { ImpTransportStack.StackType, record.StackType }, { ImpTransportStack.StackPosition, record.StackPosition }, { ImpTransportStack.MaxLength, record.MaxLength }, { ImpTransportStack.MaxWidth, record.MaxWidth }, { ImpTransportStack.MaxHeight, record.MaxHeight }, { ImpTransportStack.MaxMass, record.MaxMass }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Insert the specified record into the database. /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public int InsertCalendar(RecCalendar record) { var insert = new ImpactInsert(ImpCalendar.Instance) { Columns = { { ImpCalendar.Factory, record.Factory }, { ImpCalendar.Project, record.Factory }, // Factory level! { ImpCalendar.Name, record.Name }, { ImpCalendar.Description, record.Description }, { ImpCalendar.CreatedBy, record.CreatedBy }, { ImpCalendar.CreatedDate, record.CreatedDate }, } }; string statement = insert.ToString(); int result; using (ImpactDatabase database = new ImpactDatabase()) { result = database.ExecuteNonQuery(statement); } return result; }
/// <summary> /// Creates all the needed number generator objects /// </summary> /// <param name="factory"></param> /// <param name="project"></param> /// <param name="variableName"></param> public void Verify( string factory, string project, string variableName ) { const string Description = "Initial value by system"; var selectQuery = new ImpactQuery() { From = { ImpNumGen.As( "T1" ) }, Where = { ImpNumGen.Factory.Equal( factory ), ImpNumGen.Project.Equal( project ), ImpNumGen.Variable.Equal( variableName ), } }; var insert = new ImpactInsert( ImpNumGen.Instance ) { Columns = { { ImpNumGen.Factory, factory }, { ImpNumGen.Project, project }, { ImpNumGen.Variable, variableName }, { ImpNumGen.Description, Description }, { ImpNumGen.UpperBound, RecNumberGenerator.UPPER_BOUND }, { ImpNumGen.LowerBound, RecNumberGenerator.LOWER_BOUND }, { ImpNumGen.NextNumber, RecNumberGenerator.LOWER_BOUND + 1 }, { ImpNumGen.ChangedDate, DateTime.Now }, } }; switch( ImpactDatabase.DataSource ) { case DataSource.SqlServer: case DataSource.SqlServerExpress: { using( ImpactDatabase database = new ImpactDatabase() ) { var statement = string.Format( "IF NOT EXISTS ( {0} ) {1}", selectQuery.ToString(), insert.ToString() ); database.ExecuteNonQuery( statement ); } break; } case DataSource.Ingres92: case DataSource.Ingres100: { List<RecNumberGenerator> result; using( var database = new ImpactDatabase() ) { result = database.GetAll( selectQuery.ToString(), ParseNumGen ).ToList(); } if( result.Count == 0 ) { using( var database = new ImpactDatabase() ) { database.ExecuteNonQuery( insert.ToString() ); } } break; } } }
/// <summary> /// Insert the specified record into the database. /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public int InsertSlabStyleStd( RecSlabStyleStd record ) { var insert = new ImpactInsert( ImpSlabStyleStd.Instance ) { Columns = { { ImpSlabStyleStd.Factory, record.Factory }, { ImpSlabStyleStd.Project, record.Project }, { ImpSlabStyleStd.ElementType, record.ElementType }, { ImpSlabStyleStd.Name, record.Name }, { ImpSlabStyleStd.Description, record.Description }, { ImpSlabStyleStd.Width, record.Width }, { ImpSlabStyleStd.Tolerance, record.Tolerance }, { ImpSlabStyleStd.ElementThickness, record.ElementThickness }, { ImpSlabStyleStd.Thickness, record.Thickness }, { ImpSlabStyleStd.Material, record.Material }, { ImpSlabStyleStd.EndStopCim, record.EndStopCim }, { ImpSlabStyleStd.DirectionArrowCim, record.DirectionArrowCim }, { ImpSlabStyleStd.DirectionArrowJustify, record.DirectionArrowJustify }, { ImpSlabStyleStd.ProductionLine, record.ProductionLine }, { ImpSlabStyleStd.RcPrimary, record.RcPrimary }, { ImpSlabStyleStd.RcSecondary, record.RcSecondary }, { ImpSlabStyleStd.RcBentEnds, record.RcBentEnds }, { ImpSlabStyleStd.CoverBottom, record.CoverBottom }, { ImpSlabStyleStd.PlacementLower, record.PlacementLower }, { ImpSlabStyleStd.RcMeshAddPrimary, record.RcMeshAddPrimary }, { ImpSlabStyleStd.RcMeshAddSecondary, record.RcMeshAddSecondary }, { ImpSlabStyleStd.PrimaryRcDistribution, record.PrimaryRcDistribution }, { ImpSlabStyleStd.PrimaryRcDimension, record.PrimaryRcDimension }, { ImpSlabStyleStd.PrimaryRcQuality, record.PrimaryRcQuality }, { ImpSlabStyleStd.PrimaryRcSpacing, record.PrimaryRcSpacing }, { ImpSlabStyleStd.PrimaryRcEdgeDistance, record.PrimaryRcEdgeDistance }, { ImpSlabStyleStd.PrimaryRcCoverCut, record.PrimaryRcCoverCut }, { ImpSlabStyleStd.PrimaryLength1Left, record.PrimaryLength1Left }, { ImpSlabStyleStd.PrimaryLength2Left, record.PrimaryLength2Left }, { ImpSlabStyleStd.PrimaryLength1Right, record.PrimaryLength1Right }, { ImpSlabStyleStd.PrimaryLength2Right, record.PrimaryLength2Right }, { ImpSlabStyleStd.PrimaryAngle1Left, record.PrimaryAngle1Left }, { ImpSlabStyleStd.PrimaryAngle2Left, record.PrimaryAngle2Left }, { ImpSlabStyleStd.PrimaryAngle1Right, record.PrimaryAngle1Right }, { ImpSlabStyleStd.PrimaryAngle2Right, record.PrimaryAngle2Right }, { ImpSlabStyleStd.SecondaryRcDistribution, record.SecondaryRcDistribution }, { ImpSlabStyleStd.SecondaryRcDimension, record.SecondaryRcDimension }, { ImpSlabStyleStd.SecondaryRcQuality, record.SecondaryRcQuality }, { ImpSlabStyleStd.SecondaryRcSpacing, record.SecondaryRcSpacing }, { ImpSlabStyleStd.SecondaryRcEdgeDistance, record.SecondaryRcEdgeDistance }, { ImpSlabStyleStd.SecondaryRcCoverCut, record.SecondaryRcCoverCut }, { ImpSlabStyleStd.LatticeGirderCim, record.LatticeGirderCim }, { ImpSlabStyleStd.LatticeGirderEdgeDistance, record.LatticeGirderEdgeDistance }, { ImpSlabStyleStd.LatticeGirderNumberOf, record.LatticeGirderNumberOf }, { ImpSlabStyleStd.LatticeGirderCover, record.LatticeGirderCover }, { ImpSlabStyleStd.LatticeGirderEdgeMax, record.LatticeGirderEdgeMax }, { ImpSlabStyleStd.LatticeGirderEdgeMin, record.LatticeGirderEdgeMin }, { ImpSlabStyleStd.LatticeGirderAddPrimary, record.LatticeGirderAddPrimary }, { ImpSlabStyleStd.StrandDistribution, record.StrandDistribution }, { ImpSlabStyleStd.StrandDimension, record.StrandDimension }, { ImpSlabStyleStd.StrandQuality, record.StrandQuality }, { ImpSlabStyleStd.StrandSpacing, record.StrandSpacing }, { ImpSlabStyleStd.StrandEdgeDistance, record.StrandEdgeDistance }, { ImpSlabStyleStd.StrandPrestressing, record.StrandPrestressing }, { ImpSlabStyleStd.StrandZ, record.StrandZ }, { ImpSlabStyleStd.LiftRotation, record.LiftRotation }, { ImpSlabStyleStd.LiftCim, record.LiftCim }, { ImpSlabStyleStd.LiftPlacingSs, record.LiftPlacingSs }, { ImpSlabStyleStd.LiftPlacingParameterSs, record.LiftPlacingParameterSs }, { ImpSlabStyleStd.LiftPlacingLs, record.LiftPlacingLs }, { ImpSlabStyleStd.LiftPlacingParameterLs, record.LiftPlacingParameterLs }, { ImpSlabStyleStd.LiftLargeElements, record.LiftLargeElements }, { ImpSlabStyleStd.LiftMassLimit, record.LiftMassLimit }, { ImpSlabStyleStd.LiftWidthLimit, record.LiftWidthLimit }, { ImpSlabStyleStd.LiftLengthLimit, record.LiftLengthLimit }, { ImpSlabStyleStd.LiftSpacing, record.LiftSpacing }, { ImpSlabStyleStd.LiftType, record.LiftType }, { ImpSlabStyleStd.ElementMarkPrefix, record.ElementMarkPrefix }, { ImpSlabStyleStd.ElementGrp, record.ElementGrp }, { ImpSlabStyleStd.ProductPrefix, record.ProductPrefix }, { ImpSlabStyleStd.Product, record.Product }, { ImpSlabStyleStd.DrawingNamePrefix, record.DrawingNamePrefix }, { ImpSlabStyleStd.DrawingType, record.DrawingType }, { ImpSlabStyleStd.DrawingTemplate, record.DrawingTemplate }, { ImpSlabStyleStd.EdgeStandardBetweenElements, record.EdgeStandardBetweenElements }, { ImpSlabStyleStd.EdgeStandardOther, record.EdgeStandardOther }, { ImpSlabStyleStd.CreatedBy, record.CreatedBy }, { ImpSlabStyleStd.CreatedDate, record.CreatedDate }, { ImpSlabStyleStd.ChangedBy, record.ChangedBy }, { ImpSlabStyleStd.ChangedDate, record.ChangedDate }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Insert the specified record into the database. /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public RecProductionCast InsertProductionCast( RecProductionCast record ) { // Get new sequence ProjectManager ng = new ProjectManager(); string company = ProjectManager.GetCompany( record.Factory ); int castId = ng.GetNextNumber( company, company, RecNumberGenerator.CMP_NG_CAST_ID ); var insert = new ImpactInsert( ImpProductionCast.Instance ) { Columns = { { ImpProductionCast.Factory, record.Factory }, { ImpProductionCast.Project, record.Factory }, // Factory, Factory for productionCast { ImpProductionCast.CastId, castId }, //Sequence { ImpProductionCast.CastType, record.CastType }, { ImpProductionCast.Description, record.Description }, { ImpProductionCast.Shift, record.Shift }, { ImpProductionCast.StartDate, record.StartDate }, { ImpProductionCast.EndDate, record.EndDate }, { ImpProductionCast.Form, record.Form }, { ImpProductionCast.Tolerance, record.Tolerance }, { ImpProductionCast.ElementType, record.ElementType }, { ImpProductionCast.Style, record.Style }, { ImpProductionCast.Strandptn, record.Strandptn }, { ImpProductionCast.CastStatus, record.CastStatus }, { ImpProductionCast.CastDivision, record.CastDivision }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } // Copy strands from template (form) if (!string.IsNullOrWhiteSpace(record.Form)) { record.CastId = castId; ProjectManager svc = new ProjectManager( ); svc.CopyStrandsFromTemplate( record ); } return record; }
/// <summary> /// Insert the specified record into the database. /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public int InsertWallStyleStd( RecWallStyleStd record ) { var insert = new ImpactInsert(ImpWallStyleStd.Instance) { Columns = { { ImpWallStyleStd.Factory, record.Factory }, { ImpWallStyleStd.Project, record.Project }, { ImpWallStyleStd.ElementType, record.ElementType }, { ImpWallStyleStd.Name, record.Name }, { ImpWallStyleStd.Description, record.Description }, { ImpWallStyleStd.CastType, record.CastType }, { ImpWallStyleStd.RcLayout, record.RcLayout }, { ImpWallStyleStd.RcTemplate, record.RcTemplate }, { ImpWallStyleStd.ProductionLine, record.ProductionLine }, { ImpWallStyleStd.LiftType, record.LiftType }, { ImpWallStyleStd.LiftDistanceMax, record.LiftDistanceMax }, { ImpWallStyleStd.LiftDistanceMin, record.LiftDistanceMin }, { ImpWallStyleStd.LiftSpacing, record.LiftSpacing }, { ImpWallStyleStd.BracingCim, record.BracingCim }, { ImpWallStyleStd.BracingSide, record.BracingSide }, { ImpWallStyleStd.BracingPlacingLs, record.BracingPlacingLs }, { ImpWallStyleStd.BracingPlacingParameterLs, record.BracingPlacingParameterLs }, { ImpWallStyleStd.BracingPlacingEl, record.BracingPlacingEl }, { ImpWallStyleStd.BracingPlacingParameterEl, record.BracingPlacingParameterEl }, { ImpWallStyleStd.ElementGrp, record.ElementGrp }, { ImpWallStyleStd.ProductPrefix, record.ProductPrefix }, { ImpWallStyleStd.Product, record.Product }, { ImpWallStyleStd.ElementMarkPrefix, record.ElementMarkPrefix }, { ImpWallStyleStd.DrawingNamePrefix, record.DrawingNamePrefix }, { ImpWallStyleStd.DrawingType, record.DrawingType }, { ImpWallStyleStd.DrawingTemplate, record.DrawingTemplate }, { ImpWallStyleStd.CreatedBy, record.CreatedBy }, { ImpWallStyleStd.CreatedDate, record.CreatedDate }, { ImpWallStyleStd.ChangedBy, record.ChangedBy }, { ImpWallStyleStd.ChangedDate, record.ChangedDate }, { ImpWallStyleStd.LiftOtherType, record.LiftOtherType }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Insert the specified record into the database. /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public int InsertProductionFormStd( RecProductionFormStd record ) { var insert = new ImpactInsert( ImpProductionFormStd.Instance ) { Columns = { { ImpProductionFormStd.Factory, record.Factory }, { ImpProductionFormStd.Project, record.Factory }, // Factory level ie(Factory, Factory)!!! { ImpProductionFormStd.Name, record.Name }, { ImpProductionFormStd.FormType, record.FormType }, { ImpProductionFormStd.Description, record.Description }, { ImpProductionFormStd.Location, record.Location }, { ImpProductionFormStd.NbrOfShift, record.NbrOfShift }, { ImpProductionFormStd.Length, record.Length }, { ImpProductionFormStd.Width, record.Width }, { ImpProductionFormStd.Height, record.Height }, { ImpProductionFormStd.Tolerance, record.Tolerance }, { ImpProductionFormStd.MaxLength, record.MaxLength }, { ImpProductionFormStd.MaxWidth, record.MaxWidth }, { ImpProductionFormStd.MaxHeight, record.MaxHeight }, { ImpProductionFormStd.MaxMass, record.MaxMass }, { ImpProductionFormStd.ElementType, record.ElementType }, { ImpProductionFormStd.Style, record.Style }, { ImpProductionFormStd.StrandType, record.StrandType }, { ImpProductionFormStd.Strandptn, record.Strandptn }, { ImpProductionFormStd.Division, record.Division }, { ImpProductionFormStd.CreatedBy, record.CreatedBy }, { ImpProductionFormStd.CreatedDate, record.CreatedDate }, { ImpProductionFormStd.ChangedBy, record.ChangedBy }, { ImpProductionFormStd.ChangedDate, record.ChangedDate }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// The update planning element data. /// </summary> /// <param name="factory"> /// The factory. /// </param> /// <param name="project"> /// The project. /// </param> /// <param name="planningElementList"> /// The planning element list. /// </param> /// <exception cref="InvalidOperationException"> /// Thrown when the database source is unknown. /// </exception> public void UpdatePlanningElementData( string factory, string project, List<PlanningElementDataUpdate> planningElementList ) { project = Util.CorrectProjectName( project ); switch( ImpactDatabase.DataSource ) { case DataSource.Ingres92: case DataSource.Ingres100: { // Create a query that return all the id's of those elements that aldready has planning data. ImpactQuery query = new ImpactQuery() { From = { ImpModelPlanning.As( "T1" ) }, Select = { ImpModelPlanning.ElementId }, Where = { ImpModelPlanning.Factory.Equal(factory), ImpModelPlanning.Project.Equal(project), ImpModelPlanning.ElementId.In<int>( planningElementList.Select( element => element.ElementId ) ) } }; using( var database = new ImpactDatabase() ) { var existingIds = database.GetAll( query.ToString(), reader => reader[0].Cast<int>() ); var statementList = new List<string>( planningElementList.Count ); foreach( var element in planningElementList ) { string producingFactory; if( 0 == string.Compare( Factory.External.Number, element.ProducingFactory, StringComparison.OrdinalIgnoreCase ) ) { producingFactory = ProjectBrowserLoader.ProducingFactoryExternalValue; } else { producingFactory = element.ProducingFactory; } if( existingIds.Contains( element.ElementId ) ) { // We have an update. var update = new ImpactUpdate( ImpModelPlanning.Instance ) { Where = { ImpModelPlanning.Factory.Equal( factory ), ImpModelPlanning.Project.Equal( project ), ImpModelPlanning.ElementId.Equal( element.ElementId ), }, Columns = { { ImpModelPlanning.ProductionFactory, producingFactory ?? string.Empty }, { ImpModelPlanning.DivisionProduction, element.Division ?? string.Empty }, { ImpModelPlanning.ProductionDate, element.ProductionDate }, { ImpModelPlanning.DeliveryDate, element.DeliveryDate }, { ImpModelPlanning.ErectionSequenceNo, element.ErectionSequenceNo }, { ImpModelPlanning.PlannedDrawingDate, element.PlannedDrawingDate }, { ImpModelPlanning.PlannedProductionDate, element.PlannedProductionDate }, { ImpModelPlanning.PlannedReadyForDeliveryDate, element.PlannedStorageDate }, { ImpModelPlanning.PlannedDeliveryDate, element.PlannedDeliveryDate }, { ImpModelPlanning.PlannedErectionDate, element.PlannedErectionDate }, { ImpModelPlanning.ElementIdStatus, element.Status }, } }; statementList.Add( update.ToString() ); } else { // We must insert a new row. var insert = new ImpactInsert( ImpModelPlanning.Instance ) { Columns = { { ImpModelPlanning.Factory, factory }, { ImpModelPlanning.Project, project }, { ImpModelPlanning.ElementId, element.ElementId }, { ImpModelPlanning.ProductionFactory, producingFactory ?? string.Empty }, { ImpModelPlanning.DivisionProduction, element.Division ?? string.Empty }, { ImpModelPlanning.ProductionDate, element.ProductionDate }, { ImpModelPlanning.DeliveryDate, element.DeliveryDate }, { ImpModelPlanning.ErectionSequenceNo, element.ErectionSequenceNo }, { ImpModelPlanning.PlannedDrawingDate, element.PlannedDrawingDate }, { ImpModelPlanning.PlannedProductionDate, element.PlannedProductionDate }, { ImpModelPlanning.PlannedReadyForDeliveryDate, element.PlannedStorageDate }, { ImpModelPlanning.PlannedDeliveryDate, element.PlannedDeliveryDate }, { ImpModelPlanning.PlannedErectionDate, element.PlannedErectionDate }, { ImpModelPlanning.ElementIdStatus, element.Status }, } }; statementList.Add( insert.ToString() ); } } database.ExecuteNonQuery( statementList.ToArray() ); } break; } case DataSource.SqlServer: case DataSource.SqlServerExpress: { List<string> statementList = new List<string>( planningElementList.Count ); foreach( var element in planningElementList ) { string producingFactory; if( 0 == string.Compare( Factory.External.Number, element.ProducingFactory, StringComparison.OrdinalIgnoreCase ) ) { producingFactory = ProjectBrowserLoader.ProducingFactoryExternalValue; } else { producingFactory = element.ProducingFactory; } ImpactInsertOrUpdate insertOrUpdate = new ImpactInsertOrUpdate( ImpModelPlanning.Instance ) { Keys = { { ImpModelPlanning.Factory, factory }, { ImpModelPlanning.Project, project }, { ImpModelPlanning.ElementId, element.ElementId }, }, Columns = { { ImpModelPlanning.ProductionFactory, producingFactory ?? string.Empty }, { ImpModelPlanning.DivisionProduction, element.Division ?? string.Empty }, { ImpModelPlanning.ProductionDate, element.ProductionDate }, { ImpModelPlanning.DeliveryDate, element.DeliveryDate }, { ImpModelPlanning.ErectionSequenceNo, element.ErectionSequenceNo }, { ImpModelPlanning.PlannedDrawingDate, element.PlannedDrawingDate }, { ImpModelPlanning.PlannedProductionDate, element.PlannedProductionDate }, { ImpModelPlanning.PlannedReadyForDeliveryDate, element.PlannedStorageDate }, { ImpModelPlanning.PlannedDeliveryDate, element.PlannedDeliveryDate }, { ImpModelPlanning.PlannedErectionDate, element.PlannedErectionDate }, { ImpModelPlanning.ElementIdStatus, element.Status }, } }; statementList.Add( insertOrUpdate.ToString() ); } using( var database = new ImpactDatabase() ) { database.ExecuteNonQuery( statementList.ToArray() ); } break; } default: { throw new InvalidOperationException( "Unknown database source." ); } } }
/// <summary> /// Creates a new record if the desired record is not yet created. /// </summary> /// <param name="rec">RecTransportPlanner</param> /// <param name="factory"> </param> /// <param name="project"> </param> /// <param name="elementId"> </param> public void Verify( string factory, string project, int elementId ) { if( string.IsNullOrEmpty(factory) || string.IsNullOrEmpty(project) || elementId <= 0 ) { return; } var selectQuery = new ImpactQuery() { From = { ImpModelPlanning.As( "T1" ) }, Where = { ImpModelPlanning.Factory.Equal( factory ), ImpModelPlanning.Project.Equal( project ), ImpModelPlanning.ElementId.Equal( elementId ), } }; var insert = new ImpactInsert( ImpModelPlanning.Instance ) { Columns = { { ImpModelPlanning.Factory, factory }, { ImpModelPlanning.Project, project }, { ImpModelPlanning.ElementId, elementId }, } }; switch( ImpactDatabase.DataSource ) { case DataSource.SqlServer: case DataSource.SqlServerExpress: { using( var database = new ImpactDatabase() ) { var statement = string.Format( "IF NOT EXISTS ( {0} ) {1}", selectQuery.ToString(), insert.ToString() ); database.ExecuteNonQuery( statement ); } break; } case DataSource.Ingres92: case DataSource.Ingres100: { List<RecTMElement> result; using( var database = new ImpactDatabase() ) { result = database.GetAll( selectQuery.ToString(), ParseModelPlanning ).ToList(); } if( result.Count == 0 ) { using( var database = new ImpactDatabase() ) { database.ExecuteNonQuery( insert.ToString() ); } } break; } } }
/// <summary> /// Insert of Transport items /// </summary> /// <param name="transport"></param> /// <returns></returns> public RecTransport InsertTransport( RecTransport record ) { if( record == null ) { throw new ArgumentNullException( "Transport" ); } RecTransport newTransport = new RecTransport( record ); string project = ""; if( record.IsTemplate == 1 ) { //Secure and easy solution for unique sequence id's!!! // Use negative value to distinguish templates from transports! ProjectManager ng = new ProjectManager(); newTransport.TransportId = -ng.GetNextNumber( record.Factory, record.Project, RecNumberGenerator.NG_TRANSPORT_ID ); // Templates are saved on factory level (factory, factory), 2012-04-23 project = record.Factory; } else { //Now let's use the slow, unsecure and bad unique id's using max, what a mess :( newTransport.TransportId = GetMaxTransportId( record ) + 1; project = record.Project; } var insert = new ImpactInsert( ImpTransport.Instance ) { Columns = { { ImpTransport.Factory, record.Factory }, { ImpTransport.Project, project },// Templates are saved on factory level (factory, factory), 2012-04-23 { ImpTransport.TransportId, newTransport.TransportId }, // The new Id! { ImpTransport.Description, record.Description }, { ImpTransport.LoadDate, record.LoadDate }, { ImpTransport.DeliveryDate, record.DeliveryDate }, { ImpTransport.IsTemplate, record.IsTemplate }, { ImpTransport.IsVisible, record.IsVisible }, { ImpTransport.TemplateId, record.TemplateId }, { ImpTransport.TimeInterval, record.TimeInterval }, { ImpTransport.TransportStatus, record.TransportStatus }, { ImpTransport.LoadLocation, record.LoadLocation }, { ImpTransport.LoadDivision, record.LoadDivision }, { ImpTransport.DeliveryDivision, record.DeliveryDivision }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return newTransport; }
/// <summary> /// Insert the specified record into the database. /// </summary> /// <param name="record">The record to insert into the database.</param> /// <returns>The number of affected records.</returns> public int InsertTransportVehicleStackStd( RecTransportVehicleStackStd record ) { ProjectManager ng = new ProjectManager(); string company = ProjectManager.GetCompany( record.Factory ); record.StackId = ng.GetNextNumber( company, company, RecNumberGenerator.CMP_NG_STACK_ID ); var insert = new ImpactInsert( ImpTransportVehicleStackStd.Instance ) { Columns = { { ImpTransportVehicleStackStd.Factory, record.Factory }, { ImpTransportVehicleStackStd.Project, record.Factory }, //Std use, Factory, Factory { ImpTransportVehicleStackStd.Name, record.Name }, { ImpTransportVehicleStackStd.StackId, record.StackId }, { ImpTransportVehicleStackStd.Rack, record.Rack }, { ImpTransportVehicleStackStd.StackPosition, record.StackPosition }, { ImpTransportVehicleStackStd.StackX, record.StackX }, { ImpTransportVehicleStackStd.StackY, record.StackY }, { ImpTransportVehicleStackStd.StackZ, record.StackZ }, { ImpTransportVehicleStackStd.StackRotation, record.StackRotation }, { ImpTransportVehicleStackStd.Description, record.Description }, { ImpTransportVehicleStackStd.StackType, record.StackType }, { ImpTransportVehicleStackStd.MaxLength, record.MaxLength }, { ImpTransportVehicleStackStd.MaxWidth, record.MaxWidth }, { ImpTransportVehicleStackStd.MaxHeight, record.MaxHeight }, { ImpTransportVehicleStackStd.MaxMass, record.MaxMass }, } }; string statement = insert.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }