protected static FR_L5SO_DSP_1449 Execute(DbConnection Connection, DbTransaction Transaction, P_L5SO_DSP_1449 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5SO_DSP_1449(); //get shipment position by ID CL1_LOG_SHP.ORM_LOG_SHP_Shipment_Position shipmentPositionToDelete = new ORM_LOG_SHP_Shipment_Position(); shipmentPositionToDelete.Load(Connection, Transaction, Parameter.PositionID); ORM_LOG_RSV_Reservation.Query.SoftDelete(Connection, Transaction, new ORM_LOG_RSV_Reservation.Query { LOG_SHP_Shipment_Position_RefID = shipmentPositionToDelete.LOG_SHP_Shipment_PositionID, IsDeleted = false }); //remove shipment position shipmentPositionToDelete.Remove(Connection, Transaction); // update header total value cls_Update_Current_TotalValue_on_ShipmentHeader_from_Positions.Invoke(Connection, Transaction, new P_L5SO_UCTVoSHfP_1549 { ShipmentHeaderID = Parameter.ShipmentHeaderID }, securityTicket); returnValue.Result = new L5SO_DSP_1449(); returnValue.Result.DeletedPosition = Parameter.PositionID; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5OD_DPSP_1408 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); ORM_HEC_ShippingPosition_BarcodeLabel shippmentLabel = new ORM_HEC_ShippingPosition_BarcodeLabel(); var result = shippmentLabel.Load(Connection, Transaction, Parameter.ShippmentLabelID); if (result.Status != FR_Status.Success || shippmentLabel.HEC_ShippingPosition_BarcodeLabelID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } shippmentLabel.IsDeleted = true; shippmentLabel.Save(Connection, Transaction); ORM_LOG_SHP_Shipment_Position logShippmentPosition = new ORM_LOG_SHP_Shipment_Position(); var result1 = logShippmentPosition.Load(Connection, Transaction, shippmentLabel.LOG_SHP_Shipment_Position_RefID); if (result1.Status != FR_Status.Success || logShippmentPosition.LOG_SHP_Shipment_PositionID == Guid.Empty) { var error = new FR_Guid(); error.ErrorMessage = "No Such ID"; error.Status = FR_Status.Error_Internal; return(error); } logShippmentPosition.IsDeleted = true; logShippmentPosition.Save(Connection, Transaction); return(returnValue); #endregion UserCode }
protected static FR_L5SO_SSPC_1240 Execute(DbConnection Connection, DbTransaction Transaction, P_L5SO_SSPC_1240 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5SO_SSPC_1240(); //Put your code here returnValue.Result = new L5SO_SSPC_1240(); //saving quantities and prices for positions foreach (var correction in Parameter.Corrections) { var shipmentPosition = new ORM_LOG_SHP_Shipment_Position(); shipmentPosition.Load(Connection, Transaction, correction.PositionID); shipmentPosition.QuantityToShip = correction.ChangedQuantity; shipmentPosition.ShipmentPosition_PricePerUnitValueWithoutTax = correction.UnitPrice; shipmentPosition.ShipmentPosition_ValueWithoutTax = Convert.ToDecimal(shipmentPosition.QuantityToShip) * correction.UnitPrice; shipmentPosition.Save(Connection, Transaction); } //update shipment header cls_Update_Current_TotalValue_on_ShipmentHeader_from_Positions. Invoke(Connection, Transaction, new P_L5SO_UCTVoSHfP_1549 { ShipmentHeaderID = Parameter.ShipmentHeaderID }, securityTicket); #endregion returnValue.Result.IsSaved = true; return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L2SH_SLSSP_1413 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_Guid(); var item = new ORM_LOG_SHP_Shipment_Position(); if (Parameter.LOG_SHP_Shipment_PositionID != Guid.Empty) { var result = item.Load(Connection, Transaction, Parameter.LOG_SHP_Shipment_PositionID); } if (Parameter.IsDeleted == true) { item.IsDeleted = true; return(new FR_Guid(item.Save(Connection, Transaction), item.LOG_SHP_Shipment_PositionID)); } //Creation specific parameters (Tenant, Account ... ) if (Parameter.LOG_SHP_Shipment_PositionID == Guid.Empty) { item.Tenant_RefID = securityTicket.TenantID; } item.ShipmentPositionITL = Parameter.ShipmentPositionITL; item.LOG_SHP_Shipment_Header_RefID = Parameter.LOG_SHP_Shipment_Header_RefID; item.CMN_PRO_Product_RefID = Parameter.CMN_PRO_Product_RefID; item.CMN_PRO_ProductVariant_RefID = Parameter.CMN_PRO_ProductVariant_RefID; item.CMN_PRO_ProductRelease_RefID = Parameter.CMN_PRO_ProductRelease_RefID; item.TrackingInstance_ToShip_RefID = Parameter.TrackingInstance_ToShip_RefID; item.QuantityToShip = Parameter.QuantityToShip; item.ShipmentPosition_PricePerUnitValueWithoutTax = Parameter.ShipmentPosition_PricePerUnitValueWithoutTax; item.ShipmentPosition_ValueWithoutTax = Parameter.ShipmentPosition_PricePerUnitValueWithoutTax * Convert.ToDecimal(item.QuantityToShip); return(new FR_Guid(item.Save(Connection, Transaction), item.LOG_SHP_Shipment_PositionID)); #endregion UserCode }
protected static FR_L5CO_ACOaCS_2108_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L5CO_ACOaCS_2108[] Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5CO_ACOaCS_2108_Array(); List <L5CO_ACOaCS_2108> confirmedProcurementOrders = new List <L5CO_ACOaCS_2108>(); foreach (var param in Parameter) { L5CO_ACOaCS_2108 procurementOrderITL = new L5CO_ACOaCS_2108(); var confirmedStatus = ORM_ORD_CUO_CustomerOrder_Status.Query.Search(Connection, Transaction, new ORM_ORD_CUO_CustomerOrder_Status.Query { GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(ECustomerOrderStatus.Confirmed), Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).Single().ORD_CUO_CustomerOrder_StatusID; var customerOrder = new ORM_ORD_CUO_CustomerOrder_Header(); customerOrder.Load(Connection, Transaction, param.CustomerOrderHeaderID); customerOrder.Current_CustomerOrderStatus_RefID = confirmedStatus; customerOrder.IsCustomerOrderFinalized = true; customerOrder.Save(Connection, Transaction); ORM_USR_Account account = new ORM_USR_Account(); account.Load(Connection, Transaction, securityTicket.AccountID); ORM_ORD_CUO_CustomerOrder_StatusHistory newStatusInHistory = new ORM_ORD_CUO_CustomerOrder_StatusHistory(); newStatusInHistory.CustomerOrder_Header_RefID = customerOrder.ORD_CUO_CustomerOrder_HeaderID; newStatusInHistory.StatusHistoryComment = param.Message; newStatusInHistory.Tenant_RefID = securityTicket.TenantID; newStatusInHistory.CustomerOrder_Status_RefID = confirmedStatus; newStatusInHistory.PerformedBy_BusinessParticipant_RefID = account.BusinessParticipant_RefID; newStatusInHistory.Save(Connection, Transaction); procurementOrderITL.ProcurementOrderITL = customerOrder.ProcurementOrderITL; procurementOrderITL.ProcuringTenatID = customerOrder.OrderingCustomer_BusinessParticipant_RefID.ToString(); ORM_CMN_NumberRange_UsageArea numberRangeUsageArea = ORM_CMN_NumberRange_UsageArea.Query.Search(Connection, Transaction, new ORM_CMN_NumberRange_UsageArea.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, GlobalStaticMatchingID = NumberRangeGlobalPropertyMatchingID }).FirstOrDefault(); if (numberRangeUsageArea == null) { throw new Exception(String.Format("Number range usage area with GPMID = {0} was not found.", NumberRangeGlobalPropertyMatchingID)); } ORM_CMN_NumberRange numberRange = ORM_CMN_NumberRange.Query.Search(Connection, Transaction, new ORM_CMN_NumberRange.Query() { IsDeleted = false, Tenant_RefID = securityTicket.TenantID, NumberRange_UsageArea_RefID = numberRangeUsageArea.CMN_NumberRange_UsageAreaID }).FirstOrDefault(); if (numberRange == null) { throw new Exception(String.Format("Number range for area with GPMID = {0} was not found.", NumberRangeGlobalPropertyMatchingID)); } numberRange.Value_Current++; numberRange.Save(Connection, Transaction); string shipmentNumber = numberRange.FixedPrefix + numberRange.Value_Current.ToString().PadLeft(numberRange.Formatting_NumberLength, numberRange.Formatting_LeadingFillCharacter[0]); ORM_LOG_SHP_Shipment_Header shipmentHeader = new ORM_LOG_SHP_Shipment_Header(); shipmentHeader.LOG_SHP_Shipment_HeaderID = Guid.NewGuid(); shipmentHeader.RecipientBusinessParticipant_RefID = customerOrder.OrderingCustomer_BusinessParticipant_RefID; shipmentHeader.ShipmentHeaderITL = shipmentHeader.LOG_SHP_Shipment_HeaderID.ToString(); shipmentHeader.ShipmentHeader_Number = shipmentNumber; shipmentHeader.Shippipng_AddressUCD_RefID = customerOrder.ShippingAddressUCD_RefID; shipmentHeader.ShipmentPriority = 0; shipmentHeader.ShipmentHeader_ValueWithoutTax = customerOrder.TotalValue_BeforeTax; shipmentHeader.ShipmentHeader_Currency_RefID = customerOrder.CustomerOrder_Currency_RefID; shipmentHeader.Tenant_RefID = securityTicket.TenantID; shipmentHeader.IsDeleted = false; shipmentHeader.Save(Connection, Transaction); var customerOrderPositions = ORM_ORD_CUO_CustomerOrder_Position.Query.Search(Connection, Transaction, new ORM_ORD_CUO_CustomerOrder_Position.Query() { CustomerOrder_Header_RefID = customerOrder.ORD_CUO_CustomerOrder_HeaderID, IsDeleted = false, Tenant_RefID = securityTicket.TenantID }); if (customerOrderPositions != null) { foreach (var customerOrderPosition in customerOrderPositions) { ORM_LOG_SHP_Shipment_Position shipmentPosition = new ORM_LOG_SHP_Shipment_Position(); shipmentPosition.LOG_SHP_Shipment_PositionID = Guid.NewGuid(); shipmentPosition.ShipmentPositionITL = shipmentPosition.LOG_SHP_Shipment_PositionID.ToString(); shipmentPosition.LOG_SHP_Shipment_Header_RefID = shipmentHeader.LOG_SHP_Shipment_HeaderID; shipmentPosition.CMN_PRO_Product_RefID = customerOrderPosition.CMN_PRO_Product_RefID; shipmentPosition.CMN_PRO_ProductVariant_RefID = customerOrderPosition.CMN_PRO_Product_Variant_RefID; shipmentPosition.CMN_PRO_ProductRelease_RefID = customerOrderPosition.CMN_PRO_Product_Release_RefID; shipmentPosition.QuantityToShip = customerOrderPosition.Position_Quantity; shipmentPosition.ShipmentPosition_PricePerUnitValueWithoutTax = customerOrderPosition.Position_ValuePerUnit; shipmentPosition.ShipmentPosition_ValueWithoutTax = customerOrderPosition.Position_ValueTotal; shipmentPosition.IsCancelled = false; shipmentPosition.Tenant_RefID = securityTicket.TenantID; shipmentPosition.IsDeleted = false; shipmentPosition.Save(Connection, Transaction); ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition customerOrderPositionToShipmentPosition = new ORM_ORD_CUO_CustomerOrder_Position_2_ShipmentPosition(); customerOrderPositionToShipmentPosition.AssignmentID = Guid.NewGuid(); customerOrderPositionToShipmentPosition.LOG_SHP_Shipment_Position_RefID = shipmentPosition.LOG_SHP_Shipment_PositionID; customerOrderPositionToShipmentPosition.ORD_CUO_CustomerOrder_Position_RefID = customerOrderPosition.ORD_CUO_CustomerOrder_PositionID; customerOrderPositionToShipmentPosition.Tenant_RefID = securityTicket.TenantID; customerOrderPositionToShipmentPosition.IsDeleted = false; customerOrderPositionToShipmentPosition.Save(Connection, Transaction); } } //TO DO: UNCOMMENT AFTER JANKO ADD STATUSES //var shipmentStatusHistoryStatusID = ORM_LOG_SHP_Shipment_Status.Query.Search(Connection, Transaction, new ORM_LOG_SHP_Shipment_Status.Query() //{ // GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EShipmentStatus.Created), // Tenant_RefID = securityTicket.TenantID, // IsDeleted = false //}).Single().LOG_SHP_Shipment_StatusID; //ORM_LOG_SHP_Shipment_StatusHistory shipmentStatusHistory = new ORM_LOG_SHP_Shipment_StatusHistory(); //shipmentStatusHistory.LOG_SHP_Shipment_StatusHistoryID = Guid.NewGuid(); //shipmentStatusHistory.LOG_SHP_Shipment_Header_RefID = shipmentHeader.LOG_SHP_Shipment_HeaderID; //shipmentStatusHistory.LOG_SHP_Shipment_Status_RefID = shipmentStatusHistoryStatusID; //shipmentStatusHistory.PerformedBy_BusinessParticipant_RefID = securityTicket.TenantID; //shipmentStatusHistory.Tenant_RefID = securityTicket.TenantID; //shipmentStatusHistory.IsDeleted = false; //shipmentStatusHistory.Save(Connection, Transaction); ORM_LOG_SHP_ShipmentHeader_2_CustomerOrderHeader shipmentToCustomerOrderHeader = new ORM_LOG_SHP_ShipmentHeader_2_CustomerOrderHeader(); shipmentToCustomerOrderHeader.AssignmentID = Guid.NewGuid(); shipmentToCustomerOrderHeader.LOG_SHP_Shipment_Header_RefID = shipmentHeader.LOG_SHP_Shipment_HeaderID; shipmentToCustomerOrderHeader.ORD_CUO_CustomerOrder_Header_RefID = customerOrder.ORD_CUO_CustomerOrder_HeaderID; shipmentToCustomerOrderHeader.Tenant_RefID = securityTicket.TenantID; shipmentToCustomerOrderHeader.IsDeleted = false; shipmentToCustomerOrderHeader.Save(Connection, Transaction); confirmedProcurementOrders.Add(procurementOrderITL); } returnValue.Result = confirmedProcurementOrders.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_L5RS_CSaRSPfH_0449 Execute(DbConnection Connection, DbTransaction Transaction, P_L5RS_CSaRSPfH_0449 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5RS_CSaRSPfH_0449(); returnValue.Result = new L5RS_CSaRSPfH_0449(); FR_Base resultHeader, resultPosition, resultReturnPosition; if (Parameter.Positions.Count() <= 0) { returnValue.Status = FR_Status.Success; returnValue.Result = null; return(returnValue); } #region Load Shipment Header and calculate Total Price decimal totalValueWithoutTax = 0; #region Load Shipment Header var shipmentHeader = new ORM_LOG_SHP_Shipment_Header(); var result = shipmentHeader.Load(Connection, Transaction, Parameter.Positions[0].ShipmentHeaderID); if (result.Status != FR_Status.Success) { returnValue.Status = FR_Status.Error_Internal; returnValue.Result = null; return(returnValue); } #endregion #region Load Shipment Header Positions And Calculate Total Value var shipmentPositions = ORM_LOG_SHP_Shipment_Position.Query.Search( Connection, Transaction, new ORM_LOG_SHP_Shipment_Position.Query() { LOG_SHP_Shipment_Header_RefID = shipmentHeader.LOG_SHP_Shipment_HeaderID, Tenant_RefID = securityTicket.TenantID }).ToList(); foreach (var position in shipmentPositions) { totalValueWithoutTax += position.ShipmentPosition_ValueWithoutTax; } #endregion shipmentHeader.ShipmentHeader_ValueWithoutTax = totalValueWithoutTax; #endregion var resultShipmentPositionsIDs = new List <Guid>(); var resultReturnShipmentPositionIDs = new List <Guid>(); foreach (P_L5RS_CSaRSPfH_0449a position in Parameter.Positions) { #region Create Shipment Position Object var newShipmentPositionObject = new ORM_LOG_SHP_Shipment_Position(); newShipmentPositionObject.CMN_PRO_Product_RefID = position.ProductId; newShipmentPositionObject.Creation_Timestamp = DateTime.Now; newShipmentPositionObject.LOG_SHP_Shipment_Header_RefID = position.ShipmentHeaderID; newShipmentPositionObject.LOG_SHP_Shipment_PositionID = Guid.NewGuid(); newShipmentPositionObject.QuantityToShip = position.Quantity; newShipmentPositionObject.ShipmentPosition_ValueWithoutTax = position.PricePerUnit * position.Quantity; newShipmentPositionObject.ShipmentPosition_PricePerUnitValueWithoutTax = position.PricePerUnit; newShipmentPositionObject.Tenant_RefID = securityTicket.TenantID; shipmentHeader.ShipmentHeader_ValueWithoutTax += newShipmentPositionObject.ShipmentPosition_ValueWithoutTax; #endregion #region Create ReturnShipment Position Object var newReturnShipmentPositionObject = new ORM_LOG_SHP_ReturnShipment_Position(); newReturnShipmentPositionObject.Creation_Timestamp = DateTime.Now; newReturnShipmentPositionObject.Ext_Shipment_Position_RefID = newShipmentPositionObject.LOG_SHP_Shipment_PositionID; newReturnShipmentPositionObject.LOG_SHP_ReturnShipment_PositionID = Guid.NewGuid(); newReturnShipmentPositionObject.ReturnPolicy_RefID = position.ReturnPolicyId; newReturnShipmentPositionObject.ReturnProductOriginatedFromReceiptPosition_RefID = position.ReceiptPositionId; newReturnShipmentPositionObject.ReturnShipment_Header_RefID = position.ReturnShipmentHeaderID; newReturnShipmentPositionObject.Tenant_RefID = securityTicket.TenantID; #endregion #region Save Position resultPosition = newShipmentPositionObject.Save(Connection, Transaction); resultReturnPosition = newReturnShipmentPositionObject.Save(Connection, Transaction); if (resultPosition.Status != FR_Status.Success || resultReturnPosition.Status != FR_Status.Success) { returnValue.Status = FR_Status.Error_Internal; returnValue.Result = null; return(returnValue); } resultShipmentPositionsIDs.Add(newShipmentPositionObject.LOG_SHP_Shipment_PositionID); resultReturnShipmentPositionIDs.Add(newReturnShipmentPositionObject.LOG_SHP_ReturnShipment_PositionID); #endregion } #region Update Shipment Header with Total Value resultHeader = shipmentHeader.Save(Connection, Transaction); if (resultHeader.Status != FR_Status.Success) { returnValue.Status = FR_Status.Error_Internal; returnValue.Result = null; return(returnValue); } #endregion #region Fetch ShipmentHeader SupplierName var supplierBusinessParticipant = new ORM_CMN_BPT_BusinessParticipant(); supplierBusinessParticipant.Load(Connection, Transaction, shipmentHeader.RecipientBusinessParticipant_RefID); #endregion returnValue.Status = FR_Status.Success; returnValue.Result.ShipmentPositionIDs = resultShipmentPositionsIDs.ToArray(); returnValue.Result.ReturnShipmentPositionIDs = resultReturnShipmentPositionIDs.ToArray(); returnValue.Result.ShipmentHeaderSupplierName = supplierBusinessParticipant == null ? string.Empty : supplierBusinessParticipant.DisplayName; returnValue.Result.ShipmentHeaderNumber = shipmentHeader.ShipmentHeader_Number; returnValue.Result.ShipmentHeaderTotalValue = shipmentHeader.ShipmentHeader_ValueWithoutTax; return(returnValue); #endregion UserCode }
protected static FR_L5SO_RSP_1524 Execute(DbConnection Connection, DbTransaction Transaction, P_L5SO_RSP_1524 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L5SO_RSP_1524(); returnValue.Result = new L5SO_RSP_1524(); var shipmentPositionToReplace = new ORM_LOG_SHP_Shipment_Position(); shipmentPositionToReplace.Load(Connection, Transaction, Parameter.PositionID); var startProduct = new ORM_CMN_PRO_Product(); startProduct.Load(Connection, Transaction, shipmentPositionToReplace.CMN_PRO_Product_RefID); var finalProduct = new ORM_CMN_PRO_Product(); finalProduct.Load(Connection, Transaction, Parameter.ProductID); shipmentPositionToReplace.ShipmentPosition_PricePerUnitValueWithoutTax = Parameter.Price; shipmentPositionToReplace.ShipmentPosition_ValueWithoutTax = Parameter.Price * (Decimal)shipmentPositionToReplace.QuantityToShip; shipmentPositionToReplace.CMN_PRO_Product_RefID = Parameter.ProductID; returnValue.Result.ReplacedPosition = new FR_Guid(shipmentPositionToReplace.Save(Connection, Transaction), shipmentPositionToReplace.LOG_SHP_Shipment_PositionID).Result; P_L2LN_GALFTID_1530 langParam = new P_L2LN_GALFTID_1530(); langParam.Tenant_RefID = securityTicket.TenantID; SessionSecurityTicket fakeTicket = new SessionSecurityTicket(); var DBLanguages = cls_Get_All_Languages_ForTenantID.Invoke(Connection, Transaction, langParam, fakeTicket).Result; var languages = DBLanguages.Select(i => new ISOLanguage() { ISO = i.ISO_639_1, LanguageID = i.CMN_LanguageID }).ToList(); var dicts = EnumUtils.GetDictObjectsForStaticListData <ECustomMessages>(ResourceFilePath.CustomMessages, ORM_LOG_SHP_Shipment_Note.TableName, languages); ORM_LOG_SHP_Shipment_Note note = new ORM_LOG_SHP_Shipment_Note(); note.LOG_SHP_Shipment_NoteID = Guid.NewGuid(); note.Shipment_Header_RefID = Parameter.ShipmentHeaderID; note.Comment = String.Format(dicts["comment.article-replaced"].Contents[1].Content, startProduct.Product_Name.Contents[0].Content, startProduct.Product_Number, finalProduct.Product_Name.Contents[0].Content, finalProduct.Product_Number); note.Tenant_RefID = securityTicket.TenantID; note.IsNotePrintedOnDeliveryPaper = true; note.Save(Connection, Transaction); returnValue.Result.ReplacedPosition = new FR_Guid(shipmentPositionToReplace.Save(Connection, Transaction), shipmentPositionToReplace.LOG_SHP_Shipment_PositionID).Result; ORM_LOG_RSV_Reservation.Query.SoftDelete(Connection, Transaction, new ORM_LOG_RSV_Reservation.Query { LOG_SHP_Shipment_Position_RefID = shipmentPositionToReplace.LOG_SHP_Shipment_PositionID, IsDeleted = false }); #region CommentedUseful #endregion cls_Update_Current_TotalValue_on_ShipmentHeader_from_Positions.Invoke(Connection, Transaction, new P_L5SO_UCTVoSHfP_1549 { ShipmentHeaderID = Parameter.ShipmentHeaderID }, securityTicket); return(returnValue); #endregion UserCode }
protected static FR_Guids Execute(DbConnection Connection, DbTransaction Transaction, P_L5OS_ABL_1157 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guids(); List <Guid> retVal = new List <Guid>(); Guid shippmentHeaderID = Guid.Empty; P_L5OS_GASFD_1234 param = new P_L5OS_GASFD_1234(); param.HEC_DoctorID = Parameter.HEC_Doctor_RefID; var dateNow = DateTime.Now; param.ToDate = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 23, 59, 59, 999); param.FormDate = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 0, 0, 0, 0); var res = cls_Get_ActiveShippmentForDoctorID.Invoke(Connection, Transaction, param, securityTicket).Result; if (res != null && res.Length > 0) { shippmentHeaderID = res[0].LOG_SHP_Shipment_HeaderID; } if (shippmentHeaderID == Guid.Empty) { ORM_LOG_SHP_Shipment_Header header = new ORM_LOG_SHP_Shipment_Header(); header.IsShipped = false; header.Tenant_RefID = securityTicket.TenantID; header.Save(Connection, Transaction); shippmentHeaderID = header.LOG_SHP_Shipment_HeaderID; } for (int i = 0; i < Parameter.Count; i++) { ORM_LOG_SHP_Shipment_Position logShippmentPosition = new ORM_LOG_SHP_Shipment_Position(); logShippmentPosition.CMN_PRO_Product_RefID = Parameter.CMN_PRO_ProductID; logShippmentPosition.LOG_SHP_Shipment_Header_RefID = shippmentHeaderID; logShippmentPosition.Save(Connection, Transaction); ORM_HEC_ShippingPosition_BarcodeLabel shippmentLabel = new ORM_HEC_ShippingPosition_BarcodeLabel(); shippmentLabel.Doctor_RefID = Parameter.HEC_Doctor_RefID; shippmentLabel.LOG_SHP_Shipment_Position_RefID = logShippmentPosition.LOG_SHP_Shipment_PositionID; shippmentLabel.R_IsSubmission_Complete = false; shippmentLabel.Tenant_RefID = securityTicket.TenantID; List <ORM_HEC_ShippingPosition_BarcodeLabel> positionLabels; String barcodeLabel = ""; do { barcodeLabel = RandomString.Generate(9); var positionLabelsQuery = new ORM_HEC_ShippingPosition_BarcodeLabel.Query(); positionLabelsQuery.ShippingPosition_BarcodeLabel = barcodeLabel; positionLabelsQuery.Tenant_RefID = securityTicket.TenantID; positionLabelsQuery.IsDeleted = false; positionLabels = ORM_HEC_ShippingPosition_BarcodeLabel.Query.Search(Connection, Transaction, positionLabelsQuery); } while (positionLabels != null && positionLabels.Count != 0); shippmentLabel.ShippingPosition_BarcodeLabel = barcodeLabel; shippmentLabel.Save(Connection, Transaction); retVal.Add(shippmentLabel.HEC_ShippingPosition_BarcodeLabelID); } returnValue.Result = retVal.ToArray(); return(returnValue); #endregion UserCode }