///<summary> /// Opens the connection/transaction for the given connectionString, and closes them when complete ///<summary> public static FR_Guids Invoke(string ConnectionString, P_L5DI_SPO_1452 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(null, null, ConnectionString, Parameter, securityTicket)); }
///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_Guids Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5DI_SPO_1452 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_Guids functionReturn = new FR_Guids(); 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_Save_PotentialObservation", ex); } return(functionReturn); }
protected static FR_Guids Execute(DbConnection Connection, DbTransaction Transaction, P_L5DI_SPO_1452 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guids(); //Put your code here List <Guid> resultID = new List <Guid>(); foreach (var observationParam in Parameter.PotentialObservation) { ORM_HEC_DIA_TypicalPotentialObservation typicalPotentialObservation = ORM_HEC_DIA_TypicalPotentialObservation.Query.Search(Connection, Transaction, new ORM_HEC_DIA_TypicalPotentialObservation.Query { HEC_DIA_TypicalPotentialObservationID = observationParam.TypicalPotentialObservationID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }).SingleOrDefault(); if (!observationParam.IsDeleted) { if (observationParam.NewPotentialObservation) { ORM_HEC_PotentialObservation potentialObservation = new ORM_HEC_PotentialObservation(); potentialObservation.HEC_PotentialObservationID = observationParam.PotentialObservationID; potentialObservation.Observation_Text = observationParam.Observation_Text; potentialObservation.IsDeleted = false; potentialObservation.Tenant_RefID = securityTicket.TenantID; potentialObservation.Save(Connection, Transaction); } if (typicalPotentialObservation == null) { typicalPotentialObservation = new ORM_HEC_DIA_TypicalPotentialObservation(); typicalPotentialObservation.HEC_DIA_TypicalPotentialObservationID = observationParam.TypicalPotentialObservationID; } typicalPotentialObservation.PotentialDiagnosis_RefID = observationParam.PotentialDiagnosis_RefID; typicalPotentialObservation.PotentialObservation_RefID = observationParam.PotentialObservationID; typicalPotentialObservation.IsDeleted = false; typicalPotentialObservation.Tenant_RefID = securityTicket.TenantID; typicalPotentialObservation.Save(Connection, Transaction); resultID.Add(typicalPotentialObservation.HEC_DIA_TypicalPotentialObservationID); } else if (typicalPotentialObservation != null && observationParam.IsDeleted) { typicalPotentialObservation.IsDeleted = true; typicalPotentialObservation.Save(Connection, Transaction); resultID.Add(typicalPotentialObservation.HEC_DIA_TypicalPotentialObservationID); } } returnValue.Result = resultID.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_Guids Invoke(DbConnection Connection, DbTransaction Transaction, P_L5DI_SPO_1452 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(Connection, Transaction, null, Parameter, securityTicket)); }