protected static FR_L2CN_GCCfPI_1222_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L2CN_GCCfPI_1222 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_L2CN_GCCfPI_1222_Array(); #region xmlContactTypes var xmlContactTypes = cls_Get_AllComunicationContactTypes.Invoke(Connection, Transaction, securityTicket).Result; #endregion #region peristedContactTypes var query = new ORM_CMN_PER_CommunicationContact_Type.Query(); query.IsDeleted = false; query.Tenant_RefID = securityTicket.TenantID; var peristedContactTypes = ORM_CMN_PER_CommunicationContact_Type.Query.Search(Connection, Transaction, query); #endregion #region contacts var query2 = new ORM_CMN_PER_CommunicationContact.Query(); query2.IsDeleted = false; query2.Tenant_RefID = securityTicket.TenantID; query2.PersonInfo_RefID = Parameter.PersonInfoID; var contacts = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, query2); #endregion var result = new List <L2CN_GCCfPI_1222>(); var differentTypes = contacts.GroupBy(i => i.Contact_Type).Select(g => g.First()).ToList(); foreach (var contact in differentTypes) { var persitedContactType = peristedContactTypes.Where(i => i.CMN_PER_CommunicationContact_TypeID == contact.Contact_Type).SingleOrDefault(); if (persitedContactType == null) { continue; } var xmlContactType = xmlContactTypes.Where(i => i.Type == persitedContactType.Type).Single(); var temp = new L2CN_GCCfPI_1222(); temp.CMN_PER_CommunicationContact_TypeID = persitedContactType.CMN_PER_CommunicationContact_TypeID; temp.Type = persitedContactType.Type; temp.TypeName = xmlContactType.Name; var relevantContacts = contacts.Where(i => i.Contact_Type == contact.Contact_Type); temp.Contacts = relevantContacts.Select(i => new L2CN_GCCfPI_1222a() { CMN_PER_CommunicationContactID = i.CMN_PER_CommunicationContactID, Content = i.Content }).ToArray(); result.Add(temp); } returnValue.Result = result.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_L2CN_GCCfPI_1222_Array Invoke(DbConnection Connection, DbTransaction Transaction, P_L2CN_GCCfPI_1222 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(Connection, Transaction, null, Parameter, securityTicket)); }
///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_L2CN_GCCfPI_1222_Array Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L2CN_GCCfPI_1222 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_L2CN_GCCfPI_1222_Array functionReturn = new FR_L2CN_GCCfPI_1222_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_ComunicationContacts_for_PersonInfoID", ex); } return(functionReturn); }
///<summary> /// Opens the connection/transaction for the given connectionString, and closes them when complete ///<summary> public static FR_L2CN_GCCfPI_1222_Array Invoke(string ConnectionString, P_L2CN_GCCfPI_1222 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(null, null, ConnectionString, Parameter, securityTicket)); }