Example #1
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();
        }
Example #2
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();
        }