protected static FR_L6ED_GPTIwAaS_0816_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L6ED_GPTIwAaS_0816 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L6ED_GPTIwAaS_0816_Array();

            #region Get Storage Places
            var filterCriteria = new P_L3WH_GSPfFC_1504()
            {
                WarehouseGroupID    = null,
                WarehouseID         = null,
                AreaID              = null,
                RackID              = null,
                UseShelfIDList      = false,
                ShelfIDs            = new Guid[] { Guid.Empty },
                UseProductIDList    = false,
                ProductIDs          = new Guid[] { Guid.Empty },
                BottomShelfQuantity = 1,
                TopShelfQuantity    = null,
                UseProductTrackingInstanceIDList = Parameter.ProductTrackingInstanceIds != null,
                ProductTrackingInstanceIDs       = Parameter.ProductTrackingInstanceIds == null
                    ? new Guid[] { Guid.Empty } : Parameter.ProductTrackingInstanceIds,
                StartExpirationDate = Parameter.StartDate,
                EndExpirationDate   = Parameter.EndDate
            };
            var resultStoragePlaces = cls_Get_StoragePlaces_for_FilterCriteria.Invoke(
                Connection,
                Transaction,
                filterCriteria,
                securityTicket);

            if (resultStoragePlaces.Status != FR_Status.Success || resultStoragePlaces.Result == null || resultStoragePlaces.Result.Count() == 0)
            {
                returnValue.Status = FR_Status.Error_Internal;
                returnValue.Result = new L6ED_GPTIwAaS_0816[] { };
                return(returnValue);
            }
            #endregion

            #region Get Articles
            var parameterProductIds = new P_L3AR_GAfAL_0942();
            parameterProductIds.ProductID_List = resultStoragePlaces.Result.Select(rsp => rsp.Product_RefID).Distinct().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 Get Supplier
            var parameterProductsBatchNumbers = new P_L6ED_GSRtTIbBNaP_1353();
            parameterProductsBatchNumbers.ProductIDs   = parameterProductIds.ProductID_List;
            parameterProductsBatchNumbers.BatchNumbers = resultStoragePlaces.Result.Select(rsp => rsp.BatchNumber).Distinct().ToArray <string>();
            var resultSuppliers = cls_Get_StockReceipt_through_TrackingInstance_by_BatchNumbers_and_ProductIDs.Invoke(Connection, Transaction, parameterProductsBatchNumbers, securityTicket);
            if (resultSuppliers.Status != FR_Status.Success)
            {
                returnValue.Status = FR_Status.Error_Internal;
                returnValue.Result = new L6ED_GPTIwAaS_0816[] { };
                return(returnValue);
            }
            #endregion

            #region Get MSR
            Guid[] productIds     = articles.Select(x => x.CMN_PRO_ProductID).ToArray();
            var    msrForProducts = cls_Get_MSR_for_ProductIDList.Invoke(
                Connection,
                Transaction,
                new P_L3AS_GSMRfPL_1508 {
                ProductIDList = productIds
            },
                securityTicket
                ).Result;
            #endregion


            #region Set Result
            var result = new List <L6ED_GPTIwAaS_0816>();
            foreach (var storagePlace in resultStoragePlaces.Result)
            {
                var suppliers = resultSuppliers.Result
                                .Where(rs => rs.BatchNumber == storagePlace.BatchNumber && rs.ReceiptPosition_Product_RefID == storagePlace.Product_RefID)
                                .GroupBy(s => s.SupplierId, (key, group) => group.First());

                var msrForProduct = msrForProducts.SingleOrDefault(x => x.ProductID == storagePlace.Product_RefID);

                result.Add(new L6ED_GPTIwAaS_0816()
                {
                    StoragePlaces = storagePlace,
                    Article       = articles.FirstOrDefault(a => a.CMN_PRO_ProductID == storagePlace.Product_RefID),
                    Suppliers     = suppliers.ToArray(),
                    MSR           = (msrForProduct != null) ? msrForProduct.MSR : 0.0
                });
            }
            returnValue.Result = result.ToArray();
            returnValue.Status = FR_Status.Success;
            #endregion


            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_L6ED_GPTIwAaS_0816_Array Invoke(DbConnection Connection, DbTransaction Transaction, P_L6ED_GPTIwAaS_0816 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L6ED_GPTIwAaS_0816_Array Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L6ED_GPTIwAaS_0816 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L6ED_GPTIwAaS_0816_Array functionReturn = new FR_L6ED_GPTIwAaS_0816_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_ProductTrackingInstance_with_Articles_and_Suppliers", ex);
            }
            return(functionReturn);
        }
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_L6ED_GPTIwAaS_0816_Array Invoke(string ConnectionString, P_L6ED_GPTIwAaS_0816 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }