Esempio n. 1
0
    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);
    }
Esempio n. 2
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);
        }
Esempio n. 3
0
    public IntermodalRater.railResult getRate_Old()
    {
        try
        {
            //HelperFuncs.writeToSiteErrors("Streamline", "hit func");

            #region Variables

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

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

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

            #endregion

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

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

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

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

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

            // getLocationInfo_Streamline

            //

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

            //

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

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

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

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

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

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

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

            railResultObj = new IntermodalRater.railResult();

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

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

                scrapeResult(ref ratesDoc);

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

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

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

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

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

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

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

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

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

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

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

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

                    #endregion
                }

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



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

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

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

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

                        return(railResultObj);
                    }
                }

                #endregion
            }

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

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

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

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

            //    return;
            //}
            #endregion

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

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

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

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

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

                return(railResultObj);

                #endregion
            }

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

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

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

            #endregion
        }
    }
Esempio n. 4
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
    }
Esempio n. 5
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);
    }
Esempio n. 6
0
    private void loginTo_ModalX(ref HelperFuncs.ModalX_Result res)
    {
        #region Variables

        DateTime now      = DateTime.Now;
        DateTime today    = DateTime.Today;
        DateTime tomorrow = DateTime.Today.AddDays(3);

        Int64 timeStampNow      = SharedRail.GetTime(ref now);
        Int64 timeStampToday    = SharedRail.GetTime(ref today);
        Int64 timeStampTomorrow = SharedRail.GetTime(ref tomorrow);

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

        #endregion

        #region Go to home page

        url         = "https://www.modal-x.com/modalx/";
        referrer    = "";
        contentType = "";
        accept      = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
        method      = "GET";
        doc         = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, "", false, false, "", "");

        #endregion

        #region 2 requests with username and password

        referrer = url;
        url      = "https://www.modal-x.com/tw-services/modalx/v1.0.0/TDIS/users/" + username + "/login?_dc=" + timeStampNow.ToString();

        //HelperFuncs.writeToSiteErrors("ModalX", url);
        // Here the request throws a 401 Not Authorized exception, but this is what happens if the ModalX site is used by any Browser as well
        try
        {
            doc = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, "", false, false, "", "");
        }
        catch (Exception e)
        {
            string str = e.ToString();
        }

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

        url         = "https://www.modal-x.com/tw-services/modalx/v1.0.0/TDIS/users/" + username + "/login/j_security_check";
        contentType = "application/x-www-form-urlencoded; charset=UTF-8";
        method      = "POST";
        data        = "j_username="******"@", "%40") + "&j_password="******"string", container, url, referrer, contentType, accept, method, data, false, false, "", "");

        //HelperFuncs.writeToSiteErrors("ModalX", url);
        //HelperFuncs.writeToSiteErrors("ModalX", data);
        #endregion

        #region Some required requests
        //--------------------------------------------------------------------------------------------------------------------

        timeStampNow = SharedRail.GetTime(ref now);

        url         = "https://www.modal-x.com/tw-services/modalx/v1.0.0/TDIS/users/" + username + "/login?_dc=" + timeStampNow.ToString();
        contentType = "";
        accept      = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
        method      = "GET";
        doc         = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, "", false, false, "", "");
        // Get user info here
        SharedRail.ModalX_PurchasedBy purchasedBy = new SharedRail.ModalX_PurchasedBy();
        getPurchasedInfo_ModalX(ref purchasedBy, ref doc);
        //--------------------------------------------------------------------------------------------------------------------

        timeStampNow = SharedRail.GetTime(ref now);

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

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

        timeStampNow = SharedRail.GetTime(ref now);

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

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

        timeStampNow = SharedRail.GetTime(ref now);

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

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

        #region Not used
        //Cookie cookie = new System.Net.Cookie("modal-x_user", "");
        //container.Add(cookie);
        //Uri uri = new Uri("https://www.modal-x.com/");
        //container.Add(uri, cookie);
        #endregion

        #region This request is the final step of the login process, and goes to landing page with some recent shipments displayed

        //url = "https://www.modal-x.com/tw-services/modalx/v1.0.0/TDIS/requests/search?isSummary=true";
        url         = "https://www.modal-x.com/tw-services/modalx/v1.0.0/TDIS/requests/summary/search";
        contentType = "application/json; charset=UTF-8";
        method      = "POST";
        data        = "{\"minPickup\":" + timeStampToday.ToString() + ",\"maxPickup\":\"\"}";
        doc         = (string)HelperFuncs.generic_http_request_3("string", container, url, referrer, contentType, accept, method, data, false, false, "", "");

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

        SharedRail.RailResult railResult = new SharedRail.RailResult();
        tryDate_ModalX(ref railResult, ref tomorrow, ref timeStampTomorrow, ref referrer, ref timeStampNow, ref now,
                       ref purchasedBy, ref res);
    }
Esempio n. 7
0
    private void GetResultObjectFromUSFReddaway(ref GCMRateQuote gcmRateQuote)
    {
        try
        {
            Logins.Login_info login_info;
            Logins            logins = new Logins();
            logins.Get_login_info(120, out login_info);

            string url = string.Concat("https://api.reddawayregional.com/api/RateQuote/doRateQuote?accessKey=",
                                       login_info.API_Key,

                                       "&accountId=", acctInfo.acctNum,
                                       "&originZipCode=", quoteData.origZip, "&destZipCode=", quoteData.destZip, "&direction=3rdParty&chargeType=", acctInfo.chargeType,
                                       "&AspxAutoDetectCookieSupport=1");

            for (byte i = 1; i <= quoteData.m_lPiece.Length; i++)
            {
                url += string.Concat("&shipmentClass", i, "=", quoteData.m_lPiece[i - 1].FreightClass,
                                     "&shipmentWeight", i, "=", quoteData.m_lPiece[i - 1].Weight);
            }

            string responseFromServer = (string)HelperFuncs.generic_http_request_3("string", null, url, "", "",
                                                                                   "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "GET", "", false, false, "", "");

            //DB.Log("USFReddawayPrepaid responseFromServer", responseFromServer);

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(responseFromServer);
            XmlNodeList nodeList     = xmlDoc.GetElementsByTagName("TOTAL_COST");
            double      totalCharges = 0;
            if (nodeList.Count > 0)
            {
                totalCharges = Convert.ToDouble(nodeList[0].InnerText);
            }

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

            nodeList = xmlDoc.GetElementsByTagName("SERVICEDAYS");
            int standardDays = 0;
            if (nodeList.Count > 0)
            {
                standardDays = Convert.ToInt32(nodeList[0].InnerText);
            }

            nodeList = xmlDoc.GetElementsByTagName("ASCLASS");

            int transitDays;
            transitDays = standardDays;

            gcmRateQuote.TotalPrice = totalCharges;

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

            gcmRateQuote.DeliveryDays = transitDays;
        }
        catch (Exception exp)
        {
            gcmRateQuote = null;
            DB.Log("USFReddawayPrepaid", exp.ToString());
        }
    }