/// <summary> /// Load Slab Style /// </summary> /// <param name="factory"></param> /// <param name="project"></param> /// <returns></returns> private IEnumerable<RecSectionStyleStd> GetSlabStyles( string factory, string project ) { // Load Slab Style var slabStyleSvc = new ProjectManager(); var slabStyles = slabStyleSvc.LoadSlabStyleStd( factory, project ); var styles = new List<RecSectionStyleStd>(); foreach( var ss in slabStyles ) { var rec = new RecSectionStyleStd { Factory = ss.Factory, Project = ss.Project, ElementType = ss.ElementType, Name = ss.Name, DirectionArrowJustify = ss.DirectionArrowJustify, SectionType = "", Description = ss.Description, StrandSpacing = ss.StrandSpacing, StrandEdgeDistance = ss.StrandEdgeDistance, Strandpatterns = new List<Strandpattern>(), }; //int numOfStrands = 0 //if( rec //rec.Strandpatterns.Add( new Strandpattern( "", rec.NumOfStrands ) ); styles.Add( rec ); } return styles; }
/// <summary> /// Load Wall Style /// </summary> /// <param name="factory"></param> /// <param name="project"></param> /// <returns></returns> private IEnumerable<RecSectionStyleStd> GetWallStyles( string factory, string project ) { // Load Wall Style var wallStyleSvc = new ProjectManager(); var wallStyles = wallStyleSvc.LoadWallStyleStd( factory, project ); var styles = new List<RecSectionStyleStd>(); foreach( var ss in wallStyles ) { var rec = new RecSectionStyleStd { Factory = ss.Factory, Project = ss.Project, ElementType = ss.ElementType, Name = ss.Name, SectionType = "", Description = ss.Description, }; styles.Add( rec ); } return styles; }
/// <summary> /// Update the specified record in the database. /// </summary> /// <param name="record">The record to update.</param> /// <returns></returns> public int UpdateSectionStyleStd( RecSectionStyleStd record ) { var update = new ImpactUpdate( ImpSectionStyleStd.Instance ) { Columns = { { 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 }, }, Where = { { ImpSectionStyleStd.Factory.Equal( record.Factory ) }, { ImpSectionStyleStd.Project.Equal( record.Project ) }, { ImpSectionStyleStd.ElementType.Equal( record.ElementType ) }, { ImpSectionStyleStd.Name.Equal( record.Name ) }, }, }; string statement = update.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Delete the specified record from the database. /// </summary> /// <param name="record">The record to delete from the database.</param> /// <returns>The number of affected records.</returns> public int DeleteSectionStyleStd( RecSectionStyleStd record ) { var delete = new ImpactDelete( ImpSectionStyleStd.Instance ) { Where = { { ImpSectionStyleStd.Factory.Equal( record.Factory )}, { ImpSectionStyleStd.Project.Equal( record.Project )}, { ImpSectionStyleStd.ElementType.Equal( record.ElementType )}, { ImpSectionStyleStd.Name.Equal( record.Name )}, } }; string statement = delete.ToString(); int result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.ExecuteNonQuery( statement ); } return result; }
/// <summary> /// Parses one row in <see cref="System.Data.Common.DbDataReader"/> into /// a new instance of <see cref="Paths.Common.Records.RecSectionStyleStd"/>. /// </summary> /// <param name="dataReader">The data reader.</param> /// <returns>A new instance of <see cref="Paths.Common.Records.RecSectionStyleStd"/>.</returns> public static RecSectionStyleStd ParseSectionStyleStd( DbDataReader dataReader ) { var record = new RecSectionStyleStd(); record.Factory = DataConverter.Cast<string>( dataReader[0] ); record.Project = DataConverter.Cast<string>( dataReader[1] ); record.ElementType = DataConverter.Cast<string>( dataReader[2] ); record.Name = DataConverter.Cast<string>( dataReader[3] ); record.SectionType = DataConverter.Cast<string>( dataReader[4] ); record.Description = DataConverter.Cast<string>( dataReader[5] ); record.Strandptn = DataConverter.Cast<string>( dataReader[6] ); record.NumOfStrands = DataConverter.Cast<int>( dataReader[7] ); //record.Width = DataConverter.Cast<double>(dataReader[6]); //record.WidthTolerance = DataConverter.Cast<double>(dataReader[7]); //record.DiffBottomTop = DataConverter.Cast<double>(dataReader[8]); //record.Height = DataConverter.Cast<double>(dataReader[9]); //record.Endcap = DataConverter.Cast<string>(dataReader[10]); //record.Strandptn = DataConverter.Cast<string>(dataReader[11]); //record.RcTemplate = DataConverter.Cast<string>(dataReader[12]); //record.Material = DataConverter.Cast<string>(dataReader[13]); //record.ProductionLine = DataConverter.Cast<string>(dataReader[14]); //record.CutType = DataConverter.Cast<int>(dataReader[15]); //record.UseCutZone = DataConverter.Cast<int>(dataReader[16]); //record.LiftMethod = DataConverter.Cast<int>(dataReader[17]); //record.LiftRotation1 = DataConverter.Cast<double>(dataReader[18]); //record.LiftRotation2 = DataConverter.Cast<double>(dataReader[19]); //record.LiftPlacingLs = DataConverter.Cast<int>(dataReader[20]); //record.LiftParameterLs = DataConverter.Cast<double>(dataReader[21]); //record.LiftPlacingSs = DataConverter.Cast<int>(dataReader[22]); //record.LiftParameterSs = DataConverter.Cast<double>(dataReader[23]); //record.LiftCores = DataConverter.Cast<string>(dataReader[24]); //record.LiftCoreLength = DataConverter.Cast<double>(dataReader[25]); //record.LiftCoreDisplayMode = DataConverter.Cast<int>(dataReader[26]); //record.LiftDistanceMax = DataConverter.Cast<double>(dataReader[27]); //record.LiftDistanceMin = DataConverter.Cast<double>(dataReader[28]); //record.LiftSpacing = DataConverter.Cast<double>(dataReader[29]); //record.LiftType = DataConverter.Cast<string>(dataReader[30]); //record.SectionViewDimStrandGrp = DataConverter.Cast<int>(dataReader[31]); //record.SectionViewTxtStrandGrp = DataConverter.Cast<int>(dataReader[32]); //record.SectionViewNbrCores = DataConverter.Cast<int>(dataReader[33]); //record.SectionViewScale = DataConverter.Cast<double>(dataReader[34]); //record.UseSectionViewSymbol = DataConverter.Cast<int>(dataReader[35]); //record.SectionViewFilename = DataConverter.Cast<string>(dataReader[36]); //record.ChamferDistance = DataConverter.Cast<double>(dataReader[37]); //record.ChamferText = DataConverter.Cast<string>(dataReader[38]); //record.ChamferVisibility = DataConverter.Cast<int>(dataReader[39]); //record.RcCoverCut1 = DataConverter.Cast<double>(dataReader[40]); //record.RcCoverCut2 = DataConverter.Cast<double>(dataReader[41]); //record.ElementGrp = DataConverter.Cast<string>(dataReader[42]); //record.ProductPrefix = DataConverter.Cast<string>(dataReader[43]); //record.Product = DataConverter.Cast<string>(dataReader[44]); //record.ElementMarkPrefix = DataConverter.Cast<string>(dataReader[45]); //record.DrawingNamePrefix = DataConverter.Cast<string>(dataReader[46]); //record.DrawingType = DataConverter.Cast<string>(dataReader[47]); //record.DrawingTemplate = DataConverter.Cast<string>(dataReader[48]); //record.CreatedBy = DataConverter.Cast<string>(dataReader[49]); //record.CreatedDate = DataConverter.Cast<System.DateTime?>(dataReader[50]); //record.ChangedBy = DataConverter.Cast<string>(dataReader[51]); //record.ChangedDate = DataConverter.Cast<System.DateTime?>(dataReader[52]); //record.LiftHolePosition = DataConverter.Cast<double>(dataReader[53]); return record; }
/// <summary> /// Load all records of the same factory and project as the supplied record. /// </summary> /// <param name="record">A record with factory and project set.</param> /// <returns>A list of all mathcing records.</returns> public List<RecSectionStyleStd> LoadSqlServer( RecSectionStyleStd record ) { if( record == null || record.Factory == null ) { return null; } string company = record.Factory.Substring( 0, 2 ) + "00"; //Is this really OK ??!! WhereGroup wgElementType = WhereGroup.Or( ImpSectionStyleStd.ElementType.Equal( "HD/F" ), ImpSectionStyleStd.ElementType.Equal( "D/F" )); // Prepare Factory, Project statement ImpactQuery projectQuery = new ImpactQuery() { Select = { ImpSectionStyleStd.Factory, ImpSectionStyleStd.Project, ImpSectionStyleStd.ElementType, ImpSectionStyleStd.Name, ImpSectionStyleStd.SectionType, ImpSectionStyleStd.Description, }, From = { ImpSectionStyleStd.As( "T1" ) }, Where = { ImpSectionStyleStd.Factory.Equal( record.Factory ), ImpSectionStyleStd.Project.Equal( record.Project ), wgElementType }, }; string projectStatement = projectQuery.ToString(); // Prepare Factory, Factory statement ImpactQuery factoryQuery = new ImpactQuery() { Select = { ImpSectionStyleStd.Factory, ImpSectionStyleStd.Project, ImpSectionStyleStd.ElementType, ImpSectionStyleStd.Name, ImpSectionStyleStd.SectionType, ImpSectionStyleStd.Description, }, From = { ImpSectionStyleStd.As( "T1" ) }, Where = { ImpSectionStyleStd.Factory.Equal( record.Factory ), ImpSectionStyleStd.Project.Equal( record.Factory ), wgElementType }, }; string factoryStatement = factoryQuery.ToString(); ImpactQuery projectSubquery = new ImpactQuery { Select = { ImpSectionStyleStd.Name }, From = { ImpSectionStyleStd.As( "T1" ) }, Where = { ImpSectionStyleStd.Factory.Equal( record.Factory ), ImpSectionStyleStd.Project.Equal( record.Project ), wgElementType }, }; factoryStatement += " AND T1.Name Not In (" + projectSubquery.ToString() + ")"; // Prepare Company, Company statement ImpactQuery companyQuery = new ImpactQuery() { Select = { ImpSectionStyleStd.Factory, ImpSectionStyleStd.Project, ImpSectionStyleStd.ElementType, ImpSectionStyleStd.Name, ImpSectionStyleStd.SectionType, ImpSectionStyleStd.Description, }, From = { ImpSectionStyleStd.As( "T1" ) }, Where = { ImpSectionStyleStd.Factory.Equal( company ), ImpSectionStyleStd.Project.Equal( company ), wgElementType }, }; string companyStatement = companyQuery.ToString(); ImpactQuery factorySubquery = new ImpactQuery() { Select = { ImpSectionStyleStd.Name }, From = { ImpSectionStyleStd.As( "T1" ) }, Where = { ImpSectionStyleStd.Factory.Equal( record.Factory ), ImpSectionStyleStd.Project.Equal( record.Factory ), wgElementType }, }; companyStatement += " AND T1.Name Not In (" + projectSubquery.ToString() + ")" + " AND T1.Name Not In (" + factorySubquery.ToString() + ")"; string statement = projectStatement + " Union " + factoryStatement + " Union " + companyStatement + " Order By T1.ELEMENT_TYPE, T1.Name"; List<RecSectionStyleStd> result; using( ImpactDatabase database = new ImpactDatabase() ) { result = database.GetAll( statement, ParseSectionStyleStd ); } return result; }