Beispiel #1
0
 public static Shipment CloneAddressesFromInterface(IShipment source)
 {
     Shipment result = new Shipment();
     result.DestinationAddress = MerchantTribe.Web.Geography.SimpleAddress.CloneAddress(source.DestinationAddress);
     result.SourceAddress = MerchantTribe.Web.Geography.SimpleAddress.CloneAddress(source.SourceAddress);
     return result;
 }
Beispiel #2
0
 private MerchantTribe.Shipping.IShipment ConvertGroupsToShipments(List <ShippingGroup> groups)
 {
     MerchantTribe.Shipping.IShipment result = new MerchantTribe.Shipping.Shipment();
     foreach (ShippingGroup g in groups)
     {
         result.Items.Add(g.AsIShippable());
         result.DestinationAddress = g.DestinationAddress;
         result.SourceAddress      = g.SourceAddress;
     }
     return(result);
 }
Beispiel #3
0
        protected void btnTest_Click(object sender, EventArgs e)
        {
            this.SaveData();

            var testSettings = new FedExGlobalServiceSettings();
            testSettings.AccountNumber = this.AccountNumberField.Text;
            testSettings.DefaultDropOffType = (DropOffType)int.Parse(this.lstDropOffType.SelectedValue);
            testSettings.DefaultPackaging = (PackageType)int.Parse(this.lstPackaging.SelectedValue);
            testSettings.DiagnosticsMode = true;
            testSettings.ForceResidentialRates = this.chkResidential.Checked;
            testSettings.MeterNumber = this.MeterNumberField.Text.Trim();
            testSettings.UseListRates = this.chkListRates.Checked;
            testSettings.UserKey = this.KeyField.Text.Trim();
            testSettings.UserPassword = this.PasswordField.Text.Trim();

            var logger = new MerchantTribe.Web.Logging.TextLogger();

            var testSvc = new MerchantTribe.Shipping.FedEx.FedExProvider(testSettings, logger);
            testSvc.Settings.ServiceCode = int.Parse(this.lstServicesTest.SelectedValue);
            testSvc.Settings.Packaging = (int)testSettings.DefaultPackaging;

            var testShipment = new Shipment();
            testShipment.DestinationAddress = this.DestinationAddress.GetAsAddress();
            testShipment.SourceAddress = this.SourceAddress.GetAsAddress();
            var testItem = new Shippable();
            testItem.BoxHeight = decimal.Parse(this.TestHeight.Text);
            testItem.BoxLength = decimal.Parse(this.TestLength.Text);
            testItem.BoxWidth = decimal.Parse(this.TestWidth.Text);
            testItem.BoxLengthType = LengthType.Inches;
            testItem.BoxWeight = decimal.Parse(this.TestWeight.Text);
            testItem.BoxWeightType = MerchantTribe.Shipping.WeightType.Pounds;
            testShipment.Items.Add(testItem);

            StringBuilder sb = new StringBuilder();
            sb.Append("Starting Rate Test at " + DateTime.Now + "<br />");
            var rates = testSvc.RateShipment(testShipment);
            foreach (var r in rates)
            {
                sb.Append("Rate Found: " + r.EstimatedCost.ToString("C") + " | " + r.DisplayName + " (" + r.ServiceCodes + ", " + r.ServiceId + ")<br />");
            }
            sb.Append("<br />");
            sb.Append("LOG:<br />");
            foreach (var m in logger.Messages)
            {
                sb.Append(m + "<br />");
            }
            sb.Append("Finished Rate Test at " + DateTime.Now);
            this.litTestOuput.Text = sb.ToString();
        }
 private MerchantTribe.Shipping.IShipment ConvertGroupsToShipments(List<ShippingGroup> groups)
 {
     MerchantTribe.Shipping.IShipment result = new MerchantTribe.Shipping.Shipment();
     foreach (ShippingGroup g in groups)
     {
         result.Items.Add(g.AsIShippable());
         result.DestinationAddress = g.DestinationAddress;
         result.SourceAddress = g.SourceAddress;
     }
     return result;
 }