protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5DE_SDI_0909 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); if (!Parameter.IsDelete) { ORM_PPS_DEV_Device_Instance deviceInstance; if (Parameter.PPS_DEV_Device_InstanceID == Guid.Empty) { deviceInstance = new ORM_PPS_DEV_Device_Instance(); deviceInstance.PPS_DEV_Device_InstanceID = Guid.NewGuid(); deviceInstance.Device_RefID = Parameter.PPS_DEV_DeviceID; deviceInstance.Tenant_RefID = securityTicket.TenantID; } else { deviceInstance = ORM_PPS_DEV_Device_Instance.Query.Search(Connection, Transaction, new ORM_PPS_DEV_Device_Instance.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, PPS_DEV_Device_InstanceID = Parameter.PPS_DEV_Device_InstanceID }).Single(); } deviceInstance.DeviceInventoryNumber = Parameter.DeviceInventoryNumber; deviceInstance.Save(Connection, Transaction); ORM_PPS_DEV_Device_Instance_OfficeLocation location = ORM_PPS_DEV_Device_Instance_OfficeLocation.Query.Search(Connection, Transaction, new ORM_PPS_DEV_Device_Instance_OfficeLocation.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, DeviceInstance_RefID = deviceInstance.PPS_DEV_Device_InstanceID }).SingleOrDefault(); if (location == null) { location = new ORM_PPS_DEV_Device_Instance_OfficeLocation(); location.PPS_DEV_Device_Instance_OfficeLocationID = Guid.NewGuid(); location.DeviceInstance_RefID = deviceInstance.PPS_DEV_Device_InstanceID; location.Tenant_RefID = securityTicket.TenantID; } location.CMN_STR_Office_RefID = Parameter.OfficeID; location.Save(Connection, Transaction); returnValue.Result = deviceInstance.PPS_DEV_Device_InstanceID; } else { ORM_PPS_DEV_Device_Instance deviceInstance = ORM_PPS_DEV_Device_Instance.Query.Search(Connection, Transaction, new ORM_PPS_DEV_Device_Instance.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, PPS_DEV_Device_InstanceID = Parameter.PPS_DEV_Device_InstanceID }).Single(); ORM_PPS_DEV_Device_Instance.Query.SoftDelete(Connection, Transaction, new ORM_PPS_DEV_Device_Instance.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, PPS_DEV_Device_InstanceID = Parameter.PPS_DEV_Device_InstanceID }); ORM_PPS_DEV_Device_Instance_OfficeLocation.Query.SoftDelete(Connection, Transaction, new ORM_PPS_DEV_Device_Instance_OfficeLocation.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, DeviceInstance_RefID = deviceInstance.PPS_DEV_Device_InstanceID }); } 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_Guid Invoke(DbConnection Connection, DbTransaction Transaction, P_L5DE_SDI_0909 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(Connection, Transaction, null, Parameter, securityTicket)); }
///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5DE_SDI_0909 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_Guid functionReturn = new FR_Guid(); 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_DeviceInstance", ex); } return(functionReturn); }
///<summary> /// Opens the connection/transaction for the given connectionString, and closes them when complete ///<summary> public static FR_Guid Invoke(string ConnectionString, P_L5DE_SDI_0909 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(null, null, ConnectionString, Parameter, securityTicket)); }