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 }
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()); } }
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); } }
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); } }
//-- #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 }
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; } }
// 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); } }
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()); } }
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()); } }
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()); } }
public void Get_rate(ref string access_token, out GCMRateQuote Daylight_Quote_Genera) { try { Web_client http = new Web_client(); #region Pickup date string day = DateTime.Today.Day.ToString(), month = DateTime.Today.Month.ToString(); if (day.Length == 1) { day = string.Concat("0", day); } if (month.Length == 1) { month = string.Concat("0", month); } #endregion #region Build items StringBuilder sb_items = new StringBuilder(); if (quoteData.m_lPiece.Length == 1) { sb_items.Append(string.Concat("\"item\": {", "\"description\": \"Test\",", "\"nmfcNumber\": \"\",", "\"nmfcSubNumber\": \"\",", "\"pcs\": ", quoteData.m_lPiece[0].Pieces, ",", "\"pallets\": ", quoteData.m_lPiece[0].Quantity, ",", "\"weight\": ", quoteData.m_lPiece[0].Weight, ", ", "\"actualClass\": \"", quoteData.m_lPiece[0].FreightClass, "\"", "}")); } else { sb_items.Append("\"item\": ["); string items_nodes = ""; for (byte i = 0; i < quoteData.m_lPiece.Length; i++) { items_nodes += string.Concat("{", "\"description\": \"Test\",", "\"nmfcNumber\": \"\",", "\"nmfcSubNumber\": \"\",", "\"pcs\": ", quoteData.m_lPiece[i].Pieces, ",", "\"pallets\": ", quoteData.m_lPiece[i].Quantity, ",", "\"weight\": ", quoteData.m_lPiece[i].Weight, ", ", "\"actualClass\": \"", quoteData.m_lPiece[i].FreightClass, "\"", "}," ); } // Remove the comma at the end sb_items.Append(items_nodes.Remove(items_nodes.Length - 1)); sb_items.Append("]"); } #endregion #region Accessorials var sb_accessorials = new StringBuilder(); byte num_of_acc = 0; Get_num_of_acc(ref num_of_acc, ref quoteData); //DB.LogGenera("Daylight", "num_of_acc", num_of_acc.ToString()); if (num_of_acc == 0) { // Do nothing } else if (num_of_acc == 1) { string acc = ""; Get_acc_nodes(ref acc, ref num_of_acc, ref quoteData); // Remove the comma at the end acc = acc.Remove(acc.Length - 1); sb_accessorials.Append(acc); } else { // More than one sb_accessorials.Append("\"accessorial\": ["); string acc = ""; Get_acc_nodes(ref acc, ref num_of_acc, ref quoteData); //DB.LogGenera("Daylight", "acc before remove", acc); // Remove the comma at the end acc = acc.Remove(acc.Length - 1); //DB.LogGenera("Daylight", "acc after remove", acc); sb_accessorials.Append(acc); sb_accessorials.Append("]"); } #endregion http.url = "https://api.dylt.com/rateQuote"; http.method = "POST"; #region post_data http.post_data = string.Concat("{", "\"dyltRateQuoteReq\": {", "\"accountNumber\": \"", AppCodeConstants.DYLT_Genera_account, "\",", "\"userName\": \"", AppCodeConstants.DYLT_Genera_username, "\",", "\"password\": \"", AppCodeConstants.DYLT_Genera_password, "\",", "\"billTerms\": \"PP\",", "\"serviceType\": \"LTL\",", "\"pickupDate\": \"", DateTime.Today.Year, "-", month, "-", day, "\",", "\"shipperInfo\": {", "\"customerNumber\": \"\",", "\"customerName\": \"\",", //Genera Corp "\"customerAddress\": {", "\"streetAddress\": \"\",", //600 Freeport Pkwy Ste 250 "\"aptAddress\": \"\",", "\"city\": \"", quoteData.origCity, "\",", //Coppell "\"state\": \"", quoteData.origState, "\",", //TX "\"zip\": \"", quoteData.origZip, "\"", //75019 "}", "},", "\"consigneeInfo\": {", "\"customerNumber\": \"\",", "\"customerName\": \"\",", //Simco Automotive Inc "\"customerAddress\": {", "\"streetAddress\": \"\",", // 13425 Estelle St "\"aptAddress\": \"string\",", "\"city\": \"", quoteData.destCity, "\",", //Corona "\"state\": \"", quoteData.destState, "\",", //CA "\"zip\": \"", quoteData.destZip, "\"", //92879 "}", "},", "\"items\": {", sb_items, "},", "\"accessorials\": {", sb_accessorials, // "\"accessorial\": {", // "\"accName\": \"DELIVERY\",", //"\"accId\": \"APPOINTMENT FEE\",", //"\"accValue\": 0", // "}", "}", "}", "}" ); //DB.LogGenera("Daylight", "post_data", http.post_data); //Daylight_Quote_Genera = new GCMRateQuote(); //return; #endregion http.accept = "*/*"; //http.accept = "application/json"; http.content_type = "application/json"; http.header_names = new string[1]; http.header_names[0] = "Authorization"; http.header_values = new string[1]; http.header_values[0] = string.Concat("Bearer ", access_token); string doc = http.Make_http_request(); //DB.LogGenera("Daylight", "response", doc); dynamic dyn = JsonConvert.DeserializeObject(doc); #region Parse result #region Sample Response // { // "dyltRateQuoteResp":{ // "success":"YES", // "errorInformation":{ // "errorMessage":"NULL" // }, // "quoteNumber":"CQ20093199", // "quoteDate":"08\/05\/2020", // "pickupDate":"08\/05\/2020", // "earliestDeliveryDate":"08\/07\/2020", // "totalWeight":500, // "origZip":75019, // "destZip":92879, // "rateBaseName":"DYLT507AP 2020-02-03", // "itemCharges":{ // "itemCharge":[ // { // "description":"Test", // "pcs":1, // "pallets":1, // "weight":500, // "actualClass":50, // "rateClass":50, // "rate":215.47, // "charge":1077.35, // "discountPct":86.5 // } // ] // }, // "accessorialCharges":{ // "accessorialCharge":[ // { // "reqAccessorial":"California Compliance Surcharge", // "accRate":9.95, // "accCharge":9.95 // }, // { // "reqAccessorial":"Appointment Notification", // "accRate":0.0, // "accCharge":0.0 // }, // { // "reqAccessorial":"Fuel Surcharge", // "accRate":0.207, // "accCharge":30.11 // } // ] // }, // "totalCharges":{ // "grossCharge":1077.35, // "fuelSurcharge":30.11, // "totalAccessorial":40.06, // "discountAmt":931.91, // "netCharge":185.5 // } // } //} #endregion string totalCharges = "", quoteNumber = "", netCharge = "", str_earliestDeliveryDate = "", str_pickupDate = ""; var dyltRateQuoteResp = new Newtonsoft.Json.Linq.JObject(); if (dyn.dyltRateQuoteResp != null) { if (dyn.dyltRateQuoteResp.totalCharges != null) { if (dyn.dyltRateQuoteResp.totalCharges.netCharge != null) { netCharge = dyn.dyltRateQuoteResp.totalCharges.netCharge; } } if (dyn.dyltRateQuoteResp.quoteNumber != null) { quoteNumber = dyn.dyltRateQuoteResp.quoteNumber; } if (dyn.dyltRateQuoteResp.earliestDeliveryDate != null) { str_earliestDeliveryDate = dyn.dyltRateQuoteResp.earliestDeliveryDate; } if (dyn.dyltRateQuoteResp.pickupDate != null) { str_pickupDate = dyn.dyltRateQuoteResp.pickupDate; } } int transit_days = 5; if (DateTime.TryParse(str_earliestDeliveryDate, out DateTime earliestDeliveryDate) && DateTime.TryParse(str_pickupDate, out DateTime pickupDate)) { var h = new Utilities.Helper(); transit_days = h.Get_business_days_between_2_dates(pickupDate, earliestDeliveryDate); } #region Not used, get data from dynamic array //string Charge = ""; //foreach (var obj in dyn.totalCharges) //{ // if (obj.Charge != null) // { // netCharge = obj.netCharge; // } //} #endregion #endregion #region Set result Daylight_Quote_Genera = new GCMRateQuote(); if (decimal.TryParse(netCharge, out decimal totalCharge) && totalCharge > 0.0M) { Daylight_Quote_Genera.TotalPrice = (double)totalCharge; Daylight_Quote_Genera.DeliveryDays = transit_days; Daylight_Quote_Genera.CarrierQuoteID = quoteNumber; Daylight_Quote_Genera.DisplayName = "Daylight - Genera"; Daylight_Quote_Genera.CarrierKey = "DayLight"; Daylight_Quote_Genera.BookingKey = "#1#"; Daylight_Quote_Genera.Scac = "DYLT"; } #endregion } catch (Exception e) { DB.LogGenera("Daylight", "e", e.ToString()); Daylight_Quote_Genera = new GCMRateQuote(); } }
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()); } }
public IntermodalRater.railResult getRate() { try { HelperFuncs.writeToSiteErrors("LOUP new function", "LOUP new function"); Random random = new Random(); int randInt = random.Next(999); // Max value string randStr = "1543" + randInt.ToString(); randInt = random.Next(999999); // Max value randStr += randInt.ToString(); Web_client http = new Web_client(); http.method = "GET"; http.url = string.Concat("http://www.shipstreamline.com/"); http.referrer = ""; http.accept = "text/html, application/xhtml+xml, */*"; string doc = http.Make_http_request(); // Set headers http.header_names = new string[1]; http.header_names[0] = "X-Requested-With"; http.header_values = new string[1]; http.header_values[0] = "XMLHttpRequest"; http.referrer = "https://www.shipstreamline.com/"; http.url = string.Concat( "http://www.shipstreamline.com/customers/apps/news/list-json.cfm?_=", randStr); http.method = "GET"; http.accept = "text/plain, */*; q=0.01"; http.content_type = ""; doc = http.Make_http_request(); // Empty headers http.header_names = new string[0]; http.header_values = new string[0]; http.referrer = "https://www.shipstreamline.com/"; http.url = "https://www.shipstreamline.com/admin/login.fcc"; http.accept = "text/html, application/xhtml+xml, */*"; http.method = "POST"; http.content_type = "application/x-www-form-urlencoded"; http.post_data = "target=%2Fstm%2Fresponsive%2Fsecure%2Flogin.shtml&USER="******"&PASSWORD="******"&submitBtn=Login"; //http http = new http(info); doc = http.Make_http_request(); // Get_LOUP_random Get_LOUP_random(ref random, ref randInt, ref randStr); // Set headers http.header_names = new string[1]; http.header_names[0] = "X-Requested-With"; http.header_values = new string[1]; http.header_values[0] = "XMLHttpRequest"; http.referrer = "https://www.shipstreamline.com/"; http.url = string.Concat( "https://www.shipstreamline.com/admin/tools/clear-count.shtml?_=", randStr); http.method = "GET"; http.accept = "*/*"; http.content_type = ""; doc = http.Make_http_request(); // // Empty headers http.header_names = new string[0]; http.header_values = new string[0]; http.url = "https://www.shipstreamline.com/stm/redirect/quoteline.shtml?track=mini-app-more"; http.accept = "text/html, application/xhtml+xml, */*"; doc = http.Make_http_request(); http.referrer = http.url; http.url = "https://www.shipstreamline.com/customers/quoteline/secure/index.shtml?track=mini-app-more"; doc = http.Make_http_request(); // Get_LOUP_random Get_LOUP_random(ref random, ref randInt, ref randStr); // // Set headers http.header_names = new string[1]; http.header_names[0] = "X-Requested-With"; http.header_values = new string[1]; http.header_values[0] = "XMLHttpRequest"; http.referrer = http.url; http.url = string.Concat( "https://www.shipstreamline.com/customers/quoteline/secure/i18n/locale_en-US.json?cb=", randStr); http.accept = "application/json, text/javascript, */*; q=0.01"; doc = http.Make_http_request(); // Get_LOUP_random Get_LOUP_random(ref random, ref randInt, ref randStr); // Empty headers http.header_names = new string[0]; http.header_values = new string[0]; http.url = string.Concat( "https://www.shipstreamline.com/pricing-services/secure/jas/api/user?cb=", randStr); http.accept = "application/json, text/plain, */*"; doc = http.Make_http_request(); // // Make missing requests http.url = "https://www.shipstreamline.com/customers/quoteline/secure/assets/spinner/spinner_32.gif"; http.accept = "image/webp,image/apng,image/*,*/*;q=0.8"; doc = http.Make_http_request(); // Set headers http.header_names = new string[1]; http.header_names[0] = "X-Requested-With"; http.header_values = new string[1]; http.header_values[0] = "XMLHttpRequest"; http.url = string.Concat("https://www.shipstreamline.com/stm/ssi/ue-apps/components/mapping/location-data/can.min.json?d=2018-11-28"); http.accept = "application/json, text/javascript, */*; q=0.01"; doc = http.Make_http_request(); http.url = string.Concat("https://www.shipstreamline.com/stm/ssi/ue-apps/components/mapping/location-data/usa.min.json?d=2018-11-28"); doc = http.Make_http_request(); http.url = string.Concat("https://www.shipstreamline.com/stm/ssi/ue-apps/components/mapping/location-data/mex.min.json?d=2018-11-28"); doc = http.Make_http_request(); http.url = string.Concat("https://www.shipstreamline.com/stm/ssi/ue-apps/components/mapping/location-data/usa-state-lines.min.json?d=2018-11-28"); doc = http.Make_http_request(); http.url = string.Concat("https://www.shipstreamline.com/stm/ssi/ue-apps/components/mapping/location-data/base-ramps.json?d=2018-11-28"); doc = http.Make_http_request(); // // Get_LOUP_random Get_LOUP_random(ref random, ref randInt, ref randStr); // Set headers http.header_names = new string[1]; http.header_names[0] = "X-Requested-With"; http.header_values = new string[1]; http.header_values[0] = "XMLHttpRequest"; http.url = string.Concat( "https://www.shipstreamline.com/customer-services/secure/jas/capacity-freight?_=", randStr); http.accept = "text/plain, */*; q=0.01"; doc = http.Make_http_request(); // Get_LOUP_random Get_LOUP_random(ref random, ref randInt, ref randStr); // Empty headers http.header_names = new string[0]; http.header_values = new string[0]; http.url = "https://www.shipstreamline.com/pricing-services/secure/jas/api/quote/specials"; http.accept = "application/json, text/plain, */*"; doc = http.Make_http_request(); #region Locations requests // Set headers http.header_names = new string[1]; http.header_names[0] = "X-Requested-With"; http.header_values = new string[1]; http.header_values[0] = "XMLHttpRequest"; // Get locations http.url = string.Concat( "https://www.shipstreamline.com/pricing-services/secure/jas/api/location/search?term=1521"); http.accept = "*/*"; doc = http.Make_http_request(); http.url = string.Concat( "https://www.shipstreamline.com/pricing-services/secure/jas/api/location/search?term=15214"); doc = http.Make_http_request(); http.url = string.Concat( "https://www.shipstreamline.com/pricing-services/secure/jas/api/location/search?term=9814"); doc = http.Make_http_request(); http.url = string.Concat( "https://www.shipstreamline.com/pricing-services/secure/jas/api/location/search?term=98144"); doc = http.Make_http_request(); #endregion // Empty headers http.header_names = new string[0]; http.header_values = new string[0]; // Get_LOUP_random Get_LOUP_random(ref random, ref randInt, ref randStr); HelperFuncs.writeToSiteErrors("LOUP before summary", "LOUP before summary"); http.url = string.Concat( "https://www.shipstreamline.com/pricing-services/secure/jas/api/pricing/summary?cb=", randStr); http.accept = "application/json, text/plain, */*"; http.method = "POST"; http.content_type = "application/json;charset=utf-8"; http.post_data = "{\"hazmatShipment\":false,\"beneficialOwner\":{\"name\":\"BCO_UNKNOWN\"},\"pickupDate\":\"20181128\",\"intermodalMoveType\":\"DOOR_TO_DOOR\",\"shipFromLocation\":{\"spotLiveType\":\"STAY\",\"locationId\":\"018413\",\"city\":\"PITTSBURGH\",\"state\":\"PA\",\"zipcode\":\"15214\",\"country\":\"US\",\"area\":\"PIT\",\"latitude\":40.481828,\"longitude\":-80.016002,\"timeZone\":\"ED\",\"services\":[]},\"shipToLocation\":{\"spotLiveType\":\"STAY\",\"locationId\":\"130145\",\"city\":\"SEATTLE\",\"state\":\"WA\",\"zipcode\":\"98144\",\"country\":\"US\",\"area\":\"SEA\",\"latitude\":47.58564,\"longitude\":-122.298,\"timeZone\":\"PD\",\"services\":[]},\"extraPickups\":[],\"extraDeliveries\":[]}"; doc = http.Make_http_request(); HelperFuncs.writeToSiteErrors("LOUP doc", doc); railResultObj = new IntermodalRater.railResult(); railResultObj.success = ""; return(railResultObj); } catch (Exception e) { #region Catch HelperFuncs.writeToSiteErrors("LOUP", e.ToString()); railResultObj = new IntermodalRater.railResult(); railResultObj.success = ""; return(railResultObj); #endregion } }
public void Get_rates(out GCMRateQuote Pyle_Quote_Genera) { try { #region Build accessorials string string accessorials = ""; if (quoteData.isHazmat == true) { accessorials += "&hazard=1"; } if (quoteData.AccessorialsObj.LGPU) { accessorials += "&nplift=1"; } if (quoteData.AccessorialsObj.LGDEL) { accessorials += "&nlift=1"; } if (quoteData.AccessorialsObj.RESPU) { accessorials += "LGATEP"; } if (quoteData.AccessorialsObj.RESDEL) { accessorials += "&nresid=1"; } if (quoteData.AccessorialsObj.CONPU) { accessorials += "LGATEP"; } if (quoteData.AccessorialsObj.CONDEL) { accessorials += "&ncons=1"; } if (quoteData.AccessorialsObj.APTPU) { } if (quoteData.AccessorialsObj.APTDEL) { accessorials += "&ncall=1"; } if (quoteData.AccessorialsObj.TRADEPU) { accessorials += "LGATEP"; } if (quoteData.AccessorialsObj.TRADEDEL) { accessorials += "LGATEP"; } if (quoteData.AccessorialsObj.INSDEL) { accessorials += "&nid=1"; } #endregion #region Build items string //StringBuilder items = new StringBuilder(); string items = ""; //StringBuilder weights = new StringBuilder(); //StringBuilder classes = new StringBuilder(); //StringBuilder counts = new StringBuilder(); //StringBuilder dims = new StringBuilder(); string weights = "", classes = "", counts = "", dims = ""; for (byte i = 0; i < quoteData.m_lPiece.Length; i++) { weights += string.Concat((int)quoteData.m_lPiece[i].Weight, ","); classes += string.Concat(quoteData.m_lPiece[i].FreightClass, ","); counts += string.Concat(quoteData.m_lPiece[i].Quantity, ","); if (quoteData.m_lPiece[i].Length > 0 && quoteData.m_lPiece[i].Width > 0 && quoteData.m_lPiece[i].Height > 0) { dims += string.Concat(quoteData.m_lPiece[i].Length, "x", quoteData.m_lPiece[i].Width, "x", quoteData.m_lPiece[i].Height, ","); } } items = string.Concat("&weights=", weights.Remove(weights.Length - 1), "&classes=", classes.Remove(classes.Length - 1), "&count=", counts.Remove(counts.Length - 1) ); if (dims.Length > 0) { items += string.Concat("&dim=", dims.Remove(dims.Length - 1)); } //DB.LogGenera("Pyle", "items", items); #endregion //11550 string URL = string.Concat( "https://www.aduiepyle.com/publicdocs/RateQuoteAPI4?MyPyleID=", AppCodeConstants.pyle_genera_id, "&account=", AppCodeConstants.pyle_genera_acct, "&terms=P&oZip=08831&dZip=", quoteData.destZip, items, //"&weights=5000&classes=55&count=4", //"&dim=48x40x48", "&ctrtype=pallet&isfull=empty", accessorials, //"&hazard=1", //"&ins=10000", "&json=1"); //DB.LogGenera("Pyle", "Request URL", URL); #region Get result from server Web_client http = new Web_client(); http.url = URL; http.method = "GET"; http.accept = "application/json"; string doc = http.Make_http_request(); //DB.LogGenera("Pyle", "Response", doc); dynamic dyn = JsonConvert.DeserializeObject(doc); #endregion #region Parse result string RateQuoteNumber = "", ShippingDays = "", TotalCharge = ""; if (dyn.RateQuoteNumber != null) { RateQuoteNumber = dyn.RateQuoteNumber; } if (dyn.ShippingDays != null) { ShippingDays = dyn.ShippingDays; } if (dyn.TotalCharge != null) { TotalCharge = dyn.TotalCharge; } #region Not used, get data from dynamic array //string Charge = ""; //foreach (var obj in dyn.ShipmentCharges) //{ // if(obj.Charge != null) // { // Charge = obj.Charge; // } //} #endregion Pyle_Quote_Genera = new GCMRateQuote(); double TotalPrice; int DeliveryDays; if (double.TryParse(TotalCharge, out TotalPrice)) { Pyle_Quote_Genera.TotalPrice = TotalPrice; if (int.TryParse(ShippingDays, out DeliveryDays)) { Pyle_Quote_Genera.DeliveryDays = DeliveryDays; } else { Pyle_Quote_Genera.DeliveryDays = 5; } Pyle_Quote_Genera.DisplayName = "A.Duie Pyle - Genera"; Pyle_Quote_Genera.CarrierKey = "UPS"; Pyle_Quote_Genera.BookingKey = "#1#"; Pyle_Quote_Genera.Scac = "PYLE"; Pyle_Quote_Genera.CarrierQuoteID = RateQuoteNumber; } #endregion } catch (Exception e) { Pyle_Quote_Genera = new GCMRateQuote(); DB.LogGenera("", "e", e.ToString()); } }
// #region Request_pickup public void Request_pickup() { 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>", "<ShipDate>", quoteData.puDate.ToShortDateString(), "</ShipDate>", "<Terms>P</Terms>", "<LiabilityCoverage>25000</LiabilityCoverage>", "<WingExpress>N</WingExpress>", "<ShipperName>ORouke</ShipperName><ShipperAddress>1875 Water Ridge</ShipperAddress>", "<ReadyTime>1400</ReadyTime><CloseTime>1700</CloseTime><Phone>2106623272</Phone><Contact>Randy</Contact>", "<PUInstruction1>long beam</PUInstruction1><PUInstruction2>2 pallets</PUInstruction2>", "</SMTLRateRequest>"); data = string.Concat( "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>", "<SMTLPickUpRequest>", "<SMTLIam>Genera_api</SMTLIam>", "<Token>Si2wKXpsU!</Token>", "<SessionId>", sess_1, sess_2, "</SessionId>", "<ShipperName> ORouke </ShipperName >", "<ShipperAddress> 1875 Water Ridge </ShipperAddress>", "<FromCity>", quoteData.origCity, "</FromCity>", "<FromState>", quoteData.origState, "</FromState>", "<FromZip>", quoteData.origZip, "</FromZip>", "<ShipDate>", quoteData.puDate.ToShortDateString(), "</ShipDate>", "<ReadyTime> 1400 </ReadyTime>", "<CloseTime> 1700 </CloseTime>", "<Phone> 2106623272 </Phone>",// ***no edits just number "<Contact> Randy </Contact>", "<OneCity> Tulsa </OneCity>", "<OneState> OK </OneState>", "<OneZip> 74115 </OneZip>", "<OnePUComment1> long beam </OnePUComment1>", "<OnePUComment2> 2 pallets </OnePUComment2>", "<OnePieces> 3 </OnePieces>", "<OneWeight> 500 </OneWeight>", //***whole number no decimals "<OnePckgCode> SK </OnePckgCode>", "<OneHazMat> Y </OneHazMat>", "<OneFrtIdNbr> 357357</OneFrtIdNbr>", "<TwoCity> McAllen </TwoCity>", "<TwoState> TX </TwoState>", "<TwoZip> 78501 </TwoZip>", "<TwoPUComment1> flexible conduit </TwoPUComment1>", "<TwoPUComment2> 2 pallets </TwoPUComment2>", "<TwoPieces> 2 </TwoPieces>", "<TwoWeight> 514 </TwoWeight>", "<TwoPckgCode> PT </TwoPckgCode>", "<TwoHazMat> N </TwoHazMat>", "<TwoFrtIdNbr> 357358 </TwoFrtIdNbr>", "<ThrCity> PortLand </ThrCity>", "<ThrState> OR </ThrState>", "<ThrZip> 97216 </ThrZip>", "<ThrPUComment1> 38 boxes per pallet </ThrPUComment1> ", "<ThrPUComment2>do not double stack</ThrPUComment2>", "<ThrPieces> 2 </ThrPieces>", "<ThrWeight> 1298 </ThrWeight>", "<ThrPckgCode> PT </ThrPckgCode>", "<ThrHazMat> N </ThrHazMat>", "<ThrFrtIdNbr> 357357 </ThrFrtIdNbr>", "</SMTLPickUpRequest> "); //DB.Log("SMTL Pickup Request data", data); Web_client http = new Web_client(); http.url = string.Concat("http://www2.smtl.com/rpgsp/SMTLPCKUP.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 Pickup Request doc", doc); #region Parse result //string[] tokens = new string[3]; //tokens[0] = "<FreightCharges>"; //tokens[1] = ">"; //tokens[2] = "<"; //string FreightCharges_str = HelperFuncs.scrapeFromPage(tokens, doc); #endregion } catch (Exception e) { DB.Log("SMTL", e.ToString()); } }
// Not used, in favor of net_core public void Get_YRC_API_Spot_Quote_Volume(ref Volume_result result) { #region Not used /* * string url = string.Concat("https://my.yrc.com/myyrc-api/national/servlet?CONTROLLER=com.rdwy.ec.rexcommon.proxy.http.controller.ProxyApiController&redir=/tfq561", * "&LOGIN_USER=&LOGIN_PASSWORD=&BusId=", * "&BusRole=Third Party&PaymentTerms=Prepaid", * * "&OrigCityName=", orig_city, "&OrigStateCode=", orig_state, "&OrigZipCode=", orig_zip, "&OrigNationCode=USA", * "&DestCityName=", dest_city, "&DestStateCode=", dest_state, "&DestZipCode=", dest_zip, "&DestNationCode=USA", * "&ServiceClass=SPOT&PickupDate=20190102", * * "&LineItemWeight1=13500&LineItemCount=1", * "&LineItemPackageLength1=144&LineItemPackageWidth1=80&LineItemPackageHeight1=80", * * "&AcceptTerms=Y&LineItemHandlingUnits1=1&AccOption1=NTFY&AccOptionCount=1"); */ #endregion try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Web_client http = new Web_client { url = "", content_type = "", accept = "*/*", method = "GET" }; //DB.Log("gcmAPI_Get_LOUP_Rates before send request", "before send request"); //string doc = http.Make_http_request(); Logins.Login_info login_info; Logins logins = new Logins(); logins.Get_login_info(37, out login_info); http.method = "POST"; //http.referrer = http.url; http.url = "https://my.yrc.com/dynamic/national/servlet"; http.post_data = string.Concat("CNTR=&AccOptionCount=1&AccOption1=NTFY&AcceptTerms=Y", "&DestZipCode=", quoteData.destZip, "&OrigNationCode=USA", "&LineItemPackageWidth1=80", "&LOGIN_USER="******"&LineItemPackageHeight1=80", "&DestCityName=", quoteData.destCity, "&LineItemPackageLength1=144", "&BusId=", login_info.account, "&redir=%2Ftfq561", "&LineItemHandlingUnits1=1&LineItemWeight1=13500", "&OrigZipCode=", quoteData.origZip, "&LineItemCount=1&BusRole=Third Party&OrigCityName=", quoteData.origCity, "&DestStateCode=", quoteData.destState, "&PickupDate=20190102&CONTROLLER=com.rdwy.ec.rexcommon.proxy.http.controller.ProxyApiController", "&ServiceClass=SPOT&PaymentTerms=Prepaid&OrigStateCode=", quoteData.origState, "&DestNationCode=USA", "&LOGIN_USERID=", login_info.username, "&LOGIN_PASSWORD="******"YRC post_data volume", http.post_data); string doc = http.Make_http_request(); //DB.Log("YRC response volume", doc); #region Parse result XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(doc); XmlNodeList nodeList = xmlDoc.GetElementsByTagName("TotalCharges"); double TotalCharges = 0; if (nodeList.Count > 0) { TotalCharges = Convert.ToDouble(nodeList[0].InnerText); } TotalCharges = TotalCharges / 100; nodeList = xmlDoc.GetElementsByTagName("StandardDate"); DateTime StandardDate = DateTime.MaxValue; string delivery_date = nodeList[0].InnerText; string delivery_year = ""; string delivery_month = ""; string delivery_day = ""; try { delivery_year = delivery_date.Remove(4); delivery_date = delivery_date.Substring(4); delivery_month = delivery_date.Remove(2); delivery_day = delivery_date.Substring(2); } catch { // Do nothing } int transit_days = 10; if (DateTime.TryParse(string.Concat(delivery_month, "/", delivery_day, "/", delivery_year), out StandardDate)) { transit_days = Convert.ToInt32((StandardDate - DateTime.Today).TotalDays); } nodeList = xmlDoc.GetElementsByTagName("QuoteId"); string QuoteId = string.Empty; if (nodeList.Count > 0) { QuoteId = nodeList[0].InnerText; } nodeList = xmlDoc.GetElementsByTagName("ReferenceId"); string ReferenceId = string.Empty; if (nodeList.Count > 0) { ReferenceId = nodeList[0].InnerText; } #endregion result.cost = TotalCharges; result.quote_number = QuoteId; result.transit_days = transit_days; result.carrier_name = "YRC Spot Quote"; } catch (Exception e) { DB.Log("YRC exception volume", e.ToString()); } }
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()); } }
// For Volume quoting #region Get_USF_API_Volume_Quote public Volume_result Get_USF_API_Volume_Quote(ref int total_units) { try { //quoteData.totalWeight //DB.Log("quoteData.totalWeight", quoteData.totalWeight.ToString()); int Total_lineal_feet = total_units * 2; if (quoteData.linealFeet > 0.0) // Requested by XML GCM API { Total_lineal_feet = Convert.ToInt32(quoteData.linealFeet); } Logins.Login_info login_info; Logins logins = new Logins(); logins.Get_login_info(120, out login_info); string url = string.Concat("https://api.reddawayregional.com/api/SpotQuote/doSpotQuote?accessKey=", login_info.API_Key, //"&originZip=29154&destinationZip=30303", "&originZip=", quoteData.origZip, "&destinationZip=", quoteData.destZip, "&weight=", quoteData.totalWeight, "&handlingUnits=", total_units, "&palletized=Y&stackable=N&lengthInFeet=", Total_lineal_feet); //DB.Log("Get_USF_API_Volume_Quote request", url); Web_client http = new Web_client { url = url, content_type = "", accept = "*/*", method = "GET" }; //DB.Log("gcmAPI_Get_LOUP_Rates before send request", "before send request"); string doc = http.Make_http_request(); //DB.Log("Get_USF_API_Volume_Quote response", doc); Volume_result volume_result = new Volume_result(); #region Parse result XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(doc); XmlNodeList nodeList = xmlDoc.GetElementsByTagName("CHARGES"); double CHARGES = 0; if (nodeList.Count > 0) { CHARGES = Convert.ToDouble(nodeList[0].InnerText); volume_result.cost = CHARGES; } nodeList = xmlDoc.GetElementsByTagName("FREIGHTCHARGES"); double FREIGHTCHARGES = 0; if (nodeList.Count > 0) { FREIGHTCHARGES = Convert.ToDouble(nodeList[0].InnerText); } if (FREIGHTCHARGES != CHARGES) { #region Send email EmailInfo info = new EmailInfo { to = AppCodeConstants.Alex_email, fromAddress = AppCodeConstants.Alex_email, fromName = "Alex", subject = "FREIGHTCHARGES != CHARGES" }; Mail mail = new Mail(ref info); mail.SendEmail(); #endregion } //if (quoteData.isHazmat.Equals(true)) //{ // totalCharges += 20.5; //} nodeList = xmlDoc.GetElementsByTagName("SERVICEDAYS"); int SERVICEDAYS = 0; if (nodeList.Count > 0) { SERVICEDAYS = Convert.ToInt32(nodeList[0].InnerText); volume_result.transit_days = SERVICEDAYS; } nodeList = xmlDoc.GetElementsByTagName("SPOTQUOTEID"); string SPOTQUOTEID = string.Empty; if (nodeList.Count > 0) { SPOTQUOTEID = nodeList[0].InnerText; volume_result.quote_number = SPOTQUOTEID; } volume_result.carrier_name = "USF Holland"; #endregion return(volume_result); } catch (Exception e) { DB.Log("Get_USF_API_Volume_Quote", e.ToString()); Volume_result volume_result = new Volume_result(); return(volume_result); } }