Пример #1
0
        // Not used, This SOAP function is not giving the correct rates, for an unknown reason..
        public Volume_result Get_ESTES_volume_rates()
        {
            #region Variables

            Logins.Login_info login_info;
            Logins            logins = new Logins();
            logins.Get_login_info(111, out login_info);

            string username = login_info.username, password = login_info.password, account = login_info.account, payor = "T", terms = "PPD";

            //string origZip = "55317", origCity = "CHANHASSEN",
            //     origState = "MN", destZip = "22102", destCity = "MC LEAN", destState = "VA";

            //string destCountry = "US", origCountry = "US";

            //DateTime pickupDate = quoteData.puDate.AddDays(1);
            DateTime pickupDate = quoteData.puDate;
            bool     hazmat     = false;

            //List<string> fClasses = new List<string>();
            //List<string> weights = new List<string>();

            List <string> accessorials = new List <string>();

            #endregion

            try
            {
                RateQuoteService service = new RateQuoteService();

                string[] res = new string[4];

                // Define rateService object, makes the request to Estes API, accepts rateRequest object as parameter
                RateQuoteService rateServ = new RateQuoteService();

                //estesRatingService.RateQuoteType abc = new estesRatingService.RateQuoteType();
                //abc.

                rateQuote rateQuote = new rateQuote();              //define rateQuote object, response rate quote

                rateRequest rateRequest = new rateRequest();        //define rateRequest object, stores iformation about the shipment

                PricingInfoType[] pricing = new PricingInfoType[1]; //define pricing object stores cost and delivery date and other fields

                PickupType pickupType = new PickupType
                {
                    date = pickupDate
                };

                #region Not used LTL class and weight
                //estesRatingService.BaseCommoditiesType baseCommodities = new estesRatingService.BaseCommoditiesType();

                //estesRatingService.BaseCommodityType[] commodTypeArray = new estesRatingService.BaseCommodityType[weights.Count];
                //for (int i = 0; i < weights.Count; i++)
                //{
                //    estesRatingService.BaseCommodityType commodType = new estesRatingService.BaseCommodityType(); //object that holds one class/weight pair
                //    commodType.@class = Convert.ToDecimal(fClasses[i]);
                //    commodType.weight = weights[i];
                //    commodTypeArray[i] = commodType; //set class/weight to an item in array or classes/weights
                //}

                //baseCommodities.commodity = commodTypeArray; //set the classes/weights array to the commodity object
                //rateRequest.Item = baseCommodities;
                #endregion

                //

                FullCommoditiesType fullCommodities = new FullCommoditiesType();
                FullCommodityType[] commodTypeArray = new FullCommodityType[quoteData.m_lPiece.Length];
                for (int i = 0; i < quoteData.m_lPiece.Length; i++)
                {
                    // Object that holds one class/weight pair
                    FullCommodityType commodType     = new FullCommodityType();
                    BaseCommodityType base_commodity = new BaseCommodityType
                    {
                        weight = quoteData.m_lPiece[i].Weight.ToString(),
                        @class = Convert.ToDecimal(quoteData.m_lPiece[i].FreightClass)
                    };
                    commodType.baseCommodity = base_commodity;

                    //commodType.@class = Convert.ToDecimal(fClasses[i]);
                    //commodType.weight = weights[i];
                    commodType.dimensions = new DimensionsType
                    {
                        length = "48",
                        width  = "48",
                        height = "70"
                    };
                    //DB.Log("Get_ESTES_volume_rates quoteData.m_lPiece[i].Quantity", quoteData.m_lPiece[i].Quantity.ToString());

                    commodType.pieces    = quoteData.m_lPiece[i].Quantity.ToString();
                    commodType.pieceType = new PackagingType();
                    //commodType.pieceType = estesRatingService.PackagingType.CR;
                    //commodType.pieceType = estesRatingService.PackagingType.CT;
                    commodType.pieceType = PackagingType.PT;
                    commodTypeArray[i]   = commodType; //set class/weight to an item in array or classes/weights
                }

                fullCommodities.commodity = commodTypeArray; //set the classes/weights array to the commodity object
                rateRequest.Item          = fullCommodities;

                rateRequest.equipmentType = "TRAILER";

                #region Origin and destination

                //DB.Log("quoteData.origCountry", quoteData.origCountry);
                //DB.Log("quoteData.destCountry", quoteData.destCountry);

                rateRequest.originPoint = new PointType
                {
                    countryCode   = quoteData.origCountry,
                    postalCode    = quoteData.origZip,
                    city          = quoteData.origCity,
                    stateProvince = quoteData.origState
                };

                rateRequest.destinationPoint = new PointType
                {
                    countryCode   = quoteData.destCountry,
                    postalCode    = quoteData.destZip,
                    city          = quoteData.destCity,
                    stateProvince = quoteData.destState
                };

                #endregion

                #region Accessorials

                //accessorials.Add("LGATE");
                accessorials.Add("APT");

                if (accessorials.Count == 0)
                {
                    rateRequest.accessorials = null;
                }
                else
                {
                    rateRequest.accessorials = new string[accessorials.Count];
                    for (int i = 0; i < accessorials.Count; i++)
                    {
                        rateRequest.accessorials[i] = accessorials[i];
                        //DB.Log("Estes acc live", accessorials[i], "");
                    }
                }

                #endregion

                rateRequest.requestID = " ";
                rateRequest.account   = account;

                rateRequest.payor  = payor;
                rateRequest.terms  = terms;
                rateRequest.pickup = pickupType;
                //rateRequest.liability = "1";
                //rateRequest.declaredValue = 100;
                //rateRequest.declaredValueSpecified = true;

                #region Hazmat and stackable
                //DB.Log("Estes", hazmat.ToString(), "");
                rateRequest.hazmatSpecified = true;
                if (hazmat)
                {
                    rateRequest.hazmat = YesNoBlankType.Y;
                }
                else
                {
                    rateRequest.hazmat = YesNoBlankType.N;
                }

                //rateRequest.stackableSpecified = true; //to do ask Bob about this
                //rateRequest.stackable = estesRatingService.YesNoBlankType.Y;
                #endregion

                rateRequest.requestID = "123";

                rateServ.auth = new AuthenticationType
                {
                    user     = username,
                    password = password
                };

                // Make the API call
                rateQuote = rateServ.getQuote(rateRequest);

                pricing = rateQuote.quote.pricing;
                res[1]  = pricing[0].standardPrice.ToString();

                //DB.Log("Get_ESTES_volume_rates", pricing[0].guaranteedPrice.ToString());


                //pricing[0].
                //double totalCharges;
                //if (!double.TryParse(res[1], out totalCharges))
                //{
                //    res[1] = rateQuote.
                //}

                DateTime delDate = pricing[0].deliveryDate;

                res[2] = (delDate - pickupDate).TotalDays.ToString();

                res[0] = "success";

                Volume_result volume_result = new Volume_result
                {
                    cost         = (double)pricing[0].guaranteedPrice,
                    carrier_name = "Estes",
                    quote_number = "",
                    transit_days = Convert.ToInt32((delDate - pickupDate).TotalDays)
                };

                return(volume_result);
            }
            catch (Exception e)
            {
                DB.Log("Get_ESTES_volume_rates", e.ToString());
                Volume_result volume_result = new Volume_result();
                return(volume_result);
            }
        }
Пример #2
0
        // This function is an attempt to consume an SOAP API, using XML instead. This is because the SOAP API
        // Is not giving the correct rate for some reason. XML is easier to debug.

        public Volume_result Get_ESTES_volume_rates_xml(ref Estes.Volume_result estes_volume_economy_result,
                                                        ref Estes.Volume_result estes_volume_basic_result)
        {
            try
            {
                #region Build Items string

                int total_units = 0;

                StringBuilder items = new StringBuilder();

                for (byte i = 0; i < quoteData.m_lPiece.Length; i++)
                {
                    // Guard
                    if (quoteData.m_lPiece[i].Length > 48 || quoteData.m_lPiece[i].Width > 48)
                    {
                        throw new Exception("Overlength for volume Estes");
                        //return;
                    }

                    //items.Append(string.Concat(
                    //    "{ \"total_weight\":", m_lPiece[i].Weight,
                    //    ", \"length\":", m_lPiece[i].Length, ", \"width\":", m_lPiece[i].Width, ", \"height\":", m_lPiece[i].Height,
                    //    ", \"units\":", m_lPiece[i].Units, " }"));

                    items.Append(string.Concat(
                                     "{ \"total_weight\":", quoteData.m_lPiece[i].Weight,
                                     ", \"length\":48, \"width\":48, \"height\":70, \"units\":", quoteData.m_lPiece[i].Units,
                                     ", \"freight_class\":", quoteData.m_lPiece[i].FreightClass, " }"));

                    //DB.Log("P44 i", i.ToString());
                    //DB.Log("P44 Length - 1", (m_lPiece.Length - 1).ToString());

                    if (i == quoteData.m_lPiece.Length - 1) // Last iteration
                    {
                        // Do nothing
                    }
                    else
                    {
                        //DB.Log("P44 ", "i not equal to length - 1");
                        items.Append(",");
                    }

                    //

                    total_units += quoteData.m_lPiece[i].Units;
                }

                //DB.Log("P44 items", items.ToString());

                #endregion


                // Guard
                if (total_units < 4)
                {
                    throw new Exception("Less than 4 units for volume Estes");
                    //return;
                }

                #region Set pickup date variables

                DateTime puDate = quoteData.puDate;
                string   puDateDay = puDate.Day.ToString(), puDateMonth = puDate.Month.ToString();

                if (puDateDay.Length == 1)
                {
                    puDateDay = "0" + puDateDay;
                }
                if (puDateMonth.Length == 1)
                {
                    puDateMonth = "0" + puDateMonth;
                }

                #endregion

                #region Build Items string

                StringBuilder sb_items = new StringBuilder();
                for (byte i = 0; i < quoteData.m_lPiece.Length; i++)
                {
                    sb_items.Append(string.Concat("<commodity>"));

                    sb_items.Append(string.Concat("<baseCommodity>"));
                    sb_items.Append(string.Concat("<class>", quoteData.m_lPiece[i].FreightClass,
                                                  "</class><weight>", quoteData.m_lPiece[i].Weight, "</weight>"));
                    sb_items.Append(string.Concat("</baseCommodity>"));

                    sb_items.Append(string.Concat("<pieces>", quoteData.m_lPiece[i].Quantity, "</pieces><pieceType>PT</pieceType>"));
                    sb_items.Append(string.Concat("<dimensions><length>48</length><width>48</width><height>70</height></dimensions>"));

                    sb_items.Append(string.Concat("</commodity>"));
                }

                #endregion

                #region Accessorials

                string hazmat = "N";
                if (quoteData.isHazmat == true)
                {
                    hazmat = "Y";
                }

                StringBuilder accessorials = new StringBuilder();

                #region Accessorials

                // Add APT by default
                accessorials.Append("<accessorialCode>APT</accessorialCode>");

                if (quoteData.AccessorialsObj.LGPU)
                {
                    accessorials.Append("<accessorialCode>LGATEP</accessorialCode>");
                }
                if (quoteData.AccessorialsObj.LGDEL)
                {
                    accessorials.Append("<accessorialCode>LGATE</accessorialCode>");
                }
                if (quoteData.AccessorialsObj.RESPU)
                {
                    accessorials.Append("<accessorialCode>HPUP</accessorialCode>");
                }
                if (quoteData.AccessorialsObj.RESDEL)
                {
                    accessorials.Append("<accessorialCode>HD</accessorialCode>");
                }
                if (quoteData.AccessorialsObj.CONPU)
                {
                    accessorials.Append("<accessorialCode>LAPU</accessorialCode>");
                }
                if (quoteData.AccessorialsObj.CONDEL)
                {
                    accessorials.Append("<accessorialCode>CONST</accessorialCode>");
                }
                //if (AccessorialsObj.APTPU || AccessorialsObj.APTDEL)
                //{
                //    accessorsList.Add("APT");
                //}
                //if (AccessorialsObj.APTDEL)
                //{
                //    accessorsList.Add("APTDEL");
                //}
                if (quoteData.AccessorialsObj.TRADEPU)
                {
                    accessorials.Append("<accessorialCode>FAIRPU</accessorialCode>");
                }
                if (quoteData.AccessorialsObj.TRADEDEL)
                {
                    accessorials.Append("<accessorialCode>FAIRDL</accessorialCode>");
                }
                if (quoteData.AccessorialsObj.INSDEL)
                {
                    accessorials.Append("<accessorialCode>INS</accessorialCode>");
                }

                #endregion


                #endregion

                Logins.Login_info login_info;
                Logins            logins = new Logins();
                logins.Get_login_info(111, out login_info);

                string data = string.Concat(
                    "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Header><auth xmlns=\"http://ws.estesexpress.com/ratequote\">",
                    "<user>", login_info.username, "</user><password>", login_info.password, "</password></auth></soap:Header><soap:Body><rateRequest xmlns=\"http://ws.estesexpress.com/schema/2017/07/ratequote\">",
                    "<requestID>123</requestID><account>", login_info.account, "</account>",
                    "<originPoint><countryCode>US</countryCode><postalCode>", quoteData.origZip, "</postalCode>",
                    "<city>", quoteData.origCity, "</city><stateProvince>", quoteData.origState, "</stateProvince></originPoint>",
                    "<destinationPoint><countryCode>US</countryCode><postalCode>", quoteData.destZip, "</postalCode>",
                    "<city>", quoteData.destCity, "</city><stateProvince>", quoteData.destState, "</stateProvince></destinationPoint>",
                    "<payor>T</payor><terms>PPD</terms><pickup><date>", puDate.Year, "-", puDateMonth, "-", puDateDay, "</date></pickup>",
                    "<hazmat>", hazmat, "</hazmat><equipmentType>TRAILER</equipmentType>",

                    "<fullCommodities>",

                    //"<commodity>",
                    //"<baseCommodity>",
                    //"<class>125</class><weight>6000</weight></baseCommodity>",

                    //"<pieces>8</pieces><pieceType>PT</pieceType>",
                    //"<dimensions><length>48</length><width>48</width><height>70</height></dimensions>",
                    //"</commodity>",

                    sb_items,

                    "</fullCommodities>",

                    "<accessorials>",

                    //"<accessorialCode>APT</accessorialCode>",

                    accessorials,

                    "</accessorials>",

                    "</rateRequest></soap:Body></soap:Envelope>");

                //DB.Log("Estes Volume request", data);

                Web_client http = new Web_client
                {
                    url          = "https://www.estes-express.com/tools/rating/ratequote/v3.0/services/RateQuoteService",
                    content_type = "text/xml; charset=utf-8",
                    //accept = "*/*",
                    post_data = data,
                    method    = "POST"
                };

                http.header_names     = new string[1];
                http.header_names[0]  = "SOAPAction";
                http.header_values    = new string[1];
                http.header_values[0] = "\"http://ws.estesexpress.com/ratequote/getQuote\"";

                //DB.Log("gcmAPI_Get_LOUP_Rates before send request", "before send request");

                string doc = http.Make_http_request();


                //DB.Log("Estes Volume result", doc);

                string[] tokens = new string[3];
                tokens[0] = "<rat:quoteNumber>";
                tokens[1] = ">";
                tokens[2] = "<";

                string quoteNumber = HelperFuncs.scrapeFromPage(tokens, doc);

                List <Estes_price_res> list = new List <Estes_price_res>();
                int ind;
                while (doc.IndexOf("<rat:price>") != -1)
                {
                    ind = doc.IndexOf("<rat:price>");
                    doc = doc.Substring(ind + 1);

                    ind = doc.IndexOf("</rat:price>");
                    if (ind != -1)
                    {
                        Parse_one_estes_result(ref list, doc.Remove(ind), ref quoteNumber);
                    }
                    else
                    {
                        // Do nothing
                    }
                }

                double cost = 0.0, cost_economy = 0.0, cost_basic = 0.0;
                //int transit_days;
                DateTime delDate = DateTime.MinValue, delDate_economy = DateTime.MinValue,
                         delDate_basic = DateTime.MinValue;
                DateTime pickupDate    = quoteData.puDate;

                for (byte i = 0; i < list.Count; i++)
                {
                    if (list[i].serviceLevel.Equals("Volume and Truckload Guaranteed Standard"))
                    {
                        if (list[i].standardPrice > 0)
                        {
                            cost    = list[i].standardPrice;
                            delDate = list[i].deliveryDate;
                        }
                        else if (list[i].guaranteedPrice > 0)
                        {
                            cost    = list[i].guaranteedPrice;
                            delDate = list[i].deliveryDate;
                        }
                        else
                        {
                            // Do nothing
                        }
                        //break;
                    }
                    else if (list[i].serviceLevel.Equals("Volume and Truckload Guaranteed Economy"))
                    {
                        if (list[i].standardPrice > 0)
                        {
                            cost_economy    = list[i].standardPrice;
                            delDate_economy = list[i].deliveryDate;
                        }
                        else if (list[i].guaranteedPrice > 0)
                        {
                            cost_economy    = list[i].guaranteedPrice;
                            delDate_economy = list[i].deliveryDate;
                        }
                        else
                        {
                            // Do nothing
                        }
                        //break;
                    }
                    else if (list[i].serviceLevel.Equals("Volume and Truckload Basic"))
                    {
                        if (list[i].standardPrice > 0)
                        {
                            cost_basic    = list[i].standardPrice;
                            delDate_basic = list[i].deliveryDate;
                        }
                        else if (list[i].guaranteedPrice > 0)
                        {
                            cost_basic    = list[i].guaranteedPrice;
                            delDate_basic = list[i].deliveryDate;
                        }
                        else
                        {
                            // Do nothing
                        }
                        //break;
                    }
                    else
                    {
                        // Do nothing
                    }
                }

                Volume_result volume_result = new Volume_result
                {
                    cost         = cost,
                    scac         = "EXLA",
                    carrier_name = "Estes Standard",
                    quote_number = quoteNumber,
                    transit_days = Convert.ToInt32((delDate - pickupDate).TotalDays)
                };

                estes_volume_economy_result.cost         = cost_economy;
                estes_volume_economy_result.scac         = "EXLA";
                estes_volume_economy_result.carrier_name = "Estes Economy";
                estes_volume_economy_result.quote_number = quoteNumber;
                estes_volume_economy_result.transit_days = Convert.ToInt32((delDate_economy - pickupDate).TotalDays);

                estes_volume_basic_result.cost         = cost_basic;
                estes_volume_basic_result.scac         = "EXLA";
                estes_volume_basic_result.carrier_name = "Estes Basic";
                estes_volume_basic_result.quote_number = quoteNumber;
                estes_volume_basic_result.transit_days = Convert.ToInt32((delDate_economy - pickupDate).TotalDays);

                if (delDate_economy == DateTime.MinValue)
                {
                    estes_volume_basic_result.transit_days = 10;
                }

                //DB.Log("Get_ESTES_volume_rates_xml", estes_volume_basic_result.transit_days.ToString());

                //DB.Log("Get_ESTES_volume_rates_xml delDate_economy", delDate_economy.ToShortDateString());

                //DB.Log("Get_ESTES_volume_rates_xml pickupDate", pickupDate.ToShortDateString());

                return(volume_result);
            }
            catch (Exception e)
            {
                DB.Log("Get_ESTES_volume_rates_xml", e.ToString());
                Volume_result volume_result = new Volume_result();
                return(volume_result);
            }
        }
Пример #3
0
    public void Get_XPO_Spot_Quote_rates(ref string access_token, ref Volume_result result)
    {
        try
        {
            #region Build Items string

            int total_units = 0;

            StringBuilder items = new StringBuilder();

            for (byte i = 0; i < quoteData.m_lPiece.Length; i++)
            {
                items.Append(string.Concat("{ \"pieceCnt\": 3, \"packageCd\": \"PLT\", \"stackableInd\": \"N\", ",
                                           "\"length\": 48, \"width\": 48, \"height\": 72, \"dimensionUOM\": \"IN\", ",
                                           "\"grossWeight\": ", quoteData.m_lPiece[i].Weight, "\"grossWeightUOM\": \"LBS\", \"nmfcClass\": \"70\" }"));

                //if(i>0 && i < quoteData.m_lPiece.Length-1)
                //{
                //    items.Append(",");
                //}

                items.Append(",");

                total_units += quoteData.m_lPiece[i].Units;
            }

            string items_str = items.ToString().Remove(items.ToString().Length - 1);
            //strgroupids = strgroupids.Remove(strgroupids.Length - 1);

            //DB.Log("XPO_Spot_Quote items", items_str);

            #endregion


            // Guard
            if (total_units < 4)
            {
                throw new Exception("Less than 4 units for volume XPO_Spot_Quote");
                //return;
            }

            int Total_lineal_feet = total_units * 2;

            if (quoteData.linealFeet > 0.0) // Requested by XML GCM API
            {
                Total_lineal_feet = Convert.ToInt32(quoteData.linealFeet);
            }

            #region Date

            string day = DateTime.Today.Day.ToString(), month = DateTime.Today.Month.ToString();

            if (day.Length == 1)
            {
                day = "0" + day;
            }

            if (month.Length == 1)
            {
                month = "0" + month;
            }

            #endregion

            //string data = string.Concat("{ \"requestDateTime\": \"", DateTime.Today.Year, "-", month, "-", day, "T09:30:47Z\", ",
            //    "\"shipmentValue\": { \"amt\": 1000, \"currencyCd\": \"USD\" } , \"requestedCurrency\": \"USD\", ",
            //    "\"pkupDate\": \"", DateTime.Today.Year, "-", month, "-", day, "\", \"shipperAcctId\": 697924925, ",
            //    "\"shipperPostalCd\": \"80001\", ",
            //    "\"shipperName\": \"Shipper Name\", \"consigneeAcctId\": 0, \"consigneePostalCd\": \"30303\", ",
            //    "\"consigneeName\": \"Consignee Name\", \"shipperBill2AcctId\": 0, \"consigneeBill2AcctId\": 0, ",
            //    "\"thirdBill2AcctId\": 0, \"serviceTypeCd\": \"\", ",
            //    "\"commodityLine\": ",

            //    "[{ \"pieceCnt\": 5, \"packageCd\": \"PLT\", \"stackableInd\": \"N\", ",
            //    "\"length\": 40, \"width\": 48, \"height\": 72, \"dimensionUOM\": \"IN\", ",
            //    "\"grossWeight\": 6500, \"grossWeightUOM\": \"LBS\", \"nmfcClass\": \"70\" } ],",

            //    "\"reference\": [{\"reference\": \"\", \"typeCd\": \"\"}]}");

            string data = string.Concat("{ \"requestDateTime\": \"", DateTime.Today.Year, "-", month, "-", day, "T09:30:47Z\", ",
                                        "\"shipmentValue\": { \"amt\": 1000, \"currencyCd\": \"USD\" } , \"requestedCurrency\": \"USD\", ",
                                        "\"pkupDate\": \"", DateTime.Today.Year, "-", month, "-", day, "\", \"shipperAcctId\": 697924925, ",
                                        "\"shipperPostalCd\": \"", quoteData.origZip, "\", ",
                                        "\"shipperName\": \"Shipper Name\", \"consigneeAcctId\": 0, \"consigneePostalCd\": \"", quoteData.destZip, "\", ",
                                        "\"consigneeName\": \"Consignee Name\", \"shipperBill2AcctId\": 0, \"consigneeBill2AcctId\": 0, ",
                                        "\"thirdBill2AcctId\": 0, \"serviceTypeCd\": \"\", ",
                                        "\"commodityLine\": ",

                                        "[",

                                        items_str,
                                        //"{ \"pieceCnt\": 3, \"packageCd\": \"PLT\", \"stackableInd\": \"N\", ",
                                        //"\"length\": 48, \"width\": 48, \"height\": 72, \"dimensionUOM\": \"IN\", ",
                                        //"\"grossWeight\": 3000, \"grossWeightUOM\": \"LBS\", \"nmfcClass\": \"70\" }, ",

                                        //"{ \"pieceCnt\": 3, \"packageCd\": \"PLT\", \"stackableInd\": \"N\", ",
                                        //"\"length\": 48, \"width\": 48, \"height\": 72, \"dimensionUOM\": \"IN\", ",
                                        //"\"grossWeight\": 3000, \"grossWeightUOM\": \"LBS\", \"nmfcClass\": \"70\" } ",
                                        "],",

                                        "\"reference\": [{\"reference\": \"\", \"typeCd\": \"\"}]}");

            Web_client http = new Web_client
            {
                url          = "https://api.ltl.xpo.com/rating/1.0/spotquotes",
                content_type = "application/json",
                accept       = "*/*",
                post_data    = data,
                method       = "POST"
            };

            http.header_names     = new string[1];
            http.header_names[0]  = "Authorization";
            http.header_values    = new string[1];
            http.header_values[0] = string.Concat("Bearer ", access_token);

            string doc = http.Make_http_request();

            #region Parse result

            string[] tokens = new string[4];
            tokens[0] = "totChargeAmt\":";
            tokens[1] = "amt\"";
            tokens[2] = ":";
            tokens[3] = ",";

            //string cost_string = HelperFuncs.scrapeFromPage(tokens, doc);

            double.TryParse(HelperFuncs.scrapeFromPage(tokens, doc), out double total_cost);

            //--

            tokens[0] = "spotQuoteNbr\":";
            tokens[1] = ":";
            tokens[2] = "\"";
            tokens[3] = "\"";

            string spotQuoteNbr = HelperFuncs.scrapeFromPage(tokens, doc);

            tokens[0] = "transitDays\":";
            tokens[1] = "\"";
            tokens[2] = ":";
            tokens[3] = ",";

            //string transitDays = HelperFuncs.scrapeFromPage(tokens, doc);

            int.TryParse(HelperFuncs.scrapeFromPage(tokens, doc), out int days);

            #endregion

            result.cost         = total_cost;
            result.quote_number = spotQuoteNbr;
            result.transit_days = days;
            result.carrier_name = "XPO Spot Quote";
        }
        catch (Exception e)
        {
            //string str = e.ToString();
            DB.Log("Get_XPO_Spot_Quote_rates", e.ToString());
        }
    }
Пример #4
0
        // Not used, in favor of net_core
        public void Get_YRC_API_Spot_Quote_Volume(ref Volume_result result)
        {
            #region Not used

            /*
             * string url = string.Concat("https://my.yrc.com/myyrc-api/national/servlet?CONTROLLER=com.rdwy.ec.rexcommon.proxy.http.controller.ProxyApiController&redir=/tfq561",
             *  "&LOGIN_USER=&LOGIN_PASSWORD=&BusId=",
             *  "&BusRole=Third Party&PaymentTerms=Prepaid",
             *
             *  "&OrigCityName=", orig_city, "&OrigStateCode=", orig_state, "&OrigZipCode=", orig_zip, "&OrigNationCode=USA",
             *  "&DestCityName=", dest_city, "&DestStateCode=", dest_state, "&DestZipCode=", dest_zip, "&DestNationCode=USA",
             *  "&ServiceClass=SPOT&PickupDate=20190102",
             *
             *  "&LineItemWeight1=13500&LineItemCount=1",
             *  "&LineItemPackageLength1=144&LineItemPackageWidth1=80&LineItemPackageHeight1=80",
             *
             *  "&AcceptTerms=Y&LineItemHandlingUnits1=1&AccOption1=NTFY&AccOptionCount=1");
             */
            #endregion

            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                Web_client http = new Web_client
                {
                    url          = "",
                    content_type = "",
                    accept       = "*/*",
                    method       = "GET"
                };

                //DB.Log("gcmAPI_Get_LOUP_Rates before send request", "before send request");

                //string doc = http.Make_http_request();

                Logins.Login_info login_info;
                Logins            logins = new Logins();
                logins.Get_login_info(37, out login_info);

                http.method = "POST";
                //http.referrer = http.url;
                http.url       = "https://my.yrc.com/dynamic/national/servlet";
                http.post_data = string.Concat("CNTR=&AccOptionCount=1&AccOption1=NTFY&AcceptTerms=Y",
                                               "&DestZipCode=", quoteData.destZip, "&OrigNationCode=USA",
                                               "&LineItemPackageWidth1=80",
                                               "&LOGIN_USER="******"&LineItemPackageHeight1=80",
                                               "&DestCityName=", quoteData.destCity,
                                               "&LineItemPackageLength1=144",
                                               "&BusId=", login_info.account, "&redir=%2Ftfq561",
                                               "&LineItemHandlingUnits1=1&LineItemWeight1=13500",
                                               "&OrigZipCode=", quoteData.origZip, "&LineItemCount=1&BusRole=Third Party&OrigCityName=",
                                               quoteData.origCity,
                                               "&DestStateCode=", quoteData.destState,
                                               "&PickupDate=20190102&CONTROLLER=com.rdwy.ec.rexcommon.proxy.http.controller.ProxyApiController",
                                               "&ServiceClass=SPOT&PaymentTerms=Prepaid&OrigStateCode=", quoteData.origState,
                                               "&DestNationCode=USA",
                                               "&LOGIN_USERID=", login_info.username, "&LOGIN_PASSWORD="******"YRC post_data volume", http.post_data);

                string doc = http.Make_http_request();

                //DB.Log("YRC response volume", doc);

                #region Parse result

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(doc);
                XmlNodeList nodeList     = xmlDoc.GetElementsByTagName("TotalCharges");
                double      TotalCharges = 0;
                if (nodeList.Count > 0)
                {
                    TotalCharges = Convert.ToDouble(nodeList[0].InnerText);
                }

                TotalCharges = TotalCharges / 100;



                nodeList = xmlDoc.GetElementsByTagName("StandardDate");
                DateTime StandardDate = DateTime.MaxValue;

                string delivery_date = nodeList[0].InnerText;

                string delivery_year  = "";
                string delivery_month = "";
                string delivery_day   = "";

                try
                {
                    delivery_year = delivery_date.Remove(4);

                    delivery_date = delivery_date.Substring(4);

                    delivery_month = delivery_date.Remove(2);

                    delivery_day = delivery_date.Substring(2);
                }
                catch
                {
                    // Do nothing
                }

                int transit_days = 10;
                if (DateTime.TryParse(string.Concat(delivery_month, "/", delivery_day, "/", delivery_year), out StandardDate))
                {
                    transit_days = Convert.ToInt32((StandardDate - DateTime.Today).TotalDays);
                }

                nodeList = xmlDoc.GetElementsByTagName("QuoteId");
                string QuoteId = string.Empty;
                if (nodeList.Count > 0)
                {
                    QuoteId = nodeList[0].InnerText;
                }

                nodeList = xmlDoc.GetElementsByTagName("ReferenceId");
                string ReferenceId = string.Empty;
                if (nodeList.Count > 0)
                {
                    ReferenceId = nodeList[0].InnerText;
                }

                #endregion

                result.cost         = TotalCharges;
                result.quote_number = QuoteId;
                result.transit_days = transit_days;
                result.carrier_name = "YRC Spot Quote";
            }
            catch (Exception e)
            {
                DB.Log("YRC exception volume", e.ToString());
            }
        }
Пример #5
0
    // For Volume quoting
    #region Get_USF_API_Volume_Quote

    public Volume_result Get_USF_API_Volume_Quote(ref int total_units)
    {
        try
        {
            //quoteData.totalWeight

            //DB.Log("quoteData.totalWeight", quoteData.totalWeight.ToString());

            int Total_lineal_feet = total_units * 2;

            if (quoteData.linealFeet > 0.0) // Requested by XML GCM API
            {
                Total_lineal_feet = Convert.ToInt32(quoteData.linealFeet);
            }

            Logins.Login_info login_info;
            Logins            logins = new Logins();
            logins.Get_login_info(120, out login_info);

            string url = string.Concat("https://api.reddawayregional.com/api/SpotQuote/doSpotQuote?accessKey=", login_info.API_Key,

                                       //"&originZip=29154&destinationZip=30303",
                                       "&originZip=", quoteData.origZip, "&destinationZip=", quoteData.destZip,
                                       "&weight=", quoteData.totalWeight, "&handlingUnits=", total_units,
                                       "&palletized=Y&stackable=N&lengthInFeet=", Total_lineal_feet);

            //DB.Log("Get_USF_API_Volume_Quote request", url);

            Web_client http = new Web_client
            {
                url          = url,
                content_type = "",
                accept       = "*/*",
                method       = "GET"
            };

            //DB.Log("gcmAPI_Get_LOUP_Rates before send request", "before send request");

            string doc = http.Make_http_request();

            //DB.Log("Get_USF_API_Volume_Quote response", doc);

            Volume_result volume_result = new Volume_result();

            #region Parse result

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(doc);
            XmlNodeList nodeList = xmlDoc.GetElementsByTagName("CHARGES");
            double      CHARGES  = 0;
            if (nodeList.Count > 0)
            {
                CHARGES            = Convert.ToDouble(nodeList[0].InnerText);
                volume_result.cost = CHARGES;
            }

            nodeList = xmlDoc.GetElementsByTagName("FREIGHTCHARGES");
            double FREIGHTCHARGES = 0;
            if (nodeList.Count > 0)
            {
                FREIGHTCHARGES = Convert.ToDouble(nodeList[0].InnerText);
            }

            if (FREIGHTCHARGES != CHARGES)
            {
                #region Send email

                EmailInfo info = new EmailInfo
                {
                    to          = AppCodeConstants.Alex_email,
                    fromAddress = AppCodeConstants.Alex_email,
                    fromName    = "Alex",
                    subject     = "FREIGHTCHARGES != CHARGES"
                };
                Mail mail = new Mail(ref info);
                mail.SendEmail();

                #endregion
            }

            //if (quoteData.isHazmat.Equals(true))
            //{
            //    totalCharges += 20.5;
            //}

            nodeList = xmlDoc.GetElementsByTagName("SERVICEDAYS");
            int SERVICEDAYS = 0;
            if (nodeList.Count > 0)
            {
                SERVICEDAYS = Convert.ToInt32(nodeList[0].InnerText);
                volume_result.transit_days = SERVICEDAYS;
            }

            nodeList = xmlDoc.GetElementsByTagName("SPOTQUOTEID");
            string SPOTQUOTEID = string.Empty;
            if (nodeList.Count > 0)
            {
                SPOTQUOTEID = nodeList[0].InnerText;
                volume_result.quote_number = SPOTQUOTEID;
            }

            volume_result.carrier_name = "USF Holland";

            #endregion

            return(volume_result);
        }
        catch (Exception e)
        {
            DB.Log("Get_USF_API_Volume_Quote", e.ToString());
            Volume_result volume_result = new Volume_result();
            return(volume_result);
        }
    }