Exemplo n.º 1
0
        private void SaveData()
        {
            ShippingMethod.Name           = this.NameField.Text.Trim();
            ShippingMethod.ZoneId         = long.Parse(this.lstZones.SelectedItem.Value);
            ShippingMethod.AdjustmentType = (ShippingMethodAdjustmentType)int.Parse(AdjustmentDropDownList.SelectedValue);
            ShippingMethod.Adjustment     = decimal.Parse(AdjustmentTextBox.Text, System.Globalization.NumberStyles.Currency);

            // Global Settings
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsAccountNumber    = this.AccountNumberField.Text.Trim();
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsForceResidential = this.ResidentialAddressCheckBox.Checked;
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsPickupType       = int.Parse(this.PickupTypeRadioButtonList.SelectedValue);
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsDefaultService   = int.Parse(this.DefaultServiceField.SelectedValue);
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsDefaultPackaging = int.Parse(this.DefaultPackagingField.SelectedValue);
            //MyPage.Services.CurrentStore.Settings.ShippingUpsDefaultPayment = int.Parse(this.DefaultPaymentField.SelectedValue);
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsSkipDimensions = this.SkipDimensionsCheckBox.Checked;
            MyPage.MTApp.CurrentStore.Settings.ShippingUPSDiagnostics    = this.chkDiagnostics.Checked;



            // Method Settings
            UPSServiceSettings Settings = new UPSServiceSettings();

            Settings.Merge(ShippingMethod.Settings);

            List <MerchantTribe.Shipping.IServiceCode> filter = new List <MerchantTribe.Shipping.IServiceCode>();

            if (this.rbFilterMode.SelectedValue == "0")
            {
                Settings.GetAllRates = false;

                foreach (ListItem item in ShippingTypesCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        MerchantTribe.Shipping.ServiceCode code = new MerchantTribe.Shipping.ServiceCode()
                        {
                            Code = item.Value, DisplayName = item.Text
                        };
                        filter.Add(code);
                    }
                }
            }
            else
            {
                Settings.GetAllRates = true;
            }

            Settings.ServiceCodeFilter = filter;
            Settings["highlight"]      = this.lstHighlights.SelectedValue;
            ShippingMethod.Settings.Merge(Settings);

            MyPage.MTApp.AccountServices.Stores.Update(MyPage.MTApp.CurrentStore);
        }
Exemplo n.º 2
0
        private void SaveData()
        {
            ShippingMethod.Name = this.NameField.Text.Trim();            
            ShippingMethod.ZoneId = long.Parse(this.lstZones.SelectedItem.Value);
            ShippingMethod.AdjustmentType = (ShippingMethodAdjustmentType)int.Parse(AdjustmentDropDownList.SelectedValue);
            ShippingMethod.Adjustment = decimal.Parse(AdjustmentTextBox.Text, System.Globalization.NumberStyles.Currency);

            // Global Settings
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsAccountNumber = this.AccountNumberField.Text.Trim();
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsForceResidential = this.ResidentialAddressCheckBox.Checked;
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsPickupType = int.Parse(this.PickupTypeRadioButtonList.SelectedValue);
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsDefaultService = int.Parse(this.DefaultServiceField.SelectedValue);
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsDefaultPackaging = int.Parse(this.DefaultPackagingField.SelectedValue);
            //MyPage.Services.CurrentStore.Settings.ShippingUpsDefaultPayment = int.Parse(this.DefaultPaymentField.SelectedValue);
            MyPage.MTApp.CurrentStore.Settings.ShippingUpsSkipDimensions = this.SkipDimensionsCheckBox.Checked;
            MyPage.MTApp.CurrentStore.Settings.ShippingUPSDiagnostics = this.chkDiagnostics.Checked;
            


            // Method Settings
            UPSServiceSettings Settings = new UPSServiceSettings();
            Settings.Merge(ShippingMethod.Settings);

            List<MerchantTribe.Shipping.IServiceCode> filter = new List<MerchantTribe.Shipping.IServiceCode>();

            if (this.rbFilterMode.SelectedValue == "0")
            {
                Settings.GetAllRates = false;

                foreach (ListItem item in ShippingTypesCheckBoxList.Items)
                {
                    if (item.Selected)
                    {
                        MerchantTribe.Shipping.ServiceCode code = new MerchantTribe.Shipping.ServiceCode() { Code = item.Value, DisplayName = item.Text };
                        filter.Add(code);
                    }
                }
            }
            else
            {
                Settings.GetAllRates = true;
            }

            Settings.ServiceCodeFilter = filter;
            Settings["highlight"] = this.lstHighlights.SelectedValue;
            ShippingMethod.Settings.Merge(Settings);

            MyPage.MTApp.AccountServices.Stores.Update(MyPage.MTApp.CurrentStore);
        }
Exemplo n.º 3
0
        protected void btnGetRates_Click(object sender, EventArgs e)
        {
            MerchantTribe.Shipping.Shipment shipment = new MerchantTribe.Shipping.Shipment();
            shipment.DestinationAddress.PostalCode = this.ToZipField.Text.Trim();
            shipment.SourceAddress.PostalCode      = this.FromZipField.Text.Trim();

            // box
            MerchantTribe.Shipping.Shippable item = new MerchantTribe.Shipping.Shippable();
            decimal length = 0m;

            decimal.TryParse(this.LengthField.Text.Trim(), out length);
            decimal height = 0m;

            decimal.TryParse(this.HeightField.Text.Trim(), out height);
            decimal width = 0m;

            decimal.TryParse(this.WidthField.Text.Trim(), out width);
            decimal weightPounds = 0m;

            decimal.TryParse(this.WeightPoundsField.Text.Trim(), out weightPounds);
            decimal weightOunces = 0m;

            decimal.TryParse(this.WeightOuncesField.Text.Trim(), out weightOunces);
            item.BoxLength            = length;
            item.BoxHeight            = height;
            item.BoxWidth             = width;
            item.BoxLengthType        = MerchantTribe.Shipping.LengthType.Inches;
            item.BoxWeight            = weightPounds + MerchantTribe.Web.Conversions.OuncesToDecimalPounds(weightOunces);
            item.BoxWeightType        = MerchantTribe.Shipping.WeightType.Pounds;
            item.QuantityOfItemsInBox = 1;

            shipment.Items.Add(item);

            // Global Settings
            MerchantTribe.Shipping.USPostal.USPostalServiceGlobalSettings globalSettings = new USPostalServiceGlobalSettings();
            globalSettings.DiagnosticsMode  = true;
            globalSettings.IgnoreDimensions = false;

            // Settings
            MerchantTribe.Shipping.USPostal.USPostalServiceSettings settings = new USPostalServiceSettings();
            MerchantTribe.Shipping.ServiceCode code = new MerchantTribe.Shipping.ServiceCode();
            code.Code        = this.lstServiceTypes.SelectedItem.Value;
            code.DisplayName = this.lstServiceTypes.SelectedItem.Text;
            List <MerchantTribe.Shipping.IServiceCode> codes = new List <MerchantTribe.Shipping.IServiceCode>();

            codes.Add(code);
            settings.ServiceCodeFilter = codes;
            int temp = -1;

            int.TryParse(this.lstPackagingType.SelectedItem.Value, out temp);
            settings.PackageType = (MerchantTribe.Shipping.USPostal.v4.DomesticPackageType)temp;

            // Provider
            MerchantTribe.Web.Logging.TextLogger             logger   = new MerchantTribe.Web.Logging.TextLogger();
            MerchantTribe.Shipping.USPostal.DomesticProvider provider = new DomesticProvider(globalSettings, logger);
            provider.Settings = settings;

            List <MerchantTribe.Shipping.IShippingRate> rates = provider.RateShipment(shipment);

            this.litRates.Text = "<ul>";
            foreach (MerchantTribe.Shipping.IShippingRate rate in rates)
            {
                this.litRates.Text += "<li>" + rate.EstimatedCost.ToString("c") + " - " + rate.DisplayName + "</li>";
            }
            this.litRates.Text += "</ul>";

            this.litMessages.Text = "<ul>";
            foreach (MerchantTribe.Shipping.ShippingServiceMessage msg in provider.LatestMessages)
            {
                switch (msg.MessageType)
                {
                case MerchantTribe.Shipping.ShippingServiceMessageType.Diagnostics:
                    this.litMessages.Text += "<li>DIAGNOSTICS:";
                    break;

                case MerchantTribe.Shipping.ShippingServiceMessageType.Information:
                    this.litMessages.Text += "<li>INFO:";
                    break;

                case MerchantTribe.Shipping.ShippingServiceMessageType.Error:
                    this.litMessages.Text += "<li>ERROR:";
                    break;
                }
                this.litMessages.Text += System.Web.HttpUtility.HtmlEncode(msg.Description + " " + msg.Code) + "</li>";
            }
            this.litMessages.Text += "</ul>";


            this.litXml.Text = "";
            while (logger.Messages.Count > 0)
            {
                string tempXml = logger.Messages.Dequeue();
                tempXml           = tempXml.Replace("\n", "<br />");
                tempXml           = tempXml.Replace("\r", "<br />");
                tempXml           = tempXml.Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
                this.litXml.Text += "<li>" + System.Web.HttpUtility.HtmlEncode(tempXml) + "</li>";
            }
        }
        protected void btnGetRates_Click(object sender, EventArgs e)
        {


            MerchantTribe.Shipping.Shipment shipment = new MerchantTribe.Shipping.Shipment();
            shipment.DestinationAddress.CountryData.Name = this.lstCountries.SelectedItem.Value;
            shipment.SourceAddress.PostalCode = this.FromZipField.Text.Trim();

            // box
            MerchantTribe.Shipping.Shippable item = new MerchantTribe.Shipping.Shippable();
            decimal length = 0m;
            decimal.TryParse(this.LengthField.Text.Trim(), out length);
            decimal height = 0m;
            decimal.TryParse(this.HeightField.Text.Trim(), out height);
            decimal width = 0m;
            decimal.TryParse(this.WidthField.Text.Trim(), out width);
            decimal weightPounds = 0m;
            decimal.TryParse(this.WeightPoundsField.Text.Trim(), out weightPounds);
            decimal weightOunces = 0m;
            decimal.TryParse(this.WeightOuncesField.Text.Trim(), out weightOunces);
            item.BoxLength = length;
            item.BoxHeight = height;
            item.BoxWidth = width;
            item.BoxLengthType = MerchantTribe.Shipping.LengthType.Inches;
            item.BoxWeight = weightPounds + MerchantTribe.Web.Conversions.OuncesToDecimalPounds(weightOunces);
            item.BoxWeightType = MerchantTribe.Shipping.WeightType.Pounds;
            item.QuantityOfItemsInBox = 1;

            shipment.Items.Add(item);

            // Global Settings
            MerchantTribe.Shipping.USPostal.USPostalServiceGlobalSettings globalSettings = new USPostalServiceGlobalSettings();
            globalSettings.DiagnosticsMode = true;
            globalSettings.IgnoreDimensions = false;

            // Settings
            MerchantTribe.Shipping.USPostal.USPostalServiceSettings settings = new USPostalServiceSettings();
            MerchantTribe.Shipping.ServiceCode code = new MerchantTribe.Shipping.ServiceCode();
            code.Code = this.lstServiceTypes.SelectedItem.Value;
            code.DisplayName = this.lstServiceTypes.SelectedItem.Text;
            List<MerchantTribe.Shipping.IServiceCode> codes = new List<MerchantTribe.Shipping.IServiceCode>();
            codes.Add(code);
            settings.ServiceCodeFilter = codes;
            
            // Provider
            MerchantTribe.Web.Logging.TextLogger logger = new MerchantTribe.Web.Logging.TextLogger();
            MerchantTribe.Shipping.USPostal.InternationalProvider provider = new InternationalProvider(globalSettings, logger);
            provider.Settings = settings;

            List<MerchantTribe.Shipping.IShippingRate> rates = provider.RateShipment(shipment);

            this.litRates.Text = "<ul>";
            foreach (MerchantTribe.Shipping.IShippingRate rate in rates)
            {
                this.litRates.Text += "<li>" + rate.EstimatedCost.ToString("c") + " - " + rate.DisplayName + "</li>";
            }
            this.litRates.Text += "</ul>";

            this.litMessages.Text = "<ul>";
            foreach (MerchantTribe.Shipping.ShippingServiceMessage msg in provider.LatestMessages)
            {
                switch (msg.MessageType)
                {
                    case MerchantTribe.Shipping.ShippingServiceMessageType.Diagnostics:
                        this.litMessages.Text += "<li>DIAGNOSTICS:";
                        break;
                    case MerchantTribe.Shipping.ShippingServiceMessageType.Information:
                        this.litMessages.Text += "<li>INFO:";
                        break;
                    case MerchantTribe.Shipping.ShippingServiceMessageType.Error:
                        this.litMessages.Text += "<li>ERROR:";
                        break;
                }
                this.litMessages.Text += System.Web.HttpUtility.HtmlEncode(msg.Description + " " + msg.Code) + "</li>";
            }
            this.litMessages.Text += "</ul>";


            this.litXml.Text = "";
            while (logger.Messages.Count > 0)
            {
                string tempXml = logger.Messages.Dequeue();
                tempXml = tempXml.Replace("\n", "<br />");
                tempXml = tempXml.Replace("\r", "<br />");
                tempXml = tempXml.Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
                this.litXml.Text += "<li>" + System.Web.HttpUtility.HtmlEncode(tempXml) + "</li>";
            }
        }