コード例 #1
0
        /// <summary>
        /// Method to GET WareHouseAddress details by WareHouseId
        /// </summary>
        public void GetAddressByWareHouseID()
        {
            bool check = false;

            do
            {
                try
                {
                    WriteLine("You chose to Get the Address details byWareHouseId");
                    //Created an object for WarehouseAddress Business class and is stored in a reference variable
                    WareHouseAddressBusinessLogicLayer wabl = new WareHouseAddressBusinessLogicLayer();

                    WriteLine("Enter the existing WareHouse Id");
                    WriteLine("The Warehouse Id should start with WHID and of length 6.It shouldn't contain special characters");
                    //Reads the WareHouseId and is stored in a reference variable
                    string warehouseid = ReadLine();

                    //Calls the GetAddressByAddressID methof of WareHouseAddressBusinessLogicLayer
                    WareHouseAddress add = wabl.GetAddressByWareHouseID(warehouseid);

                    //Condition to check whether the address id exists or not
                    if (add != null)
                    {
                        check = true;
                        WriteLine("WareHouseID" + "   " + "AddressID" + "  " + "Door Number" + "  " + "LocationName" + "  " + "State" + "  " + "Pincode");
                        WriteLine(add.WareHouseId + "    " + add.AddressId + "  " + add.DoorNumber + " " + add.LocationName + "  " + add.State + "  " + add.Pincode);
                    }
                }
                catch (WareHouseException ex)
                {
                    WriteLine(ex.Message);
                }
            } while (check == false);
        }
コード例 #2
0
 /// <summary>
 /// Method to ADD address details to the list
 /// </summary>
 /// <param name="addressDetails">Represents the </param>
 public override void AddAddress(WareHouseAddress address)
 {
     //Condition to check whether the WareHouseId exists or not
     if (address.AddressId != null)
     {
         _addressList.Add(address);
         SaveIntoFile();
     }
     else
     {
         throw new WareHouseException("Warehouse id doesnot exist");
     }
 }
コード例 #3
0
        /// <summary>
        ///Method to UPDATE the Pincode of WareHouse
        /// </summary>
        /// <param name="address">Represents the object of WareHouseAddress</param>
        public void UpdatePincode(WareHouseAddress address)
        {
            //Condition to check whether the AddressId exists or not
            WareHouseAddress wha = _addressList.Find(n => n.AddressId == address.AddressId);

            if (wha != null)
            {
                wha.Pincode = address.Pincode;
                SaveIntoFile();
            }
            else
            {
                throw new WareHouseException("Address Id doesn't exist");
            }
        }
コード例 #4
0
        /// <summary>
        /// Method to UPDATE the Location Name of WareHouse
        /// </summary>
        /// <param name="address">Represents the object of WareHouseAddress</param>
        public void UpdateLocationName(WareHouseAddress address)
        {
            //Condition to check whether the AddressId exists or not
            WareHouseAddress wha = _addressList.Find(temp => temp.AddressId == address.AddressId);

            if (wha != null)
            {
                wha.LocationName = address.LocationName;
                SaveIntoFile();
            }
            else
            {
                throw new WareHouseException("Address Id doesn't exist");
            }
        }
 /// <summary>
 /// Method to ADD Address details to the list
 /// </summary>
 /// <param name="address">Represents the object of WareHouse Address</param>
 public void AddAddress(WareHouseAddress address)
 {
     try
     {
         //AddressId should not be null
         if (address.AddressId != null)
         {
             //Calls the AddAddress Method of WareHouseAddress Data Layer
             wadl.AddAddress(address);
         }
     }
     catch (WareHouseException ex)
     {
         throw new WareHouseException(ex.Message);
     }
 }
コード例 #6
0
 /// <summary>
 /// Method to UPDATE Door Number of WareHouse
 /// </summary>
 /// <param name="address">Represents the object of WareHouseAddress</param>
 public void UpdateDoorNumber(WareHouseAddress address)// update WareHouse Name
 {
     //Condition to check whether the AddressId exists or not
     if (_addressList.Exists(temp => temp.AddressId == address.AddressId))
     {
         //Returns the condition matching elements
         WareHouseAddress wha = _addressList.Find(temp => temp.AddressId == address.AddressId);
         if (wha != null)
         {
             wha.DoorNumber = address.DoorNumber;
             SaveIntoFile();
         }
     }
     else
     {
         throw new WareHouseException("Address Id doesn't exist");
     }
 }
コード例 #7
0
        /// <summary>
        /// Method to REMOVE an address of the Warehouse
        /// </summary>
        public void RemoveWareHouseAddress()
        {
            WareHouseAddress w = new WareHouseAddress();                                        // creating the object for Warehouse class
            WareHouseAddressBusinessLogicLayer wabl = new WareHouseAddressBusinessLogicLayer(); // Creating thhe object for WareHouseBusinessLogic class

            WriteLine("select on which type you want to remove the WareHouse Address");
            WriteLine("1.on WareHouseId");
            WriteLine("2.on AddressId");
            int  Option;
            bool a;

            a = int.TryParse(ReadLine(), out Option);

            if (a == true)
            {
                switch (Option)
                {
                case 1: RemoveAddressByWareHouseID(); break;

                case 2: RemoveAddressByAddressID(); break;

                default: WriteLine("Please Choose enter correct Option"); break;
                }
            }
            else
            {
                WriteLine("Please Enter Correct Option");
            }

            //Local function to REMOVE an address of the Warehouse by wareHouseID
            void RemoveAddressByWareHouseID()
            {
                bool check = false;

                do
                {
                    WriteLine("You chose to Remove the Address by WareHouseId");
                    Write("Enter the WarehouseID of the Address to be Deleted:");
                    WriteLine("The WareHouse Id should start with WHID and of length 6.It shouldn't contain special characters");
                    //Reads the WarehouseID and is stored in a reference variable
                    string whID = ReadLine();
                    try
                    {
                        WareHouseAddress addr = wabl.GetAddressByWareHouseID(whID);
                        // Condition to check whether WarHouseId exists or not
                        if (addr != null)
                        {
                            check = true;
                            //Calls the RemoveAddressByWareHouseID method of WareHouseAddressBusinessLogicLayer
                            wabl.RemoveAddressByWareHouseID(whID);
                            WriteLine("Warehouse Removed");
                        }
                    }
                    catch (WareHouseException ex)
                    {
                        WriteLine(ex.Message);
                    }
                } while (check == false);
            }

            //Local function to REMOVE an address of the Warehouse by addressID
            void RemoveAddressByAddressID()
            {
                bool check = false;

                do
                {
                    WriteLine("You chose to Remove the Address by AddressId");
                    Write("Enter the AddressId to be Deleted:");
                    WriteLine("The Address Id should start with W and of length 4.It shouldn't contain special characters");

                    //Reads the entered AddressId
                    string addressId = ReadLine();
                    try
                    {
                        WareHouseAddress addr = wabl.GetAddressByAddressID(addressId);
                        // Condition to check whether AddressId exists or not
                        if (addr != null)
                        {
                            check = true;
                            //Calls the RemoveAddressByAddressID method of WareHouseAddressBusinessLogicLayer
                            wabl.RemoveAddressByAddressID(addressId);
                            WriteLine("Warehouse Removed");
                        }
                    }
                    catch (WareHouseException ex)
                    {
                        WriteLine(ex.Message);
                    }
                } while (check == false);
            }
        }
コード例 #8
0
        /// <summary>
        /// Method to UPDATE the details of WareHouse Address
        /// </summary>
        public void UpdateWareHouseAddress()
        {
            //Created an object for WareHouseAddress Business class and stored it in a reference variable
            WareHouseAddressBusinessLogicLayer wabl = new WareHouseAddressBusinessLogicLayer();

            WriteLine("1. Update Door Number ");
            WriteLine("2. Update Location Name");
            WriteLine("3. Update State");
            WriteLine("4. Update Pincode");


            int  Option;
            bool a;

            a = int.TryParse(ReadLine(), out Option);

            if (a == true)
            {
                switch (Option)
                {
                case 1:
                    UpdateDoorNumber(); break;

                case 2:
                    UpdateLocationName(); break;

                case 3:
                    UpdateState(); break;

                case 4:
                    UpdatePincode(); break;

                default: WriteLine("Enter correct option"); break;
                }
            }

            //Local Function to UPDATE Door Number of WareHouse
            void UpdateDoorNumber()
            {
                bool check = false;

                do
                {
                    try
                    {
                        WriteLine("You chose to Update the Door Number of a WareHouse Address");
                        WriteLine("Enter Existing Address ID");
                        WriteLine("The Address Id should start with W and of length 4.It shouldn't contain special characters");
                        //Reads the AddressId and is stored in a reference variable
                        string adId = ReadLine();

                        //Calls the GetAddressByAddressID methof of WareHouseAddressBusinessLogicLayer
                        WareHouseAddress wadd = wabl.GetAddressByAddressID(adId);

                        //Condition to check whether AddressId is null or not
                        if (wadd != null)
                        {
                            check = true;
                            WriteLine("Enter the new Door Number for the WareHouse");
                            WriteLine("Door Number shouldn't be null or empty");

                            //Reads the DoorNumber and is stored in reference variable
                            wadd.DoorNumber = ReadLine();

                            //Calls the UpdateDoorNumber method of WareHouseAddressBusiess Logic
                            wabl.UpdateDoorNumber(wadd);
                            WriteLine("Door Number Updated Sucessfully!!!");
                        }
                        else
                        {
                            WriteLine("Address id doesn't exist");
                        }
                    }
                    catch (WareHouseException ex)
                    {
                        WriteLine(ex.Message);
                    }
                } while (check == false);
            }

            //Local Function to UPDATE the Location Name of WareHouse
            void UpdateLocationName()
            {
                bool check = false;

                do
                {
                    try
                    {
                        WriteLine("You chose to Update the LocationName of a WareHouse Address");
                        WriteLine("Enter Existing Address ID");
                        WriteLine("The Address Id should start with W and of length 4.It shouldn't contain special characters");

                        //Reads the AddressId and is stored in a reference variable
                        string adId = ReadLine();

                        //Calls the GetAddressByAddressID methof of WareHouseAddressBusinessLogicLayer
                        WareHouseAddress wadd = wabl.GetAddressByAddressID(adId);

                        //Condition to check whether AddressId is null or not
                        if (wadd != null)
                        {
                            check = true;
                            WriteLine("Enter the new Location Name for the WareHouse");
                            WriteLine("Location name shouldn't be null or empty and special characters are not allowed ");
                            //Reads the LocationName and is stored in reference variable
                            wadd.LocationName = ReadLine();

                            //Calls the UpdateLocationName method of WareHouseAddressBusiess Logic
                            wabl.UpdateLocationName(wadd);
                            WriteLine("Door Number Updated Sucessfully!!!");
                        }
                        else
                        {
                            WriteLine("Address id doesn't exist");
                        }
                    }
                    catch (WareHouseException ex)
                    {
                        WriteLine(ex.Message);
                    }
                } while (check == false);
            }

            //Local Function to UPDATE the State of WareHouse
            void UpdateState()
            {
                bool check = false;

                do
                {
                    try
                    {
                        WriteLine("You chose to Update the State of a WareHouse Address");
                        WriteLine("Enter Existing Address ID");
                        WriteLine("The Address Id should start with W and of length 4.It shouldn't contain special characters");

                        //Reads the AddressId and is stored in a reference variable
                        string adId = ReadLine();

                        //Calls the GetAddressByAddressID method of WareHouseAddressBusinessLogicLayer
                        WareHouseAddress wadd = wabl.GetAddressByAddressID(adId);
                        //Condition to check whether AddressId is null or not
                        if (wadd != null)
                        {
                            check = true;
                            WriteLine("Enter the new State for the WareHouse");
                            WriteLine("State shouldn't be null or empty and special characters are not allowed ");
                            //Reads the State and is stored in an reference variable
                            wadd.State = ReadLine();

                            //Calls the UpdateState method of WareHouseAddressBusinessLogicLayer
                            wabl.UpdateState(wadd);
                            WriteLine("Door Number Updated Sucessfully!!!");
                        }
                        else
                        {
                            WriteLine("Address id doesn't exist");
                        }
                    }
                    catch (WareHouseException ex)
                    {
                        WriteLine(ex.Message);
                    }
                } while (check == false);
            }

            //Local Function to UPDATE the Pincode of WareHouse
            void UpdatePincode()
            {
                bool check = false;

                do
                {
                    try
                    {
                        WriteLine("You chose to Update the Pincode of a WareHouse Address");
                        WriteLine("Enter Existing Address ID");
                        WriteLine("The Address Id should start with W and of length 4.It shouldn't contain special characters");

                        //Reads the AddressId and is stored in a reference variable
                        string adId = ReadLine();

                        //Calls the GetAddressByAddressID method of WareHouseAddressBusinessLogicLayer
                        WareHouseAddress wadd = wabl.GetAddressByAddressID(adId);
                        //Condition to check whether AddressId is null or not
                        if (wadd != null)
                        {
                            check = true;
                            WriteLine("Enter the new Pincode for the WareHouse");
                            WriteLine("Numeric values with length 6 are only allowed");
                            //Reads the Pincode and is stored in a reference variable
                            wadd.Pincode = ReadLine();

                            //Calls the UpdatePincode method of WareHouseAddressBusinessLogicLayer
                            wabl.UpdatePincode(wadd);
                            WriteLine("Door Number Updated Sucessfully!!!");
                        }
                        else
                        {
                            WriteLine("Address id doesn't exist");
                        }
                    }
                    catch (WareHouseException ex)
                    {
                        WriteLine(ex.Message);
                    }
                } while (check == false);
            }
        }
コード例 #9
0
        /// <summary>
        ///Method to ADD Address details to the list
        /// </summary>
        public void AddAddress()
        {
            bool check = false;

            do
            {
                try
                {
                    WriteLine("You chose to Add the Address to a WareHouse");
                    //Created an object for WareHouseAddress class and stored it in a reference variable
                    WareHouseAddress address = new WareHouseAddress();

                    //Created an object for WareHouseAddress Business class and stored it in a reference variable
                    WareHouseAddressBusinessLogicLayer wabl = new WareHouseAddressBusinessLogicLayer();

                    WriteLine("You chose to add address to the WareHouse");
                    WriteLine("Enter Existing WareHouseId");
                    WriteLine("The Warehouse Id should start with WHID and of length 6.It shouldn't contain special characters");
                    //Reads the WareHouseid and is stored in the WareHouseAddress object
                    address.WareHouseId = ReadLine();

                    //Condition to check whether WareHouseid exists or not
                    if (CheckWareHouseId(address.WareHouseId) == true)
                    {
                        //Condition to check whether Addressid exists or not
                        if (CheckAddressId(address.AddressId) == false)
                        {
                            check = true;
                            WriteLine("Enter Address id");
                            WriteLine("Addressid must be of length 6 and should contain only alphanumeric values");
                            //Reads the AddressId and is stored in the WareHouseAddress object
                            address.AddressId = ReadLine();

                            WriteLine("Enter Door Number");
                            WriteLine("Door Number shouldn't be null or empty");
                            //Reads the DoorNumber and is stored in the WareHouseAddress object
                            address.DoorNumber = ReadLine();

                            WriteLine("Enter Location Name");
                            WriteLine("Location Name shouldn't be null and should contain alphabets");
                            //Reads the LocationName and is stored in the WareHouseAddress object
                            address.LocationName = ReadLine();

                            WriteLine("Enter State");
                            WriteLine("State shouldn't be null and should contain alphabets");
                            //Reads the State and is stored in the WareHouseAddress object
                            address.State = ReadLine();

                            WriteLine("Enter the Pincode");
                            WriteLine("Pincode must be numeric and length should be exactly 6");
                            //Reads the Pincode and is stored in the WareHouseAddress object
                            address.Pincode = ReadLine();

                            //Calls the AddAddress method of WareHouseAddressBusinessLogic
                            wabl.AddAddress(address);


                            WriteLine("Address added successfully");
                        }
                        else
                        {
                            WriteLine("Address id exists already");
                        }
                    }
                    else
                    {
                        WriteLine("WareHouse id doesn't exist or is invalid");
                    }
                }
                catch (WareHouseException ex)
                {
                    WriteLine(ex.Message);
                }
            } while (check == false);
        }
コード例 #10
0
ファイル: USPS.cs プロジェクト: xiaoxiaocoder/AspxCommerce2.7
        public List<USPSRateResponse> GetRate(WareHouseAddress originAddress, DestinationAddress destination, List<USPSPackage> plist, bool isDomestic, int providerId, int storeId, int portalId)
        {

            //GetOriginAddress()
            _originAddress = originAddress;
            List<USPSRateResponse> response;
            LoadConfig(providerId, storeId, portalId);
            XmlDocument xx = new XmlDocument();
            string api = ""; //RateV4Request
            XmlNode wrap;
            XmlNode userId;

            if (isDomestic)
            {
                api = "RateV4";
                wrap = xx.CreateNode(XmlNodeType.Element, "RateV4Request", "");
                userId = xx.CreateNode(XmlNodeType.Attribute, "USERID", "");
                userId.Value = this._userId;
                wrap.Attributes.SetNamedItem(userId);
            }
            else
            {
                if (_isItemWiseCalculation)
                {
                    api = "IntlRateV2";
                    wrap = xx.CreateNode(XmlNodeType.Element, "IntlRateV2Request", "");
                    userId = xx.CreateNode(XmlNodeType.Attribute, "USERID", "");
                    userId.Value = this._userId;
                    wrap.Attributes.SetNamedItem(userId);
                }
                else
                {
                    api = "IntlRate";
                    wrap = xx.CreateNode(XmlNodeType.Element, "IntlRateRequest", "");
                    userId = xx.CreateNode(XmlNodeType.Attribute, "USERID", "");
                    userId.Value = this._userId;
                    wrap.Attributes.SetNamedItem(userId);
                }



            }
            int i = 1;

            foreach (var package in plist)
            {
                XmlNode root = xx.CreateNode(XmlNodeType.Element, "Package", "");
                XmlNode ids = xx.CreateNode(XmlNodeType.Attribute, "ID", "");
                ids.Value = i.ToString();
                root.Attributes.SetNamedItem(ids); //save attribute value

                if (isDomestic)
                {

                    decimal totalWeight = 0;
                    totalWeight = package.Quantity * package.WeightValue;

                    XmlNode node = xx.CreateNode(XmlNodeType.Element, "Service", "");
                    root.AppendChild(node); // append node to root 
                    root.SelectSingleNode("Service").InnerXml = package.ServiceType.ToString();

                    //if  servicetype=all then no mailtype specification
                    //  root.AppendChild(xx.CreateNode(XmlNodeType.Element, "MailType", ""));
                    //  root.SelectSingleNode("MailType").InnerXml = package.ServiceType.ToString();

                    root.AppendChild(xx.CreateNode(XmlNodeType.Element, "ZipOrigination", ""));
                    root.SelectSingleNode("ZipOrigination").InnerXml = _originAddress.PostalCode; //package.OriginZipcode.ToString();

                    root.AppendChild(xx.CreateNode(XmlNodeType.Element, "ZipDestination", ""));
                    root.SelectSingleNode("ZipDestination").InnerXml = destination.ToPostalCode;
                    if (package.WeightUnit.ToLower() == WeightUnits.POUNDS.ToString().ToLower() ||
                            package.WeightUnit.ToLower() == "pound" ||
                            package.WeightUnit.ToLower() == "lb" ||
                          package.WeightUnit.ToLower() == WeightUnits.LBS.ToString().ToLower())
                    {
                        //pound to ounce conversion
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Pounds", ""));
                        root.SelectSingleNode("Pounds").InnerXml = totalWeight.ToString();

                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Ounces", ""));
                        root.SelectSingleNode("Ounces").InnerXml = "0";// (package.WeightValue * 16).ToString();
                    }
                    else if (package.WeightUnit.ToLower() == WeightUnits.KGS.ToString().ToLower() ||
                            package.WeightUnit.ToLower() == "kg")
                    {
                        //pound to ounce conversion
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Pounds", ""));
                        root.SelectSingleNode("Pounds").InnerXml =
                            (double.Parse(package.WeightValue.ToString()) * 2.20462262185).ToString();

                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Ounces", ""));
                        root.SelectSingleNode("Ounces").InnerXml = "0";
                        // (double.Parse(package.WeightValue.ToString()) * 2.20462262185 * 16).ToString();
                    }
                    root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Container", ""));
                    if (package.Container.ToString().ToLower() != "none")
                        root.SelectSingleNode("Container").InnerXml = package.Container.ToString();

                    root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Size", ""));
                    root.SelectSingleNode("Size").InnerXml = package.PackageSize.ToString();

                    root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Machinable", ""));
                    root.SelectSingleNode("Machinable").InnerXml = package.Machinable.ToString();

                    if (package.Container.ToString().ToLower() == "none")
                    {

                        //root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Width", ""));
                        //root.SelectSingleNode("Width").InnerXml = package.Width.ToString();

                        //root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Length", ""));
                        //root.SelectSingleNode("Length").InnerXml = package.Length.ToString();

                        //root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Height", ""));
                        //root.SelectSingleNode("Height").InnerXml = package.Height.ToString();

                        ////for international rate
                        //// The "girth" of the package as measured in inches rounded
                        ////to the nearest whole inch. Required to obtain GXG pricing
                        ////when pricing and when Size=”LARGE” and
                        ////Container=”NONRECTANGULAR”.
                        ////For example: <Girth>15</Girth>
                        //root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Girth", ""));
                        //root.SelectSingleNode("Girth").InnerXml = package.Girth.ToString();
                    }

                    // root.AppendChild(node);//append node to root 

                }
                else
                {
                    if (_isItemWiseCalculation)
                    {
                        decimal totalWeight = 0;
                        totalWeight = package.Quantity * package.WeightValue;
                        if (package.WeightUnit.ToLower() == WeightUnits.POUNDS.ToString().ToLower() ||
                            package.WeightUnit.ToLower() == "pound" ||
                            package.WeightUnit.ToLower() == "lb" ||
                          package.WeightUnit.ToLower() == WeightUnits.LBS.ToString().ToLower())
                        {
                            //pound to ounce conversion
                            root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Pounds", ""));
                            root.SelectSingleNode("Pounds").InnerXml = totalWeight.ToString();

                            root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Ounces", ""));
                            root.SelectSingleNode("Ounces").InnerXml = "0";//(totalWeight * 16).ToString();
                        }
                        else if (package.WeightUnit.ToLower() == WeightUnits.KGS.ToString().ToLower() ||
                            package.WeightUnit.ToLower() == "kg")
                        {
                            //pound to ounce conversion
                            root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Pounds", ""));
                            root.SelectSingleNode("Pounds").InnerXml =
                                (double.Parse(totalWeight.ToString()) * 2.20462262185).ToString();

                            root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Ounces", ""));
                            root.SelectSingleNode("Ounces").InnerXml = "0";
                            // (double.Parse(totalWeight.ToString())*2.20462262185*16).ToString();
                        }
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Machinable", ""));
                        root.SelectSingleNode("Machinable").InnerXml = package.Machinable.ToString();

                        //if  servicetype=all then no mailtype specification
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "MailType", ""));
                        root.SelectSingleNode("MailType").InnerXml = package.MailType.ToString();

                        XmlNode gxg = xx.CreateNode(XmlNodeType.Element, "GXG", "");
                        XmlNode poboxFlag = xx.CreateNode(XmlNodeType.Element, "POBoxFlag", "");
                        gxg.AppendChild(poboxFlag);
                        XmlNode giftFlag = xx.CreateNode(XmlNodeType.Element, "GiftFlag", "");
                        gxg.AppendChild(giftFlag);
                        gxg.SelectSingleNode("POBoxFlag").InnerXml = package.PoBoxFlag.ToString();
                        gxg.SelectSingleNode("GiftFlag").InnerXml = package.GiftFlag.ToString();

                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "ValueOfContents", ""));
                        root.SelectSingleNode("ValueOfContents").InnerXml = package.ValueOfContents.ToString();
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Country", ""));
                        root.SelectSingleNode("Country").InnerXml = destination.ToCountryName;
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Container", ""));
                        root.SelectSingleNode("Container").InnerXml = package.Container.ToString();
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Size", ""));
                        root.SelectSingleNode("Size").InnerXml = package.Size.ToString();
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Width", ""));
                        root.SelectSingleNode("Width").InnerXml = package.Width.ToString();
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Length", ""));
                        root.SelectSingleNode("Length").InnerXml = package.Length.ToString();
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Height", ""));
                        root.SelectSingleNode("Height").InnerXml = package.Height.ToString();
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Girth", ""));
                        root.SelectSingleNode("Girth").InnerXml = package.Girth.ToString();
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "CommercialFlag", ""));
                        root.SelectSingleNode("CommercialFlag").InnerXml = package.CommercialFlag.ToString();
                    }
                    else
                    {

                        decimal totalWeight = plist.Sum(item => item.Quantity * item.WeightValue);// plist.Sum(packageweight => packageweight.WeightValue);

                        if (package.WeightUnit.ToLower() == WeightUnits.POUNDS.ToString().ToLower() ||
                            package.WeightUnit.ToLower() == "pound" ||
                            package.WeightUnit.ToLower() == "lb" ||
                          package.WeightUnit.ToLower() == WeightUnits.LBS.ToString().ToLower())
                        {
                            //pound to ounce conversion
                            root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Pounds", ""));
                            root.SelectSingleNode("Pounds").InnerXml = totalWeight.ToString();

                            //applying only one weight is ok 
                            root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Ounces", ""));
                            root.SelectSingleNode("Ounces").InnerXml = "0";// (totalWeight * 16).ToString();
                        }
                        else if (package.WeightUnit.ToLower() == WeightUnits.KGS.ToString().ToLower() ||
                            package.WeightUnit.ToLower() == "kg")
                        {
                            //pound to ounce conversion
                            root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Pounds", ""));
                            root.SelectSingleNode("Pounds").InnerXml =
                                (double.Parse(totalWeight.ToString()) * 2.20462262185).ToString();

                            root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Ounces", ""));
                            root.SelectSingleNode("Ounces").InnerXml = "0";
                            // (double.Parse(totalWeight.ToString()) * 2.20462262185 * 16).ToString();
                        }
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "MailType", ""));
                        root.SelectSingleNode("MailType").InnerXml = package.MailType.ToString();
                        root.AppendChild(xx.CreateNode(XmlNodeType.Element, "Country", ""));
                        root.SelectSingleNode("Country").InnerXml = destination.ToCountryName;
                        wrap.AppendChild(root);
                        xx.AppendChild(wrap);

                        break;
                    }

                }


                //  root.AppendChild(node);
                wrap.AppendChild(root);
                xx.AppendChild(wrap);

                i++;
            }
            XmlDocument rateResponse = SendRequestToProvider(xx, api);
            //calling parsefunction
            if (!isDomestic)
            {
                if (_isItemWiseCalculation)
                    response = ParseRateInterNationalV2(rateResponse);
                else
                    response = ParseRateInterNational(rateResponse);
            }
            else
            {

                response = ParseRate(rateResponse);
            }

            return response;
        }
コード例 #11
0
ファイル: USPS.cs プロジェクト: xiaoxiaocoder/AspxCommerce2.7
        public List<object> GetRateFromUsps(WareHouseAddress originAddress, DestinationAddress destination, ArrayList plist, int providerId, int storeId, int portalId)
        {
            var lists = new List<object>();
            List<USPSPackage> list = new List<USPSPackage>(plist.Count);
            list.AddRange(plist.Cast<USPSPackage>());
            try
            {
                if (originAddress.Country == "US")
                {
                    List<USPSRateResponse> rateResponses;
                    if (originAddress.Country.ToLower() == destination.ToCountry.ToLower())
                    {
                        rateResponses = GetRate(originAddress, destination, list, true, providerId, storeId, portalId);
                    }
                    else
                    {
                        rateResponses = GetRate(originAddress, destination, list, false, providerId, storeId, portalId);
                    }


                    foreach (var item in rateResponses)
                    {
                        if (string.IsNullOrEmpty(item.ErrorMessage))
                        {
                            if (item.IsDomestic)
                            {
                                lists.AddRange(item.Postage.Cast<object>());
                            }
                            else
                            {
                                lists.AddRange(item.IntRateList.Cast<object>());
                            }
                        }
                        else
                        {
                            lists.Add(item);
                        }

                    }




                }
            }
            catch (Exception ex)
            {

                throw ex;
            }

            return lists;
        }
コード例 #12
0
 /// <summary>
 /// //Method to add address details to the list
 /// </summary>
 /// <param name="addressDetails"></param>
 public abstract void AddAddress(WareHouseAddress addressDetails);