示例#1
0
        private void GetRateFromRRTS_QuoteByAccount(ref gcmAPI.RRTS_WebService.QuoteResponse objRoadRunnerResult)
        {
            //DB.Log("GetRateFromRRTS_QuoteByAccount", "");
            try
            {
                if (quoteData.username.Equals("durachem"))
                {
                    return;
                }

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

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

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

                gcmAPI.RRTS_WebService.ServiceOptions[] objSOArray;

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

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

                quoteAccountRequest.ShipmentDetails = getRRTS_ShipmentDetails(ref rateAsClass50);

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

                quoteAccountRequest.ShipDate = quoteData.puDate;

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

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

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

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

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

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

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

                //objQResponse = objRQ.CallRateQuote(quoteAccountRequest);

                objQResponse = objRQ.RateQuoteByAccount(quoteAccountRequest);

                objRoadRunnerResult = objQResponse;
            }
            catch (Exception ex)
            {
                //if (!ex.Message.Contains("no standard service") && !ex.Message.Contains("not in the standard") && !ex.Message.Contains("must be today") && !ex.Message.Contains("timed out"))
                //{
                //    DB.Log("Roadrunner (Live)", ex.ToString(), "");
                //}
                DB.Log("Roadrunner (Live)", ex.ToString());
            }
        }
示例#2
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
            }
        }