protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5ME_SL_1047 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); //get languages for Tenant P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530(); langParam.Tenant_RefID = securityTicket.TenantID; var DBLanguages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, securityTicket).Result; foreach (var item in Parameter.Localization) { //Delete if (item.IsDeleted) { var localizationQuery = new ORM_HEC_DIA_Diagnosis_Localization.Query(); localizationQuery.IsDeleted = false; localizationQuery.HEC_DIA_Diagnosis_LocalizationID = item.LocalizationID; localizationQuery.Diagnosis_RefID = Parameter.DiagnoseID; var localization = ORM_HEC_DIA_Diagnosis_Localization.Query.Search(Connection, Transaction, localizationQuery).SingleOrDefault(); if (localization != null) { localization.IsDeleted = true; localization.Save(Connection, Transaction); } } else { var localizationQuery = new ORM_HEC_DIA_Diagnosis_Localization.Query(); localizationQuery.IsDeleted = false; localizationQuery.HEC_DIA_Diagnosis_LocalizationID = item.LocalizationID; localizationQuery.Diagnosis_RefID = Parameter.DiagnoseID; var localization = ORM_HEC_DIA_Diagnosis_Localization.Query.Search(Connection, Transaction, localizationQuery).SingleOrDefault(); //Edit if (localization != null) { Dict name = new Dict("hec_dia_diagnosis_localizations"); for (int i = 0; i < DBLanguages.Length; i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, item.LocalizationName); } localization.DiagnosisLocalization_Name = name; localization.Save(Connection, Transaction); } else // New { ORM_HEC_DIA_Diagnosis_Localization localizationNew = new ORM_HEC_DIA_Diagnosis_Localization(); localizationNew.HEC_DIA_Diagnosis_LocalizationID = item.LocalizationID; Dict name = new Dict("hec_dia_diagnosis_localizations"); for (int i = 0; i < DBLanguages.Length; i++) { name.AddEntry(DBLanguages[i].CMN_LanguageID, item.LocalizationName); } localizationNew.DiagnosisLocalization_Name = name; localizationNew.Tenant_RefID = securityTicket.TenantID; localizationNew.Creation_Timestamp = DateTime.Now; localizationNew.Diagnosis_RefID = Parameter.DiagnoseID; localizationNew.Save(Connection, Transaction); } } } 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_L5ME_SL_1047 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_L5ME_SL_1047 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 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_L5ME_SL_1047 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(null, null, ConnectionString, Parameter, securityTicket)); }