Пример #1
0
 /// <remarks/>
 public void ProcessShipmentAsync(ShipmentRequest ShipmentRequest, object userState) {
     if ((this.ProcessShipmentOperationCompleted == null)) {
         this.ProcessShipmentOperationCompleted = new System.Threading.SendOrPostCallback(this.OnProcessShipmentOperationCompleted);
     }
     this.InvokeAsync("ProcessShipment", new object[] {
                 ShipmentRequest}, this.ProcessShipmentOperationCompleted, userState);
 }
        public ShipmentResponse CallUPSShipmentRequest(string serviceCode, int ShipmentID)
        {
            //var dbShipment = ShipmentModule.GetShipmentByID(ShipmentID);
            var shipmentDetails = ShipmentModule.GetShipmentShipmentDetails(ShipmentID);

            var shpSvc = new ShipService();
            var shipmentRequest = new ShipmentRequest();
            AddUpsSecurity(shpSvc);
            var request = new RequestType();
            String[] requestOption = { "1" }; //{ "nonvalidate" };
            request.RequestOption = requestOption;
            shipmentRequest.Request = request;
            var shipment = new ShipmentType();
            shipment.Description = "Ship webservice example";
            AddShipper(shipment);
            AddShipFromAddress(shipment);
            AddShipToAddress(shipment);
            AddBillShipperAccount(shipment);
            //AddPaymentInformation(shipment);

            var service = new ServiceType();
            service.Code = serviceCode;
            shipment.Service = service;

            PackageType[] pkgArray;
            pkgArray = new PackageType[shipmentDetails.Count];
            var i = 0;
            foreach (var box in shipmentDetails)
            {
                AddPackage(box.UnitWeight.Value, Convert.ToInt32(box.UnitPrice), box.DimensionH.Value, box.DimensionD.Value, box.DimensionL.Value, PackagingTypeCode, "USD", pkgArray, i);
                i = i + 1;
            }
            shipment.Package = pkgArray;

            var labelSpec = new LabelSpecificationType();
            var labelStockSize = new LabelStockSizeType();
            labelStockSize.Height = "3";
            labelStockSize.Width = "2";
            labelSpec.LabelStockSize = labelStockSize;
            var labelImageFormat = new LabelImageFormatType();
            labelImageFormat.Code = "GIF";//"SPL";
            labelSpec.LabelImageFormat = labelImageFormat;
            shipmentRequest.LabelSpecification = labelSpec;
            shipmentRequest.Shipment = shipment;

            var shipmentResponse = shpSvc.ProcessShipment(shipmentRequest);
            return shipmentResponse;
        }
Пример #3
0
 /// <remarks/>
 public void ProcessShipmentAsync(ShipmentRequest ShipmentRequest) {
     this.ProcessShipmentAsync(ShipmentRequest, null);
 }