コード例 #1
0
ファイル: RateWareProxy.cs プロジェクト: jpheary/Argix08
        public static Rates CalculateRates(string tariff, string originZip, string classCode, double discount, int floorMin, string[] destinationZips)
        {
            //
            Rates rates = null;

            try {
                rates = _Client.CalculateRates(tariff, originZip, classCode, discount, floorMin, destinationZips);
            }
            catch (FaultException fe) { throw new ApplicationException("CalculateRates() service error.", fe); }
            catch (TimeoutException te) { throw new ApplicationException("CalculateRates() timeout error.", te); }
            catch (CommunicationException ce) { throw new ApplicationException("CalculateRates() communication error.", ce); }
            return(rates);
        }
コード例 #2
0
ファイル: FinanceGateway.cs プロジェクト: jpheary/Argix10
        public static Rates CalculateRates(RateQuoteRequest request)
        {
            //
            Rates rates = null;
            RateQuoteServiceClient client = new RateQuoteServiceClient();

            try {
                rates = client.CalculateRates(request.Tariff, request.OriginPostalCode, request.ClassCode, request.MCDiscount, request.UserMinimumChargeFloor, request.DestinationPostalCodes);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <RateQuoteFault> rfe) { client.Abort(); throw new ApplicationException(rfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(rates);
        }
コード例 #3
0
        public Rates CalculateRates(string tariff, string originZip, string classCode, double discount, int floorMin, string[] destinationZips)
        {
            //Calcualate rates
            Rates rates = new Rates();

            CZARCOMLib.czardllClass czarLib = null;
            try {
                czarLib = new CZARCOMLib.czardllClass();
                czarLib.InitializeCzar();
                czarLib.Clear();
                czarLib.tariff_name   = tariff.Substring(0, 8);
                czarLib.shipment_date = tariff.Substring(12, 2) + "/" + tariff.Substring(14, 2) + "/" + tariff.Substring(8, 4);
                czarLib.orgzip        = originZip;
                czarLib.set_cls(0, classCode);
                czarLib.set_wbdisc_in(0, discount); // min charge
                czarLib.set_wbdisc_in(1, discount); // < 500
                czarLib.set_wbdisc_in(2, discount); // > 500
                czarLib.set_wbdisc_in(3, discount); // > 1000
                czarLib.set_wbdisc_in(4, discount); // > 2000
                czarLib.set_wbdisc_in(5, discount); // > 5000
                czarLib.use_dscnts      = "Y";
                czarLib.discount_type   = "R";
                czarLib.single_shipment = "N";

                //bool isSuccess = false;
                ArrayList rateArray = new ArrayList(WEIGHT_RANGE_COUNT);
                for (int i = 0; i < destinationZips.Length; i++)
                {
                    rateArray.Clear();
                    //Rate the shipment now - we are rating one shipment at a time - multiple shipments give same rates
                    for (int j = 0; j < WEIGHT_RANGE_COUNT; j++)
                    {
                        int weight = Convert.ToInt32(WEIGHT_RANGES[j].ToString());
                        czarLib.dstzip = destinationZips[i].ToString();
                        czarLib.set_wgt(0, Convert.ToInt32(weight.ToString()));

                        try { czarLib.RateShipment(); } catch { }
                        if (czarLib.error_status == 0)
                        {
                            rateArray.Add(czarLib.get_rte(0).ToString("C")); //format double to 2-digit number
                        }
                        else
                        {
                            rateArray.Add("");
                        }

                        //Quit the whole thing if we encounter error with fixed properties
                        //Check for error code 217 - Destination Tariff not found continue with the next if it's Destination related error
                        //if(!isSuccess && czarLib.error_status != 217) break;
                        //if (!(czarLib.error_status == 0 || czarLib.error_status == 217)) break;
                    }

                    //Take lesser of min charge from rate ware or set floor min
                    double minCharge = Convert.ToDouble(czarLib.min_charge.ToString("F"));
                    if (minCharge < floorMin)
                    {
                        minCharge = floorMin;
                    }

                    //Add rates to the grid
                    RateDS.RateTableRow _rate = new RateDS().RateTable.NewRateTableRow();
                    _rate.OrgZip    = czarLib.orgzip;
                    _rate.DestZip   = czarLib.dstzip.Substring(0, 3);
                    _rate.MinCharge = minCharge.ToString("C");
                    _rate.Rate1     = rateArray[0].ToString();
                    _rate.Rate501   = rateArray[1].ToString();
                    _rate.Rate1001  = rateArray[2].ToString();
                    _rate.Rate2001  = rateArray[3].ToString();
                    _rate.Rate5001  = rateArray[4].ToString();
                    _rate.Rate10001 = rateArray[5].ToString();
                    _rate.Rate20001 = rateArray[6].ToString();
                    rates.Add(new Rate(_rate));
                }
            }
            catch (Exception ex) { throw new FaultException <RateWareFault>(new RateWareFault(new ApplicationException(ex.Message, ex))); }
            finally {
                czarLib.EndCzar();
            }
            return(rates);
        }