///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_L5BD_GBFRG_1005_Array Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5BD_GBFRG_1005 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_L5BD_GBFRG_1005_Array functionReturn = new FR_L5BD_GBFRG_1005_Array(); try { if (cleanupConnection == true) { Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString); Connection.Open(); } if (cleanupTransaction == true) { Transaction = Connection.BeginTransaction(); } functionReturn = Execute(Connection, Transaction, Parameter, securityTicket); #region Cleanup Connection/Transaction //Commit the transaction if (cleanupTransaction == true) { Transaction.Commit(); } //Close the connection if (cleanupConnection == true) { Connection.Close(); } #endregion } catch (Exception ex) { try { if (cleanupTransaction == true && Transaction != null) { Transaction.Rollback(); } } catch { } try { if (cleanupConnection == true && Connection != null) { Connection.Close(); } } catch { } throw ex; } return(functionReturn); }
///<summary> /// Opens the connection/transaction for the given connectionString, and closes them when complete ///<summary> public static FR_L5BD_GBFRG_1005_Array Invoke(string ConnectionString, P_L5BD_GBFRG_1005 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(null, null, ConnectionString, Parameter, securityTicket)); }
///<summary> /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured ///<summary> public static FR_L5BD_GBFRG_1005_Array Invoke(DbConnection Connection, DbTransaction Transaction, P_L5BD_GBFRG_1005 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(Connection, Transaction, null, Parameter, securityTicket)); }
protected static FR_L5BD_GBFRG_1005_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5BD_GBFRG_1005 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5BD_GBFRG_1005_Array(); //Put your code here List <L5BD_GBFRG_1005> returnList = new List <L5BD_GBFRG_1005>(); ORM_RES_DUD_Revision.Query rvQuery = new ORM_RES_DUD_Revision.Query(); rvQuery.IsDeleted = false; rvQuery.Tenant_RefID = securityTicket.TenantID; rvQuery.RevisionGroup_RefID = Parameter.RevisionGroupID; List <ORM_RES_DUD_Revision> revisions = ORM_RES_DUD_Revision.Query.Search(Connection, Transaction, rvQuery); foreach (var revision in revisions) { ORM_RES_BLD_Building bdQuery = new ORM_RES_BLD_Building(); L5BD_GBFRG_1005 item = new L5BD_GBFRG_1005(); ORM_RES_BLD_Building building = new ORM_RES_BLD_Building(); building.Load(Connection, Transaction, revision.RES_BLD_Building_RefID); ORM_RES_BLD_Apartment.Query apQuery = new ORM_RES_BLD_Apartment.Query(); apQuery.Tenant_RefID = securityTicket.TenantID; apQuery.IsDeleted = false; apQuery.Building_RefID = building.RES_BLD_BuildingID; List <ORM_RES_BLD_Apartment> apList = ORM_RES_BLD_Apartment.Query.Search(Connection, Transaction, apQuery); List <L5BD_GBFRG_1005_Apartment> apResult = new List <L5BD_GBFRG_1005_Apartment>(); foreach (var part in apList) { L5BD_GBFRG_1005_Apartment itemPart = new L5BD_GBFRG_1005_Apartment(); itemPart.ApartmentSize_Unit_RefID = part.ApartmentSize_Unit_RefID; itemPart.ApartmentSize_Value = part.ApartmentSize_Value; itemPart.IsAppartment_ForRent = part.IsDeleted; itemPart.RES_BLD_ApartmentID = part.RES_BLD_ApartmentID; itemPart.Appartment_FlooringType = part.TypeOfFlooring_RefID; itemPart.Appartment_HeatingType = part.TypeOfHeating_RefID; itemPart.Appartment_WallCoveringType = part.TypeOfWallCovering_RefID; ORM_RES_STR_Apartment strApartment = ORM_RES_STR_Apartment.Query.Search(Connection, Transaction, new ORM_RES_STR_Apartment.Query() { RES_BLD_Apartment_RefID = part.RES_BLD_ApartmentID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).FirstOrDefault(); if (strApartment != null) { itemPart.ApartmentsDocumentHeader_RefID = strApartment.DocumentHeader_RefID; Guid[] documentHeaders = ORM_RES_STR_Apartment_PropertyAssessment.Query.Search(Connection, Transaction, new ORM_RES_STR_Apartment_PropertyAssessment.Query() { STR_Apartment_RefID = strApartment.RES_STR_ApartmentID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Select(i => i.DocumentHeader_RefID).ToArray(); if (documentHeaders != null) { itemPart.ApartmentsPropertyDocumentHeaders = documentHeaders; } } apResult.Add(itemPart); } item.Apartments = apResult.ToArray(); ORM_RES_BLD_Attic.Query atQuery = new ORM_RES_BLD_Attic.Query(); atQuery.Tenant_RefID = securityTicket.TenantID; atQuery.IsDeleted = false; atQuery.Building_RefID = building.RES_BLD_BuildingID; List <ORM_RES_BLD_Attic> atList = ORM_RES_BLD_Attic.Query.Search(Connection, Transaction, atQuery); List <L5BD_GBFRG_1005_Attic> atResult = new List <L5BD_GBFRG_1005_Attic>(); foreach (var part in atList) { L5BD_GBFRG_1005_Attic itemPart = new L5BD_GBFRG_1005_Attic(); itemPart.RES_BLD_AtticID = part.RES_BLD_AtticID; ORM_RES_STR_Attic strAttic = ORM_RES_STR_Attic.Query.Search(Connection, Transaction, new ORM_RES_STR_Attic.Query() { RES_BLD_Attic_RefID = part.RES_BLD_AtticID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).FirstOrDefault(); if (strAttic != null) { itemPart.AtticsDocumentHeader_RefID = strAttic.DocumentHeader_RefID; Guid[] documentHeaders = ORM_RES_STR_Attic_PropertyAssessment.Query.Search(Connection, Transaction, new ORM_RES_STR_Attic_PropertyAssessment.Query() { STR_Attic_RefID = strAttic.RES_STR_AtticID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Select(i => i.DocumentHeader_RefID).ToArray(); if (documentHeaders != null) { itemPart.AtticsPropertyDocumentHeaders = documentHeaders; } } atResult.Add(itemPart); } item.Attics = atResult.ToArray(); ORM_RES_BLD_Basement.Query baQuery = new ORM_RES_BLD_Basement.Query(); baQuery.Tenant_RefID = securityTicket.TenantID; baQuery.IsDeleted = false; baQuery.Building_RefID = building.RES_BLD_BuildingID; List <ORM_RES_BLD_Basement> baList = ORM_RES_BLD_Basement.Query.Search(Connection, Transaction, baQuery); List <L5BD_GBFRG_1005_Basement> baResult = new List <L5BD_GBFRG_1005_Basement>(); foreach (var part in baList) { L5BD_GBFRG_1005_Basement itemPart = new L5BD_GBFRG_1005_Basement(); itemPart.Basement_FloorType = part.TypeOfFloor_RefID; itemPart.RES_BLD_BasementID = part.RES_BLD_BasementID; ORM_RES_STR_Basement strBasement = ORM_RES_STR_Basement.Query.Search(Connection, Transaction, new ORM_RES_STR_Basement.Query() { RES_BLD_Basement_RefID = part.RES_BLD_BasementID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).FirstOrDefault(); if (strBasement != null) { itemPart.BasementsDocumentHeader_RefID = strBasement.DocumentHeader_RefID; Guid[] documentHeaders = ORM_RES_STR_Basement_PropertyAssessment.Query.Search(Connection, Transaction, new ORM_RES_STR_Basement_PropertyAssessment.Query() { STR_Basement_RefID = strBasement.RES_STR_BasementID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Select(i => i.DocumentHeader_RefID).ToArray(); if (documentHeaders != null) { itemPart.BasementsPropertyDocumentHeaders = documentHeaders; } } baResult.Add(itemPart); } item.Basements = baResult.ToArray(); ORM_RES_BLD_Facade.Query faQuery = new ORM_RES_BLD_Facade.Query(); faQuery.Tenant_RefID = securityTicket.TenantID; faQuery.IsDeleted = false; faQuery.Building_RefID = building.RES_BLD_BuildingID; List <ORM_RES_BLD_Facade> faList = ORM_RES_BLD_Facade.Query.Search(Connection, Transaction, faQuery); List <L5BD_GBFRG_1005_Facade> faResult = new List <L5BD_GBFRG_1005_Facade>(); foreach (var part in faList) { L5BD_GBFRG_1005_Facade itemPart = new L5BD_GBFRG_1005_Facade(); itemPart.RES_BLD_FacadeID = part.RES_BLD_FacadeID; ORM_RES_STR_Facade strFacade = ORM_RES_STR_Facade.Query.Search(Connection, Transaction, new ORM_RES_STR_Facade.Query() { RES_BLD_Facade_RefID = part.RES_BLD_FacadeID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).FirstOrDefault(); if (strFacade != null) { itemPart.FacadesDocumentHeader_RefID = strFacade.DocumentHeader_RefID; Guid[] documentHeaders = ORM_RES_STR_Facade_PropertyAssessment.Query.Search(Connection, Transaction, new ORM_RES_STR_Facade_PropertyAssessment.Query() { STR_Facade_RefID = strFacade.RES_STR_FacadeID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Select(i => i.DocumentHeader_RefID).ToArray(); if (documentHeaders != null) { itemPart.FacadesPropertyDocumentHeaders = documentHeaders; } } faResult.Add(itemPart); } item.Facades = faResult.ToArray(); ORM_RES_BLD_HVACR.Query hvQuery = new ORM_RES_BLD_HVACR.Query(); hvQuery.Tenant_RefID = securityTicket.TenantID; hvQuery.IsDeleted = false; hvQuery.Building_RefID = building.RES_BLD_BuildingID; List <ORM_RES_BLD_HVACR> hvList = ORM_RES_BLD_HVACR.Query.Search(Connection, Transaction, hvQuery); List <L5BD_GBFRG_1005_HVACR> hvResult = new List <L5BD_GBFRG_1005_HVACR>(); foreach (var part in hvList) { L5BD_GBFRG_1005_HVACR itemPart = new L5BD_GBFRG_1005_HVACR(); itemPart.RES_BLD_HVACRID = part.RES_BLD_HVACRID; ORM_RES_STR_HVACR strHVACR = ORM_RES_STR_HVACR.Query.Search(Connection, Transaction, new ORM_RES_STR_HVACR.Query() { RES_BLD_HVACR_RefID = part.RES_BLD_HVACRID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).FirstOrDefault(); if (strHVACR != null) { itemPart.HVACRsDocumentHeader_RefID = strHVACR.DocumentHeader_RefID; Guid[] documentHeaders = ORM_RES_STR_HVACR_PropertyAssessment.Query.Search(Connection, Transaction, new ORM_RES_STR_HVACR_PropertyAssessment.Query() { STR_HVACR_RefID = strHVACR.RES_STR_HVACRID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Select(i => i.DocumentHeader_RefID).ToArray(); if (documentHeaders != null) { itemPart.HVACRsPropertyDocumentHeaders = documentHeaders; } } hvResult.Add(itemPart); } item.HVACRs = hvResult.ToArray(); ORM_RES_BLD_OutdoorFacility.Query ofQuery = new ORM_RES_BLD_OutdoorFacility.Query(); ofQuery.Tenant_RefID = securityTicket.TenantID; ofQuery.IsDeleted = false; ofQuery.Building_RefID = building.RES_BLD_BuildingID; List <ORM_RES_BLD_OutdoorFacility> ofList = ORM_RES_BLD_OutdoorFacility.Query.Search(Connection, Transaction, ofQuery); List <L5BD_GBFRG_1005_OutdoorFacility> ofResult = new List <L5BD_GBFRG_1005_OutdoorFacility>(); foreach (var part in ofList) { L5BD_GBFRG_1005_OutdoorFacility itemPart = new L5BD_GBFRG_1005_OutdoorFacility(); itemPart.OutdoorFacility_AccessRoadType = part.TypeOfAccessRoad_RefID; itemPart.OutdoorFacility_FenceType = part.TypeOfFence_RefID; itemPart.RES_BLD_OutdoorFacilityID = part.RES_BLD_OutdoorFacilityID; ORM_RES_STR_OutdoorFacility strOutdoorFacility = ORM_RES_STR_OutdoorFacility.Query.Search(Connection, Transaction, new ORM_RES_STR_OutdoorFacility.Query() { RES_BLD_OutdoorFacility_RefID = part.RES_BLD_OutdoorFacilityID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).FirstOrDefault(); if (strOutdoorFacility != null) { itemPart.OutdoorFacilitiesDocumentHeader_RefID = strOutdoorFacility.DocumentHeader_RefID; Guid[] documentHeaders = ORM_RES_STR_OutdoorFacility_PropertyAssessment.Query.Search(Connection, Transaction, new ORM_RES_STR_OutdoorFacility_PropertyAssessment.Query() { STR_OutdoorFacility_RefID = strOutdoorFacility.RES_STR_OutdoorFacilityID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Select(i => i.DocumentHeader_RefID).ToArray(); if (documentHeaders != null) { itemPart.OutdoorFacilitiesPropertyDocumentHeaders = documentHeaders; } } ofResult.Add(itemPart); } item.OutdoorFacilities = ofResult.ToArray(); ORM_RES_BLD_Roof.Query roQuery = new ORM_RES_BLD_Roof.Query(); roQuery.Tenant_RefID = securityTicket.TenantID; roQuery.IsDeleted = false; roQuery.Building_RefID = building.RES_BLD_BuildingID; List <ORM_RES_BLD_Roof> roList = ORM_RES_BLD_Roof.Query.Search(Connection, Transaction, roQuery); List <L5BD_GBFRG_1005_Roof> roResult = new List <L5BD_GBFRG_1005_Roof>(); foreach (var part in roList) { L5BD_GBFRG_1005_Roof itemPart = new L5BD_GBFRG_1005_Roof(); itemPart.RES_BLD_Roof_Type_RefID = ORM_RES_BLD_Roof_2_RoofType.Query.Search(Connection, Transaction, new ORM_RES_BLD_Roof_2_RoofType.Query() { Tenant_RefID = securityTicket.TenantID, IsDeleted = false, RES_BLD_Roof_RefID = part.RES_BLD_RoofID }).Select(r => r.RES_BLD_Roof_Type_RefID).FirstOrDefault(); itemPart.RES_BLD_RoofID = part.RES_BLD_RoofID; ORM_RES_STR_Roof strRoof = ORM_RES_STR_Roof.Query.Search(Connection, Transaction, new ORM_RES_STR_Roof.Query() { RES_BLD_Roof_RefID = part.RES_BLD_RoofID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).FirstOrDefault(); if (strRoof != null) { itemPart.RoofsDocumentHeader_RefID = strRoof.DocumentHeader_RefID; Guid[] documentHeaders = ORM_RES_STR_Roof_PropertyAssessment.Query.Search(Connection, Transaction, new ORM_RES_STR_Roof_PropertyAssessment.Query() { STR_Roof_RefID = strRoof.RES_STR_RoofID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Select(i => i.DocumentHeader_RefID).ToArray(); if (documentHeaders != null) { itemPart.RoofsPropertyDocumentHeaders = documentHeaders; } } roResult.Add(itemPart); } item.Roofs = roResult.ToArray(); ORM_RES_BLD_Staircase.Query stQuery = new ORM_RES_BLD_Staircase.Query(); stQuery.Tenant_RefID = securityTicket.TenantID; stQuery.IsDeleted = false; stQuery.Building_RefID = building.RES_BLD_BuildingID; List <ORM_RES_BLD_Staircase> stList = ORM_RES_BLD_Staircase.Query.Search(Connection, Transaction, stQuery); List <L5BD_GBFRG_1005_Staircase> stResult = new List <L5BD_GBFRG_1005_Staircase>(); foreach (var part in stList) { L5BD_GBFRG_1005_Staircase itemPart = new L5BD_GBFRG_1005_Staircase(); itemPart.RES_BLD_StaircaseID = part.RES_BLD_StaircaseID; ORM_RES_STR_Staircase strStaircase = ORM_RES_STR_Staircase.Query.Search(Connection, Transaction, new ORM_RES_STR_Staircase.Query() { RES_BLD_Staircase_RefID = part.RES_BLD_StaircaseID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).FirstOrDefault(); if (strStaircase != null) { itemPart.StaircasesDocumentHeader_RefID = strStaircase.DocumentHeader_RefID; Guid[] documentHeaders = ORM_RES_STR_Staircase_PropertyAssessment.Query.Search(Connection, Transaction, new ORM_RES_STR_Staircase_PropertyAssessment.Query() { STR_Staircase_RefID = strStaircase.RES_STR_StaircaseID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).Select(i => i.DocumentHeader_RefID).ToArray(); if (documentHeaders != null) { itemPart.StaircasesPropertyDocumentHeaders = documentHeaders; } } stResult.Add(itemPart); } item.Staircases = stResult.ToArray(); item.Building_BalconyPortionPercent = building.Building_BalconyPortionPercent; item.Building_DocumentationStructure_RefID = building.Building_DocumentationStructure_RefID; item.Building_ElevatorCoveragePercent = building.Building_ElevatorCoveragePercent; item.Building_Name = building.Building_Name; item.Building_NumberOfAppartments = building.Building_NumberOfAppartments; item.Building_NumberOfFloors = building.Building_NumberOfFloors; item.Building_NumberOfOccupiedAppartments = building.Building_NumberOfOccupiedAppartments; item.Building_NumberOfOffices = building.Building_NumberOfOffices; item.Building_NumberOfOtherUnits = building.Building_NumberOfOtherUnits; item.Building_NumberOfProductionUnits = building.Building_NumberOfProductionUnits; item.Building_NumberOfRetailUnits = building.Building_NumberOfRetailUnits; item.IsContaminationSuspected = building.IsContaminationSuspected; item.RES_BLD_BuildingID = building.RES_BLD_BuildingID; ORM_RES_BLD_Building_2_GarbageContainerType.Query gctQuery = new ORM_RES_BLD_Building_2_GarbageContainerType.Query(); gctQuery.Tenant_RefID = securityTicket.TenantID; gctQuery.IsDeleted = false; gctQuery.RES_BLD_Building_RefID = building.RES_BLD_BuildingID; List <ORM_RES_BLD_Building_2_GarbageContainerType> garbageContainerType = ORM_RES_BLD_Building_2_GarbageContainerType.Query.Search(Connection, Transaction, gctQuery); ORM_RES_BLD_Building_2_BuildingType.Query b2tQuery = new ORM_RES_BLD_Building_2_BuildingType.Query(); b2tQuery.Tenant_RefID = securityTicket.TenantID; b2tQuery.IsDeleted = false; b2tQuery.RES_BLD_Building_RefID = building.RES_BLD_BuildingID; List <ORM_RES_BLD_Building_2_BuildingType> buildingType = ORM_RES_BLD_Building_2_BuildingType.Query.Search(Connection, Transaction, b2tQuery); ORM_RES_BLD_Building_Type.Query btQuery = new ORM_RES_BLD_Building_Type.Query(); btQuery.Tenant_RefID = securityTicket.TenantID; btQuery.IsDeleted = false; btQuery.RES_BLD_Building_TypeID = buildingType.FirstOrDefault().RES_BLD_Building_Type_RefID; List <ORM_RES_BLD_Building_Type> btList = ORM_RES_BLD_Building_Type.Query.Search(Connection, Transaction, btQuery); ORM_RES_BLD_GarbageContainerType.Query gcQuery = new ORM_RES_BLD_GarbageContainerType.Query(); gcQuery.Tenant_RefID = securityTicket.TenantID; gcQuery.IsDeleted = false; gcQuery.RES_BLD_GarbageContainerTypeID = garbageContainerType.FirstOrDefault().RES_BLD_GarbageContainerType_RefID; List <ORM_RES_BLD_GarbageContainerType> gcList = ORM_RES_BLD_GarbageContainerType.Query.Search(Connection, Transaction, gcQuery); if (btList.Count != 0) { item.Building_Type = btList.FirstOrDefault().BuildingType_Name; } if (gcList.Count != 0) { item.Building_GarbageContainerType = gcList.FirstOrDefault().GarbageContainerType_Name; } item.QuestionnaireVersion_RefID = revision.QuestionnaireVersion_RefID; item.RES_DUD_RevisionID = revision.RES_DUD_RevisionID; returnList.Add(item); } returnValue.Result = returnList.ToArray(); return(returnValue); #endregion UserCode }