示例#1
0
    private static void getPurchasedInfo_ModalX(ref SharedRail.ModalX_PurchasedBy purchasedBy, ref string doc)
    {
        string[] tokens = new string[4];
        tokens[0]         = "email";
        tokens[1]         = ":";
        tokens[2]         = "\"";
        tokens[3]         = "\"";
        purchasedBy.email = HelperFuncs.scrapeFromPage(tokens, doc);

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

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

        tokens[0]        = "fullName";
        purchasedBy.name = HelperFuncs.scrapeFromPage(tokens, doc);
    }
示例#2
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);
    }
示例#3
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);
    }