Ejemplo n.º 1
0
    public void Get_XPO_Access_token(out string access_token)
    {
        try
        {
            Logins.Login_info login_info;
            Logins            logins = new Logins();
            logins.Get_login_info(126, out login_info);

            string access_key = login_info.API_Key;

            string data = string.Concat("grant_type=password&username="******"&password="******"https://api.ltl.xpo.com/token",
                content_type = "application/x-www-form-urlencoded",
                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("Basic ", access_key);

            string doc = http.Make_http_request();

            #region Parse result

            string[] tokens = new string[4];
            tokens[0] = "access_token";
            tokens[1] = ":";
            tokens[2] = "\"";
            tokens[3] = "\"";

            access_token = HelperFuncs.scrapeFromPage(tokens, doc);

            #endregion
        }
        catch (Exception e)
        {
            access_token = "not found";
            //string str = e.ToString();
            DB.Log("Get_XPO_Access_token", e.ToString());
        }
    }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        private void GetRateFromRRTS_QuoteByAccount(ref gcmAPI.RRTS_WebService.QuoteResponse objRoadRunnerResult)
        {
            //DB.Log("GetRateFromRRTS_QuoteByAccount", "");
            try
            {
                if (quoteData.username.Equals("durachem"))
                {
                    return;
                }

                double maxLengthDim = 0;
                HelperFuncs.GetMaxLengthDimension(ref quoteData.m_lPiece, ref maxLengthDim);

                if (!quoteData.mode.Equals("NetNet"))
                {
                    if ((quoteData.AccessorialsObj.LGPU.Equals(true) ||
                         quoteData.AccessorialsObj.LGDEL.Equals(true)) && maxLengthDim > 54)
                    {
                        throw new Exception("RDFS over 54 dim");
                    }
                }
                if (quoteData.AccessorialsObj.TRADEPU || quoteData.AccessorialsObj.TRADEDEL)
                {
                    throw new Exception("tradeshow");
                }

                gcmAPI.RRTS_WebService.QuoteAccountRequest quoteAccountRequest = new gcmAPI.RRTS_WebService.QuoteAccountRequest();
                quoteAccountRequest.Account = accountNumber;

                gcmAPI.RRTS_WebService.ServiceOptions[] objSOArray;

                quoteAccountRequest.OriginZip      = quoteData.origZip;
                quoteAccountRequest.DestinationZip = quoteData.destZip;; //"N1K1B8";
                quoteAccountRequest.OriginType     = "B";                //Third Party
                quoteAccountRequest.PaymentType    = "P";                //PrePaid

                gcmAPI.RRTS_WebService.ShipmentDetail objSD;
                objSD = new gcmAPI.RRTS_WebService.ShipmentDetail();

                quoteAccountRequest.ShipmentDetails = getRRTS_ShipmentDetails(ref rateAsClass50);

                if (quoteAccountRequest.ShipmentDetails == null)
                {
                    throw new Exception("error getting inputs");
                }

                quoteAccountRequest.ShipDate = quoteData.puDate;

                objSOArray = GetShipmentOptionsForRoadRunner();
                quoteAccountRequest.ServiceDeliveryOptions = objSOArray;

                gcmAPI.RRTS_WebService.RateQuote objRQ = new gcmAPI.RRTS_WebService.RateQuote();

                gcmAPI.RRTS_WebService.AuthenticationHeader objAuthentication = new gcmAPI.RRTS_WebService.AuthenticationHeader();

                Logins.Login_info login_info;
                Logins            logins = new Logins();

                if (quoteData.username.ToLower().Equals("field16")) //account specific login
                {
                    logins.Get_login_info(22, out login_info);
                    objAuthentication.Password = login_info.password;
                    objAuthentication.UserName = login_info.username;
                }
                else
                {
                    logins.Get_login_info(21, out login_info);
                    objAuthentication.Password = login_info.password;
                    objAuthentication.UserName = login_info.username;
                }

                objRQ.Timeout = 20000;
                objRQ.AuthenticationHeaderValue = objAuthentication;

                gcmAPI.RRTS_WebService.QuoteResponse objQResponse = new gcmAPI.RRTS_WebService.QuoteResponse();

                //objQResponse = objRQ.CallRateQuote(quoteAccountRequest);

                objQResponse = objRQ.RateQuoteByAccount(quoteAccountRequest);

                objRoadRunnerResult = objQResponse;
            }
            catch (Exception ex)
            {
                //if (!ex.Message.Contains("no standard service") && !ex.Message.Contains("not in the standard") && !ex.Message.Contains("must be today") && !ex.Message.Contains("timed out"))
                //{
                //    DB.Log("Roadrunner (Live)", ex.ToString(), "");
                //}
                DB.Log("Roadrunner (Live)", ex.ToString());
            }
        }
Ejemplo n.º 5
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());
            }
        }
Ejemplo n.º 6
0
    private void GetResultObjectFromConWayFreight(ref GCMRateQuote gcmRateQuote)
    {
        Logins.Login_info login_info;
        Logins            logins = new Logins();

        logins.Get_login_info(46, out login_info);


        String userId = login_info.username; String passWd = login_info.password;


        try
        {
            if (quoteData.AccessorialsObj.TRADEPU.Equals(true) || quoteData.AccessorialsObj.TRADEDEL.Equals(true))
            {
                throw new Exception("Tradeshow not supported");
            }

            double totalCharges = 0;
            int    standardDays = -1, overlengthFee = 0;
            string multPieces = "", accessorials = "";

            CookieContainer container = new CookieContainer();

            for (int i = 0; i < quoteData.m_lPiece.Length; i++)
            {
                multPieces += string.Concat("<Item>",
                                            "<CmdtyClass>", quoteData.m_lPiece[i].FreightClass.Replace(".", ""),
                                            "</CmdtyClass>",
                                            "<Weight unit=\"lbs\">", quoteData.m_lPiece[i].Weight,
                                            "</Weight>",
                                            "</Item>");
            }

            // Get Overlenth Fee
            HelperFuncs.GetOverlengthFee(ref quoteData.m_lPiece, ref overlengthFee, 168, 168, 168, 89, 89, 89); // $88.25 per shipment

            #region Accessorials

            if (quoteData.AccessorialsObj.INSDEL)
            {
                accessorials += "<Accessorial>DID</Accessorial>";
            }
            if (quoteData.AccessorialsObj.RESDEL)
            {
                accessorials += "<Accessorial>RSD</Accessorial>";
            }
            if (quoteData.AccessorialsObj.RESPU)
            {
                accessorials += "<Accessorial>RSO</Accessorial>";
            }
            if (quoteData.AccessorialsObj.CONDEL)
            {
                accessorials += "<Accessorial>CSD</Accessorial>";
            }
            if (quoteData.AccessorialsObj.CONPU)
            {
                accessorials += "<Accessorial>OCS</Accessorial>";
            }

            /*if (AccessorialsObj.TRADEDEL)
             * {
             * request.Append("<AccessorialItem>");
             *  request.Append("<Code>InsideDelivery</Code>");
             *  request.Append("</AccessorialItem>");
             * }
             * if (AccessorialsObj.TRADEPU)
             * {
             *  request.Append("<AccessorialItem>");
             *  request.Append("<Code>InsideDelivery</Code>");
             *  request.Append("</AccessorialItem>");
             * }*/
            if (quoteData.AccessorialsObj.LGPU)
            {
                accessorials += "<Accessorial>OLG</Accessorial>";
            }
            if (quoteData.AccessorialsObj.LGDEL)
            {
                accessorials += "<Accessorial>DLG</Accessorial>";
            }
            if (quoteData.AccessorialsObj.APTDEL)
            {
                accessorials += "<Accessorial>DNC</Accessorial>";
            }
            if (quoteData.isHazmat)
            {
                accessorials += "<Accessorial>ZHM</Accessorial>";
            }

            #endregion

            // Format Today's Date into mm/dd/yy format
            string today = DateTime.Today.Month.ToString() + "/" + DateTime.Today.Day.ToString() +
                           "/" + DateTime.Today.Year.ToString().Remove(0, 2);

            #region Not used
            //string ChargeCode = "C";

            //if (acctInfo.acctNum.Equals("561452031"))
            //{
            //    ChargeCode = "P";
            //}
            //else if (quoteData.origZip.Equals("08854") || quoteData.origZip.Equals("08901") || quoteData.origZip.Equals("40109") ||
            //    quoteData.origZip.Equals("77029") || quoteData.origZip.Equals("91708"))
            //{
            //    ChargeCode = "P";
            //}
            #endregion

            string ChargeCode = acctInfo.chargeType;

            if (quoteData.origZip.Equals("08854") || quoteData.origZip.Equals("08901") || quoteData.origZip.Equals("40109") ||
                quoteData.origZip.Equals("77029") || quoteData.origZip.Equals("91708"))
            {
                ChargeCode = "P";
            }

            string rateRequest = string.Concat("<RateRequest>", "<OriginZip country=\"us\">", quoteData.origZip, "</OriginZip>",
                                               "<DestinationZip country=\"us\">", quoteData.destZip, "</DestinationZip>",
                                               "<CustNmbr shipcode=\"", acctInfo.terms, "\">", acctInfo.acctNum, "</CustNmbr>", // make dynamic
                                               "<ChargeCode>", ChargeCode, "</ChargeCode>",
                                               "<EffectiveDate>", today, "</EffectiveDate>", multPieces, accessorials,
                                               //"<Item>" + "<CmdtyClass>775</CmdtyClass>" + "<Weight unit=\"lbs\">667</Weight>" + "</Item>" +
                                               //"<Item>" +
                                               //"<CmdtyClass>100</CmdtyClass>" + "<Weight unit=\"lbs\">555</Weight>" + "</Item>" +
                                               //"<Accessorial>SSC</Accessorial>" + "<Accessorial>DNC</Accessorial>" + "<Accessorial>GUR</Accessorial>" +
                                               "</RateRequest>");

            //DB.Log("Con Way (Live)", rateRequest, "");

            string[] res = getConWayFreightRate(ref userId, ref passWd, ref rateRequest);

            totalCharges = Convert.ToDouble(res[3]);
            //DB.Log("Con Way (Live)", totalCharges.ToString());

            if (!int.TryParse(res[2], out standardDays))
            {
                standardDays = -3;
            }

            if (totalCharges > 0)
            {
                gcmRateQuote.TotalPrice    = totalCharges + overlengthFee;
                gcmRateQuote.DisplayName   = acctInfo.displayName;
                gcmRateQuote.Documentation = "";
                gcmRateQuote.DeliveryDays  = standardDays;
                gcmRateQuote.BookingKey    = "#1#";
                gcmRateQuote.CarrierKey    = "Con-way";

                //CarsOnTime carOnTime;
                //if (Session["onTimeDict"] != null && ((Dictionary<string, CarsOnTime>)Session["onTimeDict"]).TryGetValue("Frontline", out carOnTime))
                //{
                //    objQuote.OnTimePercent = carOnTime.onTimePercent + '%';
                //    objQuote.ShipsBetweenStates = carOnTime.delivOnTime + carOnTime.delivLate;
                //}
            }
            else
            {
            }
        }
        catch (Exception exp)
        {
            DB.Log("Con Way (Live)", exp.ToString());
        }
    }
Ejemplo n.º 7
0
        public GCMRateQuote GetResultObjectFromDaytonFreight()
        {
            //DB.Log("GetResultObjectFromDaytonFreight", "");
            try
            {
                if (quoteData.AccessorialsObj.TRADEPU.Equals(true) || quoteData.AccessorialsObj.TRADEDEL.Equals(true))
                {
                    throw new Exception("Tradeshow not supported");
                }

                LoadFreightArray();

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

                string strCustomerNumber = login_info.account;
                gcmAPI.com.daytonfreight.www.RateResult objDFResult;
                //gcmAPI.com.daytonfreight.www.RateResult objGRResultAM;
                //gcmAPI.com.daytonfreight.www.RateResult objGRResultPM;

                gcmAPI.com.daytonfreight.www.Credentials objCredentials = new gcmAPI.com.daytonfreight.www.Credentials();
                objCredentials.UserName = login_info.username;
                objCredentials.Password = login_info.password;
                gcmAPI.com.daytonfreight.www.ShippingService objSS = new gcmAPI.com.daytonfreight.www.ShippingService();
                objSS.CredentialsValue = objCredentials;
                /////////////////////////

                string[] arrAccCode = GetAccessorialCodesForDaytonFreight();
                objDFResult = objSS.Rate(strCustomerNumber, com.daytonfreight.www.Terms.ThirdParty,
                                         quoteData.origZip, quoteData.destZip, "", objRSIArray, arrAccCode);
                //SC

                //objGRResultAM = objSS.Rate(strCustomerNumber, com.daytonfreight.www.Terms.ThirdParty, midOrigZip, midDestZip, "AM", objRSIArray, arrAccCode);
                //objGRResultPM = objSS.Rate(strCustomerNumber, com.daytonfreight.www.Terms.ThirdParty, midOrigZip, midDestZip, "PM", objRSIArray, arrAccCode);

                //objDFResult.
                //objGUResult = objSS.GetGuaranteedServiceInformation(midOrigZip, midDestZip, Convert.ToDateTime("2008-04-17 13:58:06.000"));

                //SC
                ///////////////////////
                if (objDFResult != null)
                {
                    double dblAdditionalAccessorialCharge = 0;

                    foreach (gcmAPI.com.daytonfreight.www.AccessorialDetailInformation objAccessDetail in objDFResult.Accessorials)
                    {
                        if (
                            objAccessDetail.Code.Trim().ToUpper().Equals("LIFT") && quoteData.AccessorialsObj.LGDEL &&
                            quoteData.AccessorialsObj.LGPU
                            )
                        {
                            dblAdditionalAccessorialCharge += objAccessDetail.Amount;
                        }
                        else if (
                            objAccessDetail.Code.Trim().ToUpper().Equals("HMF") && quoteData.AccessorialsObj.APTPU &&
                            quoteData.AccessorialsObj.APTDEL
                            )
                        {
                            dblAdditionalAccessorialCharge += objAccessDetail.Amount;
                        }
                        else if (objAccessDetail.Code.Trim().ToUpper().Equals("RESID"))
                        {
                            int intCount = 0;
                            if (quoteData.AccessorialsObj.RESDEL)
                            {
                                intCount += 1;
                            }
                            if (quoteData.AccessorialsObj.RESPU)
                            {
                                intCount += 1;
                            }
                            if (quoteData.AccessorialsObj.CONDEL)
                            {
                                intCount += 1;
                            }
                            if (quoteData.AccessorialsObj.CONPU)
                            {
                                intCount += 1;
                            }
                            /////////////
                            dblAdditionalAccessorialCharge += objAccessDetail.Amount * (intCount - 1);
                        }
                    }
                    dblAdditionalAccessorialCharge += GetInsidePickupDeliveryCharge();

                    double totalCharges = objDFResult.Total + dblAdditionalAccessorialCharge;

                    #region Overlength
                    if (totalCharges > 0)
                    {
                        int overlengthFee = 0;

                        // Get Overlenth Fee
                        HelperFuncs.GetOverlengthFee(ref quoteData.m_lPiece, ref overlengthFee, 180, 180, 180, 110, 110, 110);
                        totalCharges += overlengthFee;
                    }
                    #endregion

                    #region Cost Additions
                    //if (quoteData.subdomain.Equals("spc") || isCostPlus)
                    //{
                    //    totalCharges = HelperFuncs.addSPC_Addition(totalCharges);
                    //}

                    //if (quoteData.subdomain.Equals(HelperFuncs.Subdomains.clipper))
                    //{
                    //    totalCharges = HelperFuncs.addClipperSubdomain_Addition(totalCharges);
                    //}
                    #endregion

                    gcmAPI.com.daytonfreight.www.TransitTimeResult objTransitTime;
                    objTransitTime = objSS.GetTransitTime(quoteData.origZip, quoteData.destZip);

                    Int16 transitTime;

                    if (objTransitTime != null)
                    {
                        transitTime = Convert.ToInt16(objTransitTime.TotalServiceDays);
                    }
                    else
                    {
                        transitTime = -1;
                    }

                    //objDaytonFreightResult = SetInfoToObjectQuote(ref totalCharges, "Dayton Freight", "#1#", "Dayton",
                    //"http://www.globalcargomanager.com/Documents/DaytonFreight_Guaranteed.pdf", transitTime, "Dayton");

                    GCMRateQuote gcmRateQuote = new GCMRateQuote
                    {
                        TotalPrice    = totalCharges,
                        DisplayName   = "Dayton Freight",
                        Documentation = "http://www.globalcargomanager.com/Documents/DaytonFreight_Guaranteed.pdf",
                        DeliveryDays  = transitTime,
                        BookingKey    = "#1#",
                        CarrierKey    = "Dayton"
                    };

                    return(gcmRateQuote);
                }
                else
                {
                    return(null);
                }
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                #region Catch

                //gcmRateQuote = null;
                WebServiceException[] webServiceExceptions = ParseSoapException(ex);
                StringBuilder         stringBuilder        = new StringBuilder();
                for (int i = 0; i < webServiceExceptions.Length; i++)
                {
                    stringBuilder.Append(webServiceExceptions[i].Message + "\r\n");
                }
                //throw new Exception(stringBuilder.ToString());

                DB.Log("Dayton (Live) Soap Exception", stringBuilder.ToString());

                return(null);

                #endregion
                //DB.Log("Dayton (Live) Soap Exception", ex.ToString());
            }
            catch (Exception ex)
            {
                #region Catch

                //gcmRateQuote = null;
                DB.Log("Dayton (Live)", ex.ToString());

                return(null);

                #endregion
            }
        }
Ejemplo n.º 8
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);
        }
    }
Ejemplo n.º 9
0
    private void GetResultObjectFromUSFReddaway(ref GCMRateQuote gcmRateQuote)
    {
        try
        {
            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/RateQuote/doRateQuote?accessKey=",
                                       login_info.API_Key,

                                       "&accountId=", acctInfo.acctNum,
                                       "&originZipCode=", quoteData.origZip, "&destZipCode=", quoteData.destZip, "&direction=3rdParty&chargeType=", acctInfo.chargeType,
                                       "&AspxAutoDetectCookieSupport=1");

            for (byte i = 1; i <= quoteData.m_lPiece.Length; i++)
            {
                url += string.Concat("&shipmentClass", i, "=", quoteData.m_lPiece[i - 1].FreightClass,
                                     "&shipmentWeight", i, "=", quoteData.m_lPiece[i - 1].Weight);
            }

            string responseFromServer = (string)HelperFuncs.generic_http_request_3("string", null, url, "", "",
                                                                                   "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "GET", "", false, false, "", "");

            //DB.Log("USFReddawayPrepaid responseFromServer", responseFromServer);

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

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

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

            nodeList = xmlDoc.GetElementsByTagName("ASCLASS");

            int transitDays;
            transitDays = standardDays;

            gcmRateQuote.TotalPrice = totalCharges;

            gcmRateQuote.DisplayName = acctInfo.displayName;
            gcmRateQuote.BookingKey  = acctInfo.bookingKey;
            gcmRateQuote.CarrierKey  = acctInfo.carrierKey;

            gcmRateQuote.DeliveryDays = transitDays;
        }
        catch (Exception exp)
        {
            gcmRateQuote = null;
            DB.Log("USFReddawayPrepaid", exp.ToString());
        }
    }