예제 #1
0
파일: Estes.cs 프로젝트: alefurman40/api_2
        private void Parse_one_estes_result(ref List <Estes_price_res> list, string doc, ref string quoteNumber)
        {
            Estes_price_res res = new Estes_price_res();

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

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

            tokens[0] = "<rat:guaranteedPrice>";
            double.TryParse(HelperFuncs.scrapeFromPage(tokens, doc), out res.guaranteedPrice);

            tokens[0]        = "<rat:deliveryDate>";
            res.deliveryDate = DateTime.MinValue;
            DateTime.TryParse(HelperFuncs.scrapeFromPage(tokens, doc), out res.deliveryDate);

            tokens[0]        = "<rat:serviceLevel>";
            res.serviceLevel = HelperFuncs.scrapeFromPage(tokens, doc);

            //tokens[0] = "<rat:code>";
            //res.code = HelperFuncs.scrapeFromPage(tokens, doc);

            res.quoteNumber = quoteNumber;

            list.Add(res);
        }
예제 #2
0
        public void Cancel_UPS_Freight_pickup_request(ref string PickupRequestConfirmationNumber)
        {
            string month, day;

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

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            Web_client http = new Web_client();

            string username = AppCodeConstants.ups_freight_genera_un, password = AppCodeConstants.ups_freight_genera_pwd,
                   AccessLicenseNumber = AppCodeConstants.ups_freight_genera_license_num;

            //http.url = "https://onlinetools.ups.com/rest/FreightPickup";
            http.url       = "https://wwwcie.ups.com/rest/FreightPickup";
            http.method    = "POST";
            http.post_data = string.Concat(
                "{ \"Security\": { \"UsernameToken\": { \"Username\": \"", username, "\", \"Password\": \"", password, "\" }, ",
                "\"UPSServiceAccessToken\": { \"AccessLicenseNumber\": \"", AccessLicenseNumber, "\" } }, ",
                "\"LumberJack\": \"\", \"pNg911jan06\": \"\", ",
                "\"FreightCancelPickupRequest\": { \"Request\": { \"RequestOption\": \"\", ",
                "\"TransactionReference\": { \"CustomerContext\": \"\" } }, ",
                "\"PickupRequestConfirmationNumber\": \"", PickupRequestConfirmationNumber, "\" } }");

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

            string doc = http.Make_http_request();

            #region Parse result

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

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

            //tokens[0] = "TimeInTransit";
            tokens[1] = "Description";

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

            #endregion
        }
예제 #3
0
파일: LOUP.cs 프로젝트: alefurman40/api_2
    private static void getLocationInfo(ref SharedRail.Location location, ref string zipCode, ref string city,
                                        ref CookieContainer container, ref string doc,
                                        string referrer, string url, string accept, string contentType)
    {
        referrer    = url;
        accept      = "*/*";
        contentType = "";
        url         = "https://www.shipstreamline.com/pricing-services/secure/jas/api/location/search?term=" + zipCode;
        doc         = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, "GET", "", false, false, "", "");

        int ind;

        if (doc.IndexOf(city) != -1)
        {
            ind = doc.IndexOf(city);
            doc = doc.Substring(ind - 50);
        }

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

        location.locationId = HelperFuncs.scrapeFromPage(tokens, doc);

        tokens[0]     = "city\"";
        location.city = HelperFuncs.scrapeFromPage(tokens, doc);

        tokens[0]      = "state\"";
        location.state = HelperFuncs.scrapeFromPage(tokens, doc);

        tokens[0]        = "zipcode\"";
        location.zipCode = HelperFuncs.scrapeFromPage(tokens, doc);

        tokens[0]        = "country\"";
        location.country = HelperFuncs.scrapeFromPage(tokens, doc);

        tokens[0]     = "area";
        location.area = HelperFuncs.scrapeFromPage(tokens, doc);

        tokens[0]         = "timeZone";
        location.timeZone = HelperFuncs.scrapeFromPage(tokens, doc);

        tokens[2] = ":";
        tokens[3] = ",";

        tokens[0]         = "latitude";
        location.latitude = HelperFuncs.scrapeFromPage(tokens, doc);

        tokens[0]          = "longitude";
        location.longitude = HelperFuncs.scrapeFromPage(tokens, doc);
    }
예제 #4
0
    private static void getResult_ModalX(ref string doc, ref HelperFuncs.ModalX_Result res)
    {
        string[] tokens = new string[3];
        tokens[0] = "success";
        tokens[1] = ":";
        tokens[2] = ",";

        bool.TryParse(HelperFuncs.scrapeFromPage(tokens, doc), out res.success);
        if (res.success != true)
        {
            return;
        }

        tokens[0] = "pickupDate";
        string tmp = HelperFuncs.scrapeFromPage(tokens, doc);
        long   jsDateTime;

        long.TryParse(tmp, out jsDateTime);

        if (jsDateTime < 1)
        {
            return;
        }
        else
        {
            res.pickupDate = SharedRail.getDateFromJsGetTimeValue(jsDateTime);
        }

        //--

        tokens[0] = "deliveryDate";
        tmp       = HelperFuncs.scrapeFromPage(tokens, doc);
        long.TryParse(tmp, out jsDateTime);

        if (jsDateTime < 1)
        {
            return;
        }
        else
        {
            res.deliveryDate = SharedRail.getDateFromJsGetTimeValue(jsDateTime);
        }

        //--

        tokens[0] = "totalCharge";
        tmp       = HelperFuncs.scrapeFromPage(tokens, doc);
        decimal.TryParse(tmp, out res.cost);
    }
예제 #5
0
    public void Get_XPO_Access_token(out string access_token)
    {
        try
        {
            Logins.Login_info login_info;
            Logins            logins = new Logins();
            logins.Get_login_info(126, out login_info);

            string access_key = login_info.API_Key;

            string data = string.Concat("grant_type=password&username="******"&password="******"https://api.ltl.xpo.com/token",
                content_type = "application/x-www-form-urlencoded",
                accept       = "*/*",
                post_data    = data,
                method       = "POST"
            };

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

            string doc = http.Make_http_request();

            #region Parse result

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

            access_token = HelperFuncs.scrapeFromPage(tokens, doc);

            #endregion
        }
        catch (Exception e)
        {
            access_token = "not found";
            //string str = e.ToString();
            DB.Log("Get_XPO_Access_token", e.ToString());
        }
    }
예제 #6
0
    private static void getPurchasedInfo_ModalX(ref SharedRail.ModalX_PurchasedBy purchasedBy, ref string doc)
    {
        string[] tokens = new string[4];
        tokens[0]         = "email";
        tokens[1]         = ":";
        tokens[2]         = "\"";
        tokens[3]         = "\"";
        purchasedBy.email = HelperFuncs.scrapeFromPage(tokens, doc);

        tokens[0]           = "company";
        purchasedBy.company = HelperFuncs.scrapeFromPage(tokens, doc);

        tokens[0]         = "telephone";
        purchasedBy.phone = HelperFuncs.scrapeFromPage(tokens, doc);

        tokens[0]        = "fullName";
        purchasedBy.name = HelperFuncs.scrapeFromPage(tokens, doc);
    }
예제 #7
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);
        }
예제 #8
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);
            }
        }
예제 #9
0
        public void Get_Sunset_Pacific_access_token(ref string access_token)
        {
            try
            {
                string data = string.Concat("grant_type=password&username="******"&password="******"https://api.sunsetpacific.com/token",
                    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();
                DB.Log("Get_Sunset_Pacific_access_token", str);
            }
        }
예제 #10
0
        //--

        #region Create_UPS_Freight_pickup_request
        public void Create_UPS_Freight_pickup_request(out string PickupRequestConfirmationNumber)
        {
            #region Date breakdown

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

            #endregion

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            Web_client http = new Web_client();

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

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

            string username = AppCodeConstants.ups_freight_genera_un, password = AppCodeConstants.ups_freight_genera_pwd,
                   AccessLicenseNumber = AppCodeConstants.ups_freight_genera_license_num;

            //http.url = "https://onlinetools.ups.com/rest/FreightPickup";
            http.url       = "https://wwwcie.ups.com/rest/FreightPickup";
            http.method    = "POST";
            http.post_data = string.Concat(
                "{ \"Security\": { \"UsernameToken\": { \"Username\": \"", username, "\", \"Password\": \"", password, "\" },",
                "\"UPSServiceAccessToken\": { \"AccessLicenseNumber\": \"", AccessLicenseNumber, "\" } }, ",
                "\"FreightPickupRequest\": ",
                "{ \"Request\": { \"TransactionReference\": { \"CustomerContext\": \"\" } }, ",
                "\"AdditionalComments\": \"AdditionalComments\", \"DestinationPostalCode\": \"98144\", ",
                "\"DestinationCountryCode\": \"US\", ",

                "\"Requester\": ",
                "{ \"AttentionName\": \"Mr. ABC\", \"EMailAddress\": \"", AppCodeConstants.Alex_email, "\", \"Name\": \"ABC Associates\", ",
                "\"Phone\": { \"Number\": \"123456789\" } }, ",

                "\"ShipFrom\": { \"AttentionName\": \"Mr. ABC\", \"Name\": \"Mr. ABC\", ",
                "\"Address\": { \"AddressLine\": \"1712 Shadowood PKWY SE\", \"City\": \"Atlanta\", ",
                "\"StateProvinceCode\": \"GA\", \"PostalCode\": \"30303\", ",
                "\"CountryCode\": \"US\" }, \"Phone\": { \"Number\": \"123456789\" } }, ",

                "\"ShipmentDetail\": { \"HazMatIndicator\": \"\", ",
                "\"PackagingType\": { \"Code\": \"PLT\", \"Description\": \"Pallet/Skid\" }, ", // 06 is code for Pallet
                "\"NumberOfPieces\": \"1\", \"DescriptionOfCommodity\":\"Description\", ",
                "\"Weight\": {\"UnitOfMeasurement\": { \"Code\": \"LBS\", \"Description\": \"Pounds\" }, ",
                "\"Value\": \"500\" } }, ",
                "\"PickupDate\": \"20191202\", \"EarliestTimeReady\": \"0800\", ",
                "\"LatestTimeReady\": \"1800\" } }");

            /*
             * Appendix I- Ground Freight Handling Unit Codes
             * Code Valid for Handling Valid for Handling
             * Unit One Unit Two
             * Description
             * SKD X SKID
             * CBY X CARBOY
             * PLT X PALLET
             * TOT X TOTES
             * LOO X LOOSE
             * OTH X OTHER
             */

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

            string doc = http.Make_http_request();

            #region Parse result

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

            PickupRequestConfirmationNumber = HelperFuncs.scrapeFromPage(tokens, doc);

            #endregion
        }
예제 #11
0
        public void Get_UPS_Freight_rate(out GCMRateQuote UPS_FREIGHT_Quote)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            Web_client http = new Web_client();

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

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

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

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

            http.method = "POST";

            #region Post data

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

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

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

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

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

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

                // Commodity start
                Get_items_json(),

                // Commodity end

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

            #endregion

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

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

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


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

            #region Parse result

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

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

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

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

            #endregion

            //UPS_FREIGHT_Quote = new GCMRateQuote();

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

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

                if (int.TryParse(DaysInTransit_str, out DaysInTransit))
                {
                    UPS_FREIGHT_Quote.DeliveryDays = DaysInTransit;
                }
            }
            else
            {
                UPS_FREIGHT_Quote = null;
            }
        }
예제 #12
0
파일: Rater.cs 프로젝트: alefurman40/api_2
        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);
        }
예제 #13
0
    private void tryDate_ModalX(ref SharedRail.RailResult railResult, ref DateTime date, ref Int64 dateStamp, ref string referrer,
                                ref Int64 timeStampNow, ref DateTime now, ref SharedRail.ModalX_PurchasedBy purchasedBy,
                                ref HelperFuncs.ModalX_Result res)
    {
        string url = "", contentType, accept, method = "POST", doc = "", data = "";

        // This request throws an exception, but.. this is correct. Only there are no rates for these zip codes (on the weekend)
        url         = "https://www.modal-x.com/tw-services/modalx/v1.0.0/TDIS/rates/search";
        contentType = "application/json";
        data        = "{\"origZip\":\"" + origZip + "\",\"destZip\":\"" + destZip + "\",\"pickupDate\":" + dateStamp.ToString() +
                      ",\"origCountry\":\"USA\",\"destCountry\":\"USA\"}";
        accept = "*/*";
        doc    = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, data, false, false, "", "");

        SharedRail.ModalX_Lane mXlane = new SharedRail.ModalX_Lane();
        SharedRail.ModalX_Date mXdate = new SharedRail.ModalX_Date();
        getLanes_ModalX(ref mXlane, ref mXdate, ref doc);
        //--------------------------------------------------------------------------------------------------------------------

        timeStampNow = SharedRail.GetTime(ref now);

        url         = "https://www.modal-x.com/tw-services/modalx/v1.0.0/TDIS/accessorials?_dc=" + timeStampNow.ToString();
        contentType = "";
        method      = "GET";
        doc         = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, "", false, false, "", "");

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

        url         = "https://www.modal-x.com/tw-services/modalx/v1.0.0/TDIS/requests/rates/deliverydate";
        contentType = "application/json";
        method      = "POST";
        data        = "{\"pickupDate\":" + dateStamp.ToString() + ",\"laneIndex\":{\"laneId\":" + mXlane.id +
                      ",\"origAreaId\":" + mXlane.origAreaId + ",\"destAreaId\":" + mXlane.destAreaId + "}}";
        doc = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, data, false, false, "", "");

        // Scrape delivery date
        #region delivery date

        string[] tokens = new string[3];
        tokens[0] = "payload";
        tokens[1] = "[";
        tokens[2] = "]";

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

        #endregion


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

        url = "https://www.modal-x.com/tw-services/modalx/v1.0.0/TDIS/requests/rates";

        DateTime scrapedPuDate      = SharedRail.getDateFromJsGetTimeValue(Convert.ToInt64(mXlane.modalX_Date.date));
        Int64    scrapedPuDateStamp = SharedRail.GetTime(ref scrapedPuDate);

        data = string.Concat("{\"baseRate\":null,\"preMarkkupTotal\":null,\"totalCharge\":null,\"fscPercent\":0,\"markupFee\":",
                             "{\"percent\":null,\"minAmount\":\"\",\"markupAmount\":null,\"percentAdminOverridden\":false,\"amountAdminOverridden\":false},",
                             "\"miscChargeNote\":\"\",\"railFuelSurcharge\":null,\"appliedLineHaul\":null,\"contractor\":null,\"priceAuthority\":null,",
                             "\"discountPercentage\":null,\"accessorials\":[{\"charge\":null,\"qualifier\":\"FUEL\"}],\"pickupDate\":", mXlane.modalX_Date.date,
                             ",",
                             "\"deliveryDate\":", deliveryDateStr, ",\"laneIndex\":{\"laneId\":\"", mXlane.id, "\",\"origAreaId\":\"", mXlane.origAreaId,
                             "\",\"destAreaId\":\"",
                             mXlane.destAreaId, "\"},",
                             "\"equipTypeXref\":\"U53DH\",\"locations\":[{\"order\":1,\"type\":\"ORIG\",\"postalCode\":\"", origZip, "\",\"country\":\"USA\",",
                             "\"city\":\"\",\"state\":\"\",\"county\":\"\",\"netTime\":", scrapedPuDateStamp, ",\"nltTime\":", scrapedPuDateStamp, "},",
                             "{\"order\":2,\"type\":\"ORIG\",\"postalCode\":\"\",\"country\":\"USA\",\"city\":\"\",\"state\":\"\",\"county\":\"\",",
                             "\"netTime\":", scrapedPuDateStamp, ",\"nltTime\":", scrapedPuDateStamp, "},{\"order\":3,\"type\":\"ORIG\",\"postalCode\":\"\",\"country\":\"USA\",",
                             "\"city\":\"\",\"state\":\"\",\"county\":\"\",\"netTime\":", scrapedPuDateStamp, ",\"nltTime\":", scrapedPuDateStamp, "},",
                             "{\"order\":1,\"type\":\"DEST\",\"postalCode\":\"\",\"country\":\"USA\",\"city\":\"\",\"state\":\"\",",
                             "\"county\":\"\",\"netTime\":null,\"nltTime\":null},{\"order\":2,\"type\":\"DEST\",\"postalCode\":\"\",\"country\":\"USA\",",
                             "\"city\":\"\",\"state\":\"\",\"county\":\"\",\"netTime\":null,\"nltTime\":null},{\"order\":3,\"type\":\"DEST\",",
                             "\"postalCode\":\"", destZip, "\",\"country\":\"USA\",\"city\":\"\",\"state\":\"\",\"county\":\"\",\"netTime\":null,\"nltTime\":null}],",
                             "\"hazmat\":false,\"scaleLightHeavy\":false,\"status\":null,\"numOfLoads\":1,\"note\":\"\",\"beneficialOwner\":\"\",",
                             "\"capRequestId\":null,\"lineHaul\":null,\"reqStatus\":null,\"rateRequestId\":", mXlane.rateRequestId, ",\"customer\":\"\",\"thirdParty\":\"\",",
                             "\"remainingLoads\":\"\",\"confirmationNumber\":\"\",\"requestDate\":\"\",\"lane\":\"", mXlane.lane, "\",\"purchasedBy\":",
                             "\"", purchasedBy.email, "\",\"purchasedByPhone\":\"", purchasedBy.phone, "\",\"purchasedByName\":\"", purchasedBy.name, "\",",
                             "\"purchasedByCompany\":\"", purchasedBy.company, "\"}");
        //HelperFuncs.writeToSiteErrors("ModalX data", data);
        doc = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, data, false, false, "", "");
        //HelperFuncs.writeToSiteErrors("ModalX doc", doc);
        getResult_ModalX(ref doc, ref res);
    }
예제 #14
0
파일: Estes.cs 프로젝트: alefurman40/api_2
        // This function is an attempt to consume an SOAP API, using XML instead. This is because the SOAP API
        // Is not giving the correct rate for some reason. XML is easier to debug.

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

                int total_units = 0;

                StringBuilder items = new StringBuilder();

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

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

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

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

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

                    //

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

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

                #endregion


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

                #region Set pickup date variables

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

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

                #endregion

                #region Build Items string

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

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

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

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

                #endregion

                #region Accessorials

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

                StringBuilder accessorials = new StringBuilder();

                #region Accessorials

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

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

                #endregion


                #endregion

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

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

                    "<fullCommodities>",

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

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

                    sb_items,

                    "</fullCommodities>",

                    "<accessorials>",

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

                    accessorials,

                    "</accessorials>",

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

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

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

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

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

                string doc = http.Make_http_request();


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

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

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

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

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

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

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

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

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

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

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

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

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

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

                return(volume_result);
            }
            catch (Exception e)
            {
                DB.Log("Get_ESTES_volume_rates_xml", e.ToString());
                Volume_result volume_result = new Volume_result();
                return(volume_result);
            }
        }
예제 #15
0
        public void Get_rates(out GCMRateQuote Frontier_Quote_Genera)
        {
            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

                Web_client http = new Web_client();

                #region Basic Authentication


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

                http.header_names[0] = "Authorization";

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


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

                #endregion

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

                http.method = "POST";

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

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

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

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

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

                #region Post data

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

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

                #endregion

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

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

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

                #region Parse result

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


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


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

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

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

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

                #endregion

                #region Set result

                Frontier_Quote_Genera = new GCMRateQuote();

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

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

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

                #endregion
            }
            catch (Exception e)
            {
                Frontier_Quote_Genera = new GCMRateQuote();
                DB.LogGenera("Frontier", "Get_rates", e.ToString());
            }
        }
예제 #16
0
        public void Get_rates(string enc_password, out GCMRateQuote Averitt_Quote_Genera)
        {
            try
            {
                string[] header_names  = new string[1];
                string[] header_values = new string[1];

                header_names[0] = "SOAPAction";

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


                //Host: webservices.averittexpress.com

                string password = enc_password;

                #region Date

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

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

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

                #endregion

                #region Items

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

                #endregion

                #region Accessorials

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

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

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

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

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

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

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

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

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

                #endregion

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

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

                                  "<arg0>",

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

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

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

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

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

                                  items,

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

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

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

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

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

                Web_client http = new Web_client();

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

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

                #region Parse result

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

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

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

                int EstimatedServiceDays = 10;

                Averitt_Quote_Genera = new GCMRateQuote();

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

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

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

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

                #endregion
            }
            catch (Exception e)
            {
                Averitt_Quote_Genera = new GCMRateQuote();
                DB.LogGenera("Averitt", "e", e.ToString());
            }
        }
예제 #17
0
파일: YRC.cs 프로젝트: alefurman40/api_2
        private void GetYRCInfo_API(ref bool isDurachem, ref string[] weight, ref string[] fclass,
                                    ref string[] nmfc, ref string[] pieces, ref int numLineItems, ref bool dimsProvided,
                                    ref string[] cube, ref string[] density, ref StringBuilder sbAccessorials, int AccOptionCount, ref string[] length,
                                    ref string[] width, ref string[] height)
        {
            //DB.Log("YRC Live", "GetYRCInfo");

            YRC_Res = new YRC_Result();
            try
            {
                #region Variables

                //DateTime today = DateTime.Today;
                DateTime today     = quoteData.puDate;
                string   day       = today.Day.ToString();
                string   month     = today.Month.ToString();
                string   year      = today.Year.ToString();
                string   dayOfWeek = today.DayOfWeek.ToString();
                dayOfWeek = dayOfWeek.Remove(3);
                if (day.Length == 1)
                {
                    day = "0" + day;
                }
                if (month.Length == 1)
                {
                    month = "0" + month;
                }

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

                #endregion

                #region Country

                string origCountry = "USA";
                string destCountry = "USA";
                if (HelperFuncs.GetCountryByZip(quoteData.origZip, true, quoteData.origZip, quoteData.destZip).Equals("CANADA"))
                {
                    origCountry = "CAN";
                }
                if (HelperFuncs.GetCountryByZip(quoteData.destZip, false, quoteData.origZip, quoteData.destZip).Equals("CANADA"))
                {
                    destCountry = "CAN";
                }

                #endregion

                #region 10 units limit

                if (fclass.Length > 10)
                {
                    throw new Exception("YRC Freight: Shipments of up to 10 units are handled, you have entered " + fclass.Length.ToString() + " units.");
                }

                #endregion

                #region Items

                StringBuilder items = new StringBuilder();

                string itemNum = string.Empty;

                for (int i = 0; i < fclass.Length; i++)
                {
                    itemNum = (i + 1).ToString();
                    items.Append(string.Concat("&LineItemWeight", itemNum, "=", weight[i]));

                    if (fclass[i].Equals(string.Empty))
                    {
                        // Use NMFC instead of class
                        string[] forSplit = nmfc[i].Split('-');
                        if (forSplit.Length.Equals(2))
                        {
                            items.Append(string.Concat("&LineItemNmfcPrefix", itemNum, "=", forSplit[0], "&LineItemNmfcSuffix", itemNum, "=0", forSplit[1]));
                        }
                        else
                        {
                            items.Append(string.Concat("&LineItemNmfcPrefix", itemNum, "=", nmfc[i], "&LineItemNmfcSuffix", itemNum, "="));
                        }
                    }
                    else
                    {
                        items.Append(string.Concat("&LineItemNmfcClass", itemNum, "="));
                        items.Append(fclass[i]);
                    }

                    items.Append(string.Concat("&LineItemCount", itemNum, "=", pieces[i]));

                    if (dimsProvided.Equals(true))
                    {
                        items.Append(
                            string.Concat(
                                "&LineItemPackageLength", itemNum, "=", length[i],
                                "&LineItemPackageWidth", itemNum, "=", width[i],
                                "&LineItemPackageHeight", itemNum, "=", height[i])
                            );
                    }
                }

                #endregion

                #region Make http requests

                referrer = "";
                url      = string.Concat("http://my.yrc.com/myyrc-api/national/servlet?CONTROLLER=com.rdwy.ec.rexcommon.proxy.http.controller.ProxyApiController&redir=/tfq561",
                                         "&LOGIN_USERID=", acctInfo.username, "&LOGIN_PASSWORD="******"&BusId=", acctInfo.acctNum, "&BusRole=Third%20Party&PaymentTerms=Prepaid",
                                         "&OrigCityName=", quoteData.origCity.Replace(" ", "%20"), "&OrigStateCode=", quoteData.origState, "&OrigZipCode=", quoteData.origZip, "&OrigNationCode=", origCountry,
                                         "&DestCityName=", quoteData.destCity.Replace(" ", "%20"), "&DestStateCode=", quoteData.destState, "&DestZipCode=", quoteData.destZip, "&DestNationCode=", destCountry,
                                         "&ServiceClass=STD&PickupDate=", year, month, day, "&TypeQuery=QUOTE",
                                         items, "&LineItemCount=", fclass.Length,

                                         sbAccessorials, "&AccOptionCount=", AccOptionCount);

                //"&AccOption1=HOMD&AccOptionCount=1");
                contentType = "";
                method      = "GET";
                accept      = "*/*";
                doc         = (string)HelperFuncs.generic_http_request("string", null, url, referrer, contentType, accept, method, "", false);

                //DB.Log("YRC Live request", url);
                //DB.Log("YRC_Live response", doc);


                #endregion

                #region Get regular rates

                //string tmp = doc;
                bool isIntraCanada = false;
                if (origCountry == "CAN" && destCountry == "CAN")
                {
                    if (!quoteData.username.ToLower().Equals("durachem"))
                    {
                        throw new Exception("Intra Canada");  // Intra Canada enabled only for durachem for now
                    }
                    isIntraCanada = true;
                }

                #region Get cost and transit days from the result

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

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

                //DB.Log("YRC_Live costStr", costStr);

                int costInt   = -1;
                int costCents = 0;

                if (int.TryParse(costStr, out int testInt))
                {
                    costInt   = testInt / 100;
                    costCents = testInt % 100;

                    //DB.Log("YRC_Live costInt costCents", costInt + " " + costCents);
                }

                if (double.TryParse(string.Concat(costInt, ".", costCents.ToString().PadLeft(2, '0')), out double costDouble))
                {
                    YRC_Res.standardLTL = costDouble;
                    //DB.Log("YRC_Live costDouble", costDouble.ToString());
                }

                YRC_Res.days = 5;
                tokens[0]    = "<StandardDays>";

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

                #endregion

                #endregion
            }

            catch (Exception e)
            {
                #region Exception code

                DB.Log("YRC", e.ToString());

                YRC_Res.standardLTL = -1;

                #endregion
            }
        }
예제 #18
0
        public HttpResponseMessage Post()
        {
            string data = "", DLS_PrimaryReferencePNW = "", response_string = "";

            try
            {
                #region Authentication

                var re      = Request;
                var headers = re.Headers;

                string username = "", password = "";

                if (headers.Contains("username"))
                {
                    username = headers.GetValues("username").First();
                    DB.LogGenera(iam, "username", username);
                }
                else
                {
                    DB.LogGenera(iam, "username", "none found");
                }

                if (headers.Contains("password"))
                {
                    password = headers.GetValues("password").First();
                    DB.LogGenera(iam, "password", password);
                }
                else
                {
                    DB.LogGenera(iam, "password", "none found");
                }

                #endregion

                data = this.Request.Content.ReadAsStringAsync().Result;

                DB.LogGenera(iam, "Public API booking data", data);

                string request_format = "", error_response = "",
                       content_type = "application/json";

                LTLBookRequest ltl_book_request = new LTLBookRequest();
                QuoteData      quoteData        = new QuoteData();

                //

                Validator vld = new Validator();

                DB.LogGenera(iam, "before", "Validate_booking_request_xml_json");

                // Validate_booking_request_json
                vld.Validate_booking_request_json(ref data, ref error_response, ref request_format,
                                                  ref ltl_book_request);

                DB.LogGenera(iam, "after", "Validate_booking_request_xml_json");

                Models.Public.LTL.Helper public_helper = new Models.Public.LTL.Helper();

                #region If got an error response from Validator - return error message

                DB.LogGenera(iam, "Public API error_response", error_response);

                if (error_response == "")
                {
                    // Do nothing
                }
                else
                {
                    response_string = error_response;
                    return(public_helper.Get_response_message(ref response_string, ref content_type));
                }

                #endregion

                #region Not used, MakeBookingViaSOAP
                //return new HttpResponseMessage()
                //{
                //    Content = new StringContent(response_string, Encoding.UTF8, "application/json")
                //};

                //Models.Public.LTL.Helper public_helper = new Models.Public.LTL.Helper();


                // If got to here, request is valid JSON or XML

                // Make booking via SOAP
                //LTLBooking booking = new LTLBooking();
                //response_string = booking.MakeBookingViaSOAP(ref ltl_book_request, ref username, ref password);
                #endregion

                // Get Calculated freight_class, carrier Mode
                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);

                // Get_carriers_by_QuoteID
                List <AES_API_info> quote_carriers;
                // Get_carriers_by_QuoteID
                repo.Get_carriers_by_QuoteID(api_info.QuoteId, out quote_carriers);

                //
                // Build email text
                StringBuilder sb = new StringBuilder();

                public_helper.getEmailText(ref sb, ref quote_carriers);


                DB.LogGenera("create ltl booking", "sb carriers count", quote_carriers.Count.ToString());
                DB.LogGenera("create ltl booking", "sb carriers", sb.ToString());

                // Get_items_by_QuoteID
                repo.Get_items_by_QuoteID(api_info.QuoteId, ref api_info);

                // Get_total_cube_by_QuoteID
                repo.Get_total_cube_by_QuoteID(api_info.QuoteId, ref api_info);

                #region Calculate density

                if (api_info.total_cube > 0 && api_info.total_weight > 0)
                {
                    api_info.total_density = api_info.total_weight / api_info.total_cube;
                    DB.LogGenera(iam, "api_info.total_density", api_info.total_density.ToString());
                }
                else
                {
                    DB.LogGenera(iam, "could not set density", "total cube or total weight 0");
                }

                #endregion

                string sql = "";

                #region Check for Genera carrier, if true return before getting PNW

                DB.LogGenera(iam, "before DLS Shipment Import", "before DLS Shipment Import");
                DB.LogGenera(iam, "api_info.CarrierDisplayName", api_info.CarrierDisplayName);

                if (api_info.CarrierDisplayName.Contains("Genera"))
                {
                    response_string = "Genera carrier, could not get PNW";
                    // Return error
                    return(public_helper.Get_response_message(ref response_string, ref content_type));
                }
                else
                {
                    // Do nothing
                }

                #endregion

                //

                // Book_request_vs_BookingKey
                vld.Book_request_vs_BookingKey(ref error_response, ref ltl_book_request, ref api_info);

                //

                #region DLS Shipment Import

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

                // Get_accessorials_by_RequestID
                repo.Get_accessorials_by_RequestID(ref AccessorialsObj, ref api_info);

                DLS_ShipmentImport shipment_import =
                    new DLS_ShipmentImport(ref dlsInfo, ref dispatchInfo, ref api_info, ref AccessorialsObj,
                                           ref username, "0");

                shipment_import.Set_DLS_ShipmentImport_objects(ref ltl_book_request, ref api_info);

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

                DB.LogGenera(iam, "before ShipmentImportDLS, mode:", AppCodeConstants.mode);

                if (AppCodeConstants.mode == AppCodeConstants.prod)
                {
                    DB.LogGenera(iam, "ShipmentImportDLS, mode:", "is prod");
                    // Prod ShipmentImportDLS
                    shipment_import.ShipmentImportDLS(ref DLS_PrimaryReferencePNW, ref quote_carriers, ref sb);
                }
                else if (AppCodeConstants.mode == AppCodeConstants.demo)
                {
                    DB.LogGenera(iam, "ShipmentImportDLS, mode:", "is demo");
                    // Demo ShipmentImportDLS
                    shipment_import.test_email(ref DLS_PrimaryReferencePNW, ref quote_carriers, ref sb);

                    Random rnd  = new Random();
                    int    rand = rnd.Next();

                    DLS_PrimaryReferencePNW = string.Concat("PNW", rand);
                }
                else
                {
                    DB.LogGenera(iam, "ShipmentImportDLS, mode:", "is different");
                    // A different mode
                }

                //

                DB.LogGenera(iam, "after ShipmentImportDLS", "after ShipmentImportDLS");

                #endregion

                if (DLS_PrimaryReferencePNW == "")
                {
                    throw new Exception("Did not get PNW");
                }

                #region INSERT INTO Segments.CarrierQuoteNum

                // Only for Live GCM bookings
                string[] tokens = new string[4];
                tokens[0] = "shipmentID";
                tokens[1] = ":";
                tokens[2] = "\"";
                tokens[3] = "\"";

                int shipmentID = 0;
                // Scrape the shipment id from the request string
                string shipment_id = HelperFuncs.scrapeFromPage(tokens, data);

                DB.LogGenera(iam, "shipment_id", shipment_id);

                if (int.TryParse(shipment_id, out shipmentID) && shipmentID > 0)
                {
                    // This happens only when Genera user booked in Live GCM
                    // Update CarrierQuoteNum
                    HelperFuncs.updateCarrierQuoteNum(ref shipmentID, ref DLS_PrimaryReferencePNW);
                }
                else
                {
                    // Regular booking, from the API
                    // Do nothing
                }

                //dynamic dyn = JsonConvert.DeserializeObject(doc);

                #endregion

                //response_string = DLS_PrimaryReferencePNW;

                DB.LogGenera(iam, "get_ltl_book_test", DLS_PrimaryReferencePNW);

                //
                repo.UpdateStatsQuoteWasBooked(api_info.QuoteId, DLS_PrimaryReferencePNW,
                                               ltl_book_request.destinationCompany.Replace("'", "''"));
                //

                Json_helper json_helper = new Json_helper();
                response_string = json_helper.Build_booking_response("0", "success", ref DLS_PrimaryReferencePNW, ref api_info);

                #region INSERT INTO Genera_Booking

                //
                string PO = "";
                if (!string.IsNullOrEmpty(ltl_book_request.poNumber))
                {
                    PO = ltl_book_request.poNumber;
                }
                //

                data = data.Replace("'", "''");

                sql = string.Concat("INSERT INTO Genera_Booking_2(Booking_request,Booking_request_escaped,Booking_response,PNW,PO) VALUES(",
                                    "'", data, "','",
                                    data.Replace("\"", "\\\""), "','",
                                    response_string.Replace("'", "''"), "','",
                                    DLS_PrimaryReferencePNW, "','",
                                    PO.Replace("'", "''"),
                                    "')");

                HelperFuncs.ExecuteNonQuery(AppCodeConstants.connStringAesAPI, ref sql, "Get_LTL_ratesController");

                #endregion

                return(public_helper.Get_response_message(ref response_string, ref content_type));
            }
            catch (Exception e)
            {
                #region Unknown error

                DB.LogGenera(iam, "get_ltl_book_test", e.ToString());
                Json_helper json_helper = new Json_helper();
                response_string = json_helper.Build_booking_error_response("2",
                                                                           string.Concat("Could not create booking. Please try again."));

                Models.Public.LTL.Helper public_helper = new Models.Public.LTL.Helper();
                string content_type = "application/json";

                string sql = string.Concat("INSERT INTO Genera_Booking_2(Booking_request,Booking_request_escaped,Booking_Response,PNW) VALUES(",
                                           "'", data, "','",
                                           data.Replace("\"", "\\\""), "','",
                                           response_string, "','",
                                           DLS_PrimaryReferencePNW, "')");

                HelperFuncs.ExecuteNonQuery(AppCodeConstants.connStringAesAPI, ref sql, "Get_LTL_ratesController");

                return(public_helper.Get_response_message(ref response_string, ref content_type));

                #endregion
            }
        }
예제 #19
0
    public void Get_XPO_Spot_Quote_rates(ref string access_token, ref Volume_result result)
    {
        try
        {
            #region Build Items string

            int total_units = 0;

            StringBuilder items = new StringBuilder();

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

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

                items.Append(",");

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

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

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

            #endregion


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

            int Total_lineal_feet = total_units * 2;

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

            #region Date

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

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

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

            #endregion

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

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

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

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

                                        "[",

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

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

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

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

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

            string doc = http.Make_http_request();

            #region Parse result

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

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

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

            //--

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

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

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

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

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

            #endregion

            result.cost         = total_cost;
            result.quote_number = spotQuoteNbr;
            result.transit_days = days;
            result.carrier_name = "XPO Spot Quote";
        }
        catch (Exception e)
        {
            //string str = e.ToString();
            DB.Log("Get_XPO_Spot_Quote_rates", e.ToString());
        }
    }
예제 #20
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
    }
예제 #21
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);
        }
    }
예제 #22
0
파일: LOUP.cs 프로젝트: alefurman40/api_2
    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
        }
    }
예제 #23
0
        public void Get_Sunset_Pacific_rates(ref string access_token, ref Sunset_P_Res sunset_volume_result)
        {
            try
            {
                if (quoteData.AccessorialsObj.TRADEPU.Equals(true) || quoteData.AccessorialsObj.TRADEDEL.Equals(true)

                    || quoteData.AccessorialsObj.APTPU.Equals(true) ||
                    quoteData.AccessorialsObj.APTDEL.Equals(true)

                    || quoteData.AccessorialsObj.LGPU.Equals(true) ||
                    quoteData.AccessorialsObj.LGDEL.Equals(true)

                    || quoteData.AccessorialsObj.RESPU.Equals(true) ||
                    quoteData.AccessorialsObj.RESDEL.Equals(true)

                    || quoteData.AccessorialsObj.CONPU.Equals(true) ||
                    quoteData.AccessorialsObj.CONDEL.Equals(true)

                    || quoteData.AccessorialsObj.INSDEL.Equals(true)

                    || quoteData.isHazmat == true
                    //|| quoteData.AccessorialsObj..Equals(true)

                    )
                {
                    throw new Exception("Accessorials not supported");
                }

                #region Build Items string

                int total_units = 0;

                StringBuilder items = new StringBuilder();

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

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

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

                    //

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

                //DB.Log("Sunset Pacific items", items.ToString());

                #endregion


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

                int Total_lineal_feet = total_units * 2;

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

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

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

                int orig_zip_code = 0;

                int.TryParse(quoteData.origZip, out orig_zip_code);

                //DB.Log("Get_Sunset_Pacific_rates dest_zip_code", orig_zip_code.ToString());

                string Origin_code = "1"; //1 s. California, 2 n. California

                if (orig_zip_code > 93099)
                {
                    Origin_code = "2";
                }

                string data = string.Concat("Origin=", Origin_code, "&PickUpDate=", month, "-", day, "-", quoteData.puDate.Year.ToString(),
                                            "&Destination=", quoteData.destZip, "&LinealFootageKnown=", Total_lineal_feet,
                                            "&Weight=", quoteData.totalWeight, "&IsFloorLoaded=null&ShippingRemarks=&MeasurementLFT=0",
                                            "&NonFloorLoadeds=[]&FloorLoadeds=[]");

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

                Web_client http = new Web_client
                {
                    url          = "https://api.sunsetpacific.com/api/Quotes",
                    content_type = "application/x-www-form-urlencoded",
                    accept       = "application/json",
                    post_data    = data,
                    method       = "POST"
                };

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

                string doc = http.Make_http_request();

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

                #region Parse result

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


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

                if (double.TryParse(HelperFuncs.scrapeFromPage(tokens, doc), out double total_cost))
                {
                    sunset_volume_result.cost = total_cost;
                }


                tokens[0] = "EstimatedDays\":";

                if (int.TryParse(HelperFuncs.scrapeFromPage(tokens, doc), out int days))
                {
                    sunset_volume_result.days = days;
                }

                tokens[0] = "QuoteId\":";
                sunset_volume_result.quote_id = HelperFuncs.scrapeFromPage(tokens, doc);

                #endregion
            }
            catch (Exception e)
            {
                //string str = e.ToString();
                DB.Log("Get_Sunset_Pacific_rates", e.ToString());
            }
        }
예제 #24
0
파일: SMTL.cs 프로젝트: alefurman40/api_2
        public void Get_rates(out GCMRateQuote SMTL_Quote_Genera)
        {
            Random rnd    = new Random();
            int    sess_1 = rnd.Next(10000000, 99999999);
            int    sess_2 = rnd.Next(10000000, 99999999);

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

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

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

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

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

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

                                            Get_items(),

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

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

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

                Web_client http = new Web_client();


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


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

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

                string doc = http.Make_http_request();

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

                #region Parse result

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

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

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

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

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

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

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

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

                DateTime PickupDate, DeliveryDate;

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

                        PickupDate = PickupDate.AddDays(1);
                    }
                }

                #endregion

                #region Set result

                SMTL_Quote_Genera = new GCMRateQuote();

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

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

                #endregion
            }
            catch (Exception e)
            {
                SMTL_Quote_Genera = new GCMRateQuote();
                DB.LogGenera("SMTL", "exception", e.ToString());
            }
        }