protected static FR_L6LG_GDfDLR_1522 Execute(DbConnection Connection, DbTransaction Transaction, P_L6LG_GDfDLR_1522 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6LG_GDfDLR_1522(); L5SO_GSaCOHDfSH_1446 shipmentAndCustomerOrderDetails = null; #region Retrieve Shipment and CustomerOrder Details P_L5SO_GSaCOHDfSH_1446 shipmentAndCustomerOrderDetailsParameter = new P_L5SO_GSaCOHDfSH_1446(); shipmentAndCustomerOrderDetailsParameter.ShippingHeaderID = Parameter.ShipmentHeaderID; FR_L5SO_GSaCOHDfSH_1446 shipmentAndCustomerOrderDetailsResult = CL5_APOLogistic_ShippingOrder.Atomic.Retrieval.cls_Get_Shipment_and_CustomerOrderHeaderDetails_for_ShipmentHeaderID.Invoke(Connection, Transaction, shipmentAndCustomerOrderDetailsParameter, securityTicket); shipmentAndCustomerOrderDetails = shipmentAndCustomerOrderDetailsResult.Result; #endregion #region Customer name var customerName = ""; if (shipmentAndCustomerOrderDetails != null && shipmentAndCustomerOrderDetails.OrderingCustomer_BusinessParticipant_RefID != Guid.Empty) { ORM_CMN_BPT_BusinessParticipant bp = new ORM_CMN_BPT_BusinessParticipant(); var bpResult = bp.Load(Connection, Transaction, shipmentAndCustomerOrderDetails.OrderingCustomer_BusinessParticipant_RefID); if (bpResult.Status == FR_Status.Success && bp.CMN_BPT_BusinessParticipantID != Guid.Empty) { customerName = bp.DisplayName; } } #endregion #region CustomerAddress var CustomerAddress = CL5_APOLogistic_ShippingOrder.Atomic.Retrieval.cls_Get_CustomerAddress_from_ShipmentHeaderID.Invoke(Connection, Transaction, new P_L5SO_GCAfSHI_1127 { ShipmentHeaderID = Parameter.ShipmentHeaderID }, securityTicket); #endregion #region Organisational unit Dict organizationalUnitName = null; if (shipmentAndCustomerOrderDetails != null && shipmentAndCustomerOrderDetails.CMN_BPT_CTM_OrganizationalUnit_RefID != Guid.Empty) { ORM_CMN_BPT_CTM_OrganizationalUnit orgUnit = new ORM_CMN_BPT_CTM_OrganizationalUnit(); var orgUnitResult = orgUnit.Load(Connection, Transaction, shipmentAndCustomerOrderDetails.CMN_BPT_CTM_OrganizationalUnit_RefID); if (orgUnitResult.Status == FR_Status.Success && orgUnit.CMN_BPT_CTM_OrganizationalUnitID != Guid.Empty) { organizationalUnitName = orgUnit.OrganizationalUnit_Name; } } #endregion L6SO_GASPbtWSvR_1413[] shipmentPositions = new L6SO_GASPbtWSvR_1413[0]; #region Retrieve Shipment Positions with reservation details (including storage place) P_L6SO_GASPbtWSvR_1413 shipmentPositionsParameter = new P_L6SO_GASPbtWSvR_1413(); shipmentPositionsParameter.ShipmentHeaderID = Parameter.ShipmentHeaderID; FR_L6SO_GASPbtWSvR_1413_Array shipmentPositionsForPickingListResult = cls_Get_AllShipmentPositions_bound_to_WarehouseStructure_via_Reservations.Invoke(Connection, Transaction, shipmentPositionsParameter, securityTicket); shipmentPositions = shipmentPositionsForPickingListResult.Result; #endregion #region Retrieve Customer Order Positions for Shipment Positions which are not shipped. P_L5CO_GACOPfUSP_1038 customerOrderPositionsForUnshippedShipmentPositionsParameter = new P_L5CO_GACOPfUSP_1038(); customerOrderPositionsForUnshippedShipmentPositionsParameter.ShipmentHeaderID = Parameter.ShipmentHeaderID; customerOrderPositionsForUnshippedShipmentPositionsParameter.OrganizationalUnitID = Parameter.OrganizationalUnitID; FR_L5CO_GACOPfUSP_1038_Array customerOrderPositionsForUnshippedShipmentPositionsResult = cls_Get_AllCustomerOrderPositions_for_Unshipped_ShipmentPositions.Invoke(Connection, Transaction, customerOrderPositionsForUnshippedShipmentPositionsParameter, securityTicket); L5CO_GACOPfUSP_1038[] customerOrderPositions = customerOrderPositionsForUnshippedShipmentPositionsResult.Result; #endregion // // Taking product array from shipment positions previously retrieved. // Product array is used for taking product information // IEnumerable <Guid> productIdList1 = shipmentPositions.Select(x => x.CMN_PRO_Product_RefID).Distinct(); IEnumerable <Guid> productIdList2 = customerOrderPositions.Select(x => x.CMN_PRO_Product_RefID).Distinct(); Guid[] productIdArray = productIdList1.Concat(productIdList2).Distinct().ToArray(); L3AR_GAfAL_0942[] articlesForArticleList = new L3AR_GAfAL_0942[0]; #region Retrive product details if (productIdArray.Length > 0) { P_L3AR_GAfAL_0942 articlesForArticleListParameter = new P_L3AR_GAfAL_0942(); articlesForArticleListParameter.ProductID_List = productIdArray; FR_L3AR_GAfAL_0942_Array articlesForArticleListResult = cls_Get_Articles_for_ArticleList.Invoke(Connection, Transaction, articlesForArticleListParameter, securityTicket); articlesForArticleList = articlesForArticleListResult.Result; } #endregion List <ORM_LOG_SHP_Shipment_Note> shipmentNoteList = new List <ORM_LOG_SHP_Shipment_Note>(); if (shipmentAndCustomerOrderDetails != null) { shipmentNoteList = ORM_LOG_SHP_Shipment_Note.Query .Search(Connection, Transaction, new ORM_LOG_SHP_Shipment_Note.Query { IsDeleted = false, IsNotePrintedOnDeliveryPaper = true, Shipment_Header_RefID = shipmentAndCustomerOrderDetails.LOG_SHP_Shipment_HeaderID }) .OrderBy(i => i.Creation_Timestamp).ToList(); } List <L6LG_GDfDLR_1522c> commentList = new List <L6LG_GDfDLR_1522c>(); foreach (ORM_LOG_SHP_Shipment_Note shipmentNote in shipmentNoteList) { L6LG_GDfDLR_1522c comment = new L6LG_GDfDLR_1522c(); ORM_CMN_BPT_BusinessParticipant businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); FR_Base bpLoad = businessParticipant.Load(Connection, Transaction, shipmentNote.CreatedBy_BusinessParticipant_RefID); if (bpLoad.Status == FR_Status.Success) { comment.Name = businessParticipant.DisplayName; } comment.Comment = shipmentNote.Comment; commentList.Add(comment); } #region Building return object List <L6LG_GDfDLR_1522a> tempShipmentPositions = new List <L6LG_GDfDLR_1522a>(); foreach (L6SO_GASPbtWSvR_1413 shipmentPosition in shipmentPositions) { L6LG_GDfDLR_1522a tempShipmentPosition = new L6LG_GDfDLR_1522a(); tempShipmentPosition.ShipmentPositionDetails = shipmentPosition; tempShipmentPosition.ProductDetails = articlesForArticleList.FirstOrDefault(a => a.CMN_PRO_ProductID == shipmentPosition.CMN_PRO_Product_RefID); tempShipmentPositions.Add(tempShipmentPosition); } List <L6LG_GDfDLR_1522b> tempCustomerOrderPositions = new List <L6LG_GDfDLR_1522b>(); foreach (L5CO_GACOPfUSP_1038 customerOrderPosition in customerOrderPositions) { L6LG_GDfDLR_1522b tempCustomerOrderPosition = new L6LG_GDfDLR_1522b(); tempCustomerOrderPosition.CustomerOrderPositionDetails = customerOrderPosition; tempCustomerOrderPosition.ProductDetails = articlesForArticleList.FirstOrDefault(a => a.CMN_PRO_ProductID == customerOrderPosition.CMN_PRO_Product_RefID); tempCustomerOrderPositions.Add(tempCustomerOrderPosition); } returnValue.Result = new L6LG_GDfDLR_1522(); returnValue.Result.CustomerName = customerName; returnValue.Result.StreetAndNumber = CustomerAddress != null && CustomerAddress.Result != null ? CustomerAddress.Result.Street_Name + " " + CustomerAddress.Result.Street_Number : "keine Kundenadresse"; returnValue.Result.ZipAndCity = CustomerAddress != null && CustomerAddress.Result != null ? CustomerAddress.Result.ZIP + " " + CustomerAddress.Result.Town : "keine Kundenadresse"; returnValue.Result.OrganizationalUnitName = organizationalUnitName; returnValue.Result.ShipmentPositionList = tempShipmentPositions.ToArray(); returnValue.Result.CustomerOrderPositionList = tempCustomerOrderPositions.ToArray(); returnValue.Result.ShipmentAndCustomerOrderDetails = shipmentAndCustomerOrderDetails; returnValue.Result.CommentList = commentList.ToArray(); #endregion return(returnValue); #endregion UserCode }
protected static FR_L6SO_GPDfPPE_1456 Execute(DbConnection Connection, DbTransaction Transaction, P_L6SO_GPDfPPE_1456 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6SO_GPDfPPE_1456(); #region ExtendedShipmentHeaderDetails returnValue.Result = new L6SO_GPDfPPE_1456(); P_L5SO_GSaCOHDfSH_1446 headerDetailsGetParam = new P_L5SO_GSaCOHDfSH_1446(); headerDetailsGetParam.ShippingHeaderID = Parameter.ShipmentHeaderID; returnValue.Result.ExtendedShipmentHeaderDetails = cls_Get_Shipment_and_CustomerOrderHeaderDetails_for_ShipmentHeaderID.Invoke(Connection, Transaction, headerDetailsGetParam, securityTicket).Result; #endregion #region OrganizationalUnit var organizationalUnits = cls_Get_OrganizationalUnit_for_ShipmentHeaderID.Invoke(Connection, Transaction, new P_L5SO_GOUfSH_1157 { ShippingHeaderID = Parameter.ShipmentHeaderID }, securityTicket).Result; if (organizationalUnits.Count() >= 1) { returnValue.Result.OrganizationalUnit = organizationalUnits.First(); } else { returnValue.Result.OrganizationalUnit = new L5OS_GOUfSH_1157(); } #endregion #region Address var addressForSHHeaderID = cls_Get_Address_for_ShipmentHeaderID.Invoke(Connection, Transaction, new P_L6SO_GAfSHI_1435 { ShipmentHeaderID = Parameter.ShipmentHeaderID }, securityTicket).Result; if (addressForSHHeaderID != null) { returnValue.Result.AddressForHeader = addressForSHHeaderID; } #endregion #region ShipmentPositions P_L5SO_GSPwPaSfSH_1141 shipmentPositionsParam = new P_L5SO_GSPwPaSfSH_1141() { ShippmentHeaderID = Parameter.ShipmentHeaderID, LanguageID = Parameter.LanguageID }; var shipmentPositions = cls_Get_ShipmentPositions_with_Prices_and_Stock_for_ShipmentHeaderID.Invoke(Connection, Transaction, shipmentPositionsParam, securityTicket).Result; returnValue.Result.ShipmentPositions = shipmentPositions; #endregion #region UnexecutedReservation if (shipmentPositions != null && shipmentPositions.Count() != 0) { P_L6SO_GAURfPL_1149 reservationParam = new P_L6SO_GAURfPL_1149() { ProductID = shipmentPositions.Select(x => x.CMN_PRO_ProductID).ToArray() }; var unexecutedReservation = cls_Get_All_Unexecuted_Reservation_for_ProductList.Invoke(Connection, Transaction, reservationParam, securityTicket); returnValue.Result.UnexecutedReservation = unexecutedReservation.Result.ToArray(); } else { returnValue.Result.UnexecutedReservation = new L6SO_GAURfPL_1149[0]; } #endregion #region CustomerOrderPosition var customerOrderPosition = cls_Get_CustomerOrderPosition_for_ShipmentPositionList.Invoke( Connection, Transaction, new P_L6SO_GCOPfSPL_1152 { ShipmentPositionID = shipmentPositions.Select(x => x.ShipmentPositionID).ToArray() }, securityTicket).Result; returnValue.Result.CustomerOrderPosition = customerOrderPosition; #endregion return(returnValue); #endregion UserCode }