Exemplo n.º 1
0
        // POST api/get_loup_rates
        public string Post(FormDataCollection form)
        {
            try
            {
                //return "0"; // LOUP had changed their website, need to rewrite scraper

                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                HelperFuncs.writeToSiteErrors("get_loup_rates new ", "get_loup_rates new ");
                int CarrierCompID = 78573;
                SharedRail.Parameters parameters = new SharedRail.Parameters();
                SharedRail.setParameters(ref form, ref parameters, ref CarrierCompID);

                SharedRail.ICarrier carrier = new LOUP(parameters);

                IntermodalRater.railResult railResult = new IntermodalRater.railResult();
                railResult = carrier.getRate();

                return(SharedRail.getResultString(ref railResult));
            }
            catch (Exception e)
            {
                HelperFuncs.writeToSiteErrors("get_loup_rates", e.ToString());
                return("0");
            }
        }
Exemplo n.º 2
0
        // POST api/getltlrates
        public string Post(FormDataCollection form)
        {
            try
            {
                //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                HelperFuncs.writeToSiteErrors("get_ltl_rates new ", "get_ltl_rates new ");

                //HelperFuncs.QuoteData quoteData = new HelperFuncs.QuoteData();
                QuoteData quoteData = new QuoteData();

                Models.LTL.Helper helper = new Models.LTL.Helper();
                helper.setParameters(ref form, ref quoteData);

                LTL_Carriers             carriers = new LTL_Carriers(quoteData);
                SharedLTL.CarriersResult result   = carriers.GetRates();
                //string res = carriers.GetRates();
                //HelperFuncs.writeToSiteErrors("get_ltl_rates result", res);
                StringBuilder res = new StringBuilder();

                //res.Append("myObj = {\"carrierRates\": ");
                //res.Append("\"carrierRates\": ");
                res.Append(result.totalQuotes.ToJSON());
                //SharedLTL.getCarriersResultJSON(ref result.totalQuotes, ref res);

                //res.Append("}");
                //res.Append("]");

                return(res.ToString());
            }
            catch (Exception e)
            {
                HelperFuncs.writeToSiteErrors("get_ltl_rates", e.ToString());
                return("0");
            }
        }
Exemplo n.º 3
0
        //// POST api/getintermodalrates
        //public void Post([FromBody]string value)
        //{
        //}

        // POST api/getintegrarates
        public string Post(FormDataCollection form)
        {
            //string test2 = form.Get("test2");

            //string myString = "";

            ////GetIntegraRatesModel model = new GetIntegraRatesModel();
            ////model.testFunc(ref myString);

            //Intermodal.testStaticFunc(ref myString);

            //return "value was " + myString;
            HelperFuncs.writeToSiteErrors("test", "test");

            string username = form.Get("username");
            string password = form.Get("password");
            //string pickupDate = form.Get("test2");
            string originZip      = form.Get("originZip");
            string destinationZip = form.Get("destinationZip");

            //string username = form.Get("test2");
            //List<string> additionalServices = new List<string>();
            string[] additionalServices = new string[1];
            DateTime pickupDate         = DateTime.Today;

            IntermodalRater ir      = new IntermodalRater();
            List <string[]> results = new List <string[]>();

            int QuoteID = 0;

            results = ir.GetIntermodalRate(username, password, pickupDate, originZip, destinationZip, additionalServices, ref QuoteID);

            return(QuoteID.ToString());
        }
Exemplo n.º 4
0
    public static void GetRRD_ScacByCarrierName(string CarrierName, ref string SCAC)
    {
        string sql = string.Empty;

        try
        {
            if (CarrierName.ToLower().Contains("dayton"))
            {
                sql = string.Concat("SELECT SCAC ",

                                    "FROM SQL_LTLCARRIERS ",

                                    "WHERE ID=348");
            }
            else
            {
                sql = string.Concat("SELECT SCAC ",

                                    "FROM SQL_LTLCARRIERS ",

                                    "WHERE CarrierName='", CarrierName, "'");
            }


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

                //sql = string.Concat("SELECT SCAC ",

                //    "FROM SQL_LTLCARRIERS ",

                //    "WHERE CarrierName='", CarrierName, "'");

                #endregion

                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection  = conn;
                    command.CommandText = sql;
                    conn.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            if (reader["SCAC"] != DBNull.Value)
                            {
                                SCAC = reader["SCAC"].ToString();
                            }
                        }
                    }
                }
            }
        }
        catch (Exception e)
        {
            HelperFuncs.writeToSiteErrors("GetRRD_ScacByCarrierName", e.ToString());
        }
    }
Exemplo n.º 5
0
    public static void getClassForRRTS_AAFES(ref decimal rrtsFreightClass, ref decimal totalDensity)
    {
        #region Get rrtsFreightClass by density
        if (totalDensity <= 0)
        {
            //SharedFunctions.writeToAAFES_Logs("AAFES", string.Concat("Density was less than zero po id: ", shipInfo.PO_ID.ToString()));
            //continue;
            HelperFuncs.writeToSiteErrors("rrtsFreightClass", "Density was less than zero");
            rrtsFreightClass = -1;
        }
        else if (totalDensity > 0 && totalDensity < 1)
        {
            rrtsFreightClass = 400;
        }
        else if (totalDensity >= 1 && totalDensity < 2)
        {
            rrtsFreightClass = 300;
        }
        else if (totalDensity >= 2 && totalDensity < 4)
        {
            rrtsFreightClass = 250;
        }
        else if (totalDensity >= 4 && totalDensity < 6)
        {
            rrtsFreightClass = 175;
        }
        else if (totalDensity >= 6 && totalDensity < 8)
        {
            rrtsFreightClass = 125;
        }
        else if (totalDensity >= 8 && totalDensity < 10)
        {
            rrtsFreightClass = 100;
        }
        else if (totalDensity >= 10 && totalDensity < 12)
        {
            rrtsFreightClass = 92.5M;
        }
        else if (totalDensity >= 12 && totalDensity < 15)
        {
            rrtsFreightClass = 85;
        }
        else if (totalDensity >= 15 && totalDensity < 22.5M)
        {
            rrtsFreightClass = 70;
        }
        else if (totalDensity >= 22.5M && totalDensity < 30)
        {
            rrtsFreightClass = 65;
        }
        else
        {
            rrtsFreightClass = 60;
        }


        #endregion
    }
Exemplo n.º 6
0
        //public static string GetSpecialState()
        //{
        //    string originState = "";
        //    string destState = "";

        //    try
        //    {
        //        if (!String.IsNullOrEmpty(requestedValues["oCityState"]))
        //        {
        //            string[] arrPCityState = requestedValues["oCityState"].Split(',');
        //            originState = arrPCityState[1].Trim();
        //        }
        //        else if (Session["oState"] != null)
        //        {
        //            originState = Session["oState"].ToString();
        //        }
        //        else if (!String.IsNullOrEmpty(requestedValues["q_OCity"]))
        //        {
        //            string[] arrPCityState = requestedValues["q_OCity"].Split(',');
        //            originState = arrPCityState[1].Trim();
        //        }

        //        if (!String.IsNullOrEmpty(requestedValues["dCityState"]))
        //        {
        //            string[] arrPCityState = requestedValues["dCityState"].Split(',');
        //            originState = arrPCityState[1].Trim();
        //        }
        //        else if (Session["dState"] != null)
        //        {
        //            destState = Session["dState"].ToString();
        //        }
        //        else if (!String.IsNullOrEmpty(requestedValues["q_DCity"]))
        //        {
        //            string[] arrDCityState = requestedValues["q_DCity"].Split(',');
        //            destState = arrDCityState[1].Trim();
        //        }
        //    }
        //    catch (Exception myException)
        //    {
        //        HelperFuncs.writeToSiteErrors("dispatch getSpecialState", string.Concat("oCityState: ", requestedValues["oCityState"], " q_OCity: ",
        //            requestedValues["q_OCity"], " dCityState: ", requestedValues["dCityState"], " q_DCity: ", requestedValues["q_DCity"]));

        //        throw new Exception(myException.ToString());
        //    }

        //    if (originState.ToUpper().Equals("HI") || originState.ToUpper().Equals("AK"))
        //    {
        //        return originState;
        //    }
        //    if (destState.ToUpper().Equals("HI") || destState.ToUpper().Equals("AK"))
        //    {
        //        return destState;
        //    }
        //    return "";
        //}

        #endregion

        #region GetSpecialState

        public static string GetSpecialState(ref DispatchData dispatch_data)
        {
            string originState = "";
            string destState   = "";

            try
            {
                if (!String.IsNullOrEmpty(dispatch_data.oCityState))
                {
                    string[] arrPCityState = dispatch_data.oCityState.Split(',');
                    originState = arrPCityState[1].Trim();
                }
                else if (dispatch_data.oState != null)
                {
                    originState = dispatch_data.oState;
                }
                else if (!String.IsNullOrEmpty(dispatch_data.q_OCity))
                {
                    string[] arrPCityState = dispatch_data.q_OCity.Split(',');
                    originState = arrPCityState[1].Trim();
                }

                if (!String.IsNullOrEmpty(dispatch_data.dCityState))
                {
                    string[] arrPCityState = dispatch_data.dCityState.Split(',');
                    originState = arrPCityState[1].Trim();
                }
                else if (dispatch_data.dState != null)
                {
                    destState = dispatch_data.dState;
                }
                else if (!String.IsNullOrEmpty(dispatch_data.q_DCity))
                {
                    string[] arrDCityState = dispatch_data.q_DCity.Split(',');
                    destState = arrDCityState[1].Trim();
                }
            }
            catch (Exception myException)
            {
                HelperFuncs.writeToSiteErrors("dispatch getSpecialState",
                                              string.Concat("oCityState: ", dispatch_data.oCityState, " q_OCity: ",
                                                            dispatch_data.q_OCity, " dCityState: ", dispatch_data.dCityState, " q_DCity: ",
                                                            dispatch_data.q_DCity));

                throw new Exception(myException.ToString());
            }

            if (originState.ToUpper().Equals("HI") || originState.ToUpper().Equals("AK"))
            {
                return(originState);
            }
            if (destState.ToUpper().Equals("HI") || destState.ToUpper().Equals("AK"))
            {
                return(destState);
            }
            return("");
        }
Exemplo n.º 7
0
    /*
     * function GetClassByDensity(totDensity) {
     * var classDensityBased = "-1";
     *
     * if (totDensity < 1)
     *  classDensityBased = "400";
     * else if (totDensity >= 1 && totDensity < 2)
     *  classDensityBased = "300";
     * else if (totDensity >= 2 && totDensity < 4)
     *  classDensityBased = "250";
     * else if (totDensity >= 4 && totDensity < 6)
     *  classDensityBased = "175";
     * else if (totDensity >= 6 && totDensity < 8)
     *  classDensityBased = "125";
     * else if (totDensity >= 8 && totDensity < 10)
     *  classDensityBased = "100";
     * else if (totDensity >= 10 && totDensity < 12)
     *  classDensityBased = "92.5";
     * else if (totDensity >= 12 && totDensity < 15)
     *  classDensityBased = "85";
     * else if (totDensity >= 15 && totDensity < 22.5)
     *  classDensityBased = "70";
     * else if (totDensity >= 22.5 && totDensity < 30)
     *  classDensityBased = "65";
     * else //greater than 30
     *  classDensityBased = "60";
     *
     * return classDensityBased;
     * }
     */
    public static void Get_class_by_density(ref QuoteData quoteData)
    {
        #region Get quoteData.calculated_freight_class by density
        if (quoteData.totalDensity <= 0)
        {
            HelperFuncs.writeToSiteErrors("quoteData.calculated_freight_class", "Density was less than zero");
            quoteData.calculated_freight_class = -1;
        }
        else if (quoteData.totalDensity > 0 && quoteData.totalDensity < 1)
        {
            quoteData.calculated_freight_class = 400;
        }
        else if (quoteData.totalDensity >= 1 && quoteData.totalDensity < 2)
        {
            quoteData.calculated_freight_class = 300;
        }
        else if (quoteData.totalDensity >= 2 && quoteData.totalDensity < 4)
        {
            quoteData.calculated_freight_class = 250;
        }
        else if (quoteData.totalDensity >= 4 && quoteData.totalDensity < 6)
        {
            quoteData.calculated_freight_class = 175;
        }
        else if (quoteData.totalDensity >= 6 && quoteData.totalDensity < 8)
        {
            quoteData.calculated_freight_class = 125;
        }
        else if (quoteData.totalDensity >= 8 && quoteData.totalDensity < 10)
        {
            quoteData.calculated_freight_class = 100;
        }
        else if (quoteData.totalDensity >= 10 && quoteData.totalDensity < 12)
        {
            quoteData.calculated_freight_class = 92.5;
        }
        else if (quoteData.totalDensity >= 12 && quoteData.totalDensity < 15)
        {
            quoteData.calculated_freight_class = 85;
        }
        else if (quoteData.totalDensity >= 15 && quoteData.totalDensity < 22.5)
        {
            quoteData.calculated_freight_class = 70;
        }
        else if (quoteData.totalDensity >= 22.5 && quoteData.totalDensity < 30)
        {
            quoteData.calculated_freight_class = 65;
        }
        else
        {
            quoteData.calculated_freight_class = 60;
        }


        #endregion
    }
Exemplo n.º 8
0
        public static void GetQuoteInfoByQuoteID(ref int QuoteID, ref string oZip, ref string dZip, ref DateTime Day, ref DateTime Time)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(AppCodeConstants.connStringRater2009))
                {
                    #region SQL

                    string sql = string.Concat("SELECT Origin, Destination, Day, Time ",

                                               "FROM SQL_STATS_GCM ",

                                               "WHERE ID=", QuoteID);

                    #endregion

                    byte counter = 0;

                    using (SqlCommand command = new SqlCommand())
                    {
                        command.Connection  = conn;
                        command.CommandText = sql;
                        conn.Open();
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                if (reader["Origin"] != DBNull.Value)
                                {
                                    oZip = reader["Origin"].ToString();
                                }

                                if (reader["Destination"] != DBNull.Value)
                                {
                                    dZip = reader["Destination"].ToString();
                                }

                                if (reader["Day"] != DBNull.Value)
                                {
                                    Day = (DateTime)reader["Day"];
                                }

                                if (reader["Time"] != DBNull.Value)
                                {
                                    Time = (DateTime)reader["Time"];
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                HelperFuncs.writeToSiteErrors("GetQuoteInfoByQuoteID", e.ToString());
            }
        }
Exemplo n.º 9
0
        private void getRatesFromPittOhioAPI(ref string multPieces, ref StringBuilder sbAccessorials,
                                             ref string TotalChargesString, ref string daysString)
        {
            string url = string.Concat("http://works.pittohio.com/mypittohio/b2bratecalc.asp?acctnum=",
                                       acctInfo.username, "&password="******"&ShipCity=", quoteData.origCity,
                                       "&ShipState=", quoteData.origState,
                                       "&ShipZIP=", quoteData.origZip,

                                       "&ConsCity=", quoteData.destCity,
                                       "&ConsState=", quoteData.destState,
                                       "&ConsZIP=", quoteData.destZip,

                                       "&Terms=", acctInfo.terms,                          // Options P,I,3 - Prepaid, Inbound Collect, Third Party
                                       "&ShipDate=", quoteData.puDate.ToShortDateString(), //mm/dd/yyyy

                                                                                           // ShipType=PAL // Options P or PAL for Pallets, N for not pallets (default), M for Mixed
                                                                                           //"&TestMode=Y",
                                                                                           //"&Class1=50&Wgt1=1482",
                                       multPieces,
                                       sbAccessorials
                                       //"&Acc_RES=Y&Acc_LGD=Y"
                                       );

            HelperFuncs.writeToSiteErrors("Pitt Ohio API (Live) request", url);
            //string doc = "";
            string doc = (string)HelperFuncs.generic_http_request_3(
                "string", null, url, "", "text/xml", "*/*", "GET", "", false, false, "", "");

            HelperFuncs.writeToSiteErrors("Pitt Ohio API (Live) response", doc);


            string[] tokens = new string[3];
            tokens[0]          = "TotalCharges";
            tokens[1]          = ">";
            tokens[2]          = "<";
            TotalChargesString = HelperFuncs.scrapeFromPage(tokens, doc);

            //DB.Log("Pitt Ohio API (Live) TotalChargesStr", TotalChargesString);

            tokens[0]  = "AdvertisedTransit";
            daysString = HelperFuncs.scrapeFromPage(tokens, doc);
        }
Exemplo n.º 10
0
    public static void getOTR_RateDLS()
    {
        string[] cityStateCountryOrig = new string[3];
        string[] cityStateCountryDest = new string[3];

        string oState, dState, oCity, dCity, oCountry, dCountry;

        try
        {
            SharedRail.cityStateCountryByZip(ref cityStateCountryOrig, originZipGlobal);
            SharedRail.cityStateCountryByZip(ref cityStateCountryDest, destZipGlobal);

            if (!string.IsNullOrEmpty(cityStateCountryOrig[0]))
            {
                oState   = cityStateCountryOrig[1];
                oCity    = cityStateCountryOrig[0];
                oCountry = cityStateCountryOrig[2];
            }
            else
            {
                return;
            }
            if (!string.IsNullOrEmpty(cityStateCountryDest[0]))
            {
                dState   = cityStateCountryDest[1];
                dCity    = cityStateCountryDest[0];
                dCountry = cityStateCountryDest[2];
            }
            else
            {
                return;
            }

            SharedRail.getOTR_RateDLS(ref originZipGlobal, ref destZipGlobal, ref puDateGlobal, ref oCity, ref oState, ref oCountry,
                                      ref dCity, ref dState, ref dCountry);
        }
        catch (Exception e)
        {
            HelperFuncs.writeToSiteErrors("MG OTR", e.ToString());
        }
    }
Exemplo n.º 11
0
        // POST api/get_modalx_rates
        public string Post(FormDataCollection form)
        {
            try
            {
                HelperFuncs.writeToSiteErrors("get_ModalX_rates new ", "get_ModalX_rates new ");
                int CarrierCompID = 78573; // Wrong id
                SharedRail.Parameters parameters = new SharedRail.Parameters();
                SharedRail.setParameters(ref form, ref parameters, ref CarrierCompID);

                SharedRail.ICarrier carrier = new ModalX(parameters);

                IntermodalRater.railResult railResult = new IntermodalRater.railResult();
                railResult = carrier.getRate();

                return(SharedRail.getResultString(ref railResult));
            }
            catch (Exception e)
            {
                HelperFuncs.writeToSiteErrors("get_ModalX_rates", e.ToString());
                return("0");
            }
        }
Exemplo n.º 12
0
        public void Get_access_token(ref string access_token)
        {
            try
            {
                string data =
                    string.Concat(
                        "client_secret=", AppCodeConstants.DYLT_Genera_client_secret,
                        "&grant_type=client_credentials&client_id=", AppCodeConstants.DYLT_Genera_client_id);

                Web_client http = new Web_client
                {
                    url          = "https://api.dylt.com/oauth/client_credential/accesstoken?grant_type=client_credentials",
                    content_type = "application/x-www-form-urlencoded",
                    accept       = "application/json",
                    post_data    = data,
                    method       = "POST"
                };

                string doc = http.Make_http_request();

                #region Parse result

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

                access_token = HelperFuncs.scrapeFromPage(tokens, doc);

                #endregion
            }
            catch (Exception e)
            {
                string str = e.ToString();
                HelperFuncs.writeToSiteErrors("Get_access_token", str);
            }
        }
        // POST api/getups_packagerates
        //public void Post([FromBody]string value)
        //{
        //}

        public string Post(FormDataCollection form)
        {
            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                HelperFuncs.writeToSiteErrors("GetUPS_PackageRatesController", "GetUPS_PackageRatesController");
                //HelperFuncs.writeToSiteErrors("GetUPS_PackageRatesController post string", form.ToString());

                #region Get form data

                //HelperFuncs.writeToSiteErrors("data", form.Get("data"));

                //string username = form.Get("username");
                //string password = form.Get("password");

                //string originZip = form.Get("originZip");
                //string destinationZip = form.Get("destinationZip");

                //string[] additionalServices = new string[1];
                //DateTime pickupDate;

                //if (!DateTime.TryParse(form.Get("pickupDate"), out pickupDate))
                //{
                //    pickupDate = DateTime.Today.AddDays(1);
                //}

                #endregion

                //string doc = Rater.getPackageAPI_XML_Rate(ref form);
                return(Rater.getPackageAPI_XML_Rate(ref form));
            }
            catch (Exception e)
            {
                HelperFuncs.writeToSiteErrors("GetUPS_PackageRatesController", e.ToString());
                return("-1");
            }
        }
Exemplo n.º 14
0
    public IntermodalRater.railResult getRate()
    {
        container = new CookieContainer();

        double transitTime = 10;

        username = AppCodeConstants.modalX_un;
        password = AppCodeConstants.modalX_pwd;

        HelperFuncs.ModalX_Result res = new HelperFuncs.ModalX_Result();
        try
        {
            loginTo_ModalX(ref res);

            railResultObj = new IntermodalRater.railResult();

            if (res.success == true)
            {
                #region Not used
                //modalXResultArray[4] = "";

                //modalXResultArray[0] = SharedRail.success;
                //modalXResultArray[1] = SharedRail.ModalX;
                //modalXResultArray[2] = res.cost.ToString();

                //insertIntoRailLogs("ModalX", 92184, "1", "", "", Convert.ToDouble(res.cost));


                //modalXResultArray[3] = transitTime.ToString();
                //modalXResultArray[4] = res.pickupDate.ToShortDateString();
                //modalXResultArray[5] = res.deliveryDate.ToShortDateString();
                //modalXResultArray[6] = SharedRail.FiftyThreeFt;
                #endregion

                HelperFuncs.writeToSiteErrors("ModalX", "success");

                transitTime = (res.deliveryDate - res.pickupDate).TotalDays;


                railResultObj.success           = "success";
                railResultObj.transitTime       = transitTime.ToString();
                railResultObj.rate              = res.cost.ToString();
                railResultObj.firstCapacityDate = res.pickupDate;

                if (transitTime > 0)
                {
                    railResultObj.eta = res.pickupDate.AddDays(transitTime);
                }

                railResultObj.hasCapacity   = true;
                railResultObj.containerSize = "FiftyThreeFt";

                return(railResultObj);
            }
            else
            {
                railResultObj.success = "";
                return(railResultObj);
            }
        }
        catch (Exception e)
        {
            #region Catch

            HelperFuncs.writeToSiteErrors("ModalX", e.ToString());

            railResultObj         = new IntermodalRater.railResult();
            railResultObj.success = "";
            return(railResultObj);

            #endregion
        }
    }
Exemplo n.º 15
0
    public static void GetCompInfoByUserName(string UserName, ref HelperFuncs.CompInfo info)
    {
        try
        {
            using (SqlConnection conn = new SqlConnection(AppCodeConstants.connStringAesData))
            {
                #region SQL

                string sql = string.Concat("SELECT City, State, Zip, Phone, Addr1, Addr2, CompName, Contact, EMail, Fax ",

                                           "FROM tbl_COMPANY ",

                                           "WHERE AccountNbr='", UserName, "'");

                #endregion

                byte counter = 0;

                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection  = conn;
                    command.CommandText = sql;
                    conn.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            if (reader["City"] != DBNull.Value)
                            {
                                info.City = reader["City"].ToString();
                            }

                            if (reader["State"] != DBNull.Value)
                            {
                                info.State = reader["State"].ToString();
                            }

                            if (reader["Zip"] != DBNull.Value)
                            {
                                info.Zip = reader["Zip"].ToString();
                            }

                            if (reader["CompName"] != DBNull.Value)
                            {
                                info.CompName = reader["CompName"].ToString();
                            }

                            if (reader["Contact"] != DBNull.Value)
                            {
                                info.Contact = reader["Contact"].ToString();
                            }

                            if (reader["Phone"] != DBNull.Value)
                            {
                                info.Phone = reader["Phone"].ToString();
                            }

                            if (reader["Addr1"] != DBNull.Value)
                            {
                                info.Addr1 = reader["Addr1"].ToString();
                            }

                            if (reader["Addr2"] != DBNull.Value)
                            {
                                info.Addr2 = reader["Addr2"].ToString();
                            }

                            if (reader["EMail"] != DBNull.Value)
                            {
                                info.EMail = reader["EMail"].ToString();
                            }

                            if (reader["Fax"] != DBNull.Value)
                            {
                                info.Fax = reader["Fax"].ToString();
                            }
                        }
                    }
                }
            }
        }
        catch (Exception e)
        {
            HelperFuncs.writeToSiteErrors("poSystemFuncs", e.ToString());
        }
    }
Exemplo n.º 16
0
        // POST api/getcsxiinfo
        public string Post(FormDataCollection form)
        {
            #region Not used
            //#region Get form data

            ////HelperFuncs.writeToSiteErrors("test", "test1");

            //string username = form.Get("username");
            //string password = form.Get("password");

            //string originZip = form.Get("originZip");
            //string destinationZip = form.Get("destinationZip");

            //string[] additionalServices = new string[1];
            //DateTime pickupDate;

            //if (!DateTime.TryParse(form.Get("pickupDate"), out pickupDate))
            //{
            //    pickupDate = DateTime.Today.AddDays(1);
            //}

            //#endregion

            //List<string[]> accessorials = new List<string[]>();
            //IntermodalRater.railResult railResult = new IntermodalRater.railResult();

            //SharedRail.GetCSXIInfo(ref originZip, ref destinationZip, ref pickupDate, ref accessorials, ref railResult);

            //if (string.IsNullOrEmpty(railResult.success) || !railResult.success.Equals("success"))
            //{
            //    return "0";
            //}
            //else
            //{
            //    return string.Concat("success=", railResult.success, "&rate=", railResult.rate, "&transitTime=", railResult.transitTime,
            //        "&hasCapacity=", railResult.hasCapacity, "&firstCapacityDate=", railResult.firstCapacityDate.ToShortDateString(),
            //        "&eta=", railResult.eta.ToShortDateString(), "&containerSize=", railResult.containerSize);


            //}
            #endregion

            try
            {
                HelperFuncs.writeToSiteErrors("get_CSXI_rates new ", "get_CSXI_rates new ");
                int CarrierCompID = 90199;
                SharedRail.Parameters parameters = new SharedRail.Parameters();
                SharedRail.setParameters(ref form, ref parameters, ref CarrierCompID);

                SharedRail.ICarrier carrier = new CSXI(parameters);

                IntermodalRater.railResult railResult = new IntermodalRater.railResult();
                railResult = carrier.getRate();

                return(SharedRail.getResultString(ref railResult));
            }
            catch (Exception e)
            {
                HelperFuncs.writeToSiteErrors("get_CSXI_rates", e.ToString());
                return("0");
            }
        }
Exemplo n.º 17
0
    public string makeBookingViaSOAP(ref FormDataCollection form)
    {
        //LTLBookingInfo info = new LTLBookingInfo();
        try
        {
            #region Testing

            StringBuilder logger = new StringBuilder();
            logger.Append(string.Concat("shipmentDate: ", form.Get("shipmentDate"), ", "));
            logger.Append(string.Concat("bookingKey: ", form.Get("bookingKey"), ", "));
            logger.Append(string.Concat("customerType: ", form.Get("customerType"), ", "));

            logger.Append(string.Concat("origName: ", form.Get("origName"), ", "));
            logger.Append(string.Concat("origEmail: ", form.Get("origEmail"), ", "));
            logger.Append(string.Concat("origCompany: ", form.Get("origCompany"), ", "));
            logger.Append(string.Concat("origPhone: ", form.Get("origPhone"), ", "));
            logger.Append(string.Concat("origFax: ", form.Get("origFax"), ", "));
            logger.Append(string.Concat("origAddress1: ", form.Get("origAddress1"), ", "));
            logger.Append(string.Concat("origAddress2: ", form.Get("origAddress2"), ", "));
            logger.Append(string.Concat("origCity: ", form.Get("origCity"), ", "));
            logger.Append(string.Concat("origState: ", form.Get("origState"), ", "));
            logger.Append(string.Concat("origZip: ", form.Get("origZip"), ", "));

            logger.Append(string.Concat("destName: ", form.Get("destName"), ", "));
            logger.Append(string.Concat("destEmail: ", form.Get("destEmail"), ", "));
            logger.Append(string.Concat("destCompany: ", form.Get("destCompany"), ", "));
            logger.Append(string.Concat("destPhone: ", form.Get("destPhone"), ", "));
            logger.Append(string.Concat("destFax: ", form.Get("destFax"), ", "));
            logger.Append(string.Concat("destAddress1: ", form.Get("destAddress1"), ", "));
            logger.Append(string.Concat("destAddress2: ", form.Get("destAddress2"), ", "));
            logger.Append(string.Concat("destCity: ", form.Get("destCity"), ", "));
            logger.Append(string.Concat("destState: ", form.Get("destState"), ", "));
            logger.Append(string.Concat("destZip: ", form.Get("destZip"), ", "));

            #endregion

            DateTime shipmentDate;

            if (!DateTime.TryParse(form.Get("shipmentDate"), out shipmentDate))
            {
                shipmentDate = DateTime.Today.AddDays(1);
            }

            // Initialize web service/API object
            gcmAPI.gcmWebService.RateService2 rs = new gcmAPI.gcmWebService.RateService2();

            #region Not used
            // Authenticate to the web service/API
            //string sessionId = rs.Authenticate(apiUserName, apiKey);

            //// Initialize SOAP header for authentication
            //rs.AuthHeaderValue = new MyWebReference.AuthHeader();

            //// Set session id to the SOAP header
            //rs.AuthHeaderValue.SessionID = sessionId;
            #endregion

            string bookingKey = form.Get("bookingKey");

            string customerType = form.Get("customerType"); //Set customer type

            gcmAPI.gcmWebService.BookingThirdPartyBilling thirdPartyBilling = null;
            //DateTime shipmentDate = DateTime.Now.Date; //Set shipment date

            string readyTime = "02:15 PM"; //Set ready time of the shipment
            string closeTime = "06:15 PM"; //Set close time of the shipment

            //string readyTime = "10"; //Set ready time of the shipment
            //string closeTime = "3"; //Set close time of the shipment

            string bolSendTo = "EML"; //Set BOL sending option
            //string poNumber = "45455"; //Set PO Number
            string poNumber = null;   //Set PO Number

            #region Origin and Destination

            // Set pickup location
            gcmAPI.gcmWebService.BookingPickupLocation pickupLocation = new gcmAPI.gcmWebService.BookingPickupLocation();
            pickupLocation.Name                = form.Get("origName");
            pickupLocation.Email               = form.Get("origEmail");
            pickupLocation.Company             = form.Get("origCompany");
            pickupLocation.Phone               = form.Get("origPhone");
            pickupLocation.Fax                 = form.Get("origFax");
            pickupLocation.Address1            = form.Get("origAddress1");
            pickupLocation.Address2            = form.Get("origAddress2");
            pickupLocation.City                = form.Get("origCity");
            pickupLocation.State               = form.Get("origState");
            pickupLocation.Zip                 = form.Get("origZip");
            pickupLocation.DispatchAddressesId = 1;

            // Set destination location
            gcmAPI.gcmWebService.BookingDestinationLocation destinationLocation = new gcmAPI.gcmWebService.BookingDestinationLocation();
            destinationLocation.Name     = form.Get("destName");
            destinationLocation.Email    = form.Get("destEmail");
            destinationLocation.Company  = form.Get("destCompany");
            destinationLocation.Phone    = form.Get("destPhone");
            destinationLocation.Fax      = form.Get("destFax");
            destinationLocation.Address1 = form.Get("destAddress1");
            destinationLocation.Address2 = form.Get("destAddress2");
            destinationLocation.City     = form.Get("destCity");
            destinationLocation.State    = form.Get("destState");
            destinationLocation.Zip      = form.Get("destZip");

            #endregion

            string SessionID = form.Get("SessionID");
            logger.Append(string.Concat("SessionID: ", form.Get("SessionID"), ", "));
            //SessionID
            int testInt;
            List <gcmAPI.gcmWebService.LTLBookingPiece> bookingLineItems = new List <gcmAPI.gcmWebService.LTLBookingPiece>();
            for (byte i = 1; i <= 20; i++)
            {
                if (form.Get("Tag" + i.ToString()) != null)
                {
                    //int.TryParse(form.Get("q_Piece" + i.ToString()), out pieces);
                    gcmAPI.gcmWebService.LTLBookingPiece lineItem = new gcmAPI.gcmWebService.LTLBookingPiece();
                    lineItem.Tag = form.Get("Tag" + i.ToString());

                    // Testing
                    logger.Append(string.Concat("Tag", i.ToString(), ": ", form.Get("Tag" + i.ToString()), ", "));

                    if (form.Get("NumberOfPallet" + i.ToString()) != null)
                    {
                        if (int.TryParse(form.Get("NumberOfPallet" + i.ToString()), out testInt))
                        {
                            lineItem.NumberOfPallet = testInt;
                        }

                        // Testing
                        logger.Append(string.Concat("NumberOfPallet", i.ToString(), ": ", form.Get("NumberOfPallet" + i.ToString()), ", "));
                    }

                    if (form.Get("Description" + i.ToString()) != null)
                    {
                        lineItem.Description = form.Get("Description" + i.ToString());

                        // Testing
                        logger.Append(string.Concat("Description", i.ToString(), ": ", form.Get("Description" + i.ToString()), ", "));
                    }
                    bookingLineItems.Add(lineItem);
                }
                else
                {
                    break;
                }
            }

            HelperFuncs.writeToSiteErrors("LTL Booking Restful", logger.ToString());

            #region Not used
            //Set other line items
            //gcmWebService.LTLBookingPiece[] bookingLineItems = new gcmWebService.LTLBookingPiece[1];

            //Set first line item for booking
            //bookingLineItems[0] = new gcmWebService.LTLBookingPiece();

            //// This tag is related to the object(LTLPiece) in lineItems array which is used in GetLTLBookingRate function call
            //bookingLineItems[0].Tag = form.Get("Tag");

            ////bookingLineItems[0].NMFC = 50;
            //bookingLineItems[0].NumberOfPallet = 1;
            //bookingLineItems[0].Description = form.Get("Description");

            //Set second line item for booking
            //bookingLineItems[1] = new MyWebReference.LTLBookingPiece();

            ////// This tag is related to the object(LTLPiece) in lineItems array which is used in GetLTLBookingRate function call
            //bookingLineItems[1].Tag = "2";

            //bookingLineItems[1].NMFC = 60;
            //bookingLineItems[1].NumberOfPallet = 10;
            //bookingLineItems[1].Description = "TEST";
            #endregion

            string comments = "TEST";
            //string comments = null;
            //bool insuranceRequired = true;
            bool   insuranceRequired = false;
            double declaredValue     = 100;

            //Book an LTL rate and getting the BOL and insurance certificate PDF url
            gcmAPI.gcmWebService.LTLBookingReply lbr = rs.CreateLTLBooking2(SessionID, bookingKey, customerType, thirdPartyBilling, shipmentDate, readyTime, closeTime, bolSendTo,
                                                                            poNumber, pickupLocation, destinationLocation, bookingLineItems.ToArray(), comments, insuranceRequired, declaredValue);

            HelperFuncs.writeToSiteErrors("LTL Booking Restful result", string.Concat("notification=", lbr.Notification, "&shipmentID=", lbr.ShipmentId, "&=BOLURL", lbr.BOLURL));
            return(string.Concat("notification=", lbr.Notification, "&shipmentID=", lbr.ShipmentId, "&=BOLURL", lbr.BOLURL));
        }
        catch (Exception e)
        {
            HelperFuncs.writeToSiteErrors("LTL Booking Restful", e.ToString());
            return("error");
        }
    }
Exemplo n.º 18
0
    public string makeBookingViaSOAP(ref SharedLTL.LTLBookingInfo json)
    {
        //gcmAPI.gcmWebService.LTLBookingReply lbr;

        try
        {
            //return "{ \"Notification\" : \"temporarily stopped service\" }";

            #region Testing

            StringBuilder logger = new StringBuilder();
            logger.Append(string.Concat("shipmentDate: ", json.shipmentDate, ", "));
            logger.Append(string.Concat("bookingKey: ", json.bookingKey, ", "));
            logger.Append(string.Concat("customerType: ", json.customerType, ", "));

            logger.Append(string.Concat("origName: ", json.origName, ", "));
            logger.Append(string.Concat("origEmail: ", json.origEmail, ", "));
            logger.Append(string.Concat("origCompany: ", json.origCompany, ", "));
            logger.Append(string.Concat("origPhone: ", json.origPhone, ", "));
            logger.Append(string.Concat("origFax: ", json.origFax, ", "));
            logger.Append(string.Concat("origAddress1: ", json.origAddress1, ", "));
            logger.Append(string.Concat("origAddress2: ", json.origAddress2, ", "));
            logger.Append(string.Concat("origCity: ", json.origCity, ", "));
            logger.Append(string.Concat("origState: ", json.origState, ", "));
            logger.Append(string.Concat("origZip: ", json.origZip, ", "));

            logger.Append(string.Concat("destName: ", json.destName, ", "));
            logger.Append(string.Concat("destEmail: ", json.destEmail, ", "));
            logger.Append(string.Concat("destCompany: ", json.destCompany, ", "));
            logger.Append(string.Concat("destPhone: ", json.destPhone, ", "));
            logger.Append(string.Concat("destFax: ", json.destFax, ", "));
            logger.Append(string.Concat("destAddress1: ", json.destAddress1, ", "));
            logger.Append(string.Concat("destAddress2: ", json.destAddress2, ", "));
            logger.Append(string.Concat("destCity: ", json.destCity, ", "));
            logger.Append(string.Concat("destState: ", json.destState, ", "));
            logger.Append(string.Concat("destZip: ", json.destZip, ", "));

            #endregion

            #region Not used
            //logger.Append(string.Concat("shipmentDate: ", json.shipmentDate, ", "));

            //if(j

            //if (!DateTime.TryParse(json.shipmentDate, out shipmentDate))
            //{
            //    shipmentDate = DateTime.Today.AddDays(1);
            //}



            // Authenticate to the web service/API
            //string sessionId = rs.Authenticate(apiUserName, apiKey);

            //// Initialize SOAP header for authentication
            //rs.AuthHeaderValue = new MyWebReference.AuthHeader();

            //// Set session id to the SOAP header
            //rs.AuthHeaderValue.SessionID = sessionId;
            #endregion

            DateTime shipmentDate = json.shipmentDate;

            // Initialize web service/API object
            gcmAPI.gcmWebService.RateService2 rs = new gcmAPI.gcmWebService.RateService2();

            string bookingKey = json.bookingKey;

            string customerType = json.customerType; //Set customer type

            gcmAPI.gcmWebService.BookingThirdPartyBilling thirdPartyBilling = null;
            //DateTime shipmentDate = DateTime.Now.Date; //Set shipment date

            string readyTime = "02:15 PM"; //Set ready time of the shipment
            string closeTime = "06:15 PM"; //Set close time of the shipment

            //string readyTime = "10"; //Set ready time of the shipment
            //string closeTime = "3"; //Set close time of the shipment

            string bolSendTo = "EML"; //Set BOL sending option
            //string poNumber = "45455"; //Set PO Number
            string poNumber = null;   //Set PO Number

            #region Origin and Destination

            // Set pickup location
            gcmAPI.gcmWebService.BookingPickupLocation pickupLocation = new gcmAPI.gcmWebService.BookingPickupLocation();
            pickupLocation.Name                = json.origName;
            pickupLocation.Email               = json.origEmail;
            pickupLocation.Company             = json.origCompany;
            pickupLocation.Phone               = json.origPhone;
            pickupLocation.Fax                 = json.origFax;
            pickupLocation.Address1            = json.origAddress1;
            pickupLocation.Address2            = json.origAddress2;
            pickupLocation.City                = json.origCity;
            pickupLocation.State               = json.origState;
            pickupLocation.Zip                 = json.origZip;
            pickupLocation.DispatchAddressesId = 1;

            // Set destination location
            gcmAPI.gcmWebService.BookingDestinationLocation destinationLocation = new gcmAPI.gcmWebService.BookingDestinationLocation();
            destinationLocation.Name     = json.destName;
            destinationLocation.Email    = json.destEmail;
            destinationLocation.Company  = json.destCompany;
            destinationLocation.Phone    = json.destPhone;
            destinationLocation.Fax      = json.destFax;
            destinationLocation.Address1 = json.destAddress1;
            destinationLocation.Address2 = json.destAddress2;
            destinationLocation.City     = json.destCity;
            destinationLocation.State    = json.destState;
            destinationLocation.Zip      = json.destZip;

            #endregion

            string SessionID = json.SessionID;
            logger.Append(string.Concat("SessionID: ", json.SessionID, ", "));

            //int testInt;
            List <gcmAPI.gcmWebService.LTLBookingPiece> bookingLineItems = new List <gcmAPI.gcmWebService.LTLBookingPiece>();

            for (byte i = 0; i < json.lineItems.Length; i++)
            {
                gcmAPI.gcmWebService.LTLBookingPiece lineItem = new gcmAPI.gcmWebService.LTLBookingPiece();
                lineItem.Tag            = json.lineItems[i].Tag;
                lineItem.Description    = json.lineItems[i].Description;
                lineItem.NumberOfPallet = json.lineItems[i].NumberOfPallet;

                // Testing
                logger.Append(string.Concat("Tag", i.ToString(), ": ", lineItem.Tag, ", "));
                logger.Append(string.Concat("Description", i.ToString(), ": ", lineItem.Description, ", "));
                logger.Append(string.Concat("NumberOfPallet", i.ToString(), ": ", lineItem.NumberOfPallet, ", "));

                bookingLineItems.Add(lineItem);
            }


            HelperFuncs.writeToSiteErrors("LTL Booking Restful", logger.ToString());

            #region Not used
            //Set other line items
            //gcmWebService.LTLBookingPiece[] bookingLineItems = new gcmWebService.LTLBookingPiece[1];

            //Set first line item for booking
            //bookingLineItems[0] = new gcmWebService.LTLBookingPiece();

            //// This tag is related to the object(LTLPiece) in lineItems array which is used in GetLTLBookingRate function call
            //bookingLineItems[0].Tag = form.Get("Tag");

            ////bookingLineItems[0].NMFC = 50;
            //bookingLineItems[0].NumberOfPallet = 1;
            //bookingLineItems[0].Description = form.Get("Description");

            //Set second line item for booking
            //bookingLineItems[1] = new MyWebReference.LTLBookingPiece();

            ////// This tag is related to the object(LTLPiece) in lineItems array which is used in GetLTLBookingRate function call
            //bookingLineItems[1].Tag = "2";

            //bookingLineItems[1].NMFC = 60;
            //bookingLineItems[1].NumberOfPallet = 10;
            //bookingLineItems[1].Description = "TEST";
            #endregion

            string comments = "TEST";
            //string comments = null;
            //bool insuranceRequired = true;
            bool   insuranceRequired = false;
            double declaredValue     = 100;

            //
            //Book an LTL rate and getting the BOL and insurance certificate PDF url
            gcmAPI.gcmWebService.LTLBookingReply lbr = rs.CreateLTLBooking2(SessionID, bookingKey, customerType, thirdPartyBilling, shipmentDate, readyTime, closeTime, bolSendTo,
                                                                            poNumber, pickupLocation, destinationLocation, bookingLineItems.ToArray(), comments, insuranceRequired, declaredValue);

            HelperFuncs.writeToSiteErrors("LTL Booking Restful result", string.Concat("notification=", lbr.Notification, "&shipmentID=", lbr.ShipmentId, "&=BOLURL", lbr.BOLURL));

            return(lbr.ToJSON());

            //return string.Concat("{ \"notification\" : \"", lbr.Notification, "\", \"shipmentID\" : ", lbr.ShipmentId, ", \"BOLURL", lbr.BOLURL, " }");

            //return "test test";
        }
        catch (Exception e)
        {
            HelperFuncs.writeToSiteErrors("LTL Booking Restful", e.ToString());
            return("{ \"Notification\" : \"error\" }");
            //return lbr.ToJSON;
        }
    }
Exemplo n.º 19
0
    public string MakeBookingViaSOAP(ref LTLBookRequest ltl_book_request, ref string username, ref string password)
    {
        //gcmAPI.gcmWebService.LTLBookingReply lbr;

        try
        {
            //return "{ \"Notification\" : \"temporily stopped service\" }";

            #region Testing

            StringBuilder logger = new StringBuilder();

            //ltl_book_request.lineItems.Length;
            logger.Append(string.Concat("lineItems.Length: ", ltl_book_request.items.Count, ", "));
            logger.Append(string.Concat("shipmentDate: ", ltl_book_request.pickupDate, ", "));
            logger.Append(string.Concat("bookingKey: ", ltl_book_request.bookingKey, ", "));
            logger.Append(string.Concat("customerType: ", ltl_book_request.customerType, ", "));

            logger.Append(string.Concat("origName: ", ltl_book_request.originName, ", "));
            logger.Append(string.Concat("origEmail: ", ltl_book_request.originEmail, ", "));
            logger.Append(string.Concat("origCompany: ", ltl_book_request.originCompany, ", "));
            logger.Append(string.Concat("origPhone: ", ltl_book_request.originPhone, ", "));
            logger.Append(string.Concat("origFax: ", ltl_book_request.originFax, ", "));
            logger.Append(string.Concat("origAddress1: ", ltl_book_request.originAddress1, ", "));
            logger.Append(string.Concat("origAddress2: ", ltl_book_request.originAddress2, ", "));
            logger.Append(string.Concat("origCity: ", ltl_book_request.originCity, ", "));
            logger.Append(string.Concat("origState: ", ltl_book_request.originState, ", "));
            logger.Append(string.Concat("origZip: ", ltl_book_request.originZip, ", "));

            logger.Append(string.Concat("destName: ", ltl_book_request.destinationName, ", "));
            logger.Append(string.Concat("destEmail: ", ltl_book_request.destinationEmail, ", "));
            logger.Append(string.Concat("destCompany: ", ltl_book_request.destinationCompany, ", "));
            logger.Append(string.Concat("destPhone: ", ltl_book_request.destinationPhone, ", "));
            logger.Append(string.Concat("destFax: ", ltl_book_request.destinationFax, ", "));
            logger.Append(string.Concat("destAddress1: ", ltl_book_request.destinationAddress1, ", "));
            logger.Append(string.Concat("destAddress2: ", ltl_book_request.destinationAddress2, ", "));
            logger.Append(string.Concat("destCity: ", ltl_book_request.destinationCity, ", "));
            logger.Append(string.Concat("destState: ", ltl_book_request.destinationState, ", "));
            logger.Append(string.Concat("destZip: ", ltl_book_request.destinationZip, ", "));


            HelperFuncs.writeToSiteErrors("LTL Booking Restful", logger.ToString());

            #endregion

            #region Not used
            //logger.Append(string.Concat("shipmentDate: ", ltl_book_request.shipmentDate, ", "));

            //if(j

            //if (!DateTime.TryParse(ltl_book_request.shipmentDate, out shipmentDate))
            //{
            //    shipmentDate = DateTime.Today.AddDays(1);
            //}



            // Authenticate to the web service/API
            //string sessionId = rs.Authenticate(apiUserName, apiKey);

            //// Initialize SOAP header for authentication
            //rs.AuthHeaderValue = new MyWebReference.AuthHeader();

            //// Set session id to the SOAP header
            //rs.AuthHeaderValue.SessionID = sessionId;
            #endregion

            DateTime shipmentDate = ltl_book_request.pickupDate;

            // Initialize web service/API object
            gcmAPI.gcmWebService.RateService2 rs = new gcmAPI.gcmWebService.RateService2();

            string bookingKey = ltl_book_request.bookingKey;

            string customerType = ltl_book_request.customerType; //Set customer type

            gcmAPI.gcmWebService.BookingThirdPartyBilling thirdPartyBilling = null;
            //DateTime shipmentDate = DateTime.Now.Date; //Set shipment date

            string readyTime = "02:15 PM"; //Set ready time of the shipment
            string closeTime = "06:15 PM"; //Set close time of the shipment

            //string readyTime = "10"; //Set ready time of the shipment
            //string closeTime = "3"; //Set close time of the shipment

            string bolSendTo = "EML"; //Set BOL sending option
            //string poNumber = "45455"; //Set PO Number
            string poNumber = null;   //Set PO Number

            #region Origin and Destination

            // Set pickup location
            gcmAPI.gcmWebService.BookingPickupLocation pickupLocation = new gcmAPI.gcmWebService.BookingPickupLocation();
            pickupLocation.Name                = ltl_book_request.originName;
            pickupLocation.Email               = ltl_book_request.originEmail;
            pickupLocation.Company             = ltl_book_request.originCompany;
            pickupLocation.Phone               = ltl_book_request.originPhone;
            pickupLocation.Fax                 = ltl_book_request.originFax;
            pickupLocation.Address1            = ltl_book_request.originAddress1;
            pickupLocation.Address2            = ltl_book_request.originAddress2;
            pickupLocation.City                = ltl_book_request.originCity;
            pickupLocation.State               = ltl_book_request.originState;
            pickupLocation.Zip                 = ltl_book_request.originZip;
            pickupLocation.DispatchAddressesId = 1;

            // Set destination location
            gcmAPI.gcmWebService.BookingDestinationLocation destinationLocation = new gcmAPI.gcmWebService.BookingDestinationLocation();
            destinationLocation.Name     = ltl_book_request.destinationName;
            destinationLocation.Email    = ltl_book_request.destinationEmail;
            destinationLocation.Company  = ltl_book_request.destinationCompany;
            destinationLocation.Phone    = ltl_book_request.destinationPhone;
            destinationLocation.Fax      = ltl_book_request.destinationFax;
            destinationLocation.Address1 = ltl_book_request.destinationAddress1;
            destinationLocation.Address2 = ltl_book_request.destinationAddress2;
            destinationLocation.City     = ltl_book_request.destinationCity;
            destinationLocation.State    = ltl_book_request.destinationState;
            destinationLocation.Zip      = ltl_book_request.destinationZip;

            #endregion

            //string SessionID = ltl_book_request.SessionID;
            //logger.Append(string.Concat("SessionID: ", ltl_book_request.SessionID, ", "));

            //int testInt;
            List <gcmAPI.gcmWebService.LTLBookingPiece> bookingLineItems = new List <gcmAPI.gcmWebService.LTLBookingPiece>();

            for (byte i = 0; i < ltl_book_request.items.Count; i++)
            {
                gcmAPI.gcmWebService.LTLBookingPiece lineItem = new gcmAPI.gcmWebService.LTLBookingPiece();
                lineItem.Tag         = ltl_book_request.items[i].tag;
                lineItem.Description = ltl_book_request.items[i].description;
                if (ltl_book_request.items[i].units > 0)
                {
                    lineItem.NumberOfPallet = ltl_book_request.items[i].units;
                }
                else if (ltl_book_request.items[i].pieces > 0)
                {
                    lineItem.NumberOfPallet = ltl_book_request.items[i].pieces;
                }
                else
                {
                    lineItem.NumberOfPallet = 1;
                }


                // Testing
                logger.Append(string.Concat("Tag", i.ToString(), ": ", lineItem.Tag, ", "));
                logger.Append(string.Concat("Description", i.ToString(), ": ", lineItem.Description, ", "));
                logger.Append(string.Concat("NumberOfPallet", i.ToString(), ": ", lineItem.NumberOfPallet, ", "));

                bookingLineItems.Add(lineItem);
            }


            HelperFuncs.writeToSiteErrors("LTL Booking Restful", logger.ToString());

            #region Not used
            //Set other line items
            //gcmWebService.LTLBookingPiece[] bookingLineItems = new gcmWebService.LTLBookingPiece[1];

            //Set first line item for booking
            //bookingLineItems[0] = new gcmWebService.LTLBookingPiece();

            //// This tag is related to the object(LTLPiece) in lineItems array which is used in GetLTLBookingRate function call
            //bookingLineItems[0].Tag = form.Get("Tag");

            ////bookingLineItems[0].NMFC = 50;
            //bookingLineItems[0].NumberOfPallet = 1;
            //bookingLineItems[0].Description = form.Get("Description");

            //Set second line item for booking
            //bookingLineItems[1] = new MyWebReference.LTLBookingPiece();

            ////// This tag is related to the object(LTLPiece) in lineItems array which is used in GetLTLBookingRate function call
            //bookingLineItems[1].Tag = "2";

            //bookingLineItems[1].NMFC = 60;
            //bookingLineItems[1].NumberOfPallet = 10;
            //bookingLineItems[1].Description = "TEST";
            #endregion

            string comments = "TEST";
            //string comments = null;
            //bool insuranceRequired = true;
            bool   insuranceRequired = false;
            double declaredValue     = 100;

            //
            //Book an LTL rate and getting the BOL and insurance certificate PDF url
            gcmAPI.gcmWebService.LTLBookingReply lbr = rs.CreateLTLBooking_3(username, password, bookingKey, customerType, thirdPartyBilling, shipmentDate, readyTime, closeTime, bolSendTo,
                                                                             poNumber, pickupLocation, destinationLocation, bookingLineItems.ToArray(), comments, insuranceRequired, declaredValue);

            HelperFuncs.writeToSiteErrors("LTL Booking Restful result", string.Concat("notification=", lbr.Notification,
                                                                                      "&shipmentID=", lbr.ShipmentId, "&=BOLURL", lbr.BOLURL));

            //
            DB.Log("before DLS Shipment Import", "before DLS Shipment Import");
            #region DLS Shipment Import

            try
            {
                var          repo = new gcmAPI.Models.Public.LTL.Repository();
                AES_API_info api_info;
                repo.Get_booking_info_by_booking_key(ltl_book_request.bookingKey, out api_info);

                HelperFuncs.dlsShipInfo     dlsInfo         = new HelperFuncs.dlsShipInfo();
                HelperFuncs.DispatchInfo    dispatchInfo    = new HelperFuncs.DispatchInfo();
                HelperFuncs.AccessorialsObj AccessorialsObj = new HelperFuncs.AccessorialsObj();

                DLS_ShipmentImport shipment_import = new DLS_ShipmentImport(ref dlsInfo, ref dispatchInfo, ref api_info, ref AccessorialsObj,
                                                                            ref username, lbr.ShipmentId);
                shipment_import.Set_DLS_ShipmentImport_objects(ref ltl_book_request, ref api_info);

                //DB.Log("dispatchInfo.username", dispatchInfo.username);

                string DLS_PrimaryReferencePNW = "";

                DB.Log("before ShipmentImportDLS", "before ShipmentImportDLS");

                //shipment_import.ShipmentImportDLS(ref DLS_PrimaryReferencePNW);

                DB.Log("after ShipmentImportDLS", "after ShipmentImportDLS");
            }
            catch (Exception e)
            {
                DB.Log("MakeBookingViaSOAP DLS Shipment Import", e.ToString());
            }
            DB.Log("after DLS Shipment Import", "after DLS Shipment Import");
            #endregion

            // Insert DLS_PrimaryReferencePNW into DB


            return(lbr.ToJSON());

            //return string.Concat("{ \"notification\" : \"", lbr.Notification, "\", \"shipmentID\" : ", lbr.ShipmentId, ", \"BOLURL", lbr.BOLURL, " }");

            //return "test test";
        }
        catch (Exception e)
        {
            HelperFuncs.writeToSiteErrors("LTL Booking Restful", e.ToString());
            Json_helper json_helper = new Json_helper();
            return(json_helper.Build_error_response("1", "An error occurred while processing the request"));

            //return "{ \"Notification\" : \"error\" }";
            //return lbr.ToJSON;
        }
    }
Exemplo n.º 20
0
        // GET api/getdocuments/5
        public string Get(int id)
        {
            int ind;

            string shipId = id.ToString(), retString = "";

            try
            {
                HelperFuncs.writeToSiteErrors("Get Documents", id.ToString());
                //if (!string.IsNullOrEmpty(Request.QueryString["shipId"]) && int.TryParse(Request.QueryString["shipId"], out intID))
                //{
                //    shipId = Request.QueryString["shipId"];
                //}

                List <string> data   = new List <string>();
                List <string> aesBol = new List <string>();
                HelperFuncs.getDocs(ref data, ref shipId);

                #region get AES BOL

                DirectoryInfo di;
                di = new DirectoryInfo(string.Concat(AppCodeConstants.G_root, "\\bookrate\\BOLReports"));

                DirectoryInfo diAES;
                diAES = new DirectoryInfo(string.Concat(AppCodeConstants.G_root, "\\aes\\bookrate\\BOLReports")); //some of the BOL's are in the net-net directory

                DirectoryInfo diBOLEditor;
                diBOLEditor = new DirectoryInfo(string.Concat(AppCodeConstants.G_root_demo, "\\admin\\BOLReports"));

                string fileName = "";
                foreach (FileInfo f in di.GetFiles("*_" + shipId + "_*")) //* stands for pattern
                {
                    fileName = AppCodeConstants.g_car_man_base_url + "/bookrate/BOLReports/" + f.Name;
                    aesBol.Add(fileName);
                }
                foreach (FileInfo f in diAES.GetFiles("*_" + shipId + "_*"))
                {
                    fileName = AppCodeConstants.g_car_man_base_url + "/aes/bookrate/BOLReports/" + f.Name;
                    aesBol.Add(fileName);
                }

                foreach (FileInfo f in diBOLEditor.GetFiles("*_" + shipId + "_*"))
                {
                    //HelperFuncs.writeToSiteErrors("fName", f.Name);
                    fileName = AppCodeConstants.g_car_man_base_url + "/admin/BOLReports/" + f.Name;
                    aesBol.Add(fileName);
                }

                #endregion

                for (int i = 0; i < aesBol.Count; i++)
                {
                    //ind = data[i].IndexOf("WebDocs");
                    retString += aesBol[i];

                    if (i != (aesBol.Count - 1))
                    {
                        retString += "^";
                    }
                }

                // Construct retString
                for (int i = 0; i < data.Count; i++)
                {
                    if (i.Equals(0) && aesBol.Count.Equals(0))
                    {
                    }
                    else
                    {
                        retString += "^";
                    }
                    ind        = data[i].IndexOf("WebDocs");
                    retString += data[i].Substring(ind);

                    //if (i != (data.Count - 1))
                    //    retString += "^";
                }

                return(retString);
            }
            catch (Exception cE)
            {
                if (!cE.Message.Contains("abort"))
                {
                    HelperFuncs.writeToSiteErrors("Get Documents", cE.ToString());
                }
                return("error");
            }
        }
Exemplo n.º 21
0
        public static void SetInsuranceMinimum(ref DispatchData dispatch_data, ref double insuranceCost, ref double dblShipmentValue)
        {
            if (dispatch_data.commodityName != null)
            {
                HelperFuncs.writeToSiteErrors("requestedValues commodityName",
                                              dispatch_data.commodityName);

                if (dispatch_data.commodityName.Contains("Antiques, Artwork, Sculpture"))
                {
                    HelperFuncs.writeToSiteErrors("requestedValues commodityName Contains Antiques",
                                                  dispatch_data.commodityName);
                    insuranceCost = dblShipmentValue * .0125;
                    if (insuranceCost < 65.00)
                    {
                        insuranceCost = 65.00;
                    }
                }
            }

            if (dispatch_data.Commodity1 != null)
            {
                HelperFuncs.writeToSiteErrors("Session Commodity1", dispatch_data.Commodity1.ToString());
                if ((dispatch_data.Commodity1 != null && dispatch_data.Commodity1 != "" && dispatch_data.Commodity1.ToString().Contains("Antiques, Artwork, Sculpture")) ||
                    (dispatch_data.Commodity2 != null && dispatch_data.Commodity2 != "" && dispatch_data.Commodity2.ToString().Contains("Antiques, Artwork, Sculpture")) ||
                    (dispatch_data.Commodity3 != null && dispatch_data.Commodity3 != "" && dispatch_data.Commodity3.ToString().Contains("Antiques, Artwork, Sculpture")) ||
                    (dispatch_data.Commodity4 != null && dispatch_data.Commodity4 != "" && dispatch_data.Commodity4.ToString().Contains("Antiques, Artwork, Sculpture")))
                {
                    HelperFuncs.writeToSiteErrors("Session[Commodity1].ToString()", dispatch_data.Commodity1.ToString());
                    insuranceCost = dblShipmentValue * .0125;
                    if (insuranceCost < 65.00)
                    {
                        insuranceCost = 65.00;
                    }
                }
            }


            #region For HHG, set insurance cost

            // If household goods
            if ((dispatch_data.Commodity1 != null && dispatch_data.Commodity1 != "" && dispatch_data.Commodity1.ToString() == "Household Goods") ||
                (dispatch_data.Commodity2 != null && dispatch_data.Commodity2 != "" && dispatch_data.Commodity2.ToString() == "Household Goods") ||
                (dispatch_data.Commodity3 != null && dispatch_data.Commodity3 != "" && dispatch_data.Commodity3.ToString() == "Household Goods") ||
                (dispatch_data.Commodity4 != null && dispatch_data.Commodity4 != "" && dispatch_data.Commodity4.ToString() == "Household Goods"))
            {
                insuranceCost = dblShipmentValue * .0125;
                if (insuranceCost < 65.00)
                {
                    insuranceCost = 65.00;
                }
            }

            #endregion

            //bool.TryParse(dispatch_data.isUSED, out isUSED);

            //HelperFuncs.writeToSiteErrors("dispatch IsUSED", isUSED.ToString());

            //

            bool isRESDEL = false;
            if (dispatch_data.q_ResDel != null)
            {
                bool.TryParse(dispatch_data.q_ResDel, out isRESDEL);
            }

            HelperFuncs.writeToSiteErrors("dispatch isRESDEL", isRESDEL.ToString());

            if (dispatch_data.isUSED.Equals(true) && isRESDEL.Equals(true))
            {
                if (insuranceCost < 65.00)
                {
                    insuranceCost = 65.00;
                }
            }

            HelperFuncs.writeToSiteErrors("dispatch insuranceCost", insuranceCost.ToString());
        }
Exemplo n.º 22
0
    public static void tryDateCSXI_WithCapacity(ref CookieContainer container, ref string originZipGlobal, ref string originCity,
                                                ref string originState, ref string destZipGlobal, ref string destCity, ref string destState, ref string month, ref string day,
                                                ref string year, ref bool hasCapacity, ref string transitTime, ref string price, ref bool successBool, ref bool isLastDateTry)
    {
        #region Variables

        HelperFuncs.writeToSiteErrors("CSXI date", month + " " + day);
        //HelperFuncs.writeToSiteErrors("CSXI isLastDateTry", isLastDateTry.ToString());

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

        referrer    = "https://shipcsx.com/sx_dealspace_jct/sx.dealspace/SpotQuoteBegin";
        url         = "https://shipcsx.com/sx_dealspace_jct/sx.dealspace/SpotQuoteSelectPrice";
        contentType = "application/x-www-form-urlencoded";
        accept      = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
        method      = "POST";

        data = string.Concat("addFavoriteLaneName=&originZipCode=", originZipGlobal, "&originCityStateDisplay=", originCity.Replace(" ", "+"), "%2C+", originState,
                             "&originCity=", originCity.Replace(" ", "+"), "&originState=", originState, "&destinationZipCode=", destZipGlobal,
                             "&destinationCityStateDisplay=", destCity.Replace(" ", "+"), "%2C+", destState, "&destinationCity=", destCity.Replace(" ", "+"),
                             "&destinationState=", destState, "&pickupDate=", month, "%2F", day, "%2F", year, "&selectedTimeOfDay=5&begEquipment=53",
                             "&numberOfLoads=1&extraPickup0ZipCode=&extraPickup0CityStateDisplay=&extraPickup0City=",
                             "&extraPickup0State=&extraDelivery0ZipCode=&extraDelivery0CityStateDisplay=&extraDelivery0City=",
                             "&extraDelivery0State=&doResetQuote=&reuseAdapter=true&requote=false&quoteType=&templateId=");

        #endregion

        doc = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, data, false, false, "", "");

        //HelperFuncs.writeToSiteErrors("CSXI", doc);

        // Get cost/costs from this page
        // Scrape html table

        string[] tokens2 = new string[3];
        tokens2[0] = "<table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" width=\"100%";
        tokens2[1] = ">";
        tokens2[2] = "</table>";
        string tblHtml = HelperFuncs.scrapeFromPage(tokens2, doc);
        //HelperFuncs.writeToSiteErrors("CSXI tblHtml", tblHtml);

        #region Scrape result row

        // Scrape result row

        tokens2[0] = "<tr class=\"columnBasedResultsRow";
        tokens2[1] = ">";
        tokens2[2] = "</tr>";
        string columnBasedResultsRow = HelperFuncs.scrapeFromPage(tokens2, tblHtml);
        //HelperFuncs.writeToSiteErrors("CSXI columnBasedResultsRow", columnBasedResultsRow);

        if (columnBasedResultsRow.Contains("No Capacity"))
        {
            HelperFuncs.writeToSiteErrors("CSXI no capacity", "CSXI no capacity");
            hasCapacity = false;
            if (!isLastDateTry)
            {
                //HelperFuncs.writeToSiteErrors("CSXI not LastDateTry", "CSXI not LastDateTry");
                return;
            }
            else
            {
                //HelperFuncs.writeToSiteErrors("CSXI LastDateTry", "CSXI LastDateTry");
            }
        }

        tokens2[0] = "<span";  // style=\\\"vertical-align: top;
        tokens2[1] = ">";
        tokens2[2] = "</span>";
        price      = HelperFuncs.scrapeFromPage(tokens2, columnBasedResultsRow)
                     .Replace("&nbsp;", "").Replace("$", "").Replace(",", "").Trim();
        //HelperFuncs.writeToSiteErrors("CSXI costStr", price);

        decimal testDecimal;
        if (decimal.TryParse(price, out testDecimal))
        {
            successBool = true;
        }

        // Get transit time

        string[] tokens3 = new string[5];
        tokens3[0]  = "<td";
        tokens3[1]  = "<td";
        tokens3[2]  = "<td";
        tokens3[3]  = ">";
        tokens3[4]  = "</td>";
        transitTime = HelperFuncs.scrapeFromPage(tokens3, columnBasedResultsRow).Replace(",", "").Replace("days", "")
                      .Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim();
        //HelperFuncs.writeToSiteErrors("CSXI transitTime", transitTime);

        #endregion

        #region Scrape alt result row

        // Scrape alt result row

        //tokens2[0] = "<tr class=\"columnBasedResultsRowAlt";
        //tokens2[1] = ">";
        //tokens2[2] = "</tr>";
        //string columnBasedResultsRowAlt = HelperFuncs.scrapeFromPage(tokens2, tblHtml);
        //HelperFuncs.writeToSiteErrors("CSXI columnBasedResultsRowAlt", columnBasedResultsRowAlt);

        #endregion
    }
Exemplo n.º 23
0
    public static void getClassForCTII(ref decimal ctiiFreightClass, ref decimal totalDensity)
    {
        #region Get ctiiFreightClass by density
        if (totalDensity < 0)
        {
            //SharedFunctions.writeToAAFES_Logs("AAFES", string.Concat("Density was less than zero po id: ", shipInfo.PO_ID.ToString()));
            //continue;
            HelperFuncs.writeToSiteErrors("getClassForCTII", "Density was less than zero");
            ctiiFreightClass = -3;
        }
        else if (totalDensity >= 0 && totalDensity < 1)
        {
            ctiiFreightClass = 500;
        }
        else if (totalDensity >= 1 && totalDensity < 2)
        {
            ctiiFreightClass = 400;
        }
        else if (totalDensity >= 2 && totalDensity < 3)
        {
            ctiiFreightClass = 300;
        }
        else if (totalDensity >= 3 && totalDensity < 4)
        {
            ctiiFreightClass = 250;
        }
        else if (totalDensity >= 4 && totalDensity < 5)
        {
            ctiiFreightClass = 200;
        }
        else if (totalDensity >= 5 && totalDensity < 6)
        {
            ctiiFreightClass = 175;
        }
        else if (totalDensity >= 6 && totalDensity < 7)
        {
            ctiiFreightClass = 150;
        }
        else if (totalDensity >= 7 && totalDensity < 8)
        {
            ctiiFreightClass = 125;
        }
        else if (totalDensity >= 8 && totalDensity < 9)
        {
            ctiiFreightClass = 110;
        }
        else if (totalDensity >= 9 && totalDensity < 10.5M)
        {
            ctiiFreightClass = 100;
        }
        else if (totalDensity >= 10.5M && totalDensity < 12)
        {
            ctiiFreightClass = 92.5M;
        }
        else if (totalDensity >= 12 && totalDensity < 13.5M)
        {
            ctiiFreightClass = 85;
        }
        else if (totalDensity >= 13.5M && totalDensity < 15)
        {
            ctiiFreightClass = 77.5M;
        }
        else if (totalDensity >= 15 && totalDensity < 22.5M)
        {
            ctiiFreightClass = 70;
        }
        else if (totalDensity >= 22.5M && totalDensity < 30)
        {
            ctiiFreightClass = 65;
        }
        else if (totalDensity >= 30 && totalDensity < 35)
        {
            ctiiFreightClass = 60;
        }
        else if (totalDensity >= 35 && totalDensity < 50)
        {
            ctiiFreightClass = 55;
        }
        else
        {
            ctiiFreightClass = 50;
        }


        #endregion
    }
Exemplo n.º 24
0
    public IntermodalRater.railResult getRate()
    {
        // CSXI are blocking our IP bc of scraping
        railResultObj.success = "";
        return(railResultObj);

        int timeOut = 25000;

        try
        {
            HelperFuncs.writeToSiteErrors("CSXI", "oop");
            List <HelperFuncs.Credentials> crds = new List <HelperFuncs.Credentials>();
            string username = "", password = "";

            try
            {
                crds     = HelperFuncs.GetLoginsByCarID(90199);
                username = crds[0].username;
                password = crds[0].password;
            }
            catch (Exception ex)
            {
                HelperFuncs.writeToSiteErrors("CSXI", ex.ToString());
            }

            string url, referrer, contentType, accept, method, data, doc, originCity = "", destCity = "", originState = "", destState = "";

            CookieContainer  container  = new CookieContainer();
            CookieCollection collection = new CookieCollection();

            #region Login and go to rate page

            #region Login request

            referrer    = "https://shipcsx.com/pub_sx_mainpagepublic_jct/sx.shipcsxpublic/PublicNavbar";
            url         = "https://shipcsx.com/pkmslogin.form";
            contentType = "application/x-www-form-urlencoded";
            accept      = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
            method      = "POST";
            data        = "login-form-type=pwd&username="******"&password="******"&LoginGoButton.x=7&LoginGoButton.y=8"; //user password
            collection  = (CookieCollection)HelperFuncs.generic_http_request("collection", container, url, referrer, contentType, accept, method, data, true, timeOut);

            #endregion

            #region Some required requests
            //--------------------------------------------------------------------------------------------------------------
            url         = "https://shipcsx.com/sx_mainpage_jct/sx.shipcsx/Main";
            referrer    = "";
            contentType = "";
            method      = "GET";
            collection  = (CookieCollection)HelperFuncs.generic_http_request("collection", container, url, referrer, contentType, accept, method, "", true, timeOut);

            //--------------------------------------------------------------------------------------------------------------
            referrer   = url;
            url        = "https://shipcsx.com/sx_mainpage_jct/sx.shipcsx/Navbar";
            collection = (CookieCollection)HelperFuncs.generic_http_request("collection", container, url, referrer, contentType, accept, method, "", true, timeOut);

            url         = "https://shipcsx.com/sx_dealspace_jct/sx.dealspace/TruckingMain";
            referrer    = "https://shipcsx.com/sx_mainpage_jct/sx.shipcsx/Navbar";
            contentType = "";
            method      = "GET";
            collection  = (CookieCollection)HelperFuncs.generic_http_request("collection", container, url, referrer, contentType, accept, method, "", true, timeOut);

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

            referrer   = url;
            url        = "https://shipcsx.com/sx_dealspace_jct/sx.dealspace/jsp/sx_base_classes/blank.jsp";
            collection = (CookieCollection)HelperFuncs.generic_http_request("collection", container, url, referrer, contentType, accept, method, "", true, timeOut);

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

            //referrer = "https://shipcsx.com/sx_dealspace_jct/sx.dealspace/TruckingMain";
            url        = "https://shipcsx.com/sx_dealspace_jct/sx.dealspace/SpotQuoteBegin?";
            collection = (CookieCollection)HelperFuncs.generic_http_request("collection", container, url, referrer, contentType, accept, method, "", true, timeOut);

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

            referrer   = url;
            url        = "https://shipcsx.com/sx_dealspace_jct/sx.dealspace/jsp/sx_base_classes/blank.jsp";
            collection = (CookieCollection)HelperFuncs.generic_http_request("collection", container, url, referrer, contentType, accept, method, "", true, timeOut);

            //--------------------------------------------------------------------------------------------------------------
            #endregion

            #region Get City and State

            // Get City and State
            referrer = "https://shipcsx.com/sx_dealspace_jct/sx.dealspace/SpotQuoteBegin?";
            url      = "https://shipcsx.com/sx_dealspace_jct/sx.dealspace/GetCityStateData?zip=" + origZip;
            doc      = (string)HelperFuncs.generic_http_request("string", container, url, referrer, contentType, accept, method, "", true, timeOut);

            // Scrape origin city and state
            string[] tokens = new string[3];
            tokens[0] = "<city>";
            tokens[1] = ">";
            tokens[2] = "<";

            HelperFuncs.writeToSiteErrors("CSXI origZip", origZip);

            originCity = HelperFuncs.scrapeFromPage(tokens, doc);
            if (originCity == "" || originCity == "not found")
            {
                throw new Exception("No matching City/State for zipcode " + origZip);
            }

            tokens[0]   = "<state>";
            originState = HelperFuncs.scrapeFromPage(tokens, doc);

            url = "https://shipcsx.com/sx_dealspace_jct/sx.dealspace/GetUnservicableLocations?zip=" + origZip;
            doc = (string)HelperFuncs.generic_http_request("string", container, url, referrer, contentType, accept, method, "", true, timeOut);

            url = "https://shipcsx.com/sx_dealspace_jct/sx.dealspace/GetUnservicableLocations?zip=" + destZip;
            doc = (string)HelperFuncs.generic_http_request("string", container, url, referrer, contentType, accept, method, "", true, timeOut);

            url = "https://shipcsx.com/sx_dealspace_jct/sx.dealspace/GetCityStateData?zip=" + destZip;
            doc = (string)HelperFuncs.generic_http_request("string", container, url, referrer, contentType, accept, method, "", true, timeOut);

            // Scrape destination city and state
            tokens[0] = "<city>";
            destCity  = HelperFuncs.scrapeFromPage(tokens, doc);
            if (destCity == "" || destCity == "not found")
            {
                throw new Exception("No matching City/State for zipcode " + destZip);
            }

            tokens[0] = "<state>";
            destState = HelperFuncs.scrapeFromPage(tokens, doc);

            #endregion

            #region Variables

            HelperFuncs.writeToSiteErrors("CSXI TEST TEST TEST", "CSXI TEST TEST TEST");

            HelperFuncs.writeToSiteErrors("CSXI puDate", puDate.ToShortDateString());
            DateTime dt     = puDate;
            DateTime dtLast = new DateTime();
            dtLast = DateTime.Today.AddDays(6);
            TimeSpan span = dtLast - dt;

            HelperFuncs.writeToSiteErrors("CSXI span.TotalDays", span.TotalDays.ToString());

            bool hasCapacity = true;
            //string hazmat = "";
            //double parseDbl;
            bool   successBool = false;
            string price       = "";
            string transitTime = "";

            bool isLastDateTry = false;

            #endregion

            for (int i = 0; i <= span.TotalDays; i++)
            {
                //HelperFuncs.writeToSiteErrors("CSXI i", i.ToString());
                //HelperFuncs.writeToSiteErrors("CSXI span.TotalDays", span.TotalDays.ToString());

                if (i.Equals((int)span.TotalDays))
                {
                    HelperFuncs.writeToSiteErrors("CSXI i=span", "CSXI i=span");
                    isLastDateTry = true;
                }

                dt = DateTime.Today.AddDays(i + 1);

                if (dt.DayOfWeek.ToString() == "Saturday" || dt.DayOfWeek.ToString() == "Sunday")
                {
                    continue;
                }

                #region Fix date

                string day = dt.Day.ToString(), month = dt.Month.ToString(), year = dt.Year.ToString();
                if (day.Length.Equals(1))
                {
                    day = "0" + day;
                }

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

                #endregion

                hasCapacity = true;

                tryDateCSXI_WithCapacity(ref container, ref origZip, ref originCity,
                                         ref originState, ref destZip, ref destCity, ref destState, ref month, ref day, ref year,
                                         ref hasCapacity, ref transitTime, ref price, ref successBool, ref isLastDateTry);

                if (successBool.Equals(true) && hasCapacity.Equals(true))
                {
                    break;
                }
            }

            #endregion

            #region Not used
            //for (int i = 0; i <= span.TotalDays; i++)
            //{
            //    dt = DateTime.Today.AddDays(i + 1);
            //    //dt = dt.AddDays(i);
            //    if (dt.DayOfWeek.ToString() == "Saturday" || dt.DayOfWeek.ToString() == "Sunday")
            //    {
            //        continue;
            //    }
            //    doc = tryDateCSXI(container, originZipGlobal, destZipGlobal, originCity, destCity, originState, destState, hazmat, i + 1);
            //    //if (doc.Contains("No pricing is available"))
            //    //{
            //    //    throw new Exception("No pricing is available");
            //    //}

            //    tokens[0] = "<price>";
            //    tokens[1] = ">";
            //    tokens[2] = "<";

            //    price = HelperFuncs.scrapeFromPage(tokens, doc).Replace("$", "");
            //    if (!double.TryParse(price, out parseDbl))
            //    {
            //        continue;
            //    }
            //    else
            //    {
            //        successBool = true;
            //    }

            //    tokens[0] = "<transitTime>";
            //    tokens[1] = ">";
            //    tokens[2] = "<";
            //    transitTime = HelperFuncs.scrapeFromPage(tokens, doc).Replace("days", "").Trim();

            //    if (successBool.Equals(true))
            //    {
            //        break;
            //    }
            //}
            #endregion

            if (successBool == true)
            {
                #region Set the result object

                HelperFuncs.writeToSiteErrors("CSXI success", "CSXI success");
                //string[] csxiResultArray = new string[7];
                ////csxiResultArray[0] = SharedRail.success;
                //csxiResultArray[0] = "success";
                //csxiResultArray[1] = "CSXI";

                //csxiResultArray[3] = transitTime;

                //csxiResultArray[2] = price;
                //insertIntoRailLogs("CSXI", 90199, "1", "", "", Convert.ToDouble(rate));
                HelperFuncs.writeToSiteErrors("CSXI live rate", price);

                //csxiResultArray[4] = dt.ToShortDateString();

                Int32 transit;
                //if (!Int32.TryParse(csxiResultArray[3], out transit))
                //{
                //    HelperFuncs.writeToSiteErrors("CSXI", "could not parse transit " + csxiResultArray[3]);
                //}
                //csxiResultArray[5] = dt.AddDays(transit).ToShortDateString();
                //csxiResultArray[6] = "FiftyThreeFt";

                //List<string[]> list
                //list.Add(csxiResultArray);


                railResultObj.success           = "success";
                railResultObj.transitTime       = transitTime;
                railResultObj.rate              = price;
                railResultObj.firstCapacityDate = dt;
                if (int.TryParse(transitTime, out transit))
                {
                    railResultObj.eta = dt.AddDays(transit);
                }

                railResultObj.hasCapacity   = hasCapacity;
                railResultObj.containerSize = "FiftyThreeFt";

                return(railResultObj);

                #endregion
            }
            else
            {
                //throw new Exception("No Capacity for all days, or no rate found");
                HelperFuncs.writeToSiteErrors("CSXI", "No Capacity for all days, or no rate found");
                railResultObj.success = "";
                return(railResultObj);
            }
        }
        catch (Exception e)
        {
            HelperFuncs.writeToSiteErrors("CSXI", e.ToString());
            railResultObj.success = "";
            return(railResultObj);
        }
    }
Exemplo n.º 25
0
    public IntermodalRater.railResult getRate_Old()
    {
        try
        {
            //HelperFuncs.writeToSiteErrors("Streamline", "hit func");

            #region Variables

            //List<HelperFuncs.Credentials> crds = new List<HelperFuncs.Credentials>();
            //string username = "", password = "";
            //crds = HelperFuncs.GetLoginsByCarID(78573);
            //username = crds[0].username;
            //password = crds[0].password;

            container = new CookieContainer();
            login();
            string   url = "", referrer, contentType, accept, method, doc = "", data = "";
            DateTime puDate = DateTime.Today.AddDays(1);
            string   puDateDay = puDate.Day.ToString(), puDateMonth = puDate.Month.ToString();

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

            #endregion

            referrer    = "https://www.shipstreamline.com/";
            url         = "https://www.shipstreamline.com/stm/redirect/quoteline.shtml";
            accept      = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
            contentType = "";
            method      = "GET";
            doc         = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, "", false, false, "", "");

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

            referrer = url;
            url      = "https://www.shipstreamline.com/customers/quoteline/secure/index.shtml";
            doc      = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, "", false, false, "", "");

            //--------------------------------------------------------------------------------------------------------------------
            SharedRail.Location origLocation = new SharedRail.Location();
            getLocationInfo(ref origLocation, ref origZip, ref origCity, ref container, ref doc, referrer, url, accept, contentType);

            SharedRail.Location destLocation = new SharedRail.Location();
            getLocationInfo(ref destLocation, ref destZip, ref destCity, ref container, ref doc, referrer, url, accept, contentType);
            //--------------------------------------------------------------------------------------------------------------------

            // getLocationInfo_Streamline

            //

            string hazMat = "false";
            if (isHazMat.Equals(true))
            {
                hazMat = "true";
            }

            //

            Random random  = new Random();
            int    randInt = random.Next(999); // Max value
            string randStr = "1403" + randInt.ToString();
            randInt  = random.Next(999999);    // Max value
            randStr += randInt.ToString();

            referrer    = url;
            url         = "https://www.shipstreamline.com/pricing-services/secure/jas/api/pricing/summary?cb=" + randStr;
            accept      = "application/json, text/plain, */*";
            contentType = "application/json;charset=utf-8";
            method      = "POST";

            data = string.Concat("{\"hazmatShipment\":", hazMat, ",\"beneficialOwner\":{\"name\":\"AES\"},\"pickupDate\":\"", puDate.Year.ToString(),
                                 puDateMonth, puDateDay, "\",\"intermodalMoveType\":\"DOOR_TO_DOOR\",\"shipFromLocation\":{\"spotLiveType\":\"STAY\",",
                                 "\"locationId\":\"", origLocation.locationId, "\",\"city\":\"", origLocation.city, "\",\"state\":\"", origLocation.state,
                                 "\",\"zipcode\":\"", origLocation.zipCode, "\",\"country\":\"", origLocation.country, "\",\"area\":\"", origLocation.area, "\",",
                                 "\"latitude\":", origLocation.latitude, ",\"longitude\":", origLocation.longitude, ",\"timeZone\":\"", origLocation.timeZone,
                                 "\",\"services\":[]},\"shipToLocation\":{\"spotLiveType\":\"STAY\",",
                                 "\"locationId\":\"", destLocation.locationId, "\",\"city\":\"", destLocation.city, "\",\"state\":\"", destLocation.state,
                                 "\",\"zipcode\":\"", destLocation.zipCode, "\",\"country\":\"", destLocation.country, "\",\"area\":\"", destLocation.area, "\",",
                                 "\"latitude\":", destLocation.latitude, ",\"longitude\":", destLocation.longitude,
                                 ",\"timeZone\":\"", destLocation.timeZone, "\",\"services\":[]},\"extraPickups\":[],\"extraDeliveries\":[]}");

            string ratesDoc = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, data, false, false, "", "");

            // Test
            HelperFuncs.writeToSiteErrors("Streamline ratesDoc", ratesDoc);

            //do not have capacity
            bool resHasNoCapacity = false;
            if (ratesDoc.Contains("do not have capacity"))
            {
                resHasNoCapacity = true;
            }

            streamlineResults = new List <SharedRail.Result>();
            //List<string> originRamps = new List<string>();
            //List<string> destinationRamps = new List<string>();
            int transitDays = -1;

            railResultObj = new IntermodalRater.railResult();

            if (resHasNoCapacity.Equals(false))
            {
                #region Has Capacity

                HelperFuncs.writeToSiteErrors("Streamline", "has capacity");
                originRamps      = new List <string>();
                destinationRamps = new List <string>();

                scrapeResult(ref ratesDoc);

                HelperFuncs.writeToSiteErrors("Streamline", "after scrapeResult");

                // Find index of first result that has canBook = true
                int indexOfFirstCanBookResult = -1;
                for (int i = 0; i < streamlineResults.Count; i++)
                {
                    //HelperFuncs.writeToSiteErrors("Streamline", streamlineResults[i].totalPrice.ToString());
                    if (streamlineResults[i].canBook == true)
                    {
                        indexOfFirstCanBookResult = i;
                        break;
                    }
                }

                if (indexOfFirstCanBookResult == -1)
                {
                    //throw new Exception("no rate was found");
                }
                else
                {
                    #region Get Transit Time

                    // Need to make 2 or 3 more requests here to get the transit time
                    //--------------------------------------------------------------------------------------------------------------------
                    url  = "https://www.shipstreamline.com/pricing-services/secure/jas/api/capacity";
                    data = "{\"quoteLineTransactionId\":" + streamlineResults[indexOfFirstCanBookResult].quoteLineTransactionId.Trim() + "}";
                    doc  = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, data, false, false, "", "");
                    //--------------------------------------------------------------------------------------------------------------------

                    randInt  = random.Next(999);    // Max value
                    randStr  = "1403" + randInt.ToString();
                    randInt  = random.Next(999999); // Max value
                    randStr += randInt.ToString();

                    url  = "https://www.shipstreamline.com/pricing-services/secure/jas/api/pricing/route?cb=" + randStr;
                    data = string.Concat("{\"hazmatShipment\":false,\"lane\":{\"originRamp\":\"", originRamps[indexOfFirstCanBookResult], "\",\"destinationRamp\":\"",
                                         destinationRamps[indexOfFirstCanBookResult],
                                         "\"},\"beneficialOwner\":{\"name\":\"aes\"},\"pickupDate\":\""
                                         , puDate.Year.ToString(), puDateMonth, puDateDay,

                                         "\",\"intermodalMoveType\":\"DOOR_TO_DOOR\",\"shipFromLocation\":{\"spotLiveType\":\"STAY\",\"locationId\":\"", origLocation.locationId,
                                         "\",\"city\":\"", origLocation.city, "\",\"state\":\"", origLocation.state, "\"",
                                         ",\"zipcode\":\"", origLocation.zipCode, "\",\"country\":\"", origLocation.country, "\",\"area\":\"", origLocation.area,
                                         "\",\"latitude\":\"", origLocation.latitude, "\",\"longitude\":\"", origLocation.longitude, "\",\"timeZone\":\"", origLocation.timeZone,
                                         "\",\"services\":[]},\"shipToLocation\"",

                                         ":{\"spotLiveType\":\"STAY\",\"locationId\":\"", destLocation.locationId, "\",\"city\":\"", destLocation.city,
                                         "\",\"state\":\"", destLocation.state, "\",\"zipcode\":\"", destLocation.zipCode, "\",\"country\":\"", destLocation.country,
                                         "\",\"area\":\"", destLocation.area, "\"",
                                         ",\"latitude\":\"", destLocation.latitude, "\",\"longitude\":\"", destLocation.longitude, "\",\"timeZone\":\"", destLocation.timeZone,
                                         "\",\"services\":[]},\"extraPickups\":[],\"extraDeliveries\":[],\"",
                                         "quoteLineTransactionId\":\"", streamlineResults[indexOfFirstCanBookResult].quoteLineTransactionId.Trim(),
                                         "\",\"appointmentType\":\"APPOINTMENT_BETWEEN\",\"appointmentTimeStart\":\"0800\",\"appointmentTimeEnd\":\"1600\",\"",
                                         "crossingMethodType\":\"NOT_APPLICABLE\"}");

                    doc = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, data, false, false, "", "");

                    //HelperFuncs.writeToSiteErrors("Streamline res", doc);

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

                    doc = HelperFuncs.scrapeFromPage(tokens, doc);
                    //int transitDays;
                    if (!int.TryParse(doc, out transitDays))
                    {
                        transitDays = -1;
                    }

                    #endregion
                }

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



                // Set the results
                HelperFuncs.writeToSiteErrors("Streamline", "before for each");
                foreach (SharedRail.Result streamRes in streamlineResults)
                {
                    //HelperFuncs.writeToSiteErrors("Streamline", "one result");
                    if (streamRes.canBook == true)
                    {
                        //HelperFuncs.writeToSiteErrors("Streamline", "can book");

                        //HelperFuncs.writeToSiteErrors("Streamline", "before railResultObj");
                        railResultObj.success           = "success";
                        railResultObj.transitTime       = transitDays.ToString();
                        railResultObj.rate              = streamRes.totalPrice.ToString();
                        railResultObj.firstCapacityDate = streamRes.pickupDate;

                        if (transitDays > 0)
                        {
                            railResultObj.eta = streamRes.pickupDate.AddDays(transitDays);
                        }

                        railResultObj.hasCapacity   = true;
                        railResultObj.containerSize = "FiftyThreeFt";
                        HelperFuncs.writeToSiteErrors("Streamline", "after railResultObj");

                        return(railResultObj);
                    }
                }

                #endregion
            }

            #region Not used
            //if (!streamlineResultArray[0].Equals(SharedRail.success) && streamlineResults.Count > 0) // resHasNoCapacity.Equals(true) || (
            //{
            //    HelperFuncs.writeToSiteErrors("Streamline", "no capacity");

            //    railResultObj.success = "success";
            //    railResultObj.transitTime = transitDays.ToString();
            //    railResultObj.rate = string.Format("{0:0.00}", streamlineResults[0].totalPrice);
            //    railResultObj.firstCapacityDate = DateTime.MaxValue;

            //    if (transitDays > 0)
            //    {
            //        railResultObj.eta = DateTime.MaxValue;
            //    }

            //    railResultObj.hasCapacity = false;
            //    railResultObj.containerSize = "FiftyThreeFt";

            //    return;
            //}
            #endregion

            if (resHasNoCapacity.Equals(true))
            {
                #region No Capacity

                HelperFuncs.writeToSiteErrors("Streamline", "no capacity");

                //railResultObj.success = "success";
                railResultObj.success     = "";
                railResultObj.transitTime = transitDays.ToString();
                //railResultObj.rate = string.Format("{0:0.00}", streamlineResults[0].totalPrice);
                railResultObj.rate = string.Format("{0:0.00}", 0);
                railResultObj.firstCapacityDate = DateTime.MaxValue;

                if (transitDays > 0)
                {
                    railResultObj.eta = DateTime.MaxValue;
                }

                railResultObj.hasCapacity   = false;
                railResultObj.containerSize = "FiftyThreeFt";

                return(railResultObj);

                #endregion
            }

            railResultObj.success = "";
            return(railResultObj);
        }
        catch (Exception e)
        {
            #region Catch

            HelperFuncs.writeToSiteErrors("LOUP", e.ToString());

            railResultObj         = new IntermodalRater.railResult();
            railResultObj.success = "";
            return(railResultObj);

            #endregion
        }
    }
Exemplo n.º 26
0
    public IntermodalRater.railResult getRate()
    {
        try
        {
            HelperFuncs.writeToSiteErrors("LOUP new function", "LOUP new function");

            Random random  = new Random();
            int    randInt = random.Next(999); // Max value
            string randStr = "1543" + randInt.ToString();
            randInt  = random.Next(999999);    // Max value
            randStr += randInt.ToString();

            Web_client http = new Web_client();

            http.method   = "GET";
            http.url      = string.Concat("http://www.shipstreamline.com/");
            http.referrer = "";
            http.accept   = "text/html, application/xhtml+xml, */*";

            string doc = http.Make_http_request();

            // Set headers
            http.header_names     = new string[1];
            http.header_names[0]  = "X-Requested-With";
            http.header_values    = new string[1];
            http.header_values[0] = "XMLHttpRequest";

            http.referrer = "https://www.shipstreamline.com/";
            http.url      = string.Concat(
                "http://www.shipstreamline.com/customers/apps/news/list-json.cfm?_=", randStr);
            http.method       = "GET";
            http.accept       = "text/plain, */*; q=0.01";
            http.content_type = "";
            doc = http.Make_http_request();

            // Empty headers
            http.header_names  = new string[0];
            http.header_values = new string[0];

            http.referrer     = "https://www.shipstreamline.com/";
            http.url          = "https://www.shipstreamline.com/admin/login.fcc";
            http.accept       = "text/html, application/xhtml+xml, */*";
            http.method       = "POST";
            http.content_type = "application/x-www-form-urlencoded";
            http.post_data    = "target=%2Fstm%2Fresponsive%2Fsecure%2Flogin.shtml&USER="******"&PASSWORD="******"&submitBtn=Login";

            //http http = new http(info);
            doc = http.Make_http_request();

            // Get_LOUP_random
            Get_LOUP_random(ref random, ref randInt, ref randStr);

            // Set headers
            http.header_names     = new string[1];
            http.header_names[0]  = "X-Requested-With";
            http.header_values    = new string[1];
            http.header_values[0] = "XMLHttpRequest";

            http.referrer = "https://www.shipstreamline.com/";
            http.url      = string.Concat(
                "https://www.shipstreamline.com/admin/tools/clear-count.shtml?_=", randStr);
            http.method       = "GET";
            http.accept       = "*/*";
            http.content_type = "";
            doc = http.Make_http_request();

            //

            // Empty headers
            http.header_names  = new string[0];
            http.header_values = new string[0];

            http.url =
                "https://www.shipstreamline.com/stm/redirect/quoteline.shtml?track=mini-app-more";
            http.accept = "text/html, application/xhtml+xml, */*";
            doc         = http.Make_http_request();

            http.referrer = http.url;
            http.url      =
                "https://www.shipstreamline.com/customers/quoteline/secure/index.shtml?track=mini-app-more";

            doc = http.Make_http_request();

            // Get_LOUP_random
            Get_LOUP_random(ref random, ref randInt, ref randStr);

            //

            // Set headers
            http.header_names     = new string[1];
            http.header_names[0]  = "X-Requested-With";
            http.header_values    = new string[1];
            http.header_values[0] = "XMLHttpRequest";

            http.referrer = http.url;
            http.url      = string.Concat(
                "https://www.shipstreamline.com/customers/quoteline/secure/i18n/locale_en-US.json?cb=", randStr);
            http.accept = "application/json, text/javascript, */*; q=0.01";
            doc         = http.Make_http_request();

            // Get_LOUP_random
            Get_LOUP_random(ref random, ref randInt, ref randStr);

            // Empty headers
            http.header_names  = new string[0];
            http.header_values = new string[0];

            http.url = string.Concat(
                "https://www.shipstreamline.com/pricing-services/secure/jas/api/user?cb=", randStr);
            http.accept = "application/json, text/plain, */*";
            doc         = http.Make_http_request();

            //
            // Make missing requests

            http.url    = "https://www.shipstreamline.com/customers/quoteline/secure/assets/spinner/spinner_32.gif";
            http.accept = "image/webp,image/apng,image/*,*/*;q=0.8";
            doc         = http.Make_http_request();

            // Set headers
            http.header_names     = new string[1];
            http.header_names[0]  = "X-Requested-With";
            http.header_values    = new string[1];
            http.header_values[0] = "XMLHttpRequest";

            http.url    = string.Concat("https://www.shipstreamline.com/stm/ssi/ue-apps/components/mapping/location-data/can.min.json?d=2018-11-28");
            http.accept = "application/json, text/javascript, */*; q=0.01";
            doc         = http.Make_http_request();

            http.url = string.Concat("https://www.shipstreamline.com/stm/ssi/ue-apps/components/mapping/location-data/usa.min.json?d=2018-11-28");
            doc      = http.Make_http_request();

            http.url = string.Concat("https://www.shipstreamline.com/stm/ssi/ue-apps/components/mapping/location-data/mex.min.json?d=2018-11-28");
            doc      = http.Make_http_request();

            http.url = string.Concat("https://www.shipstreamline.com/stm/ssi/ue-apps/components/mapping/location-data/usa-state-lines.min.json?d=2018-11-28");
            doc      = http.Make_http_request();

            http.url = string.Concat("https://www.shipstreamline.com/stm/ssi/ue-apps/components/mapping/location-data/base-ramps.json?d=2018-11-28");
            doc      = http.Make_http_request();


            //

            // Get_LOUP_random
            Get_LOUP_random(ref random, ref randInt, ref randStr);

            // Set headers
            http.header_names     = new string[1];
            http.header_names[0]  = "X-Requested-With";
            http.header_values    = new string[1];
            http.header_values[0] = "XMLHttpRequest";

            http.url = string.Concat(
                "https://www.shipstreamline.com/customer-services/secure/jas/capacity-freight?_=", randStr);
            http.accept = "text/plain, */*; q=0.01";
            doc         = http.Make_http_request();

            // Get_LOUP_random
            Get_LOUP_random(ref random, ref randInt, ref randStr);

            // Empty headers
            http.header_names  = new string[0];
            http.header_values = new string[0];

            http.url =
                "https://www.shipstreamline.com/pricing-services/secure/jas/api/quote/specials";
            http.accept = "application/json, text/plain, */*";
            doc         = http.Make_http_request();

            #region Locations requests

            // Set headers
            http.header_names     = new string[1];
            http.header_names[0]  = "X-Requested-With";
            http.header_values    = new string[1];
            http.header_values[0] = "XMLHttpRequest";

            // Get locations
            http.url = string.Concat(
                "https://www.shipstreamline.com/pricing-services/secure/jas/api/location/search?term=1521");

            http.accept = "*/*";
            doc         = http.Make_http_request();

            http.url = string.Concat(
                "https://www.shipstreamline.com/pricing-services/secure/jas/api/location/search?term=15214");
            doc = http.Make_http_request();

            http.url = string.Concat(
                "https://www.shipstreamline.com/pricing-services/secure/jas/api/location/search?term=9814");
            doc = http.Make_http_request();

            http.url = string.Concat(
                "https://www.shipstreamline.com/pricing-services/secure/jas/api/location/search?term=98144");
            doc = http.Make_http_request();

            #endregion

            // Empty headers
            http.header_names  = new string[0];
            http.header_values = new string[0];

            // Get_LOUP_random
            Get_LOUP_random(ref random, ref randInt, ref randStr);

            HelperFuncs.writeToSiteErrors("LOUP before summary", "LOUP before summary");

            http.url = string.Concat(
                "https://www.shipstreamline.com/pricing-services/secure/jas/api/pricing/summary?cb=", randStr);
            http.accept       = "application/json, text/plain, */*";
            http.method       = "POST";
            http.content_type = "application/json;charset=utf-8";
            http.post_data    = "{\"hazmatShipment\":false,\"beneficialOwner\":{\"name\":\"BCO_UNKNOWN\"},\"pickupDate\":\"20181128\",\"intermodalMoveType\":\"DOOR_TO_DOOR\",\"shipFromLocation\":{\"spotLiveType\":\"STAY\",\"locationId\":\"018413\",\"city\":\"PITTSBURGH\",\"state\":\"PA\",\"zipcode\":\"15214\",\"country\":\"US\",\"area\":\"PIT\",\"latitude\":40.481828,\"longitude\":-80.016002,\"timeZone\":\"ED\",\"services\":[]},\"shipToLocation\":{\"spotLiveType\":\"STAY\",\"locationId\":\"130145\",\"city\":\"SEATTLE\",\"state\":\"WA\",\"zipcode\":\"98144\",\"country\":\"US\",\"area\":\"SEA\",\"latitude\":47.58564,\"longitude\":-122.298,\"timeZone\":\"PD\",\"services\":[]},\"extraPickups\":[],\"extraDeliveries\":[]}";

            doc = http.Make_http_request();

            HelperFuncs.writeToSiteErrors("LOUP doc", doc);

            railResultObj         = new IntermodalRater.railResult();
            railResultObj.success = "";
            return(railResultObj);
        }
        catch (Exception e)
        {
            #region Catch

            HelperFuncs.writeToSiteErrors("LOUP", e.ToString());

            railResultObj         = new IntermodalRater.railResult();
            railResultObj.success = "";
            return(railResultObj);

            #endregion
        }
    }
Exemplo n.º 27
0
        public static void InsertAccessorialsIntoAccDetailsTable(ref DispatchData dispatch_data, ref ArrayList services, ref string strSQL)
        {
            bool blnResult;

            #region Not used
            //string rateType = dispatch_data.rateType.ToString(), AMPM = "";
            //if (rateType == "GUARANTEEDAM")
            //{
            //    AMPM = "Noon";
            //}
            // else if (rateType == "GUARANTEEDPM")
            #endregion

            #region Logging
            if (dispatch_data.carrier != null)
            {
                HelperFuncs.writeToSiteErrors("carrier", dispatch_data.carrier);
            }
            else
            {
                HelperFuncs.writeToSiteErrors("carrier", "was null");
            }
            #endregion

            #region Insert all accessorials
            if (dispatch_data.rateType.Equals("GUARANTEEDPM")) //dispatch_data.carrier.Contains("R+L GDD QT:") ||
            {
                HelperFuncs.writeToSiteErrors("adding guaranteed", "adding guaranteed");

                Get_Accessorial_ID_and_insert(ref dispatch_data, ref services, "GSD", "GUARANTEED SERVICE");
            }

            if (dispatch_data.q_ResPick != null && bool.TryParse(dispatch_data.q_ResPick, out blnResult))
            {
                //Get the lookup ID for Residential Pickup.
                if (blnResult)
                {
                    Get_Accessorial_ID_and_insert(ref dispatch_data, ref services, "RSP", "RESIDENTIAL PICKUP");
                }
            }
            if (dispatch_data.q_ResDel != null && bool.TryParse(dispatch_data.q_ResDel, out blnResult))
            {
                //Get the lookup ID for Residential Delivery.
                if (blnResult)
                {
                    Get_Accessorial_ID_and_insert(ref dispatch_data, ref services, "RSD", "RESIDENTIAL DELIVERY");
                }
            }
            if (dispatch_data.q_ConstPick != null && bool.TryParse(dispatch_data.q_ConstPick, out blnResult))
            {
                //Get the lookup ID for NON COMMERCIAL Pickup.
                if (blnResult)
                {
                    Get_Accessorial_ID_and_insert(ref dispatch_data, ref services, "CSP", "NON COMMERCIAL PICKUP");
                }
            }
            if (dispatch_data.q_ConstDel != null && bool.TryParse(dispatch_data.q_ConstDel, out blnResult))
            {
                //Get the lookup ID for NON COMMERCIAL Delivery.
                if (blnResult)
                {
                    Get_Accessorial_ID_and_insert(ref dispatch_data, ref services, "CSD", "NON COMMERCIAL DELIVERY");
                }
            }
            if (dispatch_data.q_TradePick != null && bool.TryParse(dispatch_data.q_TradePick, out blnResult))
            {
                //Get the lookup ID for Tradeshow Pickup.
                if (blnResult)
                {
                    Get_Accessorial_ID_and_insert(ref dispatch_data, ref services, "TSP", "TRADESHOW PICKUP");
                }
            }

            if (dispatch_data.q_TradeDel != null && bool.TryParse(dispatch_data.q_TradeDel, out blnResult))
            {
                //Get the lookup ID for Residential Delivery.
                if (blnResult)
                {
                    Get_Accessorial_ID_and_insert(ref dispatch_data, ref services, "TSD", "TRADESHOW DELIVERY");
                }
            }

            if (dispatch_data.q_TailPick != null && bool.TryParse(dispatch_data.q_TailPick, out blnResult))
            {
                //Get the lookup ID for LIFTGATE PICKUP.
                if (blnResult)
                {
                    Get_Accessorial_ID_and_insert(ref dispatch_data, ref services, "TGP", "LIFTGATE PICKUP");
                }
            }

            if (dispatch_data.q_TailDel != null && bool.TryParse(dispatch_data.q_TailDel, out blnResult))
            {
                //Get the lookup ID for LIFTGATE DELIVERY.
                if (blnResult)
                {
                    Get_Accessorial_ID_and_insert(ref dispatch_data, ref services, "TGD", "LIFTGATE DELIVERY");
                }
            }

            if (dispatch_data.q_AppPick != null && bool.TryParse(dispatch_data.q_AppPick, out blnResult))
            {
                //Get the lookup ID for NOTIFICATION PICKUP.
                if (blnResult)
                {
                    Get_Accessorial_ID_and_insert(ref dispatch_data, ref services, "AMP", "DELIVERY APPT.");
                }
            }
            if (dispatch_data.q_AppDel != null && bool.TryParse(dispatch_data.q_AppDel, out blnResult))
            {
                //Get the lookup ID for NOTIFICATION DELIVERY.
                if (blnResult)
                {
                    Get_Accessorial_ID_and_insert(ref dispatch_data, ref services, "AMD", "DELIVERY APPT.");
                }
            }
            if (dispatch_data.q_InsDel != null && bool.TryParse(dispatch_data.q_InsDel, out blnResult))
            {
                //Get the lookup ID for INSIDE DELIVERY.
                if (blnResult)
                {
                    Get_Accessorial_ID_and_insert(ref dispatch_data, ref services, "ISD", "INSIDE DELIVERY");
                }
            }
            #endregion
        }
Exemplo n.º 28
0
    public List <string[]> GetIntermodalRate(string username, string password, DateTime pickupDate, string originZip, string destinationZip,
                                             string[] additionalServices, ref int QuoteID)
    {
        try
        {
            usernameGlobal = username;
            string user = GetGCMUserNameByAPILogins(username, password);
            int[]  info = GetMarkupPercent(user);
            int    IntermodalMarkupPercent = info[0];
            int    IntermodalMinimum       = info[1];

            destZipGlobal   = destinationZip;
            originZipGlobal = originZip;

            //cityByZip();
            string[] cityStateCountryOrig = new string[3];
            string[] cityStateCountryDest = new string[3];

            SharedRail.cityStateCountryByZip(ref cityStateCountryOrig, originZip);
            SharedRail.cityStateCountryByZip(ref cityStateCountryDest, destinationZip);

            //originState = dr[0].ToString();
            //originCity = dr[1].ToString();
            //originCountry = dr[2].ToString();

            //destState = dr[0].ToString();
            //destCity = dr[1].ToString();
            //destCountry = dr[2].ToString();

            originCity    = cityStateCountryOrig[0];
            destCity      = cityStateCountryDest[0];
            originState   = cityStateCountryOrig[1];
            destState     = cityStateCountryDest[1];
            originCountry = cityStateCountryOrig[2];
            destCountry   = cityStateCountryDest[2];


            #region puDate

            puDateGlobal = pickupDate;

            DateTime tomorrow = DateTime.Today.AddDays(1);

            int comparison;
            comparison = puDateGlobal.CompareTo(tomorrow);

            if (comparison == -1) // date is earlier than tomorrow, set the date to tomorrow
            {
                puDateGlobal = tomorrow;
            }
            if (puDateGlobal.DayOfWeek.ToString() == "Saturday")
            {
                puDateGlobal = puDateGlobal.AddDays(2);
            }
            else if (puDateGlobal.DayOfWeek.ToString() == "Sunday")
            {
                puDateGlobal = puDateGlobal.AddDays(1);
            }
            #endregion

            HelperFuncs.writeToSiteErrors("GetIntermodalRate Demo", string.Concat(originZip, " ", destinationZip, " ", originCity, " ", destCity));

            //int QuoteID = 0;
            // Insert into database
            SharedRail.saveResults(false, ref originCity, ref destCity, ref originState, ref destState, ref usernameGlobal, ref results, ref puDateGlobal,
                                   ref QuoteID);

            #region Threads

            List <Thread> threads = new List <Thread>();
            results.Clear();
            threads.Clear();

            SharedRail.streamlineResultArray  = new string[13];
            SharedRail.csxiResultArray        = new string[13];
            SharedRail.modalXResultArray      = new string[13];
            SharedRail.integraResultArray     = new string[13];
            SharedRail.integraResultArray40FT = new string[13];
            SharedRail.integraResultArray45FT = new string[13];
            SharedRail.mgOtrResultArray       = new string[13];

            //SharedRail.MG_OTR_Result mgOtrRes = new SharedRail.MG_OTR_Result();

            SharedRail.synchronet20FT_DryResultArray       = new string[13];
            SharedRail.synchronet40FT_High_CubeResultArray = new string[13];
            SharedRail.synchronet45FT_High_CubeResultArray = new string[13];



            // New objects
            //SharedRail.streamlineResults = new List<IntermodalResult>();

            // Initialize the notification field to avoid null reference exception when checking for function success
            SharedRail.streamlineResultArray[0] = "";
            SharedRail.csxiResultArray[0]       = "";
            SharedRail.modalXResultArray[0]     = "";
            SharedRail.integraResultArray[0]    = "";
            SharedRail.mgOtrResultArray[0]      = "";

            SharedRail.synchronet20FT_DryResultArray[0]       = "";
            SharedRail.synchronet40FT_High_CubeResultArray[0] = "";
            SharedRail.synchronet45FT_High_CubeResultArray[0] = "";

            for (int i = 0; i < 8; i++)
            {
                Thread thread;
                //thread = new Thread(new ThreadStart(GetStreamlineInfo));
                if (i == 0)
                {
                    thread = new Thread(new ThreadStart(getRate_Streamline));
                    //continue;
                }
                else if (i == 1)
                {
                    //thread = new Thread(new ThreadStart(GetIntegraInfo));
                    //thread = new Thread(() => GetIntegraInfo(SharedRail.FiftyThreeFt));
                    continue;
                }
                else if (i == 2)
                {
                    thread = new Thread(new ThreadStart(GetModalX_Info));
                }
                else if (i.Equals(3))
                {
                    //thread = new Thread(new ThreadStart(getSynchronetInfo20));
                    continue;
                }
                else if (i.Equals(4))
                {
                    //thread = new Thread(new ThreadStart(getSynchronetInfo40));
                    continue;
                }
                else if (i.Equals(5))
                {
                    //thread = new Thread(new ThreadStart(getSynchronetInfo45));
                    continue;
                }
                else if (i.Equals(6))
                {
                    //thread = new Thread(new ThreadStart(getOTR_RateDLS));
                    continue;
                }
                //else if (i == 2)
                //{
                //    thread = new Thread(new ThreadStart(GetIDIInfo));
                //}

                else
                {
                    //thread = new Thread(new ThreadStart(GetCSXIInfo));
                    continue;
                }
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Name = i.ToString();
                threads.Add(thread);
            }


            foreach (Thread t in threads)
            {
                if (!t.Join(TimeSpan.FromSeconds(25)))
                {
                    t.Abort();
                }
            }

            GetIntegraInfo(SharedRail.FourtyFtHighCube);

            #endregion

            #region Gather all results to one results object

            decimal integra40cost = 0M, synchro40cost = 0M, integra45cost = 0M, synchro45cost = 0M;

            #region Get Synchro costs

            if (SharedRail.synchronet40FT_High_CubeResultArray[0] != null && SharedRail.synchronet40FT_High_CubeResultArray[0].Equals(SharedRail.success))
            {
                decimal.TryParse(SharedRail.synchronet40FT_High_CubeResultArray[2].Replace("$", "").Trim(), out synchro40cost);
                HelperFuncs.writeToSiteErrors("WS synchronet40FT_High_CubeResultArray", SharedRail.synchronet40FT_High_CubeResultArray[2]);
            }
            else
            {
                HelperFuncs.writeToSiteErrors("WS synchronet40FT_High_CubeResultArray", "null");
            }

            if (SharedRail.synchronet45FT_High_CubeResultArray[0] != null && SharedRail.synchronet45FT_High_CubeResultArray[0].Equals(SharedRail.success))
            {
                decimal.TryParse(SharedRail.synchronet45FT_High_CubeResultArray[2].Replace("$", "").Trim(), out synchro45cost);
                HelperFuncs.writeToSiteErrors("WS synchronet45FT_High_CubeResultArray", SharedRail.synchronet45FT_High_CubeResultArray[2]);
            }
            else
            {
                HelperFuncs.writeToSiteErrors("WS synchronet45FT_High_CubeResultArray", "null");
            }

            #endregion

            #region Get Integra costs

            if (SharedRail.integraResultArray40FT[0] != null && SharedRail.integraResultArray40FT[0].Equals(SharedRail.success))
            {
                if (SharedRail.integraResultArray40FT[0] != null && SharedRail.integraResultArray40FT[0].Equals(SharedRail.success))
                {
                    decimal.TryParse(SharedRail.integraResultArray40FT[2].Replace("$", "").Trim(), out integra40cost);
                    HelperFuncs.writeToSiteErrors("WS integraResultArray40FT", SharedRail.integraResultArray40FT[2]);
                }
                else
                {
                    HelperFuncs.writeToSiteErrors("WS integraResultArray40FT", "null");
                }

                if (SharedRail.integraResultArray45FT[0] != null && SharedRail.integraResultArray45FT[0].Equals(SharedRail.success))
                {
                    decimal.TryParse(SharedRail.integraResultArray45FT[2].Replace("$", "").Trim(), out integra45cost);
                    HelperFuncs.writeToSiteErrors("WS integraResultArray45FT", SharedRail.integraResultArray45FT[2]);
                }
                else
                {
                    HelperFuncs.writeToSiteErrors("WS integraResultArray45FT", "null");
                }
            }

            #endregion

            HelperFuncs.writeToSiteErrors("WS integra vs synchro", string.Concat(integra40cost, " ", integra45cost, " ", synchro40cost, " ", synchro45cost));

            // Gather all results to one results object
            if (SharedRail.streamlineResultArray[0].Equals(SharedRail.success))
            {
                results.Add(SharedRail.streamlineResultArray);

                //

                //IntermodalResult res = new IntermodalResult();
                //res.TotalCharge = streamRes.totalPrice;

                //if (transitDays.Equals(-1))
                //{
                //    res.EstimatedTransitTime = "10";
                //    res.EstimatedDeliveryDate = DateTime.Today.AddDays(10).ToShortDateString();
                //}
                //else
                //{
                //    res.EstimatedTransitTime = transitDays.ToString();
                //    res.EstimatedDeliveryDate = DateTime.Today.AddDays(transitDays).ToShortDateString();
                //}
                //res.Carrier = Streamline;
            }
            if (SharedRail.csxiResultArray[0].Equals(SharedRail.success))
            {
                results.Add(SharedRail.csxiResultArray);
            }
            if (SharedRail.modalXResultArray[0].Equals(SharedRail.success))
            {
                results.Add(SharedRail.modalXResultArray);
            }
            if (SharedRail.integraResultArray != null && SharedRail.integraResultArray[0] != null && SharedRail.integraResultArray[0].Equals(SharedRail.success))
            {
                results.Add(SharedRail.integraResultArray);
            }

            if (integra40cost > 0 && (integra40cost < synchro40cost || synchro40cost.Equals(0M)))
            {
                if (SharedRail.integraResultArray40FT != null && SharedRail.integraResultArray40FT[0] != null && SharedRail.integraResultArray40FT[0].Equals(SharedRail.success))
                {
                    results.Add(SharedRail.integraResultArray40FT);
                }
            }
            else if (synchro40cost > 0 && (synchro40cost < integra40cost || integra40cost.Equals(0M)))
            {
                if (SharedRail.synchronet40FT_High_CubeResultArray != null && !string.IsNullOrEmpty(SharedRail.synchronet40FT_High_CubeResultArray[0]) &&
                    SharedRail.synchronet40FT_High_CubeResultArray[0].Equals(SharedRail.success))
                {
                    results.Add(SharedRail.synchronet40FT_High_CubeResultArray);
                }
            }

            if (integra45cost > 0 && (integra45cost < synchro45cost || synchro45cost.Equals(0M)))
            {
                if (SharedRail.integraResultArray45FT != null && SharedRail.integraResultArray45FT[0] != null && SharedRail.integraResultArray45FT[0].Equals(SharedRail.success))
                {
                    results.Add(SharedRail.integraResultArray45FT);
                }
            }
            else if (synchro45cost > 0 && (synchro45cost < integra45cost || integra45cost.Equals(0M)))
            {
                if (SharedRail.synchronet45FT_High_CubeResultArray != null && !string.IsNullOrEmpty(SharedRail.synchronet45FT_High_CubeResultArray[0]) &&
                    SharedRail.synchronet45FT_High_CubeResultArray[0].Equals(SharedRail.success))
                {
                    results.Add(SharedRail.synchronet45FT_High_CubeResultArray);
                }
            }

            //if (SharedRail.synchronet20FT_DryResultArray != null && !string.IsNullOrEmpty(SharedRail.synchronet20FT_DryResultArray[0]) &&
            //    SharedRail.synchronet20FT_DryResultArray[0].Equals(SharedRail.success))
            //{
            //    results.Add(SharedRail.synchronet20FT_DryResultArray);
            //}

            //if (SharedRail.synchronet40FT_High_CubeResultArray != null && !string.IsNullOrEmpty(SharedRail.synchronet40FT_High_CubeResultArray[0]) &&
            //    SharedRail.synchronet40FT_High_CubeResultArray[0].Equals(SharedRail.success))
            //{
            //    results.Add(SharedRail.synchronet40FT_High_CubeResultArray);
            //}

            //if (SharedRail.synchronet45FT_High_CubeResultArray != null && !string.IsNullOrEmpty(SharedRail.synchronet45FT_High_CubeResultArray[0]) &&
            //    SharedRail.synchronet45FT_High_CubeResultArray[0].Equals(SharedRail.success))
            //{
            //    results.Add(SharedRail.synchronet45FT_High_CubeResultArray);
            //}

            if (SharedRail.mgOtrResultArray != null && !string.IsNullOrEmpty(SharedRail.mgOtrResultArray[0]) &&
                SharedRail.mgOtrResultArray[0].Equals(SharedRail.success))
            {
                results.Add(SharedRail.mgOtrResultArray);
            }

            //for (byte i = 0; i < SharedRail.streamlineResults.Count; i++)
            //{
            //    resultsList.Add(SharedRail.streamlineResults[i]);
            //}

            #endregion

            SharedRail.saveResults(true, ref originCity, ref destCity, ref originState, ref destState, ref usernameGlobal, ref results, ref puDateGlobal,
                                   ref QuoteID);

            #region Add percentage

            Double rate, decPercent = (Double)IntermodalMarkupPercent / (Double)100, percentSum = 0;
            //Int32 transit;

            for (int i = 0; i < results.Count; i++)
            {
                //HelperFuncs.writeToSiteErrors("GetIntermodalRate user: "******"$", "").Replace(",", "") + " " +
                //    decPercent.ToString() + " " + IntermodalMinimum.ToString());
                if (!Double.TryParse(results[i][2].Replace("$", "").Replace(",", ""), out rate))
                {
                    continue;
                }
                percentSum = rate * decPercent;
                if (percentSum < IntermodalMinimum)
                {
                    rate         += IntermodalMinimum;
                    results[i][2] = "$" + rate;
                }
                else
                {
                    rate         += percentSum;
                    results[i][2] = "$" + rate;
                }
                //throw new Exception(IntermodalMarkupPercent + " " + decPercent + " " + percentSum + " " + IntermodalMinimum);
            }

            #endregion

            #region Valid through

            DateTime today = new DateTime();
            today = DateTime.Today;
            int weekendDays = 0, daysToAdd = 0;
            for (int i = 1; i < 6; i++)
            {
                if (today.AddDays(i).DayOfWeek.ToString() == "Saturday" || today.AddDays(i).DayOfWeek.ToString() == "Sunday")
                {
                    weekendDays++;
                }
            }
            if (weekendDays == 1)
            {
                if (today.DayOfWeek.ToString() == "Monday")
                {
                    daysToAdd = 2;
                }
                else if (today.DayOfWeek.ToString() == "Saturday")
                {
                    daysToAdd = 1;
                }
            }
            else if (weekendDays == 2)
            {
                daysToAdd = 2;
            }
            else //weekend days = 0
            {
                daysToAdd = 0;
            }

            validThrough = DateTime.Today.AddDays(5 + daysToAdd);
            string vThru = validThrough.ToShortDateString();

            #endregion

            #region Compare rates

            //int indOfMinRate = -1;
            //int indOfMinTransit = -1;
            if (results.Count == 0)   // No results
            {
                return(results);
            }

            for (int i = 0; i < results.Count; i++)
            {
                if (!Double.TryParse(results[i][2].Replace("$", "").Replace(",", ""), out rate))
                {
                    continue;
                }

                results[i][6]  = validThrough.ToShortDateString();
                results[i][7]  = originCity + ", " + originState;
                results[i][8]  = originCountry;
                results[i][9]  = destCity + ", " + destState;
                results[i][10] = destCountry;

                sortedResults.Add(results[i]);

                #region Not used
                //if (i == 0)
                //{
                //    minRate = rate;
                //    indOfMinRate = i;
                //}
                //if (minRate > rate)
                //{
                //    minRate = rate;
                //    indOfMinRate = i;
                //}
                #endregion

                //IntermodalResult res = new IntermodalResult();
                //res.TotalCharge = streamRes.totalPrice;

                //if (transitDays.Equals(-1))
                //{
                //    res.EstimatedTransitTime = "10";
                //    res.EstimatedDeliveryDate = DateTime.Today.AddDays(10).ToShortDateString();
                //}
                //else
                //{
                //    res.EstimatedTransitTime = transitDays.ToString();
                //    res.EstimatedDeliveryDate = DateTime.Today.AddDays(transitDays).ToShortDateString();
                //}
                //res.Carrier = Streamline;
            }

            #region Not used
            //find index of lowest transit
            //minTransit = Int32.MaxValue;
            //for (int j = 0; j < results.Count; j++)
            //{

            //    if (!Int32.TryParse(results[j][3], out transit))
            //    {

            //        if (results[j][1].Contains("IDI<(") == false)
            //        {
            //            try
            //            {
            //                //writeBugReport("could not parse transit " + results[j][3]);
            //                HelperFuncs.writeToSiteErrors("GetIntermodalRate", "could not parse transit " + results[j][3]);
            //            }
            //            catch { }
            //        }
            //        continue;
            //    }

            //    if (minTransit > transit)
            //    {
            //        minTransit = transit;
            //        indOfMinTransit = j;
            //    }
            //}



            //if (indOfMinRate != -1)
            //{
            //    if (indOfMinTransit > -1)
            //    {
            //        results[indOfMinTransit][2] = SharedRail.normalizeTrailNumbs(results[indOfMinTransit][2]);
            //    }
            //    results[indOfMinRate][2] = SharedRail.normalizeTrailNumbs(results[indOfMinRate][2]);
            //}



            //if (indOfMinRate != -1)
            //{
            //    if (results[indOfMinRate][1].Contains("Integra")) // in case of Integra
            //    {
            //        results[indOfMinRate][6] = results[indOfMinRate][4]; //doing this way to keep the function similar to Web Page function
            //    }
            //    else
            //    {
            //        results[indOfMinRate][6] = vThru;
            //    }
            //    results[indOfMinRate][7] = originCity + ", " + originState;
            //    results[indOfMinRate][8] = originCountry;
            //    results[indOfMinRate][9] = destCity + ", " + destState;
            //    results[indOfMinRate][10] = destCountry;

            //    if (results[indOfMinRate][1].Contains("IDI<(")) // in case of IDI
            //    {
            //        results[indOfMinRate][3] = "";
            //        results[indOfMinRate][4] = "";
            //        results[indOfMinRate][5] = "";
            //        sortedResults.Add(results[indOfMinRate]);
            //    }
            //    else
            //    {
            //        sortedResults.Add(results[indOfMinRate]);
            //    }
            //}

            //if (indOfMinTransit != -1 && (indOfMinTransit != indOfMinRate) && (results[indOfMinTransit][3] != results[indOfMinRate][3])) // transit time shorter but rate higher
            //{
            //    if (results[indOfMinTransit][1].Contains("Integra")) // in case of Integra
            //    {
            //        results[indOfMinTransit][6] = results[indOfMinTransit][4]; //doing this way to keep the function similar to Web Page function
            //    }
            //    else
            //    {
            //        results[indOfMinTransit][6] = vThru;
            //    }
            //    results[indOfMinTransit][7] = originCity + ", " + originState;
            //    results[indOfMinTransit][8] = originCountry;
            //    results[indOfMinTransit][9] = destCity + ", " + destState;
            //    results[indOfMinTransit][10] = destCountry;

            //    sortedResults.Add(results[indOfMinTransit]);
            //}
            #endregion

            #endregion

            return(sortedResults);
        }
        catch (Exception exep)
        {
            HelperFuncs.writeToSiteErrors("GetIntermodalRate", exep.ToString());
            return(results);
        }
    }
Exemplo n.º 29
0
        public static string getPackageAPI_XML_Rate(ref FormDataCollection form)
        {
            #region Variables

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

            //url = "https://wwwcie.ups.com/ups.app/xml/ShipAccept";
            //url = "https://onlinetools.ups.com/ups.app/xml/ShipAccept";

            //url = "https://wwwcie.ups.com/ups.app/xml/Rate";
            url = "https://onlinetools.ups.com/ups.app/xml/Rate";

            referrer = "";
            //contentType = "application/xml";
            contentType = "text/xml; charset=utf-8";
            method      = "POST";
            //accept = "text/xml";
            accept = "*/*";

            #endregion

            #region Post Data

            //          string data = string.Concat("<?xml version=\"1.0\"?>",
            //"<AccessRequest xml:lang=\"en-US\">",
            //    "<AccessLicenseNumber></AccessLicenseNumber>",
            //    "<UserId></UserId>",
            //    "<Password></Password>",
            //"</AccessRequest>",
            //"<?xml version=\"1.0\"?>",
            //"<RatingServiceSelectionRequest xml:lang=\"en-US\">",
            //  "<Request>",
            //    "<TransactionReference>",
            //      "<CustomerContext>Rating and Service</CustomerContext>",
            //      "<XpciVersion>1.0</XpciVersion>",
            //    "</TransactionReference>",
            //    "<RequestAction>Rate</RequestAction>",
            //    "<RequestOption>Rate</RequestOption>",
            //    "<ShipmentRatingOptions><NegotiatedRatesIndicator /></ShipmentRatingOptions>",
            //  "</Request>",
            //              //"<PickupType>",
            //              //"<Code>07</Code>",
            //              //"<Description>Rate</Description>",
            //              //"</PickupType>",
            //  "<Shipment>",
            //        "<Description>Rate Description</Description>",
            //    "<Shipper>",
            //      "<Name>Name</Name>",
            //      "<PhoneNumber>1234567890</PhoneNumber>",
            //      "<ShipperNumber></ShipperNumber>",
            //      "<Address>",
            //        "<AddressLine1>Address Line</AddressLine1>",
            //        "<City>SANTA FE SPRINGS</City>",
            //        "<StateProvinceCode>CA</StateProvinceCode>",
            //        "<PostalCode>90670</PostalCode>",
            //        "<CountryCode>US</CountryCode>",
            //      "</Address>",
            //    "</Shipper>",
            //    "<ShipTo>",
            //      "<CompanyName>Company Name</CompanyName>",
            //      "<PhoneNumber>1234567890</PhoneNumber>",
            //      "<Address>",
            //        "<AddressLine1>Address Line</AddressLine1>",
            //        "<City>HIGH POINT</City>",
            //        "<StateProvinceCode>NC</StateProvinceCode>",
            //        "<PostalCode>27260</PostalCode>",
            //        "<CountryCode>US</CountryCode>",
            //      "</Address>",
            //    "</ShipTo>",

            //    "<ShipFrom>",
            //      "<CompanyName>Company Name</CompanyName>",
            //      "<AttentionName>Attention Name</AttentionName>",
            //      "<PhoneNumber>1234567890</PhoneNumber>",
            //      "<FaxNumber>1234567890</FaxNumber>",
            //      "<Address>",
            //        "<AddressLine1>Address Line</AddressLine1>",
            //        "<City>SANTA FE SPRINGS</City>",
            //        "<StateProvinceCode>CA</StateProvinceCode>",
            //        "<PostalCode>90670</PostalCode>",
            //        "<CountryCode>US</CountryCode>",
            //      "</Address>",
            //    "</ShipFrom>",
            //    "<Service>",
            //            "<Code>03</Code>",
            //    "</Service>",
            //    "<PaymentInformation>",
            //            "<Prepaid>",
            //                "<BillShipper>",
            //                    "<AccountNumber></AccountNumber>",
            //                "</BillShipper>",
            //            "</Prepaid>",
            //    "</PaymentInformation>",
            //    "<Package>",
            //            "<PackagingType>",
            //                "<Code>02</Code>",
            //                "<Description>Customer Supplied</Description>",
            //            "</PackagingType>",
            //            "<Description>Rate</Description>",
            //            "<PackageWeight>",
            //                "<UnitOfMeasurement>",
            //                  "<Code>LBS</Code>",
            //                "</UnitOfMeasurement>",
            //                "<Weight>65</Weight>",
            //            "</PackageWeight>",
            //            "<Dimensions>",
            //                "<UnitOfMeasurement>",
            //                  "<Code>IN</Code>",
            //                "</UnitOfMeasurement>",
            //                "<Length>29</Length>",
            //                "<Width>29</Width>",
            //                "<Height>42</Height>",
            //            "</Dimensions>",
            //    "</Package>",
            //              //"<ShipmentServiceOptions>",
            //              //  "<OnCallAir>",
            //              //    "<Schedule>",
            //              //        "<PickupDay>02</PickupDay>",
            //              //        "<Method>02</Method>",
            //              //    "</Schedule>",
            //              //  "</OnCallAir>",
            //              //"</ShipmentServiceOptions>",

            //    "<RateInformation><NegotiatedRatesIndicator /></RateInformation>",

            //  "</Shipment>",

            //"</RatingServiceSelectionRequest>");

            #endregion

            HelperFuncs.writeToSiteErrors("getPackageAPI_XML_Rate request xml", form.Get("data"));

            doc = (string)HelperFuncs.generic_http_request("string", null, url, referrer, contentType, accept, method,
                                                           form.Get("data"), false);

            HelperFuncs.writeToSiteErrors("getPackageAPI_XML_Rate response xml", doc);

            string[] tokens = new string[4];
            tokens[0] = "<NegotiatedRates>";
            tokens[1] = "<MonetaryValue>";
            tokens[2] = ">";
            tokens[3] = "<";
            string strNegotiatedRate = HelperFuncs.scrapeFromPage(tokens, doc);

            HelperFuncs.writeToSiteErrors("getPackageAPI_XML_Rate strNegotiatedRate", strNegotiatedRate);

            double negotiatedRate = 0.0;
            if (!double.TryParse(strNegotiatedRate, out negotiatedRate))
            {
                HelperFuncs.writeToSiteErrors("getPackageAPI_XML_Rate", string.Concat("negotiated rate not parsed to double, value was: ", strNegotiatedRate));
                return("-1");
            }



            return(strNegotiatedRate);
        }
Exemplo n.º 30
0
        public void SendEmail()
        {
            try
            {
                string[] forSplit;
                if (emailInfo.to.Contains(".") == false) // Validate email address
                {
                    throw new Exception("Invalid email address: " + emailInfo.to);
                }

                string mailServer = "", toAddressList = "";
                mailServer    = AppCodeConstants.mail_server_ip;//"smtp.gmail.com"
                toAddressList = emailInfo.to;

                SmtpClient objClient = new SmtpClient(mailServer);

                MailMessage objMessage = new MailMessage();

                if (string.IsNullOrEmpty(emailInfo.bcc))
                {
                    // Do nothing
                }
                else
                {
                    HelperFuncs.writeToSiteErrors("bcc email", emailInfo.bcc);

                    forSplit = emailInfo.bcc.Split(' ');
                    for (int i = 0; i < forSplit.Length; i++)
                    {
                        objMessage.Bcc.Add(forSplit[i].Trim());
                        HelperFuncs.writeToSiteErrors("adding bcc", forSplit[i].Trim());
                    }
                }


                MailAddress objFrom = new System.Net.Mail.MailAddress(emailInfo.fromAddress, emailInfo.fromName);
                //MailAddress objTo = new System.Net.Mail.MailAddress(toAddressList, toAddressList);

                objMessage.From = objFrom;

                forSplit = emailInfo.to.Split(' ');
                for (int i = 0; i < forSplit.Length; i++)
                {
                    objMessage.To.Add(forSplit[i].Trim());
                }
                objMessage.Subject    = emailInfo.subject;
                objMessage.IsBodyHtml = true;
                objMessage.Body       = emailInfo.body;

                if (emailInfo.attachments == null)
                {
                    // Do nothing
                }
                else
                {
                    foreach (string img in emailInfo.attachments)
                    {
                        HelperFuncs.writeToSiteErrors("adding attachment", img);
                        try
                        {
                            Attachment attachment = new Attachment(new Uri(img).LocalPath);
                            objMessage.Attachments.Add(attachment);
                        }
                        catch (Exception e1)
                        {
                            HelperFuncs.writeToSiteErrors("error adding attachment " + img, e1.ToString());
                            //MailUser("", e1.ToString(), messageText, fromName, fromAddress, messageSubject, "");
                        }
                    }
                }


                objClient.Send(objMessage);
            }
            catch (Exception e)
            {
                HelperFuncs.writeToSiteErrors("sendEmail", e.ToString());
                //MailUser("", e.ToString(), messageText, fromName, fromAddress, messageSubject, "");
            }
        }