private static void SetPackageLineItems(RateRequest request) { // request.RequestedShipment.PackageCount = "1"; var lineItem = new RequestedPackageLineItem { // SequenceNumber = "1", GroupPackageCount = "1", Weight = new Weight { Units = WeightUnits.LB, UnitsSpecified = true, Value = 2.0M, ValueSpecified = true }, Dimensions = new Dimensions { Length = "10", Width = "13", Height = "4", Units = LinearUnits.IN, UnitsSpecified = true }, // InsuredValue = new Money {Amount = 0, Currency = "USD"} }; request.RequestedShipment.RequestedPackageLineItems = new[] { lineItem }; }
private static void SetPackageLineItems(RateRequest request, Delivery delivery) { int i = 1; List <RequestedPackageLineItem> lstItems = new List <RequestedPackageLineItem>(); foreach (DeliveryItem item in delivery.Items) { SKUInfo sku = item.Product; RequestedPackageLineItem ritem = new RequestedPackageLineItem(); ritem.SequenceNumber = i.ToString(); // package sequence number ritem.GroupPackageCount = i.ToString(); // package weight ritem.Weight = new Weight(); ritem.Weight.Units = WeightUnits.LB; ritem.Weight.UnitsSpecified = true; ritem.Weight.Value = ValidationHelper.GetDecimal(sku.SKUWeight, 1) * item.Amount; ritem.Weight.ValueSpecified = true; // package dimensions ritem.Dimensions = new Dimensions(); ritem.Dimensions.UnitsSpecified = false; lstItems.Add(ritem); i += 1; } request.RequestedShipment.RequestedPackageLineItems = lstItems.ToArray(); }
private static void SetPackageLineItems(RateRequest r) { // Get the parts from the database List<PartPackage> items = new List<PartPackage>(); CurtDevDataContext db = new CurtDevDataContext(); foreach (int part in _parts) { // package type ID 1 = shipping box List<PartPackage> ppackages = db.PartPackages.Where(x => x.partID.Equals(part) && x.typeID.Equals(1)).ToList<PartPackage>(); foreach (PartPackage ppackage in ppackages) { for (int p = 0; p < ppackage.quantity; p++) { items.Add(ppackage); } } } List<RequestedPackageLineItem> packageitems = new List<RequestedPackageLineItem>(); List<FreightShipmentLineItem> freightitems = new List<FreightShipmentLineItem>(); //Weight TotalWeight = new Weight(); //TotalWeight.Units = WeightUnits.LB; //TotalWeight.Value = 0; for (int i = 0; i < items.Count; i++) { Weight pweight = null; Dimensions pdims = null; Volume pvolume = null; // package weight if (items[i].weight != null && items[i].weight > 0) { pweight = new Weight { Units = WeightUnits.LB, Value = (decimal)items[i].weight }; } if (items[i].height != null && items[i].height > 0 && items[i].width != null && items[i].width > 0 && items[i].length != null && items[i].length > 0) { pdims = new Dimensions { Height = Math.Ceiling((double)items[i].height).ToString(), Width = Math.Ceiling((double)items[i].width).ToString(), Length = Math.Ceiling((double)items[i].length).ToString(), Units = LinearUnits.IN }; pvolume = new Volume { Units = VolumeUnits.CUBIC_FT, UnitsSpecified = true, Value = Convert.ToDecimal((items[i].height * items[i].width * items[i].length) / 1728), ValueSpecified = true }; } RequestedPackageLineItem rpackage = new RequestedPackageLineItem { SequenceNumber = (packageitems.Count() + 1).ToString(), GroupPackageCount = "1", Weight = pweight, Dimensions = pdims }; FreightShipmentLineItem rfreight = new FreightShipmentLineItem { Dimensions = pdims, Weight = pweight, Volume = pvolume, Packaging = PhysicalPackagingType.BOX, PackagingSpecified = true, FreightClass = getFreightClass(Convert.ToDouble(pweight.Value / pvolume.Value)), FreightClassSpecified = true }; packageitems.Add(rpackage); freightitems.Add(rfreight); } r.RequestedShipment.RequestedPackageLineItems = packageitems.ToArray<RequestedPackageLineItem>(); r.RequestedShipment.FreightShipmentDetail.LineItems = freightitems.ToArray<FreightShipmentLineItem>(); //r.RequestedShipment.TotalWeight = TotalWeight; }
private static void SetPackageLineItems(RateRequest request, Delivery delivery) { int i = 1; List<RequestedPackageLineItem> lstItems = new List<RequestedPackageLineItem>(); foreach (DeliveryItem item in delivery.Items) { SKUInfo sku = item.Product; RequestedPackageLineItem ritem = new RequestedPackageLineItem(); ritem.SequenceNumber = i.ToString(); // package sequence number ritem.GroupPackageCount = i.ToString(); // package weight ritem.Weight = new Weight(); ritem.Weight.Units = WeightUnits.LB; ritem.Weight.UnitsSpecified = true; ritem.Weight.Value = ValidationHelper.GetDecimal(sku.SKUWeight, 1) * item.Amount; ritem.Weight.ValueSpecified = true; // package dimensions ritem.Dimensions = new Dimensions(); ritem.Dimensions.UnitsSpecified = false; lstItems.Add(ritem); i += 1; } request.RequestedShipment.RequestedPackageLineItems = lstItems.ToArray(); }
private RequestedPackageLineItem[] buildPackageSpec() { List<RequestedPackageLineItem> items = new List<RequestedPackageLineItem>(); int c = 0; foreach(var pkg in currentDespatch.Packages) { c++; RequestedPackageLineItem item = new RequestedPackageLineItem(); item.SequenceNumber = c.ToString(); item.Weight = new Weight(); item.Weight.Value = decimal.Parse(pkg.Weight); item.Weight.Units = WeightUnits.KG; item.Dimensions = new Dimensions(); item.Dimensions.Length = toInt(pkg.Depth); item.Dimensions.Height = toInt(pkg.Height); item.Dimensions.Width = toInt(pkg.Width); item.Dimensions.Units = LinearUnits.CM; item.CustomerReferences = new CustomerReference[2] { new CustomerReference(), new CustomerReference(), }; item.CustomerReferences[0].CustomerReferenceType = CustomerReferenceType.P_O_NUMBER; item.CustomerReferences[0].Value = currentDespatch.SalesOrderNumber; item.CustomerReferences[1].CustomerReferenceType = CustomerReferenceType.CUSTOMER_REFERENCE; item.CustomerReferences[1].Value = currentDespatch.SalesOrderNumber; items.Add(item); } return items.ToArray(); }