protected static FR_L5RS_GRSPwAfH_1024_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5RS_GRSPwAfH_1024 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5RS_GRSPwAfH_1024_Array(); #region Get ReturnShipmentheaders var parameterHeaderId = new P_L5RS_GRSPfH_1105 { ReturnShipmentHeaderID = Parameter.Header_ID }; var shipmentPositions = cls_Get_ReturnShipmentPositions_for_HeaderID.Invoke(Connection, Transaction, parameterHeaderId, securityTicket).Result; #endregion #region Get Articles var parameterProductIds = new P_L3AR_GAfAL_0942(); parameterProductIds.ProductID_List = shipmentPositions.Select(sh => sh.ProductId).ToArray <Guid>(); var articles = new L3AR_GAfAL_0942[0]; if (parameterProductIds.ProductID_List.Length != 0) { articles = cls_Get_Articles_for_ArticleList.Invoke(Connection, Transaction, parameterProductIds, securityTicket).Result; } #endregion #region Set Return Value var returnElements = new List <L5RS_GRSPwAfH_1024>(); foreach (var shipmentPosition in shipmentPositions) { var returnElement = new L5RS_GRSPwAfH_1024 { Article = articles.FirstOrDefault(a => a.CMN_PRO_ProductID == shipmentPosition.ProductId), Position = shipmentPosition, Header_ID = Parameter.Header_ID }; returnElements.Add(returnElement); } returnValue.Result = returnElements.ToArray(); #endregion return(returnValue); #endregion UserCode }
///<summary> /// Ivokes the method with the given Connection, leaving it open if no exceptions occured ///<summary> public static FR_L5RS_GRSPwAfH_1024_Array Invoke(DbConnection Connection, P_L5RS_GRSPwAfH_1024 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(Connection, null, null, Parameter, securityTicket)); }
///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_L5RS_GRSPwAfH_1024_Array Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5RS_GRSPwAfH_1024 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_L5RS_GRSPwAfH_1024_Array functionReturn = new FR_L5RS_GRSPwAfH_1024_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_ReturnShipmentPositions_with_Articles_for_HeaderID", ex); } return(functionReturn); }