protected static FR_L6MRMS_GARSIwR_1056_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L6MRMS_GARSIwR_1056 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6MRMS_GARSIwR_1056_Array(); var resItems = new List <L6MRMS_GARSIwR_1056>(); var readers = cls_Get_All_Accounts_For_MeasurementRun.Invoke(Connection, Transaction, new P_L6MRMS_GAAfMR_0930() { MeasurementRunID = Parameter.ReadingSessionId }, securityTicket).Result; var details = cls_Get_All_Reading_Session_Items.Invoke(Connection, Transaction, new P_L6MRMS_GARSI_2117() { ReadingSessionId = Parameter.ReadingSessionId }, securityTicket).Result; foreach (var item in details) { var detail = new L6MRMS_GARSIwR_1056() { City = item.City, ContractNumber = item.ContractNumber, MeasurementID = item.MeasurementID, MeterSerialNumber = item.MeterSerialNumber, OwnerFirstName = item.OwnerFirstName, OwnerLastName = item.OwnerLastName, RouteName = item.RouteName, SequenceInRoute = item.SequenceInRoute, StreetName = item.StreetName, StreetNumber = item.StreetNumber, City_PostalCode = item.City_PostalCode }; if (item.MeasurementValues.Count() > 0) { detail.MeasuredOn = item.MeasurementValues.First().MeasuredAt_Time; } else { detail.MeasuredOn = DateTime.MinValue; } var values = new List <L6MRMS_GARSIwR_1056_MeasurementValue>(); foreach (var val in item.MeasurementValues) { values.Add(new L6MRMS_GARSIwR_1056_MeasurementValue() { MeasuredAt_Time = val.MeasuredAt_Time, MeasurementTariffName = val.MeasurementTariffName, MeasurementValue = val.MeasurementValue, MRS_RUN_Measurement_TariffID = val.MRS_RUN_Measurement_TariffID, AcqusitionTypeGPM = val.AcqusitionTypeGPM, MRS_RUN_Measurement_ValueID = val.MRS_RUN_Measurement_ValueID, Tariff_GlobalPropertyMatchingID = val.Tariff_GlobalPropertyMatchingID }); } detail.MeasurementValues = values.ToArray(); var reader = readers.First(r => r.CMN_BPT_BusinessParticipantID == item.BoundTo_Account_RefID); detail.ReaderEmail = reader.PrimaryEmail; detail.ReaderFirstName = reader.FirstName; detail.ReaderLastName = reader.LastName; resItems.Add(detail); } returnValue.Result = resItems.ToArray(); return(returnValue); #endregion UserCode }
///<summary> /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured ///<summary> public static FR_L6MRMS_GARSIwR_1056_Array Invoke(DbConnection Connection, DbTransaction Transaction, P_L6MRMS_GARSIwR_1056 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(Connection, Transaction, null, Parameter, securityTicket)); }
///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_L6MRMS_GARSIwR_1056_Array Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L6MRMS_GARSIwR_1056 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_L6MRMS_GARSIwR_1056_Array functionReturn = new FR_L6MRMS_GARSIwR_1056_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 new Exception("Exception occured in method cls_Get_All_Reading_Session_Items_with_Readers", ex); } return(functionReturn); }
///<summary> /// Opens the connection/transaction for the given connectionString, and closes them when complete ///<summary> public static FR_L6MRMS_GARSIwR_1056_Array Invoke(string ConnectionString, P_L6MRMS_GARSIwR_1056 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(null, null, ConnectionString, Parameter, securityTicket)); }