/// <summary> /// Returns report standard data and layout info /// </summary> /// <param name="userId"> </param> /// <param name="record">RecReportStd</param> /// <param name="factory"> </param> /// <param name="project"> </param> /// <returns>ReportTemplateData</returns> public ReportTemplateData LoadReportLayout( string factory, string project, string userId, RecReportStd record ) { RecProject recProject = null; RecReportStd report = null; List<RecReportLayoutStd> layouts = null; var reports = LoadReport( record ); if( null != reports && reports.Count > 0 ) { report = reports[0]; layouts = LoadReportDetails( report ); var proj = new RecProject { Factory = factory, Project = project }; var projs = LoadProject( proj ); if( null != projs && projs.Count > 0 ) { recProject = projs[0]; } } var folders = LoadFolder( new RecFolder() { Factory = factory, Project = project } ); var recUser = LoadUser( userId ); return new ReportTemplateData( recUser, recProject, report, layouts, folders ); }
/// <summary> /// Parses one row in <see cref="System.Data.Common.DbDataReader"/> into /// a new instance of <see cref="RecProject"/>. /// </summary> /// <param name="dataReader"></param> /// <returns></returns> public static RecProject ParseProject( DbDataReader dataReader ) { var record = new RecProject { Factory = dataReader[0].Cast<string>(), Project = dataReader[1].Cast<string>(), ProjectType = dataReader[2].Cast<int>(), Status = dataReader[3].Cast<int>(), Name = dataReader[4].Cast<string>(), Description = dataReader[5].Cast<string>(), Text3 = dataReader[6].Cast<string>(), Text4 = dataReader[7].Cast<string>(), Text5 = dataReader[8].Cast<string>(), Text6 = dataReader[9].Cast<string>(), CheckedBy = dataReader[10].Cast<string>(), RegisterDate = dataReader[11].Cast<DateTime?>(), RevisionDate = dataReader[12].Cast<DateTime?>(), ErectionDate = dataReader[13].Cast<DateTime?>(), BuildingSiteName = dataReader[14].Cast<string>(), BuildingSiteStreet = dataReader[15].Cast<string>(), BuildingSiteZipcode = dataReader[16].Cast<string>(), BuildingSiteCity = dataReader[17].Cast<string>(), BuildingOwnerName = dataReader[18].Cast<string>(), BuildingOwnerStreet = dataReader[19].Cast<string>(), BuildingOwnerZipcode = dataReader[20].Cast<string>(), BuildingOwnerCity = dataReader[21].Cast<string>(), FolderPath = dataReader[22].Cast<string>(), CreatedBy = dataReader[23].Cast<string>(), ChangedBy = dataReader[24].Cast<string>() }; 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<RecProject> LoadProject( RecProject record ) { var query = new ImpactQuery() { Select = { ImpProject.Factory, ImpProject.Project, ImpProject.ProjectType, ImpProject.Status, ImpProject.Name, ImpProject.Description, ImpProject.Text3, ImpProject.Text4, ImpProject.Text5, ImpProject.Text6, ImpProject.CheckedBy, ImpProject.RegisterDate, ImpProject.RevisionDate, ImpProject.ErectionDate, ImpProject.BuildingSiteName, ImpProject.BuildingSiteStreet, ImpProject.BuildingSiteZipcode, ImpProject.BuildingSiteCity, ImpProject.BuildingOwnerName, ImpProject.BuildingOwnerStreet, ImpProject.BuildingOwnerZipcode, ImpProject.BuildingOwnerCity, ImpProject.FolderPath, ImpProject.CreatedBy, ImpProject.ChangedBy, }, From = { ImpProject.As( "T1" ) }, Where = { ImpProject.Factory.Equal( record.Factory ), ImpProject.Project.Equal( record.Project ) } }; var statement = query.ToString(); List<RecProject> result; using( var database = new ImpactDatabase() ) { result = database.GetAll( statement, ParseProject ); } return result; }