Пример #1
0
    public GCMRateQuote GetRateFromXPO()
    {
        GCMRateQuote gcmRateQuote = new GCMRateQuote();

        GetResultObjectFromConWayFreight(ref gcmRateQuote);

        return(gcmRateQuote);
    }
Пример #2
0
    private static bool IsOurRateBetter(GCMRateQuote tempQuote, GCMRateQuote newQuoteItem)
    {
        double dblRate;

        dblRate = Convert.ToDouble(Convert.ToDouble(tempQuote.TotalPrice * 105) / 100.00);
        if (newQuoteItem.TotalPrice <= dblRate || (newQuoteItem.TotalPrice - tempQuote.TotalPrice) <= 10)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Пример #3
0
        static void Main(string[] args)
        {
            //LOUP_test loup = new LOUP_test();
            //loup.Get_LOUP_rates();

            //Console.WriteLine("Hello World");
            //Console.ReadLine();

            CarrierAcctInfo acctInfo = new CarrierAcctInfo();

            acctInfo.acctNum    = "";
            acctInfo.chargeType = "P";
            acctInfo.terms      = "3";
            acctInfo.username   = "";
            acctInfo.password   = "";

            acctInfo.bookingKey  = "#1#";
            acctInfo.displayName = "Estes Genera";
            acctInfo.carrierKey  = "Estes";

            //Repository repo = new Repository();

            QuoteData quoteData = new QuoteData();

            quoteData.origCity  = "Atlanta";
            quoteData.origZip   = "30303";
            quoteData.origState = "GA";

            quoteData.destCity  = "Seattle";
            quoteData.destZip   = "98144";
            quoteData.destState = "WA";

            GCMRateQuote estesQuote_DLS_account = new GCMRateQuote();

            Estes estes = new Estes(ref acctInfo, ref quoteData);

            estes.getEstesAPI_Rate("US", "US", null, ref estesQuote_DLS_account);
        }
Пример #4
0
        public void Get_rates(out GCMRateQuote Frontier_Quote_Genera)
        {
            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

                Web_client http = new Web_client();

                #region Basic Authentication


                http.header_names  = new string[1];
                http.header_values = new string[1];

                http.header_names[0] = "Authorization";

                http.header_values[0] = "Basic " + AppCodeConstants.frontier_genera_basic_auth;


                //http.url = "https://apitest.frontierscs.com/ShippingAPI/rates/";

                #endregion

                http.url = "https://apiprod.frontierscs.com/ShippingAPI/rates/";

                http.method = "POST";

                string items = "";
                for (byte i = 0; i < quoteData.m_lPiece.Length; i++)
                {
                    items += string.Concat("{",
                                           "\"weight\":", quoteData.m_lPiece[i].Weight, ", ",
                                           "\"length\":40,",
                                           "\"width\":48,",
                                           "\"height\":40",
                                           "}");

                    if (i == quoteData.m_lPiece.Length - 1)
                    {
                        // Do nothing
                    }
                    else
                    {
                        items += ",";
                    }
                }

                //DB.LogGenera("items", "items before", items);

                //items.Remove(items.Length - 1);

                //DB.LogGenera("items", "items after", items);

                #region Post data

                http.post_data = string.Concat("{",
                                               "\"originCode\":\"", quoteData.origZip, "\",",
                                               //"\"destinationCode\":\"T1X 0A2\",",
                                               "\"destinationCode\":\"", quoteData.destZip, "\",",
                                               "\"pieceCollection\":{",
                                               "\"pieces\":[",
                                               items,
                                               //"{",
                                               //"\"weight\":60,",
                                               //"\"length\":10,",
                                               //"\"width\":10,",
                                               //"\"height\":10",
                                               //"}",
                                               "]",
                                               "}",
                                               "}");

                //DB.LogGenera("Frontier Get_rates", "http.post_data", http.post_data);

                #endregion

                http.accept       = "application/json";
                http.content_type = "application/json";

                string doc = "";
                doc = http.Make_http_request();

                //DB.LogGenera("Frontier Get_rates", "doc", doc);

                #region Parse result

                //"{\"cost\":{\"estimateCharge\":52.38,\"oversizeCharge\":0.0,\"fuelSurcharge\":8.38,\"additionalCharges\":0.0,\"tax\":0.0,
                //\"crossBorder\":0.0,\"totalCharge\":60.76,\"valid\":true,\"currency\":\"CAD\",\"accessorials\":[]},
                //\"carrier\":\"LOOMIS\",\"estimatedDeliveryDate\":\"2020-01-02\"}"


                string[] tokens = new string[3];
                tokens[0] = "totalCharge";
                tokens[1] = ":";
                tokens[2] = ",";


                string  totalCharge_str = HelperFuncs.scrapeFromPage(tokens, doc);
                decimal totalCharge     = 0M;

                DateTime delivery_date             = DateTime.MinValue;
                string   estimatedDeliveryDate_str = "";

                if (decimal.TryParse(totalCharge_str, out totalCharge))
                {
                    tokens    = new string[4];
                    tokens[0] = "estimatedDeliveryDate";
                    tokens[1] = ":";
                    tokens[2] = "\"";
                    tokens[3] = "\"";

                    estimatedDeliveryDate_str = HelperFuncs.scrapeFromPage(tokens, doc);
                }

                #endregion

                #region Set result

                Frontier_Quote_Genera = new GCMRateQuote();

                if (totalCharge > 0.0M)
                {
                    Frontier_Quote_Genera.TotalPrice = (double)totalCharge;

                    if (DateTime.TryParse(estimatedDeliveryDate_str, out delivery_date))
                    {
                        Utilities.Helper helper = new Utilities.Helper();
                        Frontier_Quote_Genera.DeliveryDays = helper.Get_business_days_between_2_dates(quoteData.puDate, delivery_date);
                        if (Frontier_Quote_Genera.DeliveryDays == 0)
                        {
                            Frontier_Quote_Genera.DeliveryDays = 10;
                        }
                    }
                    else
                    {
                        Frontier_Quote_Genera.DeliveryDays = 10;
                    }
                    //if (ServiceDays > 0)
                    //{
                    //    Frontier_Quote_Genera.DeliveryDays = ServiceDays;
                    //}
                    //else
                    //{
                    //    Frontier_Quote_Genera.DeliveryDays = 10;
                    //}

                    Frontier_Quote_Genera.DisplayName = "Frontier - Genera";
                    Frontier_Quote_Genera.CarrierKey  = "UPS";
                    Frontier_Quote_Genera.BookingKey  = "#1#";
                    Frontier_Quote_Genera.Scac        = "FXPC";
                }

                #endregion
            }
            catch (Exception e)
            {
                Frontier_Quote_Genera = new GCMRateQuote();
                DB.LogGenera("Frontier", "Get_rates", e.ToString());
            }
        }
Пример #5
0
        public void Get_rates(string enc_password, out GCMRateQuote Averitt_Quote_Genera)
        {
            try
            {
                string[] header_names  = new string[1];
                string[] header_values = new string[1];

                header_names[0] = "SOAPAction";

                header_values[0] = "\"\"";


                //Host: webservices.averittexpress.com

                string password = enc_password;

                #region Date

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

                TimeSpan end = new TimeSpan(17, 0, 0);
                TimeSpan now = DateTime.Now.TimeOfDay;

                if (now > end)
                {
                    //DB.LogGenera("averitt", "after five", now.ToString());
                    // After 5 PM, set pickup date to tomorrow
                    day   = DateTime.Today.AddDays(1).Day.ToString();
                    month = DateTime.Today.AddDays(1).Month.ToString();
                    year  = DateTime.Today.AddDays(1).Year.ToString();
                }
                else
                {
                    //DB.LogGenera("averitt", "before five", now.ToString());
                }

                #endregion

                #region Items

                StringBuilder items = new StringBuilder();
                for (byte i = 0; i < quoteData.m_lPiece.Length; i++)
                {
                    items.Append(
                        string.Concat("<ltl:Items>",
                                      "<ltl:ShipmentClass>", quoteData.m_lPiece[i].FreightClass, "</ltl:ShipmentClass>",
                                      "<ltl:ShipmentWeight>", (int)quoteData.m_lPiece[i].Weight, "</ltl:ShipmentWeight>",
                                      "<ltl:Units></ltl:Units>",
                                      "<ltl:Description></ltl:Description>",
                                      "<ltl:NmfcNumber></ltl:NmfcNumber>",
                                      "<ltl:NmfcSubNumber></ltl:NmfcSubNumber>",
                                      "</ltl:Items>"));
                }

                #endregion

                #region Accessorials

                string aptdel = "false", condel = "false", tradedel = "false", insdel = "false", liftgate = "false",
                       resdel = "false", non_commercial = "false", hazmat = "false";

                if (quoteData.AccessorialsObj.APTDEL == true)
                {
                    aptdel = "true";
                }

                if (quoteData.AccessorialsObj.CONDEL == true)
                {
                    condel = "true";
                }

                if (quoteData.AccessorialsObj.TRADEDEL == true)
                {
                    tradedel = "true";
                }

                if (quoteData.AccessorialsObj.INSDEL == true)
                {
                    insdel = "true";
                }

                if (quoteData.AccessorialsObj.LGDEL == true || quoteData.AccessorialsObj.LGPU == true)
                {
                    liftgate = "true";
                }

                if (quoteData.AccessorialsObj.RESDEL == true)
                {
                    resdel = "true";
                }

                if (quoteData.AccessorialsObj.CONPU == true)
                {
                    non_commercial = "true";
                }

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

                #endregion

                string URL = "https://webservices.averittexpress.com/LTLRateQuoteService";

                string XMLRequest =
                    string.Concat("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ltl=\"https://webservices.averittexpress.com/LTLRateQuoteService\">",
                                  "<soapenv:Header xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">",
                                  "<ns:authnHeader soapenv:mustUnderstand=\"0\" xmlns:ns=\"http://webservices.averittexpress.com/authn\" >",
                                  "<Username>", AppCodeConstants.averitt_genera_un, "</Username>",
                                  "<Password>", AppCodeConstants.averitt_genera_pwd, "</Password>",
                                  "</ns:authnHeader>",
                                  "</soapenv:Header>",
                                  "<soapenv:Body>",
                                  "<ltl:getLTLRate>",

                                  "<arg0>",

                                  "<ltl:AccountNumber>", AppCodeConstants.averitt_genera_acct, "</ltl:AccountNumber>",

                                  "<ltl:OriginCity>Coppell</ltl:OriginCity>",
                                  "<ltl:OriginState>TX</ltl:OriginState>",
                                  "<ltl:OriginZip>75019</ltl:OriginZip>",

                                  "<ltl:DestinationCity>", quoteData.destCity, "</ltl:DestinationCity>",
                                  "<ltl:DestinationState>", quoteData.destState, "</ltl:DestinationState> ",
                                  "<ltl:DestinationZip>", quoteData.destZip, "</ltl:DestinationZip>",
                                  "<ltl:ShipDate>", month, "/", day, "/", year, "</ltl:ShipDate>",
                                  "<ltl:CustomerType>Shipper</ltl:CustomerType>",
                                  "<ltl:PaymentType>Prepaid</ltl:PaymentType>",

                                  "<ltl:RequestType></ltl:RequestType>",

                                  "<ltl:ShipmentInfo>",
                                  "<!--Optional:-->",
                                  "<ltl:NumPieces></ltl:NumPieces>",
                                  "<!--Optional:-->",
                                  "<ltl:NumHandlingUnits></ltl:NumHandlingUnits>",
                                  "<!--Optional:-->",
                                  "<ltl:CubicFeet></ltl:CubicFeet>",
                                  "<!--Zero or more repetitions:--> ",

                                  items,

                                  "<!--Optional:--> ",
                                  "<ltl:TotalItem></ltl:TotalItem>",
                                  "<!--Optional:-->",
                                  "<ltl:TotalWeight></ltl:TotalWeight>",
                                  "<!--Optional:-->",

                                  "<ltl:OverLength></ltl:OverLength>",
                                  "<!--Zero or more repetitions:-->",
                                  "<ltl:Accessorial>",

                                  "<ltl:ArrivalNotify>", aptdel, "</ltl:ArrivalNotify>",
                                  "<ltl:ConventionCenterDelivery>", tradedel, "</ltl:ConventionCenterDelivery>",
                                  "<ltl:ConstructionSiteDelivery>", condel, "</ltl:ConstructionSiteDelivery>",
                                  "<ltl:InsideDelivery>", insdel, "</ltl:InsideDelivery>",
                                  "<ltl:Liftgate>", liftgate, "</ltl:Liftgate>",
                                  "<ltl:Hazmat>", hazmat, "</ltl:Hazmat>",
                                  "<ltl:ResidentialDelivery>", resdel, "</ltl:ResidentialDelivery>",
                                  "<ltl:Non-CommercialPickupDelivery>", non_commercial, "</ltl:Non-CommercialPickupDelivery>",

                                  "<ltl:StandardLTLGuarantee>false</ltl:StandardLTLGuarantee>",
                                  "<ltl:SecurityInspection>false</ltl:SecurityInspection>",
                                  "</ltl:Accessorial>",
                                  "</ltl:ShipmentInfo>",
                                  "</arg0>",
                                  "</ltl:getLTLRate>",
                                  "</soapenv:Body>",
                                  "</soapenv:Envelope>");

                //DB.LogGenera("averitt.XMLRequest", "averitt.XMLRequest", XMLRequest);

                Web_client http = new Web_client();

                http.url           = URL;
                http.header_names  = header_names;
                http.header_values = header_values;
                http.method        = "POST";
                http.content_type  = "text/xml; charset=utf-8";
                http.post_data     = XMLRequest;
                string doc = http.Make_http_request();

                //DB.LogGenera("averitt.response", "averitt.response", doc);

                #region Parse result

                /*
                 * <ns2:RateQuoteNumber>38376982</ns2:RateQuoteNumber>
                 * <ns2:EstimatedServiceDays>2</ns2:EstimatedServiceDays>
                 * <ns2:DiscountAmount>$1507.24</ns2:DiscountAmount>
                 * <ns2:DiscountFactor>86.8</ns2:DiscountFactor>
                 * <ns2:RateBase>775</ns2:RateBase>
                 * <ns2:Tariff>ARATE     </ns2:Tariff>
                 * <ns2:FuelCharge>$40.52</ns2:FuelCharge>
                 * <ns2:GrossMinimum>98.00</ns2:GrossMinimum>
                 * <ns2:NetTotal>$269.73</ns2:NetTotal>
                 * <ns2:TotalCharge>$1736.45</ns2:TotalCharge>
                 * <ns2:TotalFreightCharge>$1736.45</ns2:TotalFreightCharge>
                 */

                string[] tokens = new string[3];
                tokens[0] = "NetTotal";
                tokens[1] = ">";
                tokens[2] = "<";

                string NetTotal_str = HelperFuncs.scrapeFromPage(tokens, doc).Replace("$", "");
                double NetTotal     = 0.0;

                int EstimatedServiceDays = 10;

                Averitt_Quote_Genera = new GCMRateQuote();

                if (double.TryParse(NetTotal_str, out NetTotal))
                {
                    Averitt_Quote_Genera.TotalPrice = NetTotal;

                    tokens[0] = "EstimatedServiceDays";
                    string EstimatedServiceDays_str = HelperFuncs.scrapeFromPage(tokens, doc);
                    if (!int.TryParse(EstimatedServiceDays_str, out EstimatedServiceDays))
                    {
                        Averitt_Quote_Genera.DeliveryDays = 5;
                    }
                    else
                    {
                        Averitt_Quote_Genera.DeliveryDays = EstimatedServiceDays;
                    }

                    tokens[0] = "RateQuoteNumber";
                    string RateQuoteNumber = HelperFuncs.scrapeFromPage(tokens, doc);

                    Averitt_Quote_Genera.DisplayName    = "Averitt - Genera";
                    Averitt_Quote_Genera.CarrierKey     = "UPS";
                    Averitt_Quote_Genera.BookingKey     = "#1#";
                    Averitt_Quote_Genera.Scac           = "AVRT";
                    Averitt_Quote_Genera.CarrierQuoteID = RateQuoteNumber;
                }

                #endregion
            }
            catch (Exception e)
            {
                Averitt_Quote_Genera = new GCMRateQuote();
                DB.LogGenera("Averitt", "e", e.ToString());
            }
        }
Пример #6
0
        public GCMRateQuote Get_rate_from_TruckloadRatesCFI()
        {
            decimal      rate  = 0m;
            GCMRateQuote quote = new GCMRateQuote();

            try
            {
                using (SqlConnection conn = new SqlConnection(AppCodeConstants.connStringAesAPI))
                {
                    #region SQL

                    string sql = string.Concat("SELECT rate,transit,quote_id ",

                                               "FROM TruckloadRatesCFI ",

                                               "WHERE orig_zip='", quoteData.origZip, "' AND dest_zip='", quoteData.destZip, "'");

                    #endregion

                    using (SqlCommand command = new SqlCommand())
                    {
                        command.Connection  = conn;
                        command.CommandText = sql;
                        conn.Open();
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                if (reader["rate"] != DBNull.Value)
                                {
                                    rate              = (decimal)reader["rate"];
                                    quote.TotalPrice  = Convert.ToDouble(rate);
                                    quote.DisplayName = "RRD Truckload";
                                    quote.CarrierKey  = "NA";
                                    quote.BookingKey  = "#1#";
                                    quote.OurRate     = quote.TotalPrice;
                                    quote.RateType    = "Truckload Quote";
                                    if (reader["transit"] != DBNull.Value)
                                    {
                                        quote.DeliveryDays = (int)reader["transit"];
                                    }
                                    else
                                    {
                                        quote.DeliveryDays = 10;
                                    }
                                    quote.Scac = "DRRQ";

                                    if (reader["quote_id"] != DBNull.Value)
                                    {
                                        quote.CarrierQuoteID = reader["quote_id"].ToString();
                                    }

                                    //quote.CoverageCost = 100000;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                DB.Log("Get_rate_from_TruckloadRatesCFI", e.ToString());
            }
            return(quote);
        }
Пример #7
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());
        }
    }
Пример #8
0
        public void GetResultObjectFromYRC_API(ref GCMRateQuote gcmRateQuote)
        {
            try
            {
                //DB.Log("GetResultObjectFromYRC_API", "hit func");

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

                if (quoteData.AccessorialsObj.APTPU)
                {
                    throw new Exception("appointment pickup not supported");
                }

                #region Variables

                int count = 0;

                bool isDurachem = false;

                if (acctInfo.acctNum.Equals("13203032805"))
                {
                    isDurachem = true;
                    //If class 55 pass nmfc 101720-3
                    //If class 125 pass nmfc 41027
                }

                string[] weight  = new string[quoteData.m_lPiece.Length];
                string[] fclass  = new string[quoteData.m_lPiece.Length];
                string[] nmfc    = new string[quoteData.m_lPiece.Length];
                string[] length  = new string[quoteData.m_lPiece.Length];
                string[] width   = new string[quoteData.m_lPiece.Length];
                string[] height  = new string[quoteData.m_lPiece.Length];
                string[] pieces  = new string[quoteData.m_lPiece.Length];
                string[] cube    = new string[quoteData.m_lPiece.Length];
                string[] density = new string[quoteData.m_lPiece.Length];

                double[] lengthDbl = new double[quoteData.m_lPiece.Length];
                double[] widthDbl  = new double[quoteData.m_lPiece.Length];
                double[] heightDbl = new double[quoteData.m_lPiece.Length];

                #endregion

                #region Get inputs

                for (int i = 0; i < quoteData.m_lPiece.Length; i++)
                {
                    addOneYRC_Item(ref i, ref count, ref isDurachem, ref weight, ref fclass, ref nmfc, ref length, ref width, ref height, ref cube, ref density, ref pieces);
                }

                #endregion

                #region Accessorials

                byte accCounter = 1;

                StringBuilder sbAccessorials = new StringBuilder();

                if (quoteData.AccessorialsObj.LGPU)
                {
                    sbAccessorials.Append(string.Concat("&AccOption", accCounter, "=LFTO"));
                    //LGPU = "&rq.service.LFTO=true";
                    accCounter++;
                }

                if (quoteData.AccessorialsObj.CONPU)
                {
                    sbAccessorials.Append(string.Concat("&AccOption", accCounter, "=LTDO"));
                    //LIMACCPU = "&rq.service.LTDO=true";
                    accCounter++;
                }

                if (quoteData.AccessorialsObj.CONDEL)
                {
                    sbAccessorials.Append(string.Concat("&AccOption", accCounter, "=LTDD"));
                    //LIMACCDEL = "&rq.service.LTDD=true";
                    accCounter++;
                }

                if (quoteData.AccessorialsObj.RESPU) // || quoteData.AccessorialsObj.CONPU
                {
                    sbAccessorials.Append(string.Concat("&AccOption", accCounter, "=HOMP"));
                    //RESPU = "&rq.service.HOMP=true";
                    accCounter++;
                }

                if (quoteData.AccessorialsObj.LGDEL)
                {
                    sbAccessorials.Append(string.Concat("&AccOption", accCounter, "=LFTD"));
                    //LGDEL = "&rq.service.LFTD=true";
                    accCounter++;
                }

                if (quoteData.AccessorialsObj.RESDEL) // || quoteData.AccessorialsObj.CONDEL
                {
                    //RESDEL = string.Concat("&AccOption", accCounter, "=HOMD");
                    sbAccessorials.Append(string.Concat("&AccOption", accCounter, "=HOMD"));
                    accCounter++;
                }
                if (quoteData.AccessorialsObj.INSDEL)
                {
                    sbAccessorials.Append(string.Concat("&AccOption", accCounter, "=ID"));
                    //INSDEL = "&rq.service.ID=true";
                    accCounter++;
                }

                if (quoteData.AccessorialsObj.APTDEL)
                {
                    sbAccessorials.Append(string.Concat("&AccOption", accCounter, "=NTFY"));
                    //APT = "&rq.service.NTFY=true";
                    accCounter++;
                }

                if (quoteData.isHazmat)
                {
                    sbAccessorials.Append(string.Concat("&AccOption", accCounter, "=HAZM"));
                    //HAZ = "&rq.service.HAZM=true";
                    accCounter++;
                }

                //if (Request.QueryString["q_InsPick"].Equals("true"))
                //{
                //    sbAccessorials.Append(string.Concat("&AccOption", accCounter, "=IP"));
                //    //INSPU = "&rq.service.IP=true";
                //    accCounter++;
                //}

                if (quoteData.AccessorialsObj.TRADEPU)
                {
                    sbAccessorials.Append(string.Concat("&AccOption", accCounter, "=SHWO"));
                    //TRADEPU = "&rq.service.SHWO=true";
                    accCounter++;
                }

                if (quoteData.AccessorialsObj.TRADEDEL)
                {
                    sbAccessorials.Append(string.Concat("&AccOption", accCounter, "=SHWD"));
                    //TRADEDEL = "&rq.service.SHWD=true";
                    accCounter++;
                }


                #endregion

                //------------------------------

                GetYRCInfo_API(ref isDurachem, ref weight, ref fclass, ref nmfc, ref pieces, ref quoteData.numOfUnitsPieces,
                               ref quoteData.hasDimensions, ref cube, ref density,
                               ref sbAccessorials, --accCounter, ref length, ref width, ref height);

                //------------------------------

                if (YRC_Res.standardLTL == -1) // Error
                {
                    throw new Exception("logged error");
                }

                double totalCharges = 0;
                totalCharges = YRC_Res.standardLTL;

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

                gcmRateQuote.DeliveryDays  = YRC_Res.days;
                gcmRateQuote.Documentation = "https://my.yrc.com/dynamic/national/servlet?CONTROLLER=com.rdwy.ec.rexcommon.proxy.http.controller.PublicProxyController&redir=/TFD617&TAG=1TFA99088214BA750628&DATE=01/01/2011";
            }
            catch (Exception exp)
            {
                #region Catch

                gcmRateQuote = null;

                DB.Log("YRC Live", exp.ToString());

                //DB.Log("YRC Live", exp.ToString());
                //if (exp.Message != "logged error" && exp.Message != "appointment pickup not supported" && !exp.Message.Contains("there were not three rate results"))
                //{
                //    DB.Log("YRC Live", exp.ToString(), "");
                //}

                #endregion
            }
        }
Пример #9
0
 public void Add_result_to_array(ref GCMRateQuote estesQuote, ref GCMRateQuote[] totalQuotes)
 {
     totalQuotes = SharedLTL.AddItemsToQuoteArray(totalQuotes, estesQuote);
 }
Пример #10
0
        public void getEstesAPI_Rate(string origCountry, string destCountry,
                                     List <string> accessorials, ref GCMRateQuote estesQuote)
        {
            //string[] res = new string[4];

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

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

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

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

            gcmAPI.Estes_RateWebServ.PickupType pickupType = new gcmAPI.Estes_RateWebServ.PickupType();           //pickup date
            pickupType.date = quoteData.puDate;

            StringBuilder sb = new StringBuilder();

            #region Class and weight

            gcmAPI.Estes_RateWebServ.BaseCommoditiesType baseCommodities = new gcmAPI.Estes_RateWebServ.BaseCommoditiesType();

            gcmAPI.Estes_RateWebServ.BaseCommodityType[] commodTypeArray = new gcmAPI.Estes_RateWebServ.BaseCommodityType[quoteData.m_lPiece.Length];
            //for (int i = 0; i < weights.Count; i++)
            //{
            //    gcmAPI.Estes_RateWebServ.BaseCommodityType commodType = new gcmAPI.Estes_RateWebServ.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
            //}

            for (int i = 0; i < quoteData.m_lPiece.Length; i++)
            {
                //DB.LogGenera("ESTES", "class", quoteData.m_lPiece[i].FreightClass);
                //DB.LogGenera("ESTES", "weight", quoteData.m_lPiece[i].Weight.ToString());

                gcmAPI.Estes_RateWebServ.BaseCommodityType commodType = new gcmAPI.Estes_RateWebServ.BaseCommodityType(); //object that holds one class/weight pair
                commodType.@class = Convert.ToDecimal(quoteData.m_lPiece[i].FreightClass);
                //commodType.weight = quoteData.m_lPiece[i].Weight.ToString();
                commodType.weight  = Convert.ToInt32(quoteData.m_lPiece[i].Weight).ToString();
                commodTypeArray[i] = commodType; //set class/weight to an item in array or classes/weights

                //DB.LogGenera("ESTES", "weight fixed", commodType.weight);
            }

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

            #endregion

            #region Origin and destination

            rateRequest.originPoint               = new gcmAPI.Estes_RateWebServ.PointType();
            rateRequest.originPoint.countryCode   = origCountry;
            rateRequest.originPoint.postalCode    = quoteData.origZip;
            rateRequest.originPoint.city          = quoteData.origCity;
            rateRequest.originPoint.stateProvince = quoteData.origState;

            rateRequest.destinationPoint               = new gcmAPI.Estes_RateWebServ.PointType();
            rateRequest.destinationPoint.countryCode   = destCountry;
            rateRequest.destinationPoint.postalCode    = quoteData.destZip;
            rateRequest.destinationPoint.city          = quoteData.destCity;
            rateRequest.destinationPoint.stateProvince = quoteData.destState;

            if (quoteData.origCountry == "CANADA")
            {
                rateRequest.originPoint.postalCode = quoteData.orig_zip_Canada_no_space;
            }
            else
            {
                //rateRequest.destinationPoint.countryCode = destCountry;
            }

            if (quoteData.destCountry == "CANADA")
            {
                rateRequest.destinationPoint.postalCode = quoteData.dest_zip_Canada_no_space;
            }
            else
            {
                rateRequest.destinationPoint.countryCode = destCountry;
            }

            sb.Append(
                string.Concat(
                    rateRequest.originPoint.city, ", ",
                    rateRequest.originPoint.stateProvince, " ",
                    rateRequest.originPoint.postalCode, " ",
                    rateRequest.originPoint.countryCode, " "
                    )
                );

            sb.Append(
                string.Concat(
                    rateRequest.destinationPoint.city, ", ",
                    rateRequest.destinationPoint.stateProvince, " ",
                    rateRequest.destinationPoint.postalCode, " ",
                    rateRequest.destinationPoint.countryCode
                    )
                );

            #endregion

            //DB.LogGenera("Estes", "request info", sb.ToString());

            #region Accessorials

            if (accessorials == null || 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];
                    //HelperFuncs.writeToSiteErrors("Estes acc live", accessorials[i], "");
                }
            }

            #endregion

            rateRequest.requestID = " ";
            rateRequest.account   = acctInfo.acctNum;

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

            #region Hazmat and stackable

            //HelperFuncs.writeToSiteErrors("Estes", hazmat.ToString(), "");
            rateRequest.hazmatSpecified = true;
            if (quoteData.isHazmat)
            {
                rateRequest.hazmat = gcmAPI.Estes_RateWebServ.YesNoBlankType.Y;
            }
            else
            {
                rateRequest.hazmat = gcmAPI.Estes_RateWebServ.YesNoBlankType.N;
            }

            rateRequest.stackableSpecified = true; //to do ask Bob about this
            rateRequest.stackable          = gcmAPI.Estes_RateWebServ.YesNoBlankType.Y;

            #endregion

            rateServ.auth          = new gcmAPI.Estes_RateWebServ.AuthenticationType();
            rateServ.auth.user     = acctInfo.username;
            rateServ.auth.password = acctInfo.password;

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

            pricing = rateQuote.quote.pricing;

            DateTime delDate = pricing[0].deliveryDate;

            decimal discount = pricing[0].totalDiscount;
            //decimal fuel = pricing[0].accessorialInfo[0].charge;

            decimal accessorial_charges = 0m;
            for (byte i = 0; i < pricing[0].accessorialInfo.Length; i++)
            {
                accessorial_charges += pricing[0].accessorialInfo[i].charge;
            }

            Estes_RateWebServ.CommodityInfoType[] commodity =
                new Estes_RateWebServ.CommodityInfoType[rateQuote.quote.commodityInfo.Length];
            commodity = rateQuote.quote.commodityInfo;

            //decimal charge = commodity[0].charge;
            decimal charge = 0m;
            for (byte i = 0; i < commodity.Length; i++)
            {
                charge += commodity[i].charge;
            }


            decimal rate = commodity[0].rate;

            //DB.LogGenera("Estes", "charge", charge.ToString());

            decimal buy_rate = charge - discount + accessorial_charges;
            //DB.LogGenera("Estes", "discount", discount.ToString());
            //DB.LogGenera("Estes", "fuel", fuel.ToString());
            //DB.LogGenera("Estes", "charge", buy_rate.ToString());

            //DB.LogGenera("Estes", "buy rate", buy_rate.ToString());

            decimal TotalPrice = charge + accessorial_charges - discount;
            //rate +
            if (buy_rate > 0)
            {
                //DB.LogGenera("Estes", "got price", pricing[0].standardPrice.ToString());

                //estesQuote.TotalPrice = (double)buy_rate;

                estesQuote.TotalPrice   = (double)TotalPrice;
                estesQuote.Scac         = "EXLA";
                estesQuote.DeliveryDays = Convert.ToInt32((delDate - quoteData.puDate).TotalDays);
                estesQuote.DisplayName  = "Estes Express - Genera";
                estesQuote.CarrierKey   = "Estes";
                estesQuote.BookingKey   = "#1#";

                //

                // Check for hazmat
                if (quoteData.isHazmat)
                {
                    estesQuote.TotalPrice += 23;
                }

                // liftgate pickup and delivery together addition (when both are present only one charge is added by Estes for some reason)
                if (quoteData.AccessorialsObj.LGPU && quoteData.AccessorialsObj.LGDEL)
                {
                    estesQuote.TotalPrice += 10;
                }
            }
            else
            {
                DB.LogGenera("Estes", "NO price", "");
            }
        }
Пример #11
0
        public void Get_rates(out GCMRateQuote Pyle_Quote_Genera)
        {
            try
            {
                #region Build accessorials string

                string accessorials = "";

                if (quoteData.isHazmat == true)
                {
                    accessorials += "&hazard=1";
                }

                if (quoteData.AccessorialsObj.LGPU)
                {
                    accessorials += "&nplift=1";
                }
                if (quoteData.AccessorialsObj.LGDEL)
                {
                    accessorials += "&nlift=1";
                }
                if (quoteData.AccessorialsObj.RESPU)
                {
                    accessorials += "LGATEP";
                }
                if (quoteData.AccessorialsObj.RESDEL)
                {
                    accessorials += "&nresid=1";
                }
                if (quoteData.AccessorialsObj.CONPU)
                {
                    accessorials += "LGATEP";
                }
                if (quoteData.AccessorialsObj.CONDEL)
                {
                    accessorials += "&ncons=1";
                }
                if (quoteData.AccessorialsObj.APTPU)
                {
                }
                if (quoteData.AccessorialsObj.APTDEL)
                {
                    accessorials += "&ncall=1";
                }
                if (quoteData.AccessorialsObj.TRADEPU)
                {
                    accessorials += "LGATEP";
                }
                if (quoteData.AccessorialsObj.TRADEDEL)
                {
                    accessorials += "LGATEP";
                }
                if (quoteData.AccessorialsObj.INSDEL)
                {
                    accessorials += "&nid=1";
                }

                #endregion

                #region Build items string

                //StringBuilder items = new StringBuilder();

                string items = "";

                //StringBuilder weights = new StringBuilder();
                //StringBuilder classes = new StringBuilder();
                //StringBuilder counts = new StringBuilder();
                //StringBuilder dims = new StringBuilder();

                string weights = "", classes = "", counts = "", dims = "";

                for (byte i = 0; i < quoteData.m_lPiece.Length; i++)
                {
                    weights += string.Concat((int)quoteData.m_lPiece[i].Weight, ",");

                    classes += string.Concat(quoteData.m_lPiece[i].FreightClass, ",");

                    counts += string.Concat(quoteData.m_lPiece[i].Quantity, ",");

                    if (quoteData.m_lPiece[i].Length > 0 && quoteData.m_lPiece[i].Width > 0 && quoteData.m_lPiece[i].Height > 0)
                    {
                        dims += string.Concat(quoteData.m_lPiece[i].Length, "x", quoteData.m_lPiece[i].Width, "x", quoteData.m_lPiece[i].Height, ",");
                    }
                }

                items = string.Concat("&weights=", weights.Remove(weights.Length - 1),
                                      "&classes=", classes.Remove(classes.Length - 1),
                                      "&count=", counts.Remove(counts.Length - 1)
                                      );

                if (dims.Length > 0)
                {
                    items += string.Concat("&dim=", dims.Remove(dims.Length - 1));
                }

                //DB.LogGenera("Pyle", "items", items);

                #endregion
                //11550
                string URL =
                    string.Concat(
                        "https://www.aduiepyle.com/publicdocs/RateQuoteAPI4?MyPyleID=", AppCodeConstants.pyle_genera_id,
                        "&account=", AppCodeConstants.pyle_genera_acct,
                        "&terms=P&oZip=08831&dZip=", quoteData.destZip,

                        items,
                        //"&weights=5000&classes=55&count=4",
                        //"&dim=48x40x48",

                        "&ctrtype=pallet&isfull=empty",

                        accessorials,
                        //"&hazard=1",
                        //"&ins=10000",
                        "&json=1");

                //DB.LogGenera("Pyle", "Request URL", URL);

                #region Get result from server

                Web_client http = new Web_client();

                http.url    = URL;
                http.method = "GET";
                http.accept = "application/json";
                string doc = http.Make_http_request();

                //DB.LogGenera("Pyle", "Response", doc);

                dynamic dyn = JsonConvert.DeserializeObject(doc);

                #endregion

                #region Parse result

                string RateQuoteNumber = "", ShippingDays = "", TotalCharge = "";

                if (dyn.RateQuoteNumber != null)
                {
                    RateQuoteNumber = dyn.RateQuoteNumber;
                }

                if (dyn.ShippingDays != null)
                {
                    ShippingDays = dyn.ShippingDays;
                }

                if (dyn.TotalCharge != null)
                {
                    TotalCharge = dyn.TotalCharge;
                }

                #region Not used, get data from dynamic array

                //string Charge = "";
                //foreach (var obj in dyn.ShipmentCharges)
                //{
                //    if(obj.Charge != null)
                //    {
                //        Charge = obj.Charge;

                //    }
                //}

                #endregion

                Pyle_Quote_Genera = new GCMRateQuote();

                double TotalPrice;
                int    DeliveryDays;
                if (double.TryParse(TotalCharge, out TotalPrice))
                {
                    Pyle_Quote_Genera.TotalPrice = TotalPrice;
                    if (int.TryParse(ShippingDays, out DeliveryDays))
                    {
                        Pyle_Quote_Genera.DeliveryDays = DeliveryDays;
                    }
                    else
                    {
                        Pyle_Quote_Genera.DeliveryDays = 5;
                    }

                    Pyle_Quote_Genera.DisplayName    = "A.Duie Pyle - Genera";
                    Pyle_Quote_Genera.CarrierKey     = "UPS";
                    Pyle_Quote_Genera.BookingKey     = "#1#";
                    Pyle_Quote_Genera.Scac           = "PYLE";
                    Pyle_Quote_Genera.CarrierQuoteID = RateQuoteNumber;
                }

                #endregion
            }
            catch (Exception e)
            {
                Pyle_Quote_Genera = new GCMRateQuote();
                DB.LogGenera("", "e", e.ToString());
            }
        }
Пример #12
0
    public static GCMRateQuote[] AddItemsToQuoteArray(GCMRateQuote[] objQuoteArray, GCMRateQuote newQuoteItem)
    {
        int          intIndex;
        GCMRateQuote tempQuote;
        bool         blnIsAdded = false;
        string       strMFWDisplayName;

        GCMRateQuote[] objResultArray;


        if (objQuoteArray != null && newQuoteItem != null)
        {
            string strYRCIndexesofMFW = "";

            for (intIndex = 0; intIndex < objQuoteArray.Length; intIndex++)
            {
                tempQuote = objQuoteArray[intIndex];
                if (tempQuote != null)
                {
                    strMFWDisplayName = tempQuote.DisplayName;//.Replace(strMFWIdentification,"");

                    if ((tempQuote.CarrierKey == "MFW" && tempQuote.BookingKey.Trim().Equals("#1#")) &&
                        (strMFWDisplayName.Trim().ToLower().Contains(newQuoteItem.DisplayName.Trim().ToLower()) || newQuoteItem.DisplayName.Trim().ToLower().Equals(strMFWDisplayName.Trim().ToLower())) &&
                        !strMFWDisplayName.Trim().ToLower().Contains("max liability"))
                    {
                        if (IsOurRateBetter(tempQuote, newQuoteItem))
                        {
                            //newQuoteItem.DisplayName += strAESIdentification;
                            objQuoteArray[intIndex] = newQuoteItem;
                            return(objQuoteArray);
                        }
                        else
                        {
                            return(objQuoteArray);
                        }
                    }
                }
            }

            // If the carrier of new quote does not exist in MFW;
            int length;

            if (objQuoteArray != null)
            {
                length = objQuoteArray.Length;
            }
            else
            {
                length = 0;
            }

            length = length + 1;

            objResultArray = new GCMRateQuote[length];

            int index = 0;
            foreach (GCMRateQuote quote in objQuoteArray)
            {
                objResultArray[index] = quote;
                index = index + 1;
            }
            //////////
            //newQuoteItem.DisplayName += strAESIdentification;
            objResultArray[index] = newQuoteItem;
        }
        else
        {
            objResultArray = new GCMRateQuote[1];
            //newQuoteItem.DisplayName += strAESIdentification;
            objResultArray[0] = newQuoteItem;
        }

        return(objResultArray);
    }
Пример #13
0
        public void GetResultObjectFromOldDominion_XML(ref GCMRateQuote gcmRateQuote)
        {
            try
            {
                //DB.Log("GetResultObjectFromOldDominion zips, acct",
                //    string.Concat(quoteData.origZip, ", ", quoteData.destZip, ", ", acctInfo.acctNum));

                if (quoteData.AccessorialsObj.TRADEPU.Equals(true) || quoteData.AccessorialsObj.TRADEDEL.Equals(true))
                {
                    return;
                }

                #region Variables

                string url = "", referrer, contentType, accept, method, doc = "", data = "";

                url         = "https://www.odfl.com/wsRate_v4/RateService";
                referrer    = "";
                contentType = "text/xml; charset=utf-8";
                method      = "POST";
                accept      = "*/*";

                #endregion

                #region Build Freight Items

                //StringBuilder freightItems = new StringBuilder();
                string freightItems = string.Empty;
                string freightClass = string.Empty;
                for (byte i = 0; i < quoteData.m_lPiece.Length; i++)
                {
                    if (quoteData.m_lPiece[i].FreightClass.Equals("77.5"))
                    {
                        freightClass = "77";
                    }
                    else if (quoteData.m_lPiece[i].FreightClass.Equals("92.5"))
                    {
                        freightClass = "92";
                    }
                    else
                    {
                        freightClass = quoteData.m_lPiece[i].FreightClass;
                    }
                    freightItems += string.Concat(
                        "<freightItems><ratedClass>", freightClass,
                        "</ratedClass><weight>", quoteData.m_lPiece[i].Weight,
                        "</weight></freightItems>");
                }

                #endregion

                #region Accessorials

                /*
                 *
                 *  ARN Arrival Notification
                 *  HYD Lift Gate Service
                 * COD COD - requires COD amount
                 *  CA Appointment
                 * IND Insurance - requires insurance amount
                 *  IDC Inside Pickup/Delivery
                 *  OVL Overlength Article - 12' but less than 20'
                 *  RDC Residential/Non-Commercial Pickup/Delivery
                 *  CSD Construction Site Pickup/Delivery
                 * CDC Schools, Colleges, Churches Pickup/Delivery
                 * LDC Secured or Limited Access Pickup/Delivery
                 * SWD Self Storage Delivery
                 * PFF Protect From Freezing
                 *  HAZ Hazardous Material
                 *  OV2 Overlength Article - 20' to 28'
                 * DSM Delivery Service to Mines
                 * HSO – scale tickets per military move (Home Moves only)
                 * INH – home move insurance (Home Moves only)
                 *
                 */

                StringBuilder sbAccessorials = new StringBuilder();

                if (quoteData.AccessorialsObj.RESPU || quoteData.AccessorialsObj.RESDEL)
                {
                    sbAccessorials.Append("<accessorials>RDC</accessorials>");
                }

                if (quoteData.AccessorialsObj.CONPU || quoteData.AccessorialsObj.CONDEL)
                {
                    sbAccessorials.Append("<accessorials>CSD</accessorials>");
                }

                if (quoteData.AccessorialsObj.INSDEL)
                {
                    sbAccessorials.Append("<accessorials>IDC</accessorials>");
                }

                if (quoteData.AccessorialsObj.LGPU || quoteData.AccessorialsObj.LGDEL)
                {
                    sbAccessorials.Append("<accessorials>HYD</accessorials>");
                }

                if (quoteData.AccessorialsObj.APTDEL)
                {
                    sbAccessorials.Append("<accessorials>ARN</accessorials>");
                }

                if (quoteData.isHazmat.Equals(true))
                {
                    sbAccessorials.Append("<accessorials>HAZ</accessorials>");
                }

                double maxDim = 0;
                HelperFuncs.GetMaxDimension(ref quoteData.m_lPiece, ref maxDim);

                if (maxDim >= 240)
                {
                    sbAccessorials.Append("<accessorials>OVL</accessorials>");
                }
                else if (maxDim >= 144)
                {
                    sbAccessorials.Append("<accessorials>OV2</accessorials>");
                }
                else
                {
                    // Do nothing
                }

                #endregion

                #region Country

                string originCountry      = "usa";
                string destinationCountry = "usa";

                if (quoteData.origCountry.Equals("CANADA"))
                {
                    originCountry = "CAN";
                }

                if (quoteData.destCountry.Equals("CANADA"))
                {
                    destinationCountry = "CAN";
                }

                #endregion

                #region Post Data

                data = string.Concat("<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">",
                                     "<getLTLRateEstimate xmlns=\"http://myRate.ws.odfl.com/\"><arg0 xmlns=\"\">",

                                     sbAccessorials,
                                     "<destinationCountry>", destinationCountry, "</destinationCountry><destinationPostalCode>", quoteData.destZip, "</destinationPostalCode>",
                                     freightItems,
                                     //"<freightItems><ratedClass>55</ratedClass><weight>2012</weight></freightItems>",
                                     "<odfl4MePassword>", acctInfo.password, "</odfl4MePassword><odfl4MeUser>", acctInfo.username, "</odfl4MeUser>",
                                     "<odflCustomerAccount>", acctInfo.acctNum, "</odflCustomerAccount>",
                                     "<originCountry>", originCountry, "</originCountry><originPostalCode>", quoteData.origZip, "</originPostalCode>",
                                     "<requestReferenceNumber>false</requestReferenceNumber><shipType>LTL</shipType></arg0></getLTLRateEstimate></s:Body></s:Envelope>");

                //DB.Log("odfl request", data);

                #endregion

                #region Headers

                string[] headerNames  = new string[1];
                string[] headerValues = new string[1];

                headerNames[0] = "SOAPAction";

                headerValues[0] = "http://myRate.ws.odfl.com/RateDelegate/getLTLRateEstimateRequest";

                #endregion

                doc = (string)HelperFuncs.generic_http_request_addHeaders("string", null, url, referrer, contentType, accept, method,
                                                                          data, false, headerNames, headerValues);

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

                #region Gather results into an object

                // Gather results into an object
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(doc);

                XmlNodeList nodeList = xmlDoc.GetElementsByTagName("netFreightCharge");

                if (nodeList.Count > 0)
                {
                    string netFreightCharge = nodeList[0].InnerText.Trim();
                    //DB.Log("odfl", netFreightCharge);

                    nodeList = xmlDoc.GetElementsByTagName("serviceDays");

                    string serviceDays = string.Empty;
                    if (nodeList.Count > 0)
                    {
                        serviceDays = nodeList[0].InnerText.Trim();
                        //DB.Log("odfl serviceDays", serviceDays);
                    }

                    if (double.TryParse(netFreightCharge, out double TotalPrice))
                    {
                        //DB.Log("odfl parsed to double", TotalPrice.ToString());

                        #region Add manual Accessorial charges

                        if (quoteData.AccessorialsObj.RESPU && quoteData.AccessorialsObj.RESDEL)
                        {
                            TotalPrice += 70;
                        }

                        if (quoteData.AccessorialsObj.CONPU && quoteData.AccessorialsObj.CONDEL)
                        {
                            TotalPrice += 70;
                        }

                        if (quoteData.AccessorialsObj.LGPU && quoteData.AccessorialsObj.LGDEL)
                        {
                            TotalPrice += 70;
                        }

                        #endregion


                        gcmRateQuote = new GCMRateQuote
                        {
                            TotalPrice    = TotalPrice,
                            DisplayName   = acctInfo.displayName,
                            Documentation = "http://www.odfl.com/service/Expedited/ODFL_660.pdf",
                            BookingKey    = acctInfo.bookingKey,
                            CarrierKey    = acctInfo.carrierKey
                        };

                        if (int.TryParse(serviceDays, out int DeliveryDays))
                        {
                            gcmRateQuote.DeliveryDays = DeliveryDays;
                        }
                        //DB.Log("odfl ", "after service days");
                    }
                }

                #endregion
            }
            catch (Exception e)
            {
                DB.Log("odfl", e.ToString());
            }
        }
Пример #14
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
            }
        }
Пример #15
0
        public void Get_rates(out GCMRateQuote SMTL_Quote_Genera)
        {
            Random rnd    = new Random();
            int    sess_1 = rnd.Next(10000000, 99999999);
            int    sess_2 = rnd.Next(10000000, 99999999);

            try
            {
                string data = string.Concat("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>",
                                            "<SMTLRateRequest>",
                                            "<SMTLIam>Genera_api</SMTLIam>",
                                            "<Token>", AppCodeConstants.smtl_genera_token, "</Token>",
                                            "<Option>Rate</Option>",
                                            "<SessionId>", sess_1, sess_2, "</SessionId>",

                                            "<FromCity>", quoteData.origCity, "</FromCity>",
                                            "<FromState>", quoteData.origState, "</FromState>",
                                            "<FromZip>", quoteData.origZip, "</FromZip>",

                                            "<ToCity>", quoteData.destCity, "</ToCity>",
                                            "<ToState>", quoteData.destState, "</ToState>",
                                            "<ToZip>", quoteData.destZip, "</ToZip>",

                                            //"<FromCity>San Antonio</FromCity>",
                                            //"<FromState>TX</FromState>",
                                            //"<FromZip>78218</FromZip>",

                                            //"<ToCity>Tulsa</ToCity>",
                                            //"<ToState>OK</ToState>",
                                            //"<ToZip>74115</ToZip>",

                                            //"<ShipDate>11/01/2019</ShipDate>",
                                            "<ShipDate>", quoteData.puDate.ToShortDateString(), "</ShipDate>",
                                            "<Terms>P</Terms>",

                                            Get_items(),

                                            //"<Class01>70</Class01><Piece01>3</Piece01>",
                                            //"<Packaging01>SK</Packaging01>",
                                            //"<Weight01>500</Weight01>",
                                            //"<Class02>100</Class02><Piece02>5</Piece02>",
                                            //"<Packaging02>SK</Packaging02><Weight02>1000</Weight02>",
                                            //"<Class03>65</Class03><Piece03>15</Piece03><Packaging03>SK</Packaging03><Weight03>750</Weight03>",
                                            //"<Class04>125</Class04><Piece04>6</Piece04><Packaging04>SK</Packaging04><Weight04>600</Weight04>",
                                            //"<Class05>200</Class05><Piece05>8</Piece05><Packaging05>SK</Packaging05><Weight05>1500</Weight05>",

                                            //"<Class01>70</Class01><Piece01>3</Piece01>",
                                            //"<Packaging01>SK</Packaging01>",
                                            //"<Weight01>500</Weight01><Class02>100</Class02><Piece02>5</Piece02>",
                                            //"<Packaging02>SK</Packaging02><Weight02>1000</Weight02>",
                                            //"<Class03>65</Class03><Piece03>15</Piece03><Packaging03>SK</Packaging03><Weight03>750</Weight03>",
                                            //"<Class04>125</Class04><Piece04>6</Piece04><Packaging04>SK</Packaging04><Weight04>600</Weight04>",
                                            //"<Class05>200</Class05><Piece05>8</Piece05><Packaging05>SK</Packaging05><Weight05>1500</Weight05>",
                                            "<LiabilityCoverage>25000</LiabilityCoverage>",
                                            "<WingExpress>N</WingExpress>",
                                            Get_accessorials(),
                                            //"<Accessorial01></Accessorial01>",
                                            //"<Accessorial02></Accessorial02>",
                                            //"<Accessorial03></Accessorial03>",
                                            //"<Accessorial04></Accessorial04>",
                                            //"<Accessorial05></Accessorial05>",
                                            //"<Accessorial01>Haz</Accessorial01>",
                                            //"<Accessorial02>Const</Accessorial02>",
                                            //"<Accessorial03>Liftp</Accessorial03>",
                                            //"<Accessorial04>Liftd</Accessorial04>",
                                            //"<Accessorial05>Ib</Accessorial05>",
                                            "<ShipperName>ORouke</ShipperName><ShipperAddress>1875 Water Ridge</ShipperAddress>",
                                            "<ReadyTime>1400</ReadyTime><CloseTime>1700</CloseTime><Phone>2106623272</Phone><Contact>Randy</Contact>",
                                            "<PUInstruction1></PUInstruction1><PUInstruction2></PUInstruction2>",
                                            "</SMTLRateRequest>");

                //DB.Log("SMTL data", data);

                Web_client http = new Web_client();


                http.url = string.Concat("http://www2.smtl.com/rpgsp/SMTLRATES.pgm?Request=", data,
                                         "&SessionId=", sess_1, sess_2);


                http.content_type = "text/xml,application/xml";
                http.method       = "GET";

                http.accept = "text/xml,application/xml";

                string doc = http.Make_http_request();

                //DB.Log("SMTL doc", doc);

                #region Parse result

                string[] tokens = new string[3];
                tokens[0] = "<FreightCharges>";
                tokens[1] = ">";
                tokens[2] = "<";

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

                tokens[0] = "<DiscountAmount>";
                string DiscountAmount_str = HelperFuncs.scrapeFromPage(tokens, doc);

                tokens[0] = "<FuelSurchargeAmount>";
                string FuelSurchargeAmount_str = HelperFuncs.scrapeFromPage(tokens, doc);

                decimal TotalCharges = 0.0M, FreightCharges, DiscountAmount, FuelSurchargeAmount;

                if (decimal.TryParse(FreightCharges_str, out FreightCharges) &&
                    decimal.TryParse(DiscountAmount_str, out DiscountAmount) &&
                    decimal.TryParse(FuelSurchargeAmount_str, out FuelSurchargeAmount))
                {
                    if (FreightCharges > 0M && DiscountAmount > 0M && FuelSurchargeAmount > 0M)
                    {
                        TotalCharges = FreightCharges - DiscountAmount + FuelSurchargeAmount;
                    }
                }

                tokens[0] = "<PickupDate>";
                string PickupDate_str = HelperFuncs.scrapeFromPage(tokens, doc);

                tokens[0] = "<DeliveryDate>";
                string DeliveryDate_str = HelperFuncs.scrapeFromPage(tokens, doc);

                DateTime PickupDate, DeliveryDate;

                byte ServiceDays = 0;
                if (DateTime.TryParse(PickupDate_str, out PickupDate) &&
                    DateTime.TryParse(DeliveryDate_str, out DeliveryDate))
                {
                    for (byte i = 0; i < 15; i++)
                    {
                        if (PickupDate == DeliveryDate)
                        {
                            break;
                        }
                        if (PickupDate.DayOfWeek == DayOfWeek.Saturday || PickupDate.DayOfWeek == DayOfWeek.Sunday)
                        {
                        }
                        else
                        {
                            ServiceDays++;
                        }

                        PickupDate = PickupDate.AddDays(1);
                    }
                }

                #endregion

                #region Set result

                SMTL_Quote_Genera = new GCMRateQuote();

                if (TotalCharges > 0.0M)
                {
                    SMTL_Quote_Genera.TotalPrice = (double)TotalCharges;
                    if (ServiceDays > 0)
                    {
                        SMTL_Quote_Genera.DeliveryDays = ServiceDays;
                    }
                    else
                    {
                        SMTL_Quote_Genera.DeliveryDays = 10;
                    }

                    SMTL_Quote_Genera.DisplayName = "SMTL - Genera";
                    SMTL_Quote_Genera.CarrierKey  = "UPS";
                    SMTL_Quote_Genera.BookingKey  = "#1#";
                    SMTL_Quote_Genera.Scac        = "SMTL";
                }

                #endregion
            }
            catch (Exception e)
            {
                SMTL_Quote_Genera = new GCMRateQuote();
                DB.LogGenera("SMTL", "exception", e.ToString());
            }
        }
Пример #16
0
        public void Get_rates(out GCMRateQuote NewPenn_Quote_Genera)
        {
            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

                #region Not used

                //RateQuote rq = new RateQuote();

                //RateQuote[] res = request.quote("", "", "", "GA","Atlanta","30303","WA","Seattle","98144",
                //    "QuoteTerms","50","","","","","500","","","","","test po","quoteCashOnDelivery","accessorial1", "accessorial2",
                //    "accessorial3", "accessorial4", "accessorial5", "accessorial6","quoteHazard","quoteFreeze","GuaranteedDelivery",
                //    "OverLength","OverWidth","Skids","Drums");


                #endregion

                #region Weight and Class

                string weight1 = "", weight2 = "", weight3 = "", weight4 = "";
                string fClass1 = "", fClass2 = "", fClass3 = "", fClass4 = "";

                for (byte i = 0; i < quoteData.m_lPiece.Length; i++)
                {
                    if (quoteData.m_lPiece[i].Weight > 0)
                    {
                        if (i == 0)
                        {
                            weight1 = quoteData.m_lPiece[i].Weight.ToString();
                            fClass1 = quoteData.m_lPiece[i].FreightClass;
                        }
                        else if (i == 1)
                        {
                            weight2 = quoteData.m_lPiece[i].Weight.ToString();
                            fClass2 = quoteData.m_lPiece[i].FreightClass;
                        }
                        else if (i == 2)
                        {
                            weight3 = quoteData.m_lPiece[i].Weight.ToString();
                            fClass3 = quoteData.m_lPiece[i].FreightClass;
                        }
                        else if (i == 3)
                        {
                            weight4 = quoteData.m_lPiece[i].Weight.ToString();
                            fClass4 = quoteData.m_lPiece[i].FreightClass;
                        }
                    }
                }

                if (fClass1 == "92.5")
                {
                    fClass1 = "925";
                }
                else if (fClass1 == "77.5")
                {
                    fClass1 = "775";
                }

                if (fClass2 == "92.5")
                {
                    fClass2 = "925";
                }
                else if (fClass2 == "77.5")
                {
                    fClass2 = "775";
                }

                if (fClass3 == "92.5")
                {
                    fClass3 = "925";
                }
                else if (fClass3 == "77.5")
                {
                    fClass3 = "775";
                }

                if (fClass4 == "92.5")
                {
                    fClass4 = "925";
                }
                else if (fClass4 == "77.5")
                {
                    fClass4 = "775";
                }

                #endregion

                #region Accessorials

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

                if (accessorials.Count > 6)
                {
                    throw new Exception("Too many accessorials");
                }
                string accessorial1 = "", accessorial2 = "", accessorial3 = "", accessorial4 = "", accessorial5 = "", accessorial6 = "";

                for (byte i = 0; i < accessorials.Count; i++)
                {
                    if (i == 0)
                    {
                        accessorial1 = accessorials[i];
                    }
                    else if (i == 1)
                    {
                        accessorial2 = accessorials[i];
                    }
                    else if (i == 2)
                    {
                        accessorial3 = accessorials[i];
                    }
                    else if (i == 3)
                    {
                        accessorial4 = accessorials[i];
                    }
                    else if (i == 4)
                    {
                        accessorial5 = accessorials[i];
                    }
                    else if (i == 5)
                    {
                        accessorial6 = accessorials[i];
                    }
                }

                string hazMat = "";
                if (quoteData.isHazmat)
                {
                    hazMat = "HAZ";
                }

                #endregion

                RequestRateQuoteV6Service request = new RequestRateQuoteV6Service();
                RateQuote[] res = request.quote(AppCodeConstants.new_penn_genera_un, AppCodeConstants.new_penn_genera_pwd,
                                                AppCodeConstants.new_penn_genera_acct, "NJ", "MONROE TOWNSHIP", "08831",

                                                //"VT", "BURLINGTON", "05401",
                                                quoteData.destState, quoteData.destCity, quoteData.destZip,
                                                "PPD",

                                                //"50", "", "", "", "",
                                                //"500", "", "", "", "",

                                                fClass1, fClass2, fClass3, fClass4, "",
                                                weight1, weight2, weight3, weight4, "",

                                                "test po", "", accessorial1, accessorial2,
                                                accessorial3, accessorial4, accessorial5, accessorial6, hazMat, "", "",
                                                "", "", "", "");

                //RateQuote[] res = request.quote("", "", "",
                //"GA","Atlanta","30303",
                //"WA","Seattle","98144",
                //    "QuoteTerms","50","","","","","500","","","","","test po","quoteCashOnDelivery","accessorial1", "accessorial2",
                //    "accessorial3", "accessorial4", "accessorial5", "accessorial6","quoteHazard","quoteFreeze","GuaranteedDelivery",
                //    "OverLength","OverWidth","Skids","Drums");
                //HAZ
                string quoteNetCharges = res[0].quoteNetCharges;

                string quoteTransitDays = res[0].quoteTransitDays;

                NewPenn_Quote_Genera = new GCMRateQuote();
                double TotalPrice;
                int    DeliveryDays;
                if (double.TryParse(quoteNetCharges, out TotalPrice))
                {
                    NewPenn_Quote_Genera.TotalPrice = TotalPrice;
                    if (int.TryParse(quoteNetCharges, out DeliveryDays))
                    {
                        NewPenn_Quote_Genera.DeliveryDays = DeliveryDays;
                    }
                    else
                    {
                        NewPenn_Quote_Genera.DeliveryDays = 5;
                    }

                    NewPenn_Quote_Genera.DisplayName = "New Penn - Genera";
                    NewPenn_Quote_Genera.CarrierKey  = "UPS";
                    NewPenn_Quote_Genera.BookingKey  = "#1#";
                    NewPenn_Quote_Genera.Scac        = "NPME";
                }

                //DB.Log("New Penn", "got result");
            }
            catch (Exception e)
            {
                NewPenn_Quote_Genera = new GCMRateQuote();
                DB.Log("New Penn", e.ToString());
            }
        }
Пример #17
0
    public GCMRateQuote GetRateFromUSF()
    {
        GCMRateQuote gcmRateQuote = new GCMRateQuote();

        GetResultObjectFromUSFReddaway(ref gcmRateQuote);

        bool isSpc = false;

        if (acctInfo.acctNum.Equals("0875353"))
        {
            isSpc = true;
        }

        double overlengthFee = 0.0;

        overlengthFee = HelperFuncs.getUSF_OverlengthFee(ref quoteData.m_lPiece);

        gcmRateQuote.TotalPrice += overlengthFee;

        //DB.Log("USF overlength fee", overlengthFee.ToString());

        // Get Overlenth Fee
        //HelperFuncs.GetOverlengthFee(ref quoteData.m_lPiece, ref overlengthFee, 96, 216, 288, 100, 150, 200);

        /*
         * 8-12 feet   96 to  144         $120
         * 12-16 feet  144 to 192      $300
         * 16-20 feet   192 to 240        $600
         * 20 feet plus   240+     $1200
         */

        #region Accessorials additions

        if (gcmRateQuote != null && gcmRateQuote.TotalPrice > 0)
        {
            if (quoteData.AccessorialsObj.LGPU)
            {
                if (isSpc.Equals(true))
                {
                    gcmRateQuote.TotalPrice += 50;
                }
                else
                {
                    gcmRateQuote.TotalPrice += 65;
                }
            }

            if (quoteData.AccessorialsObj.LGDEL)
            {
                if (isSpc.Equals(true))
                {
                    gcmRateQuote.TotalPrice += 50;
                }
                else
                {
                    gcmRateQuote.TotalPrice += 65;
                }
            }

            if (quoteData.AccessorialsObj.INSDEL)
            {
                gcmRateQuote.TotalPrice += 55;
            }

            if (quoteData.AccessorialsObj.APTPU)
            {
                if (isSpc.Equals(false))
                {
                    gcmRateQuote.TotalPrice += 15;
                }
            }

            if (quoteData.AccessorialsObj.APTDEL)
            {
                if (isSpc.Equals(false))
                {
                    gcmRateQuote.TotalPrice += 15;
                }
            }
        }

        //DB.Log("USFReddawayPrepaid gcmRateQuote.TotalPrice after", gcmRateQuote.TotalPrice.ToString());

        double totalShipWeight = quoteData.totalWeight;

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

        //for (int i = 0; i < lineItems.Length; i++)
        //{
        //    totalShipWeight += lineItems[i].Weight;
        //}


        if (quoteData.AccessorialsObj.RESDEL || quoteData.AccessorialsObj.CONDEL)
        {
            double resDelCharge = (totalShipWeight / 100) * 7.2;
            if (resDelCharge < 130)
            {
                gcmRateQuote.TotalPrice += 130;
            }
            else
            {
                gcmRateQuote.TotalPrice += resDelCharge;
            }
        }
        if (quoteData.AccessorialsObj.RESPU || quoteData.AccessorialsObj.CONPU)
        {
            double resPickCharge = (totalShipWeight / 100) * 7.2;
            if (resPickCharge < 130)
            {
                gcmRateQuote.TotalPrice += 130;
            }
            else
            {
                gcmRateQuote.TotalPrice += resPickCharge;
            }
        }

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

        #endregion

        return(gcmRateQuote);
    }
Пример #18
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());
        }
    }
Пример #19
0
        public void Get_rate(ref string access_token, out GCMRateQuote Daylight_Quote_Genera)
        {
            try
            {
                Web_client http = new Web_client();

                #region Pickup date

                string day = DateTime.Today.Day.ToString(), month = DateTime.Today.Month.ToString();
                if (day.Length == 1)
                {
                    day = string.Concat("0", day);
                }
                if (month.Length == 1)
                {
                    month = string.Concat("0", month);
                }

                #endregion

                #region Build items

                StringBuilder sb_items = new StringBuilder();

                if (quoteData.m_lPiece.Length == 1)
                {
                    sb_items.Append(string.Concat("\"item\": {",

                                                  "\"description\": \"Test\",",
                                                  "\"nmfcNumber\": \"\",",
                                                  "\"nmfcSubNumber\": \"\",",
                                                  "\"pcs\": ", quoteData.m_lPiece[0].Pieces, ",",
                                                  "\"pallets\": ", quoteData.m_lPiece[0].Quantity, ",",
                                                  "\"weight\": ", quoteData.m_lPiece[0].Weight, ", ",
                                                  "\"actualClass\": \"", quoteData.m_lPiece[0].FreightClass, "\"",
                                                  "}"));
                }
                else
                {
                    sb_items.Append("\"item\": [");

                    string items_nodes = "";
                    for (byte i = 0; i < quoteData.m_lPiece.Length; i++)
                    {
                        items_nodes += string.Concat("{",

                                                     "\"description\": \"Test\",",
                                                     "\"nmfcNumber\": \"\",",
                                                     "\"nmfcSubNumber\": \"\",",
                                                     "\"pcs\": ", quoteData.m_lPiece[i].Pieces, ",",
                                                     "\"pallets\": ", quoteData.m_lPiece[i].Quantity, ",",
                                                     "\"weight\": ", quoteData.m_lPiece[i].Weight, ", ",
                                                     "\"actualClass\": \"", quoteData.m_lPiece[i].FreightClass, "\"",
                                                     "},"

                                                     );
                    }

                    // Remove the comma at the end
                    sb_items.Append(items_nodes.Remove(items_nodes.Length - 1));

                    sb_items.Append("]");
                }

                #endregion

                #region Accessorials

                var sb_accessorials = new StringBuilder();

                byte num_of_acc = 0;
                Get_num_of_acc(ref num_of_acc, ref quoteData);

                //DB.LogGenera("Daylight", "num_of_acc", num_of_acc.ToString());

                if (num_of_acc == 0)
                {
                    // Do nothing
                }
                else if (num_of_acc == 1)
                {
                    string acc = "";
                    Get_acc_nodes(ref acc, ref num_of_acc, ref quoteData);
                    // Remove the comma at the end
                    acc = acc.Remove(acc.Length - 1);

                    sb_accessorials.Append(acc);
                }
                else
                {
                    // More than one
                    sb_accessorials.Append("\"accessorial\": [");

                    string acc = "";
                    Get_acc_nodes(ref acc, ref num_of_acc, ref quoteData);

                    //DB.LogGenera("Daylight", "acc before remove", acc);

                    // Remove the comma at the end
                    acc = acc.Remove(acc.Length - 1);

                    //DB.LogGenera("Daylight", "acc after remove", acc);

                    sb_accessorials.Append(acc);

                    sb_accessorials.Append("]");
                }

                #endregion

                http.url    = "https://api.dylt.com/rateQuote";
                http.method = "POST";

                #region post_data

                http.post_data = string.Concat("{",
                                               "\"dyltRateQuoteReq\": {",
                                               "\"accountNumber\": \"", AppCodeConstants.DYLT_Genera_account, "\",",
                                               "\"userName\": \"", AppCodeConstants.DYLT_Genera_username, "\",",
                                               "\"password\": \"", AppCodeConstants.DYLT_Genera_password, "\",",
                                               "\"billTerms\": \"PP\",",
                                               "\"serviceType\": \"LTL\",",
                                               "\"pickupDate\": \"", DateTime.Today.Year, "-", month, "-", day, "\",",
                                               "\"shipperInfo\": {",
                                               "\"customerNumber\": \"\",",
                                               "\"customerName\": \"\",",                   //Genera Corp
                                               "\"customerAddress\": {",
                                               "\"streetAddress\": \"\",",                  //600 Freeport Pkwy Ste 250
                                               "\"aptAddress\": \"\",",
                                               "\"city\": \"", quoteData.origCity, "\",",   //Coppell
                                               "\"state\": \"", quoteData.origState, "\",", //TX
                                               "\"zip\": \"", quoteData.origZip, "\"",      //75019
                                               "}",
                                               "},",
                                               "\"consigneeInfo\": {",
                                               "\"customerNumber\": \"\",",
                                               "\"customerName\": \"\",",                   //Simco Automotive Inc
                                               "\"customerAddress\": {",
                                               "\"streetAddress\": \"\",",                  // 13425 Estelle St
                                               "\"aptAddress\": \"string\",",
                                               "\"city\": \"", quoteData.destCity, "\",",   //Corona
                                               "\"state\": \"", quoteData.destState, "\",", //CA
                                               "\"zip\": \"", quoteData.destZip, "\"",      //92879
                                               "}",
                                               "},",
                                               "\"items\": {", sb_items,
                                               "},",
                                               "\"accessorials\": {", sb_accessorials,

                                               //          "\"accessorial\": {",
                                               //              "\"accName\": \"DELIVERY\",",
                                               //"\"accId\": \"APPOINTMENT FEE\",",
                                               //"\"accValue\": 0",
                                               //          "}",
                                               "}",
                                               "}",
                                               "}"
                                               );

                //DB.LogGenera("Daylight", "post_data", http.post_data);
                //Daylight_Quote_Genera = new GCMRateQuote();
                //return;

                #endregion

                http.accept = "*/*";
                //http.accept = "application/json";
                http.content_type = "application/json";

                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();

                //DB.LogGenera("Daylight", "response", doc);

                dynamic dyn = JsonConvert.DeserializeObject(doc);

                #region Parse result

                #region Sample Response

                //            {
                //                "dyltRateQuoteResp":{
                //                    "success":"YES",
                //      "errorInformation":{
                //                        "errorMessage":"NULL"
                //      },
                //      "quoteNumber":"CQ20093199",
                //      "quoteDate":"08\/05\/2020",
                //      "pickupDate":"08\/05\/2020",
                //      "earliestDeliveryDate":"08\/07\/2020",
                //      "totalWeight":500,
                //      "origZip":75019,
                //      "destZip":92879,
                //      "rateBaseName":"DYLT507AP 2020-02-03",
                //      "itemCharges":{
                //                        "itemCharge":[
                //                           {
                //               "description":"Test",
                //                              "pcs":1,
                //                              "pallets":1,
                //                              "weight":500,
                //                              "actualClass":50,
                //                              "rateClass":50,
                //                              "rate":215.47,
                //                              "charge":1077.35,
                //                              "discountPct":86.5
                //            }
                //         ]
                //      },
                //      "accessorialCharges":{
                //         "accessorialCharge":[
                //            {
                //               "reqAccessorial":"California Compliance Surcharge",
                //               "accRate":9.95,
                //               "accCharge":9.95
                //            },
                //            {
                //               "reqAccessorial":"Appointment Notification",
                //               "accRate":0.0,
                //               "accCharge":0.0
                //            },
                //            {
                //               "reqAccessorial":"Fuel Surcharge",
                //               "accRate":0.207,
                //               "accCharge":30.11
                //            }
                //         ]
                //      },
                //      "totalCharges":{
                //         "grossCharge":1077.35,
                //         "fuelSurcharge":30.11,
                //         "totalAccessorial":40.06,
                //         "discountAmt":931.91,
                //         "netCharge":185.5
                //      }
                //   }
                //}

                #endregion

                string totalCharges = "", quoteNumber = "", netCharge = "", str_earliestDeliveryDate = "", str_pickupDate = "";


                var dyltRateQuoteResp = new Newtonsoft.Json.Linq.JObject();

                if (dyn.dyltRateQuoteResp != null)
                {
                    if (dyn.dyltRateQuoteResp.totalCharges != null)
                    {
                        if (dyn.dyltRateQuoteResp.totalCharges.netCharge != null)
                        {
                            netCharge = dyn.dyltRateQuoteResp.totalCharges.netCharge;
                        }
                    }

                    if (dyn.dyltRateQuoteResp.quoteNumber != null)
                    {
                        quoteNumber = dyn.dyltRateQuoteResp.quoteNumber;
                    }

                    if (dyn.dyltRateQuoteResp.earliestDeliveryDate != null)
                    {
                        str_earliestDeliveryDate = dyn.dyltRateQuoteResp.earliestDeliveryDate;
                    }

                    if (dyn.dyltRateQuoteResp.pickupDate != null)
                    {
                        str_pickupDate = dyn.dyltRateQuoteResp.pickupDate;
                    }
                }

                int transit_days = 5;
                if (DateTime.TryParse(str_earliestDeliveryDate, out DateTime earliestDeliveryDate) &&
                    DateTime.TryParse(str_pickupDate, out DateTime pickupDate))
                {
                    var h = new Utilities.Helper();
                    transit_days = h.Get_business_days_between_2_dates(pickupDate, earliestDeliveryDate);
                }


                #region Not used, get data from dynamic array

                //string Charge = "";
                //foreach (var obj in dyn.totalCharges)
                //{
                //    if (obj.Charge != null)
                //    {
                //        netCharge = obj.netCharge;

                //    }
                //}

                #endregion

                #endregion


                #region Set result

                Daylight_Quote_Genera = new GCMRateQuote();

                if (decimal.TryParse(netCharge, out decimal totalCharge) && totalCharge > 0.0M)
                {
                    Daylight_Quote_Genera.TotalPrice = (double)totalCharge;

                    Daylight_Quote_Genera.DeliveryDays   = transit_days;
                    Daylight_Quote_Genera.CarrierQuoteID = quoteNumber;
                    Daylight_Quote_Genera.DisplayName    = "Daylight - Genera";
                    Daylight_Quote_Genera.CarrierKey     = "DayLight";
                    Daylight_Quote_Genera.BookingKey     = "#1#";
                    Daylight_Quote_Genera.Scac           = "DYLT";
                }

                #endregion
            }
            catch (Exception e)
            {
                DB.LogGenera("Daylight", "e", e.ToString());
                Daylight_Quote_Genera = new GCMRateQuote();
            }
        }
Пример #20
0
        public void GetResultObjectFromEstesExpress(out GCMRateQuote estesQuote)
        {
            estesQuote = new GCMRateQuote();

            #region Variables

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

            string origCountry = "US";
            string destCountry = "US";
            bool   long20 = false, long28 = false, long53 = false;

            #endregion

            try
            {
                #region Check if Canada

                if (quoteData.origCountry.Equals("CANADA"))
                {
                    origCountry = "CN";
                }

                if (quoteData.destCountry.Equals("CANADA"))
                {
                    destCountry = "CN";
                }

                #endregion

                #region Overlength

                for (int i = 0; i < quoteData.m_lPiece.Length; i++)
                {
                    //-----------------------------------------------
                    // Length
                    if (quoteData.m_lPiece[i].Length > 336)
                    {
                        long53 = true;
                        break;
                    }
                    else if (quoteData.m_lPiece[i].Length > 239)
                    {
                        long28 = true;
                    }
                    else if (quoteData.m_lPiece[i].Length > 144)
                    {
                        long20 = true;
                    }

                    // Width
                    if (quoteData.m_lPiece[i].Width > 336)
                    {
                        long53 = true;
                        break;
                    }
                    else if (quoteData.m_lPiece[i].Width > 239)
                    {
                        long28 = true;
                    }
                    else if (quoteData.m_lPiece[i].Width > 144)
                    {
                        long20 = true;
                    }

                    // Height
                    if (quoteData.m_lPiece[i].Height > 336)
                    {
                        long53 = true;
                        break;
                    }
                    else if (quoteData.m_lPiece[i].Height > 239)
                    {
                        long28 = true;
                    }
                    else if (quoteData.m_lPiece[i].Height > 144)
                    {
                        long20 = true;
                    }
                    //-----------------------------------------------
                }

                if (long53)
                {
                    accessorsList.Add("LONG53");
                }
                else if (long28)
                {
                    accessorsList.Add("LONG28");
                }
                else if (long20)
                {
                    accessorsList.Add("LONG20");
                }

                #endregion

                #region Accessorials

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

                #endregion

                getEstesAPI_Rate(origCountry, destCountry, accessorsList, ref estesQuote);

                #region Subdomains 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
            }
            catch (Exception e)
            {
                DB.LogGenera("Estes", "Exception", e.ToString());
            }
        }
Пример #21
0
        public void GetResultObjectFromPittOhio_API(ref GCMRateQuote gcmRateQuote)
        {
            //DB.Log("GetResultObjectFromPittOhio_API", "");
            //DB.Log("GetResultObjectFromPittOhio_API", quoteData.pickupDate);

            try
            {
                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("Pitt Ohio over 54 dim");
                    }
                }

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

                #region Variables

                int           overlengthFee = 0;
                double        cost;
                Int16         days;
                string        multPieces = "", overlength = "";
                StringBuilder sbAccessorials = new StringBuilder();

                #endregion

                #region Weight/class/overlength

                for (byte i = 0; i < quoteData.m_lPiece.Length; i++)
                {
                    multPieces += string.Concat("&Class", (i + 1), "=", quoteData.m_lPiece[i].FreightClass, "&Wgt", (i + 1), "=", quoteData.m_lPiece[i].Weight);

                    if (quoteData.m_lPiece[i].Length > 143)
                    {
                        overlength = "&Acc_OVR=Y";
                    }
                    if (quoteData.m_lPiece[i].Width > 143)
                    {
                        overlength = "&Acc_OVR=Y";
                    }
                    if (quoteData.m_lPiece[i].Height > 143)
                    {
                        overlength = "&Acc_OVR=Y";
                    }
                }

                #endregion

                #region Accessorials

                sbAccessorials.Append(overlength);

                if (quoteData.AccessorialsObj.INSDEL)
                {
                    //insdel = "&Acc_IDL=Y";
                    sbAccessorials.Append("&Acc_IDL=Y");
                }
                //
                if (quoteData.AccessorialsObj.TRADEDEL)
                {
                    //tradedel = "&Acc_CNV=Y";
                    sbAccessorials.Append("&Acc_CNV=Y");
                    //throw new Exception("accessorial not supported");
                }
                if (quoteData.AccessorialsObj.TRADEPU)
                {
                    throw new Exception("accessorial not supported");
                }

                //if (quoteData.AccessorialsObj.LGDEL)
                //{
                //    sbAccessorials.Append("&Acc_LGD=Y");
                //    //lgdel = "&Acc_LGD=Y";
                //}

                if (quoteData.AccessorialsObj.LGPU && quoteData.AccessorialsObj.LGDEL)
                {
                    gcmRateQuote = null;
                    return;
                }

                if (quoteData.AccessorialsObj.LGPU || quoteData.AccessorialsObj.LGDEL)
                {
                    sbAccessorials.Append("&Acc_LGD=Y"); // Sets LGDEL, instead of LGPU
                }

                if (quoteData.AccessorialsObj.APTDEL || quoteData.AccessorialsObj.APTPU)
                {
                    sbAccessorials.Append("&Acc_MNC=Y");
                    //apt = "&Acc_MNC=Y";
                }

                //if (quoteData.AccessorialsObj.APTPU)
                //    throw new Exception("apt pickup not supported");

                if (quoteData.AccessorialsObj.RESPU)
                {
                    sbAccessorials.Append("&Acc_REP=Y");
                    //respu = "&Acc_REP=Y";
                }
                if (quoteData.AccessorialsObj.RESDEL)
                {
                    sbAccessorials.Append("&Acc_RES=Y");
                    //resdel = "&Acc_RES=Y";
                }
                if (quoteData.AccessorialsObj.CONPU)
                {
                    sbAccessorials.Append("&Acc_LAP=Y");
                    //throw new Exception("construction pickup accessorial not supported");
                    //conspu = "&Acc_LAP=Y";
                }
                if (quoteData.AccessorialsObj.CONDEL)
                {
                    sbAccessorials.Append("&Acc_CSD=Y");
                    //consdel = "&Acc_CSD=Y";
                }

                if (quoteData.isHazmat)
                {
                    sbAccessorials.Append("&Acc_HAZ=Y");
                    //hazmat = "&Acc_HAZ=Y";
                }

                #endregion

                string TotalChargesString = string.Empty, daysString = string.Empty;

                getRatesFromPittOhioAPI(ref multPieces, ref sbAccessorials, ref TotalChargesString,
                                        ref daysString);

                if (double.TryParse(TotalChargesString, out cost))
                {
                    //GCMRateQuote objQuote = new GCMRateQuote();
                    //objQuote.TotalPrice = cost + overlengthFee;

                    //DB.Log("Pitt Ohio (Live) ", cost.ToString());

                    cost += overlengthFee;

                    if (!Int16.TryParse(daysString, out days))
                    {
                        days = -3;
                    }

                    gcmRateQuote               = new GCMRateQuote();
                    gcmRateQuote.TotalPrice    = cost;
                    gcmRateQuote.DisplayName   = acctInfo.displayName;
                    gcmRateQuote.Documentation = "";
                    gcmRateQuote.DeliveryDays  = days;
                    gcmRateQuote.BookingKey    = acctInfo.bookingKey;
                    gcmRateQuote.CarrierKey    = acctInfo.carrierKey;

                    //pittOhioQuoteAPI = SetInfoToObjectQuote(ref cost, "Pitt Ohio", "#1#", carrierKey, "", days, "Pitt Ohio");
                }
                else
                {
                    gcmRateQuote = null;

                    DB.Log("Pitt Ohio error (Live) " + acctInfo.username, "");
                }
            }
            catch (Exception ecf)
            {
                #region Catch

                gcmRateQuote = null;
                DB.Log("Pitt Ohio API (Live) " + acctInfo.username, ecf.ToString());
                //if (ecf.Message != "accessorial not supported")
                //{
                //    DB.Log("Pitt Ohio (Live) " + user, ecf.ToString(), "");
                //}

                #endregion
            }
        }
Пример #22
0
        public void Get_UPS_Freight_rate(out GCMRateQuote UPS_FREIGHT_Quote)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            Web_client http = new Web_client();

            http.header_names  = new string[3];
            http.header_values = new string[3];

            http.header_names[0] = "Username";
            http.header_names[1] = "Password";
            http.header_names[2] = "AccessLicenseNumber";

            http.header_values[0] = AppCodeConstants.ups_freight_genera_un;
            http.header_values[1] = AppCodeConstants.ups_freight_genera_pwd;
            http.header_values[2] = AppCodeConstants.ups_freight_genera_license_num;
            http.url = "https://onlinetools.ups.com/ship/v1801/freight/rating/ground";

            #region Not used
            //http.url = "https://onlinetools.ups.com/ship/v1801/freight/rating/ground";
            //http.url = "https://onlinetools.ups.com/ship/%7Bversion%7D/freight/rating/%7Brequestoption%7D";
            //http.url = "https://wwwcie.ups.com/ship/v1801/freight/rating/ground";
            #endregion

            http.method = "POST";

            #region Post data

            string orig_country = "US", dest_country = "US";
            if (quoteData.origCountry == "CANADA")
            {
                orig_country = "CA";
            }
            if (quoteData.destCountry == "CANADA")
            {
                dest_country = "CA";
            }

            string month, day;
            month = quoteData.puDate.Month.ToString();
            day   = quoteData.puDate.Day.ToString();
            if (month.Length == 1)
            {
                month = "0" + month;
            }
            if (day.Length == 1)
            {
                day = "0" + day;
            }

            http.post_data = string.Concat(
                "{",
                "\"FreightRateRequest\": {",
                // FreightRateRequest start
                // ShipFrom start
                "\"ShipFrom\": {",
                "\"Name\": \"Test US Shipper\",",
                "\"Address\": {",
                "\"AddressLine\": \"123 Lane\",",
                "\"City\": \"", quoteData.origCity, "\",",
                "\"StateProvinceCode\": \"", quoteData.origState, "\",",
                "\"PostalCode\": \"", quoteData.origZip, "\",",
                "\"CountryCode\": \"", orig_country, "\",",
                "\"ResidentialAddressIndicator\": \"\"",
                "},",
                "\"AttentionName\": \"Test Shipper\",",
                "\"Phone\": {",
                "\"Number\": \"4444444444\",",
                "\"Extension\": \"4444\"",
                "},",
                "\"EMailAddress\": \"[email protected]\"",
                "},",
                // ShipFrom end
                "\"ShipperNumber\": \"54A9A6\",",

                // ShipTo end
                "\"ShipTo\": {",
                "\"Name\": \"Test US Consignee\",",
                "\"Address\": {",
                "\"AddressLine\": \"555 Main St\",",
                "\"City\": \"", quoteData.destCity, "\",\"StateProvinceCode\": \"", quoteData.destState, "\",",
                "\"PostalCode\": \"", quoteData.destZip, "\",",
                "\"CountryCode\": \"", dest_country, "\"",
                "},",
                "\"AttentionName\": \"Dilbert\",",
                "\"Phone\": {",
                "\"Number\": \"8459865555\"",
                "}",
                "},",
                // ShipTo end

                // PaymentInformation start
                "\"PaymentInformation\": {",
                "\"Payer\": {",
                "\"Name\": \"Test US Shipper\",",
                "\"Address\": {",
                "\"AddressLine\": \"123 Lane\",",
                "\"City\": \"LUTHERVILLE TIMONIUM\",",
                "\"StateProvinceCode\": \"MD\",",
                "\"PostalCode\": \"21093\",",
                "\"CountryCode\": \"US\"",
                "},",
                "\"ShipperNumber\": \"54A9A6\",",
                "\"AccountType\": \"1\",",
                "\"AttentionName\": \"Test Shipper\",",
                "\"Phone\": {",
                "\"Number\": \"4444444444\",",
                "\"Extension\": \"4444\"",
                "},",
                "\"EMailAddress\": \"[email protected]\"",
                "},",

                "\"ShipmentBillingOption\": {",
                "\"Code\": \"10\"",
                "}",
                "},",
                // PaymentInformation end
                "\"Service\": {",
                "\"Code\": \"308\"",
                "},",

                // Commodity start
                Get_items_json(),

                // Commodity end

                "\"DensityEligibleIndicator\": \"\",",
                "\"AlternateRateOptions\": {",
                "\"Code\": \"3\"",
                "},",
                "\"PickupRequest\": {",
                //"\"PickupDate\": \"20191021\"",
                "\"PickupDate\": \"", quoteData.puDate.Year, month, day, "\"",
                "},",
                "\"GFPOptions\": {",
                "\"GPFAccesorialRateIndicator\": \"\"",
                "},",
                Get_accessorials_json(),
                "\"TimeInTransitIndicator\": \"\"",
                "}",
                // FreightRateRequest end
                "}"
                );

            #endregion

            http.accept       = "application/json";
            http.content_type = "application/json";

            //DB.Log("UPS_FREIGHT post data", http.post_data);
            UPS_FREIGHT_Quote = new GCMRateQuote();
            // Test
            //return;

            string doc = "";
            try
            {
                doc = http.Make_http_request();
            }
            catch (Exception e)
            {
                DB.Log("UPS_FREIGHT", e.ToString());
            }


            //DB.Log("UPS_FREIGHT result", doc);

            #region Parse result

            string[] tokens = new string[5];
            tokens[0] = "TotalShipmentCharge";
            tokens[1] = "MonetaryValue";
            tokens[2] = ":";
            tokens[3] = "\"";
            tokens[4] = "\"";

            string TotalShipmentCharge_str = HelperFuncs.scrapeFromPage(tokens, doc);
            double TotalShipmentCharge;

            tokens[0] = "TimeInTransit";
            tokens[1] = "DaysInTransit";

            string DaysInTransit_str = HelperFuncs.scrapeFromPage(tokens, doc);
            int    DaysInTransit;

            #endregion

            //UPS_FREIGHT_Quote = new GCMRateQuote();

            if (double.TryParse(TotalShipmentCharge_str, out TotalShipmentCharge))
            {
                UPS_FREIGHT_Quote.TotalPrice = TotalShipmentCharge;

                UPS_FREIGHT_Quote.DisplayName = acctInfo.displayName;
                UPS_FREIGHT_Quote.CarrierKey  = acctInfo.carrierKey;
                UPS_FREIGHT_Quote.BookingKey  = acctInfo.bookingKey;
                UPS_FREIGHT_Quote.Scac        = "UPGF";

                if (int.TryParse(DaysInTransit_str, out DaysInTransit))
                {
                    UPS_FREIGHT_Quote.DeliveryDays = DaysInTransit;
                }
            }
            else
            {
                UPS_FREIGHT_Quote = null;
            }
        }
Пример #23
0
        public void Get_rates(out GCMRateQuote BestOvernite_Quote_Genera)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            var security = new Best_Overnite_RateService_2.securityinfods();

            security.USERNAME = AppCodeConstants.best_overnite_genera_un;
            security.PASSWORD = AppCodeConstants.best_overnite_genera_pwd;

            var quote = new Best_Overnite_RateService_2.quoteds();

            //quote.PPDCOL = "P";

            quote.IAM = "D";

            //quote.SHIPPER = new Best_Overnite_RateService_2.CUSTINFO();
            //quote.SHIPPER.ADDRESS1 = "test adddress1";
            //quote.SHIPPER.ADDRESS2 = "";
            //quote.SHIPPER.CITY = "Fontana";
            //quote.SHIPPER.STATE = "CA";
            //quote.SHIPPER.ZIP = "92335";
            //quote.SHIPPER.NAME = "";

            //quote.CONSIGNEE = new Best_Overnite_RateService_2.CUSTINFO();
            //quote.CONSIGNEE.ADDRESS1 = "test adddress1";
            //quote.CONSIGNEE.ADDRESS2 = "";
            //quote.CONSIGNEE.CITY = "San Jose";
            //quote.CONSIGNEE.STATE = "CA";
            //quote.CONSIGNEE.ZIP = "95119";
            //quote.CONSIGNEE.NAME = "";

            quote.SHIPPER          = new Best_Overnite_RateService_2.custinfo();
            quote.SHIPPER.ADDRESS1 = "test adddress1";
            quote.SHIPPER.ADDRESS2 = "";
            quote.SHIPPER.CITY     = quoteData.origCity;
            quote.SHIPPER.STATE    = quoteData.origState;
            quote.SHIPPER.ZIP      = quoteData.origZip;
            quote.SHIPPER.NAME     = "";

            quote.CONSIGNEE          = new Best_Overnite_RateService_2.custinfo();
            quote.CONSIGNEE.ADDRESS1 = "test adddress1";
            quote.CONSIGNEE.ADDRESS2 = "";
            quote.CONSIGNEE.CITY     = quoteData.destCity;
            quote.CONSIGNEE.STATE    = quoteData.destState;
            quote.CONSIGNEE.ZIP      = quoteData.destZip;
            quote.CONSIGNEE.NAME     = "";

            #region Accessorials

            byte acc_count = 0;

            if (quoteData.AccessorialsObj.RESPU)
            {
                acc_count++;
            }
            if (quoteData.AccessorialsObj.RESDEL)
            {
                acc_count++;
            }
            if (quoteData.AccessorialsObj.LGPU)
            {
                acc_count++;
            }
            if (quoteData.AccessorialsObj.LGDEL)
            {
                acc_count++;
            }
            if (quoteData.AccessorialsObj.APTPU || quoteData.AccessorialsObj.APTDEL)
            {
                acc_count++;
            }
            if (quoteData.AccessorialsObj.INSDEL)
            {
                acc_count++;
            }

            quote.ACCESSORIAL = new Best_Overnite_RateService_2.accessorialds[acc_count];

            // Reset
            acc_count = 0;

            if (quoteData.AccessorialsObj.RESPU)
            {
                quote.ACCESSORIAL[acc_count] = new Best_Overnite_RateService_2.accessorialds
                {
                    CODE = "RESPIC"
                };
                //var accessorial = new Best_Overnite_RateService_2.ACCESSORIALDS();
                //accessorial.CODE = "RESPIC";
                //quote.ACCESSORIAL[acc_count] = accessorial;
                acc_count++;
            }
            if (quoteData.AccessorialsObj.RESDEL)
            {
                quote.ACCESSORIAL[acc_count] = new Best_Overnite_RateService_2.accessorialds
                {
                    CODE = "RESDEL"
                };
                //var accessorial = new Best_Overnite_RateService_2.ACCESSORIALDS();
                //accessorial.CODE = "RESDEL";
                //quote.ACCESSORIAL[acc_count] = accessorial;
                acc_count++;
            }
            if (quoteData.AccessorialsObj.LGPU)
            {
                quote.ACCESSORIAL[acc_count] = new Best_Overnite_RateService_2.accessorialds
                {
                    CODE = "LIFPIC"
                };
                //var accessorial = new Best_Overnite_RateService_2.ACCESSORIALDS();
                //accessorial.CODE = "LIFPIC";
                //quote.ACCESSORIAL[acc_count] = accessorial;
                acc_count++;
            }
            if (quoteData.AccessorialsObj.LGDEL)
            {
                quote.ACCESSORIAL[acc_count] = new Best_Overnite_RateService_2.accessorialds
                {
                    CODE = "LIFDEL"
                };
                //var accessorial = new Best_Overnite_RateService_2.ACCESSORIALDS();
                //accessorial.CODE = "LIFDEL";
                //quote.ACCESSORIAL[acc_count] = accessorial;
                acc_count++;
            }
            if (quoteData.AccessorialsObj.APTPU || quoteData.AccessorialsObj.APTDEL)
            {
                //var accessorial = new Best_Overnite_RateService_2.ACCESSORIALDS();
                //accessorial.CODE = "NOTFEE";

                quote.ACCESSORIAL[acc_count] = new Best_Overnite_RateService_2.accessorialds
                {
                    CODE = "NOTFEE"
                };
                //quote.ACCESSORIAL[acc_count] = accessorial;
                acc_count++;
            }
            if (quoteData.AccessorialsObj.INSDEL)
            {
                quote.ACCESSORIAL[acc_count] = new Best_Overnite_RateService_2.accessorialds
                {
                    CODE = "INSDEL"
                };
                //var accessorial = new Best_Overnite_RateService_2.ACCESSORIALDS();
                //accessorial.CODE = "INSDEL";
                //quote.ACCESSORIAL[acc_count] = accessorial;
                acc_count++;
            }

            quote.ACCESSORIALCOUNT = acc_count;

            #endregion

            var quote_input = new Best_Overnite_RateService_2.getquoteInput();

            var quote_result = new Best_Overnite_RateService_2.getquoteResult();

            var items = new Best_Overnite_RateService_2.itemds();

            quote.ITEMCOUNT = quoteData.m_lPiece.Length;

            quote.ITEM = new Best_Overnite_RateService_2.itemds[quoteData.m_lPiece.Length];

            for (byte i = 0; i < quoteData.m_lPiece.Length; i++)
            {
                quote.ITEM[i]        = new Best_Overnite_RateService_2.itemds();
                quote.ITEM[i].WEIGHT = (decimal)quoteData.m_lPiece[i].Weight;


                if (quoteData.m_lPiece[i].Units > 0 && quoteData.m_lPiece[i].Pieces > 0)
                {
                    quote.ITEM[i].PIECES  = quoteData.m_lPiece[i].Pieces;
                    quote.ITEM[i].PALLETS = quoteData.m_lPiece[i].Units;;
                }
                else
                {
                    if (quoteData.m_lPiece[i].Units > 0)
                    {
                        quote.ITEM[i].PIECES  = quoteData.m_lPiece[i].Units;
                        quote.ITEM[i].PALLETS = quoteData.m_lPiece[i].Units;;
                    }
                    else if (quoteData.m_lPiece[i].Pieces > 0)
                    {
                        quote.ITEM[i].PIECES  = quoteData.m_lPiece[i].Pieces;
                        quote.ITEM[i].PALLETS = quoteData.m_lPiece[i].Pieces;
                    }
                    else
                    {
                        quote.ITEM[i].PIECES  = 1;
                        quote.ITEM[i].PALLETS = 1;
                    }
                }


                //if (quoteData.m_lPiece[i].Units > 0)
                //{
                //    quote.ITEM[i].PIECES = quoteData.m_lPiece[i].Units;
                //}
                //else if (quoteData.m_lPiece[i].Pieces > 0)
                //{
                //    quote.ITEM[i].PIECES = quoteData.m_lPiece[i].Pieces;
                //}
                //else
                //{
                //    quote.ITEM[i].PIECES = 1;
                //}
                //quote.ITEM[i].PIECES = quoteData.m_lPiece[i].Pieces;

                //quote.ITEM[i]._CLASS = Convert.ToDecimal(quoteData.m_lPiece[i].FreightClass);
                quote.ITEM[i]._CLASS = 70M;
            }


            quote_input.QUOTE        = quote;
            quote_input.SECURITYINFO = security;

            using (var quote_api = new Best_Overnite_RateService_2.TQUOTEAPI())
            {
                //quote_api.Url = "http://tgif1.bestovernite.com:10010/web/services/TQUOTEAPI";
                quote_result = quote_api.getquote(quote_input);
            }

            BestOvernite_Quote_Genera = new GCMRateQuote();

            if (quote_result != null && quote_result.RATING.AMOUNT > 0.0M)
            {
                BestOvernite_Quote_Genera.TotalPrice   = (double)quote_result.RATING.AMOUNT;
                BestOvernite_Quote_Genera.DeliveryDays = (int)quote_result.SERVICE.DAYS;
                BestOvernite_Quote_Genera.DisplayName  = "Best Overnite - Genera";
                BestOvernite_Quote_Genera.CarrierKey   = "UPS";
                BestOvernite_Quote_Genera.BookingKey   = "#1#";
                BestOvernite_Quote_Genera.Scac         = "BTVP";
            }
        }