Esempio n. 1
0
        public DateRange Get(ShipmentType shipmentType)
        {
            var now = DateTime.Now;
            var range = new DateRange();
            int count = 1, i = 1;

            while (count <= shipmentType.Days.Max)
            {
                var dateAux = now.AddDays(i);
                if (dateAux.DayOfWeek != DayOfWeek.Saturday && dateAux.DayOfWeek != DayOfWeek.Sunday)
                {
                    if (shipmentType.Days.Min == count)
                    {
                        range.Min = dateAux;
                    }
                    if (shipmentType.Days.Max == count)
                    {
                        range.Max = dateAux;
                    }
                    count++;
                }
                i++;
            }
            return(range);
        }
Esempio n. 2
0
        public ShipmentType UpdateShipmentType(ShipmentType shipmentType)
        {
            _shipmentTypeRepository.Edit(shipmentType);
            _shipmentTypeRepository.Save();

            return(shipmentType);
        }
Esempio n. 3
0
 public ShipmentProvider(ShipmentType type, string company, double fixedCost, double costPerKilo)
 {
     this.Type        = type;
     this.Company     = company;
     this.FixedCost   = fixedCost;
     this.CostPerKilo = costPerKilo;
 }
        private RateResponse CallUPSRateRequest(string scode, int Qty, int nrBoxes, int itemsInLastBox, string fullBoxWeight, int valuePerFullBox, int valuePerPartialBox, string partialBoxWeight, inv_detl details, decimal unitPrice, RateService upsService)
        {
            RateResponse rateResponse = new RateResponse();

            try
            {
                RateRequest rateRequest = new RateRequest();
                AddCustomerClassification(rateRequest);
                AddUpsSecurity(upsService);
                UPS_Shipping_Rate.UPSRateService.RequestType request = new RequestType();
                String[] requestOption = { "Rate" };
                request.RequestOption = requestOption;
                rateRequest.Request   = request;
                ShipmentType shipment = new ShipmentType();
                AddShipper(shipment);
                AddShipFromAddress(shipment);
                AddShipToAddress(shipment);
                UPS_Shipping_Rate.UPSRateService.CodeDescriptionType service = new UPS_Shipping_Rate.UPSRateService.CodeDescriptionType();
                service.Code     = scode.ToString();
                shipment.Service = service;
                ShipmentRatingOptionsType optype = new ShipmentRatingOptionsType();
                optype.NegotiatedRatesIndicator = string.Empty;
                shipment.ShipmentRatingOptions  = optype;
                AddPackageArray(nrBoxes, itemsInLastBox, fullBoxWeight, partialBoxWeight, valuePerFullBox, valuePerPartialBox, details, shipment);
                AddInvoiceTotalType(Qty, unitPrice, shipment);
                rateRequest.Shipment = shipment;
                //  ServicePointManager.ServerCertificateValidationCallback = ValidateRemoteCertificate;
                rateResponse = upsService.ProcessRate(rateRequest);
            }
            catch (Exception ex)
            {
            }
            return(rateResponse);
        }
Esempio n. 5
0
 public DespatchAdviceType()
 {
     this._despatchLine                = new List <DespatchLineType>();
     this._shipment                    = new ShipmentType();
     this._originatorCustomerParty     = new CustomerPartyType();
     this._sellerSupplierParty         = new SupplierPartyType();
     this._buyerCustomerParty          = new CustomerPartyType();
     this._deliveryCustomerParty       = new CustomerPartyType();
     this._despatchSupplierParty       = new SupplierPartyType();
     this._signature                   = new List <SignatureType>();
     this._additionalDocumentReference = new List <DocumentReferenceType>();
     this._orderReference              = new List <OrderReferenceType>();
     this._lineCountNumeric            = new LineCountNumericType();
     this._note = new List <NoteType>();
     this._despatchAdviceTypeCode = new DespatchAdviceTypeCodeType();
     this._issueTime       = new IssueTimeType();
     this._issueDate       = new IssueDateType();
     this._uUID            = new UUIDType();
     this._copyIndicator   = new CopyIndicatorType();
     this._id              = new IDType();
     this._profileID       = new ProfileIDType();
     this._customizationID = new CustomizationIDType();
     this._uBLVersionID    = new UBLVersionIDType();
     this._uBLExtensions   = new List <UBLExtensionType>();
 }
Esempio n. 6
0
 public ReceiptAdviceType()
 {
     this.receiptLineField                 = new ObservableCollection <ReceiptLineType>();
     this.shipmentField                    = new ShipmentType();
     this.sellerSupplierPartyField         = new SupplierPartyType();
     this.buyerCustomerPartyField          = new CustomerPartyType();
     this.despatchSupplierPartyField       = new SupplierPartyType();
     this.deliveryCustomerPartyField       = new CustomerPartyType();
     this.signatureField                   = new ObservableCollection <SignatureType>();
     this.additionalDocumentReferenceField = new ObservableCollection <DocumentReferenceType>();
     this.despatchDocumentReferenceField   = new ObservableCollection <DocumentReferenceType>();
     this.orderReferenceField              = new ObservableCollection <OrderReferenceType>();
     this.lineCountNumericField            = new LineCountNumericType();
     this.noteField = new ObservableCollection <NoteType>();
     this.receiptAdviceTypeCodeField = new ReceiptAdviceTypeCodeType();
     this.documentStatusCodeField    = new DocumentStatusCodeType();
     this.issueTimeField             = new IssueTimeType();
     this.issueDateField             = new IssueDateType();
     this.uUIDField               = new UUIDType();
     this.copyIndicatorField      = new CopyIndicatorType();
     this.idField                 = new IDType();
     this.profileExecutionIDField = new ProfileExecutionIDType();
     this.profileIDField          = new ProfileIDType();
     this.customizationIDField    = new CustomizationIDType();
     this.uBLVersionIDField       = new UBLVersionIDType();
     this.uBLExtensionsField      = new ObservableCollection <UBLExtensionType>();
 }
Esempio n. 7
0
 public WaybillType()
 {
     this.signatureField                   = new ObservableCollection <SignatureType>();
     this.documentDistributionField        = new ObservableCollection <DocumentDistributionType>();
     this.exchangeRateField                = new ObservableCollection <ExchangeRateType>();
     this.documentReferenceField           = new ObservableCollection <DocumentReferenceType>();
     this.shipmentField                    = new ShipmentType();
     this.freightForwarderPartyField       = new PartyType();
     this.carrierPartyField                = new PartyType();
     this.consignorPartyField              = new PartyType();
     this.otherInstructionField            = new ObservableCollection <OtherInstructionType>();
     this.declaredCarriageValueAmountField = new DeclaredCarriageValueAmountType();
     this.adValoremIndicatorField          = new AdValoremIndicatorType();
     this.shippingOrderIDField             = new ShippingOrderIDType();
     this.noteField              = new ObservableCollection <NoteType>();
     this.descriptionField       = new ObservableCollection <DescriptionType>();
     this.nameField              = new NameType1();
     this.issueTimeField         = new IssueTimeType();
     this.issueDateField         = new IssueDateType();
     this.uUIDField              = new UUIDType();
     this.carrierAssignedIDField = new CarrierAssignedIDType();
     this.idField = new IDType();
     this.profileExecutionIDField = new ProfileExecutionIDType();
     this.profileIDField          = new ProfileIDType();
     this.customizationIDField    = new CustomizationIDType();
     this.uBLVersionIDField       = new UBLVersionIDType();
     this.uBLExtensionsField      = new ObservableCollection <UBLExtensionType>();
 }
        private void AddShipper(ShipmentType shipment)
        {
            ShipperType shipper = new ShipperType();

            AddShipperAddress(shipper);

            shipment.Shipper = shipper;
        }
        public IActionResult Insert([FromBody] CrudViewModel <ShipmentType> payload)
        {
            ShipmentType value  = payload.value;
            var          result = _functionalService.Insert <ShipmentType>(value);

            value = (ShipmentType)result.Data;
            return(Ok(value));
        }
Esempio n. 10
0
        public IActionResult Update([FromBody] CrudViewModel <ShipmentType> payload)
        {
            ShipmentType shipmentType = payload.value;

            _context.ShipmentType.Update(shipmentType);
            _context.SaveChanges();
            return(Ok(shipmentType));
        }
Esempio n. 11
0
        private static RateRequest CreateNewRateRequest(string rateType, ShipToAddress origin, ShipToAddress destination, PackageRequest package)
        {
            var request = new RequestType()
            {
                RequestOption = new string[] { "Rate" }
            };

            var shipperAddress = new AddressType()
            {
                City              = origin.City,
                PostalCode        = origin.Zip,
                StateProvinceCode = origin.State,
                CountryCode       = "US"
            };

            var shipper = new ShipperType()
            {
                ShipperNumber = Environment.GetEnvironmentVariable("UPS_ACCT_NUM"),
                Address       = shipperAddress
            };

            var shipToAddress = new ShipToAddressType()
            {
                AddressLine       = new string[] { destination.AddressLine1 },
                City              = destination.City,
                PostalCode        = destination.Zip,
                StateProvinceCode = destination.State,
                CountryCode       = "US"
            };

            var shipTo = new ShipToType()
            {
                Address = shipToAddress
            };

            var service = new CodeDescriptionType()
            {
                Code = GetServiceCode(rateType)
            };

            var pkgArray = CreatePackage(package);

            var shipment = new ShipmentType()
            {
                Shipper = shipper,
                ShipTo  = shipTo,
                Service = service,
                Package = pkgArray
            };

            var rateRequest = new RateRequest()
            {
                Request  = request,
                Shipment = shipment
            };

            return(rateRequest);
        }
Esempio n. 12
0
        private void AddShipper(ShipmentType shipment)
        {
            var shipper = new ShipperType();

            shipper.ShipperNumber = ShipperNumber;
            shipper.Name          = ShipperName;
            AddShipperAddress(shipper);
            shipment.Shipper = shipper;
        }
Esempio n. 13
0
 internal static ShipmentTypeDto ToShipmentTypeDto(this ShipmentType shipmentType)
 {
     return(new ShipmentTypeDto {
         Key = shipmentType.Key,
         Name = shipmentType.Name,
         Price = shipmentType.Price,
         CreatedOn = shipmentType.CreatedOn
     });
 }
Esempio n. 14
0
        internal static ShipmentType ToShipmentType(
            this ShipmentTypeRequestModel requestModel,
            ShipmentType existingShipmentType)
        {
            existingShipmentType.Name  = requestModel.Name;
            existingShipmentType.Price = requestModel.Price.Value;

            return(existingShipmentType);
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        public IActionResult Remove([FromBody] CrudViewModel <ShipmentType> payload)
        {
            ShipmentType shipmentType = _context.ShipmentType
                                        .Where(x => x.ShipmentTypeId == (int)payload.key)
                                        .FirstOrDefault();

            _context.ShipmentType.Remove(shipmentType);
            _context.SaveChanges();
            return(Ok(shipmentType));
        }
        private void AddShipToAddress(ShipmentType shipment)
        {
            ShipToType        shipTo        = new ShipToType();
            ShipToAddressType shipToAddress = new ShipToAddressType();

            //shipToAddress.PostalCode = txtZipcode.Text;
            shipToAddress.PostalCode  = "19850";
            shipToAddress.CountryCode = "US";
            shipTo.Address            = shipToAddress;
            shipment.ShipTo           = shipTo;
        }
        private void AddShipper(ShipmentType shipment)
        {
            var shipper = new ShipperType();

            shipper.ShipperNumber = ShipperNumber;
            log.Debug("<<<Shipper information>>>");
            log.Debug("shipper Number: " + ShipperNumber);
            shipper.Name = ShipperName;
            log.Debug("shipper Name:" + ShipperName);
            AddShipperAddress(shipper);
            shipment.Shipper = shipper;
        }
        private void LoadDropDownLists()
        {
            presenter.SetSources(Global.GetDefaultCurrency());

            ShipmentType.DataTextField  = "Name";
            ShipmentType.DataValueField = "Id";
            ShipmentType.DataBind();

            ItemCategory.DataTextField  = "Name";
            ItemCategory.DataValueField = "Id";
            ItemCategory.DataBind();
        }
        private void AddShipFromAddress(ShipmentType shipment)
        {
            ShipFromType shipFrom        = new ShipFromType();
            AddressType  shipFromAddress = new AddressType();

            //  shipFromAddress.AddressLine = new String[] { txtPShipFromAddress.Text };
            shipFromAddress.City              = "South El Monte";
            shipFromAddress.PostalCode        = "91733";
            shipFromAddress.StateProvinceCode = "CA";
            shipFromAddress.CountryCode       = "US";
            shipFrom.Address  = shipFromAddress;
            shipment.ShipFrom = shipFrom;
        }
Esempio n. 21
0
        private void AddBillShipperAccount(ShipmentType shipment)
        {
            var paymentInfo   = new PaymentInfoType();
            var shpmentCharge = new ShipmentChargeType();
            var billShipper   = new BillShipperType();

            billShipper.AccountNumber = BillShipperAccountNumber;
            shpmentCharge.BillShipper = billShipper;
            shpmentCharge.Type        = ShipmentChargeType;
            ShipmentChargeType[] shpmentChargeArray = { shpmentCharge };
            paymentInfo.ShipmentCharge  = shpmentChargeArray;
            shipment.PaymentInformation = paymentInfo;
        }
        private static void AddInvoiceTotalType(int Qty, decimal unitPrice, ShipmentType shipment)
        {
            InvoiceLineTotalType invoiceType = new InvoiceLineTotalType();

            invoiceType.CurrencyCode = "USD";
            int total = (int)(Qty * unitPrice);

            if (total % 100 > 0)
            {
                total = total + (100 - total % 100);
            }
            invoiceType.MonetaryValue = total.ToString();
            shipment.InvoiceLineTotal = invoiceType;
        }
 public ActionResult EditShipmentType(ShipmentType shipmentType)
 {
     try
     {
         db.Entry(shipmentType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ListAllShipmentTypes"));
     }
     catch
     {
         Response.Write("<script>alert('invalid Data! Try again.');</script>");
         return(View(shipmentType));
     }
 }
Esempio n. 24
0
        private void AddShipToAddress(ShipmentType shipment)
        {
            var shipTo        = new ShipToType();
            var shipToAddress = new ShipToAddressType();

            shipToAddress.AddressLine       = new String[] { ShipToAddressLine };
            shipToAddress.City              = ShipToCity;//txtPShipToCity.Text;
            shipToAddress.PostalCode        = ShipToPostalCode;
            shipToAddress.StateProvinceCode = ShipToStateProvinceCode;
            shipToAddress.CountryCode       = ShipToCountryCode;
            shipTo.Address  = shipToAddress;
            shipTo.Name     = ShipToName;
            shipment.ShipTo = shipTo;
        }
Esempio n. 25
0
        private void AddShipFromAddress(ShipmentType shipment)
        {
            var shipFrom        = new ShipFromType();
            var shipFromAddress = new ShipAddressType();

            shipFromAddress.AddressLine       = new String[] { ShipFromAddressLine };
            shipFromAddress.City              = ShipFromCity;
            shipFromAddress.PostalCode        = ShipFromPostalCode;
            shipFromAddress.StateProvinceCode = ShipFromStateProvinceCode;
            shipFromAddress.CountryCode       = ShipFromCountryCode;
            shipFrom.Address  = shipFromAddress;
            shipFrom.Name     = ShipFromName;
            shipment.ShipFrom = shipFrom;
        }
        private void AddPaymentInformation(ShipmentType shipment)
        {
            var paymentInfo = new PaymentInfoType();

            var paymentInfoType = new PaymentType();

            paymentInfoType.Code = "06";
            var shipper = new ShipperType();

            shipper.ShipperNumber = ShipperNumber;
            shipper.Name          = ShipperName;
            AddShipperAddress(shipper);
            shipment.Shipper = shipper;
        }
 public ActionResult DeleteShipmentType(ShipmentType shipmentType)
 {
     try
     {
         var myShipmentType = db.ShipmentTypes.Find(shipmentType.ID);
         db.ShipmentTypes.Remove(myShipmentType);
         db.SaveChanges();
         return(RedirectToAction("ListAllShipmentTypes"));
     }
     catch
     {
         return(View(shipmentType));
     }
 }
Esempio n. 28
0
        public ActionResult ShipEbay(long id, string shippingService, string trackingno, string feedbackComment)
        {
            if (string.IsNullOrEmpty(feedbackComment))
            {
                return(Json("Please enter a feedback".ToJsonFail()));
            }

            if (string.IsNullOrEmpty(shippingService))
            {
                return(Json("Please specify a shipping service".ToJsonFail()));
            }

            var order = repository.GetOrder(subdomainid.Value, id);

            if (order == null)
            {
                return(Json("Order not found".ToJsonFail()));
            }

            var transaction = new Transaction(order, repository, sessionid.Value);

            // update local order
            transaction.UpdateOrderAsShipped(shippingService, trackingno);

            // update ebay order
            var token       = repository.GetOAuthToken(subdomainid.Value, OAuthTokenType.EBAY, true);
            var ebayservice = new OrderService(token.token_key);

            // create feedback entry
            var feedback = new FeedbackInfoType();

            feedback.CommentText = feedbackComment;
            feedback.CommentType = CommentTypeCodeType.Positive;

            // create shipment entry
            var shipment = new ShipmentType();

            shipment.ShipmentTrackingNumber = trackingno;
            shipment.ShippingCarrierUsed    = shippingService;

            // complete sale has to be called for each orderitem
            foreach (var ebayOrderitem in order.ebay_order.ebay_orderitems)
            {
                ebayservice.CompleteSale(order.ebay_order.orderid, ebayOrderitem.lineid, true, true, feedback, shipment);
            }


            return(Json("Order shipped".ToJsonOKMessage()));
        }
        private void AddShipFromAddress(ShipmentType shipment)
        {
            var shipFrom        = new ShipFromType();
            var shipFromAddress = new ShipAddressType();

            shipFromAddress.AddressLine       = new[] { ShipperAddressLine };
            shipFromAddress.City              = ShipperCity;
            shipFromAddress.PostalCode        = ShipperPostalCode;
            shipFromAddress.StateProvinceCode = ShipperStateProvinceCode;
            shipFromAddress.CountryCode       = ShipperCountryCode;
            shipFrom.Address = shipFromAddress;
            shipFrom.Name    = ShipperName;
            shipFrom.CompanyDisplayableName = ShipperCompany;
            shipment.ShipFrom = shipFrom;
        }
Esempio n. 30
0
 public OperationResult <ShipmentType> AddShipmentType(ShipmentType shipmnetType)
 {
     if (_shipmentTypeRepository.GetSingleByName(shipmnetType.Name) != null)
     {
         return(new OperationResult <ShipmentType>(false));
     }
     shipmnetType.Key       = Guid.NewGuid();
     shipmnetType.CreatedOn = DateTime.Now;
     _shipmentTypeRepository.Add(shipmnetType);
     _shipmentTypeRepository.Save();
     return(new OperationResult <ShipmentType>(true)
     {
         Entity = shipmnetType
     });
 }
Esempio n. 31
0
        private RateRequest CreateRateRequest(RateService rate)
        {
            RateRequest rateRequest = new RateRequest();
            UPSSecurity upss = new UPSSecurity();
            UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken();
            upssSvcAccessToken.AccessLicenseNumber = AccessKey;
            upss.ServiceAccessToken = upssSvcAccessToken;

            UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken();
            upssUsrNameToken.Username = UserName;
            upssUsrNameToken.Password = Password;
            upss.UsernameToken = upssUsrNameToken;
            rate.UPSSecurityValue = upss;

            RequestType request = new RequestType();
            String[] requestOption = { "Shop" };
            request.RequestOption = requestOption;
            rateRequest.Request = request;

            ShipmentType shipment = new ShipmentType();

            ShipperType shipper = new ShipperType();
            //shipper.ShipperNumber = "ISUS01";
            AddressType shipperAddress = new AddressType();
            String[] addressLine = { "Shipper\'s address line" };
            shipperAddress.AddressLine = addressLine;
            shipperAddress.City = "Shipper\'s city";
            shipperAddress.PostalCode = PostalCodeFrom;
            //shipperAddress.StateProvinceCode = UpsItem.CountryCode;
            shipperAddress.CountryCode = CountryCodeFrom;
            shipperAddress.AddressLine = addressLine;
            shipper.Address = shipperAddress;
            shipment.Shipper = shipper;

            ShipFromType shipFrom = new ShipFromType();
            AddressType shipFromAddress = new AddressType();
            shipFromAddress.AddressLine = addressLine;
            shipFromAddress.City = "ShipFrom city";
            shipFromAddress.PostalCode = PostalCodeFrom;
            //shipFromAddress.StateProvinceCode = "GA";
            shipFromAddress.CountryCode = CountryCodeFrom;
            shipFrom.Address = shipFromAddress;
            shipment.ShipFrom = shipFrom;

            ShipToType shipTo = new ShipToType();
            ShipToAddressType shipToAddress = new ShipToAddressType();
            String[] addressLine1 = { AddressTo };
            shipToAddress.AddressLine = addressLine1;
            shipToAddress.City = CityTo;
            shipToAddress.PostalCode = PostalCodeTo;
            shipToAddress.StateProvinceCode = StateTo;
            shipToAddress.CountryCode = CountryCodeTo;
            shipTo.Address = shipToAddress;
            shipment.ShipTo = shipTo;

            //CodeDescriptionType service = new CodeDescriptionType();
            //service.Code = "02";
            //shipment.Service = service;
            float weight = MeasureUnits.ConvertWeight(ShoppingCart.TotalShippingWeight, MeasureUnits.WeightUnit.Kilogramm, MeasureUnits.WeightUnit.Pound);

            var data = new List<PackageType>();
            if (!IsPackageTooHeavy(weight))
            {

                PackageType package = new PackageType();
                PackageWeightType packageWeight = new PackageWeightType();
                packageWeight.Weight = weight.ToString("F3").Replace(',', '.');

                CodeDescriptionType uom = new CodeDescriptionType();
                uom.Code = "LBS";
                uom.Description = "Pounds";
                packageWeight.UnitOfMeasurement = uom;
                package.PackageWeight = packageWeight;

                CodeDescriptionType packType = new CodeDescriptionType();
                packType.Code = "02";
                package.PackagingType = packType;
                data.Add(package);
            }
            else
            {
                int totalPackages = 1;
                int totalPackagesWeights = 1;
                if (IsPackageTooHeavy(weight))
                {
                    totalPackagesWeights = SQLDataHelper.GetInt(Math.Ceiling(weight / MaxPackageWeight));
                }

                totalPackages = totalPackagesWeights;
                if (totalPackages == 0)
                    totalPackages = 1;

                float weight2 = weight / totalPackages;

                if (weight2 < 1)
                    weight2 = 1;
                for (int i = 0; i < totalPackages; i++)
                {
                    PackageType package = new PackageType();
                    PackageWeightType packageWeight = new PackageWeightType();
                    packageWeight.Weight = weight2.ToString("F3");

                    CodeDescriptionType uom = new CodeDescriptionType();
                    uom.Code = "LBS";
                    uom.Description = "Pounds";
                    packageWeight.UnitOfMeasurement = uom;
                    package.PackageWeight = packageWeight;

                    CodeDescriptionType packType = new CodeDescriptionType();
                    packType.Code = GetPackagingTypeCode(PackagingType);
                    package.PackagingType = packType;
                    data.Add(package);
                }
            }

            PackageType[] pkgArray = data.ToArray();
            shipment.Package = pkgArray;
            rateRequest.Shipment = shipment;

            CodeDescriptionType pckup = new CodeDescriptionType() { Code = GetPickupTypeCode(PickupType) };
            rateRequest.PickupType = pckup;

            CodeDescriptionType ccustomer = new CodeDescriptionType() { Code = GetCustomerClassificationCode(CustomerType) };
            rateRequest.CustomerClassification = ccustomer;

            System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();

            return rateRequest;
        }
Esempio n. 32
0
        /// <summary>
        /// Enables a seller to do various tasks after the creation of a single line item or
        /// multiple line item order. Typically, this call is used after the
        /// buyer has paid for the order, but it can be called by the
        /// seller beforehand. Typical post-payment tasks available to this call include
        /// marking the order as paid, marking the order as shipped, providing shipment tracking
        /// details, and leaving feedback for the buyer.
        /// </summary>
        /// 
        /// <param name="ItemID">
        /// Unique identifier for an eBay item listing. An <b>ItemID</b> can be paired up
        /// with a corresponding <b>TransactionID</b> and used in the <b>CompleteSale</b> request
        /// to identify a single line item order.
        /// 
        /// Unless an <b>OrderLineItemID</b> is used to identify a single line item order,
        /// or the <b>OrderID</b> is used to identify a single or multiple line item
        /// order, the <b>ItemID</b>/<b>TransactionID</b> pair must be
        /// specified. For a multiple line item order, <b>OrderID</b>
        /// must be used. If <b>OrderID</b> or <b>OrderLineItemID</b> are specified, the
        /// <b>ItemID</b>/<b>TransactionID</b> pair is ignored if present in the same request.
        /// </param>
        ///
        /// <param name="TransactionID">
        /// Unique identifier for an eBay order line item (transaction). The
        /// <b>TransactionID</b> can be paired up with the corresponding <b>ItemID</b> and used in
        /// the <b>CompleteSale</b> request to identify a single line item order.
        /// 
        /// Unless an <b>OrderLineItemID</b> is used to identify a single line item order,
        /// or the <b>OrderID</b> is used to identify a single or multiple line item
        /// order, the <b>ItemID</b>/<b>TransactionID</b> pair must be
        /// specified. For a multiple line item order, <b>OrderID</b>
        /// must be used. If <b>OrderID</b> or <b>OrderLineItemID</b> are specified, the
        /// <b>ItemID</b>/<b>TransactionID</b> pair is ignored if present in the same request.
        /// </param>
        ///
        /// <param name="FeedbackInfo">
        /// This container is used by the seller to leave feedback for the buyer for the
        /// order line item identified in the call request. The seller must include and
        /// specify all fields of this type, including the buyer's eBay User ID, the
        /// Feedback rating (a seller can only leave a buyer a "Positive" rating), and a
        /// comment, which helps justify the Feedback rating. The eBay User ID must match 
        /// the buyer who bought the order line item, or an error will occur. An error will 
        /// also occur if Feedback has already been left for the buyer (either through API 
        /// or the Web flow).
        /// 
        /// To determine if Feedback has already been left for an order line item, you can 
        /// call <b class="con">GetFeedback</b>, passing in the 
        /// <b class="con">OrderLineItemID</b> value in the call request.
        /// </param>
        ///
        /// <param name="Shipped">
        /// The seller includes and sets this field to true if the order has been
        /// shipped. If the call is successful, the order line item(s) are marked as
        /// Shipped in My eBay.
        /// 
        /// If the seller includes and sets this field to false, the order line item(s)
        /// are marked (or remain) as Not Shipped in My eBay.
        /// 
        /// If this field is not included, the shipped status of the order line
        /// item(s) remain unchanged in My eBay.
        /// 
        /// If shipment tracking information is provided for an order line item through
        /// the Shipment container in the same request, the order line item is marked as
        /// shipped automatically and the <b>Shipped</b> field is not
        /// required.
        /// </param>
        ///
        /// <param name="Paid">
        /// The seller includes and sets this field to true if the buyer has paid for
        /// the order. If the call is successful, the
        /// order line item(s) are marked as Paid in My eBay.
        /// 
        /// If the seller includes and sets this field to false, the order line item(s)
        /// are marked (or remain) as Not Paid in My eBay.
        /// 
        /// If this field is not included, the paid status of the order line
        /// item(s) remain unchanged in My eBay.
        /// </param>
        ///
        /// <param name="ListingType">
        /// This field is required if <b>CompleteSale</b> is being used for a Half.com
        /// order. The value should be set to <i>Half</i>, which is the only applicable
        /// <b>ListingType</b> value for this call.
        /// </param>
        ///
        /// <param name="Shipment">
        /// Container consisting of shipment tracking information, shipped time, and an
        /// optional text field to provide additional details to the buyer. Setting the
        /// tracking number and shipping carrier automatically marks the item as shipped
        /// and the <b>Shipped</b> field is not required.
        /// 
        /// (If you supply <b>ShipmentTrackingNumber</b> you must also supply 
        /// <b>ShippingCarrierUsed</b>, otherwise you will get an error.
        /// 
        /// To modify the shipping tracking number and/or carrier, supply the new number
        /// in <b>ShipmentTrackingNumber</b> or supply the value for
        /// <b>ShippingCarrierUsed</b> or both. The old number and carrier
        /// are deleted and the new ones are added.
        /// 
        /// To simply delete the current tracking details altogether, supply empty
        /// <b>Shipment</b> tags.
        ///  
        /// 
        /// <span class="tablenote"><b>Note:</b>
        /// Top-Rated sellers must have a record of uploading shipment tracking
        /// information (through site or through API) for at least 90 percent of their order line
        /// items (purchased by U.S. buyers) to keep their status as Top-Rated sellers. For more
        /// information on the requirements to becoming a Top-Rated Seller, see the 
        /// <a href="http://pages.ebay.com/help/sell/top-rated.html">Becoming a Top-Rated Seller and qualifying for Top-Rated Plus</a> 
        /// customer support page.
        /// </span>
        /// 
        /// </param>
        ///
        /// <param name="OrderID">
        /// A unique identifier that identifies a single line item or multiple line
        /// item order. 
        ///  
        /// For a single line item order, the <b>OrderID</b> value is identical to the
        /// <b>OrderLineItemID</b> value that is generated upon creation of the order line
        /// item. For multiple line item orders, the <b>OrderID</b> value is created by eBay
        /// when the buyer is purchasing multiple order line items from the same seller at the same time.
        /// For multiple line item orders not going through the eBay Cart flow, a Combined Invoice order can be created by the seller
        /// through the <b>AddOrder</b> call. The <b>OrderID</b> can be used in the <b>CompleteSale</b>
        /// request to identify a single or multiple line item order.
        /// 
        /// <b>OrderID</b> overrides an <b>OrderLineItemID</b> or <b>ItemID</b>/<b>TransactionID</b> pair if
        /// these fields are also specified in the same request.
        /// </param>
        ///
        /// <param name="OrderLineItemID">
        /// <b>OrderLineItemID</b> is a unique identifier for an eBay order line item and
        /// is based upon the concatenation of <b>ItemID</b> and <b>TransactionID</b>, with a
        /// hyphen in between these two IDs. For a single line item order, the
        /// <b>OrderLineItemID</b> value can be passed into the <b>OrderID</b> field in the
        /// <b>CompleteSale</b> request.
        /// 
        /// Unless an <b>ItemID</b>/<b>TransactionID</b> pair is used to identify a single line
        /// item order, or the <b>OrderID</b> is used to identify a single or multiple line
        /// item order, the <b>OrderLineItemID</b> must be specified.
        /// For a multiple line item order, <b>OrderID</b> must be
        /// used. If <b>OrderLineItemID</b> is specified, the <b>ItemID</b>/<b>TransactionID</b> pair are
        /// ignored if present in the same request.
        /// </param>
        ///
        public void CompleteSale(string ItemID, string TransactionID, FeedbackInfoType FeedbackInfo, bool Shipped, bool Paid, ListingTypeCodeType ListingType, ShipmentType Shipment, string OrderID, string OrderLineItemID)
        {
            this.ItemID = ItemID;
            this.TransactionID = TransactionID;
            this.FeedbackInfo = FeedbackInfo;
            this.Shipped = Shipped;
            this.Paid = Paid;
            this.ListingType = ListingType;
            this.Shipment = Shipment;
            this.OrderID = OrderID;
            this.OrderLineItemID = OrderLineItemID;

            Execute();
        }
Esempio n. 33
0
        public ExternalOrderShippedResult SetOrderShipped(IOrderShipmentRequest shipmentRequests)
        {
            CompleteSaleCall completeSales = new CompleteSaleCall(eBayContext);

            ExternalOrderShippedResult result = new ExternalOrderShippedResult() { Success = false, ShippingResults = new List<ShippingResult>() };
            bool allSuccess = true;

            int successCount = 0;

            int failedCount = 0;

            StringBuilder errorBuilder = new StringBuilder();

            foreach (eBayOrderShipmentIfo request in shipmentRequests.ShipmentList)
            {
                ShippingResult shippingResult = new ShippingResult()
                {
                    StoreProviderOrderId = request.OrderId,
                    ExternalOrderHeaderId = request.ExternalOrderHeaderId,
                    ShippedDate = request.ShipmentDate,
                };

                try
                {
                    completeSales.OrderID = request.OrderId;

                    ShipmentType shipment = new ShipmentType();

                    shipment.ShippedTime = request.ShipmentDate;

                    completeSales.Shipment = shipment;

                    completeSales.Shipped = true;

                    completeSales.Site = SiteCodeType.UK;

                    completeSales.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);

                    completeSales.Execute();

                    if (completeSales.ApiResponse.Ack == AckCodeType.Success)
                    {

                        shippingResult.Success = true;

                        successCount += 1;

                    }
                    else
                    {
                        allSuccess = false;
                        shippingResult.Success = false;

                        StringBuilder sb = new StringBuilder();

                        foreach (ErrorType error in completeSales.ApiResponse.Errors)
                        {
                            sb.Append(error.LongMessage + "; ");
                        }

                        shippingResult.ErrorMessage = string.Format("eBay Code returned : {0}; Error: {1}", completeSales.ApiResponse.Ack.ToString(), sb.ToString().Trim());

                        errorBuilder.Append(sb.ToString() + " | ");
                        failedCount += 1;
                    }

                }
                catch (Exception ex)
                {
                    allSuccess = false;

                    shippingResult.Success = false;

                    shippingResult.ErrorMessage = string.Format("Error occurred while updating shipping info: {0}, Error: {1}", request.OrderId, ex.Message);

                    errorBuilder.Append(shippingResult.ErrorMessage + " | ");

                    failedCount += 1;
                }

            }

            if (allSuccess)
            {
                result.Success = true;

            }
            else
            {
                result.Success = false;
                result.ErrorMessage = "Some orders could not be shipped";
            }

            if (successCount > 0)
            {

                result.SuccessMessage = string.Format("Successfully Shipped {0} Orders ", successCount);
            }

            if (failedCount > 0)
            {

                result.ErrorMessage = string.Format("Failed to Ship {0} Orders, please check and try again.", failedCount);

                result.ErrorMessage += "<br/> " + errorBuilder.ToString();

            }

            return result;
        }
    public CompleteSaleResponseType UpdateShippingInfo(string itemID, string transactionID, string trackingNumber, string userToken)
    {
        string callname = "CompleteSale";

        #region Initialise Needed Variables

        //Get the Server to use (Sandbox or Production)
        string serverUrl = ConfigurationManager.AppSettings["TradingService"];

        //SiteID = 0  (US) - UK = 3, Canada = 2, Australia = 15, ....
        string siteID = "0";

        eBayAPIInterfaceService service = new eBayAPIInterfaceService();
        string requestURL = serverUrl + "?callname=" + callname + "&siteid=" + siteID
                            + "&appid=" + AppID + "&version=" + version + "&routing=default";
        service.Url = requestURL;

        // Set credentials
        service.RequesterCredentials = new CustomSecurityHeaderType();
        service.RequesterCredentials.Credentials = new UserIdPasswordType();
        service.RequesterCredentials.Credentials.AppId = AppID;
        service.RequesterCredentials.Credentials.DevId = DevID;
        service.RequesterCredentials.Credentials.AuthCert = CertID;
        service.RequesterCredentials.eBayAuthToken = userToken;
        #endregion

        CompleteSaleRequestType request = new CompleteSaleRequestType();
        request.WarningLevel = WarningLevelCodeType.High;
        request.ItemID = itemID;
        request.TransactionID = transactionID;

        ShipmentType shipment = new ShipmentType();
        ShipmentTrackingDetailsType shipmentDetails = new ShipmentTrackingDetailsType();
        shipmentDetails.ShipmentTrackingNumber = trackingNumber;
        shipmentDetails.ShippingCarrierUsed = ConfigurationManager.AppSettings["ShippingCarrier"];
        shipment.ShipmentTrackingDetails = new ShipmentTrackingDetailsType[] { shipmentDetails };
        request.Shipment = shipment;
        request.Version = version;

        try
        {
            CompleteSaleResponseType response = service.CompleteSale(request);
            return response;
        }
        catch (Exception ex)
        {
            if (ex.Message.ToLower().Contains("auth token"))
                throw new InvalidEbayCredentialsException();
            else
                throw ex;
        }
    }