protected static FR_L5PP_GSHwCOfPfT_1348_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5PP_GSHwCOfPfT_1348 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5PP_GSHwCOfPfT_1348_Array(); //Put your code here List <L5PP_GSHwCOfPfT_1348> retVal = new List <L5PP_GSHwCOfPfT_1348>(); returnValue.Result = retVal.ToArray(); #region Retrieve Headers // get all headers P_L2SH_GSHfT_1527 shipmentHeadersParam = new P_L2SH_GSHfT_1527(); shipmentHeadersParam.IsShipped = false; shipmentHeadersParam.ShipmentNumber = Parameter.ShipmentNumber; shipmentHeadersParam.ShipmentCreationDateFrom = Parameter.ShipmentCreationDateFrom; shipmentHeadersParam.ShipmentCreationDateTo = Parameter.ShipmentCreationDateTo; var headersResult = cls_Get_ShippmentHeaders_for_TenantID.Invoke(Connection, Transaction, shipmentHeadersParam, securityTicket).Result; if (headersResult == null) { return(returnValue); } // filter headers List <L2SH_GSHfT_1527> headers = new List <L2SH_GSHfT_1527>(); List <L2SH_GSHfT_1527> tempHeaders = new List <L2SH_GSHfT_1527>(); if (Parameter.HasPositionsPartiallyToPick) { // filtered by passed parameter option tempHeaders = headersResult.Where(i => i.IsPartiallyReadyForPicking && !i.IsManuallyCleared_ForPicking).ToList(); // add not inserted shipment headers headers.AddRange(tempHeaders.Where(i => !headers.Any(j => j.LOG_SHP_Shipment_HeaderID == i.LOG_SHP_Shipment_HeaderID)).ToList()); } if (Parameter.IsReadyForPicking) { // filtered by passed parameter option tempHeaders = headersResult.Where(i => i.IsReadyForPicking && !i.IsManuallyCleared_ForPicking).ToList(); // add not inserted shipment headers headers.AddRange(tempHeaders.Where(i => !headers.Any(j => j.LOG_SHP_Shipment_HeaderID == i.LOG_SHP_Shipment_HeaderID)).ToList()); } if (Parameter.IsInPickingProcess) { // filtered by passed parameter option tempHeaders = headersResult.Where(i => i.HasPickingStarted || i.HasPickingFinished || i.IsManuallyCleared_ForPicking).ToList(); // add not inserted shipment headers headers.AddRange(tempHeaders.Where(i => !headers.Any(j => j.LOG_SHP_Shipment_HeaderID == i.LOG_SHP_Shipment_HeaderID)).ToList()); } if (Parameter.NoPositionsFullyToPick) { // filtered by passed parameter option tempHeaders = headersResult.Where(i => !(i.IsPartiallyReadyForPicking && !i.IsManuallyCleared_ForPicking) && !(i.IsReadyForPicking && !i.IsManuallyCleared_ForPicking) && !(i.HasPickingStarted || i.HasPickingFinished || i.IsManuallyCleared_ForPicking) ).ToList(); // add not inserted shipment headers headers.AddRange(tempHeaders.Where(i => !headers.Any(j => j.LOG_SHP_Shipment_HeaderID == i.LOG_SHP_Shipment_HeaderID)).ToList()); } #endregion L5PP_GSHwCOfPfT_1348 retValItem; foreach (var header in headers) { #region Getting data #region Shipment positions // get one shipment position for shipment header ORM_LOG_SHP_Shipment_Position.Query shipmentPositionsQuery = new ORM_LOG_SHP_Shipment_Position.Query(); shipmentPositionsQuery.LOG_SHP_Shipment_Header_RefID = header.LOG_SHP_Shipment_HeaderID; shipmentPositionsQuery.Tenant_RefID = securityTicket.TenantID; shipmentPositionsQuery.IsDeleted = false; List <ORM_LOG_SHP_Shipment_Position> shipmentPositions = ORM_LOG_SHP_Shipment_Position.Query.Search(Connection, Transaction, shipmentPositionsQuery); if (shipmentPositions == null || shipmentPositions.Count == 0) { continue; } #endregion #region Customer order position for shipment position // get one customer order position for shipment position ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition customerOrder2ShipmentPosition = null; foreach (var shipmentPosition in shipmentPositions) { ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query customerOrder2ShipmentPositionQuery = new ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query(); customerOrder2ShipmentPositionQuery.LOG_SHP_Shipment_Position_RefID = shipmentPosition.LOG_SHP_Shipment_PositionID; customerOrder2ShipmentPositionQuery.Tenant_RefID = securityTicket.TenantID; customerOrder2ShipmentPositionQuery.IsDeleted = false; customerOrder2ShipmentPosition = ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition.Query .Search(Connection, Transaction, customerOrder2ShipmentPositionQuery).FirstOrDefault(); if (customerOrder2ShipmentPosition != null) { break; } } if (customerOrder2ShipmentPosition == null) { continue; } #endregion #region Customer order position ORM_ORD_CUO_CustomerOrder_Position orm_CustomerOrderPosition = new ORM_ORD_CUO_CustomerOrder_Position(); var distributionOrderPosition = orm_CustomerOrderPosition.Load(Connection, Transaction, customerOrder2ShipmentPosition.ORD_CUO_CustomerOrder_Position_RefID); if (distributionOrderPosition.Status != FR_Status.Success || orm_CustomerOrderPosition.ORD_CUO_CustomerOrder_PositionID == Guid.Empty) { continue; } #endregion #region Customer order header // get customer order header for customer order position ORM_ORD_CUO_CustomerOrder_Header.Query customerOrderHeaderQuery = new ORM_ORD_CUO_CustomerOrder_Header.Query(); customerOrderHeaderQuery.ORD_CUO_CustomerOrder_HeaderID = orm_CustomerOrderPosition.CustomerOrder_Header_RefID; customerOrderHeaderQuery.Tenant_RefID = securityTicket.TenantID; customerOrderHeaderQuery.IsDeleted = false; if (!String.IsNullOrEmpty(Parameter.CustomerOrderNumber)) { customerOrderHeaderQuery.CustomerOrder_Number = Parameter.CustomerOrderNumber; } ORM_ORD_CUO_CustomerOrder_Header customerOrderHeader = ORM_ORD_CUO_CustomerOrder_Header.Query.Search(Connection, Transaction, customerOrderHeaderQuery).FirstOrDefault(); if (customerOrderHeader == null) { continue; } // apply filter for customer order header if (Parameter.OrderDateFrom != null) { if (customerOrderHeader.CustomerOrder_Date < Parameter.OrderDateFrom) { continue; } } if (Parameter.OrderDateTo != null) { if (customerOrderHeader.CustomerOrder_Date > Parameter.OrderDateTo) { continue; } } #endregion #region Customer ORM_CMN_BPT_BusinessParticipant.Query bussinerParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query(); bussinerParticipantQuery.CMN_BPT_BusinessParticipantID = customerOrderHeader.OrderingCustomer_BusinessParticipant_RefID; bussinerParticipantQuery.Tenant_RefID = securityTicket.TenantID; bussinerParticipantQuery.IsDeleted = false; ORM_CMN_BPT_BusinessParticipant bussinerParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bussinerParticipantQuery).FirstOrDefault(); if (bussinerParticipant == null) { continue; } if (!String.IsNullOrEmpty(Parameter.Customer)) { if (!bussinerParticipant.DisplayName.ToUpper().Contains(Parameter.Customer.ToUpper())) { continue; } } #endregion #endregion retValItem = new L5PP_GSHwCOfPfT_1348(); retValItem.LOG_SHP_Shipment_HeaderID = header.LOG_SHP_Shipment_HeaderID; retValItem.ShipmentHeader_Number = header.ShipmentHeader_Number; retValItem.IsShipped = header.IsShipped; retValItem.IsBilled = header.IsBilled; retValItem.IsReadyForPicking = header.IsReadyForPicking; retValItem.IsPartiallyReadyForPicking = header.IsPartiallyReadyForPicking; retValItem.HasPickingStarted = header.HasPickingStarted; retValItem.HasPickingFinished = header.HasPickingFinished; retValItem.IsManuallyCleared_ForPicking = header.IsManuallyCleared_ForPicking; retValItem.ShipmentCreationDate = header.Creation_Timestamp; retValItem.ORD_CUO_CustomerOrder_HeaderID = customerOrderHeader.ORD_CUO_CustomerOrder_HeaderID; retValItem.CustomerOrderNumber = customerOrderHeader.CustomerOrder_Number; retValItem.CustomerOrderDate = customerOrderHeader.CustomerOrder_Date; retValItem.Customer = bussinerParticipant.DisplayName; retVal.Add(retValItem); } retVal = retVal.Skip(Parameter.From).Take(Parameter.Size).ToList(); returnValue.Result = retVal.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_L5PP_GSHwCOfPfT_1348_Array Invoke(DbConnection Connection, DbTransaction Transaction, P_L5PP_GSHwCOfPfT_1348 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(Connection, Transaction, null, Parameter, securityTicket)); }
///<summary> /// Method Invocation of wrapper classes ///<summary> protected static FR_L5PP_GSHwCOfPfT_1348_Array Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5PP_GSHwCOfPfT_1348 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { bool cleanupConnection = Connection == null; bool cleanupTransaction = Transaction == null; FR_L5PP_GSHwCOfPfT_1348_Array functionReturn = new FR_L5PP_GSHwCOfPfT_1348_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_ShippmentHeaders_with_CustomerOrder_for_Picking_for_TenantID", ex); } return(functionReturn); }
///<summary> /// Opens the connection/transaction for the given connectionString, and closes them when complete ///<summary> public static FR_L5PP_GSHwCOfPfT_1348_Array Invoke(string ConnectionString, P_L5PP_GSHwCOfPfT_1348 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { return(Invoke(null, null, ConnectionString, Parameter, securityTicket)); }