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

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

                SharedRail.ICarrier carrier = new LOUP(parameters);

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

                return(SharedRail.getResultString(ref railResult));
            }
            catch (Exception e)
            {
                HelperFuncs.writeToSiteErrors("get_loup_rates", e.ToString());
                return("0");
            }
        }
Exemple #2
0
        public void Get_LOUP_rates()
        {
            try
            {
                //return "0"; // LOUP had changed their website, need to rewrite scraper

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

                //username=gcm&password=gcm1&originZip=30303&destinationZip=98177&originCity=ATLANTA
                //&destinationCity=SEATTLE&isHazMat=False&pickupDate=6/12/2019

                var data = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("username", ""),
                    new KeyValuePair <string, string>("password", ""),
                    new KeyValuePair <string, string>("originZip", "30303"),
                    new KeyValuePair <string, string>("destinationZip", "98177"),
                    new KeyValuePair <string, string>("originCity", "ATLANTA"),
                    new KeyValuePair <string, string>("destinationCity", "SEATTLE"),
                    new KeyValuePair <string, string>("isHazMat", "False"),
                    new KeyValuePair <string, string>("pickupDate", "6/12/2019")
                };


                FormDataCollection form = new FormDataCollection(data);
                SharedRail.setParameters(ref form, ref parameters, ref CarrierCompID);

                SharedRail.ICarrier carrier = new LOUP(parameters);

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

                //return SharedRail.getResultString(ref railResult);
            }
            catch (Exception e)
            {
                string str = e.ToString();
                //HelperFuncs.writeToSiteErrors("get_loup_rates", e.ToString());
                //return "0";
            }
        }
Exemple #3
0
        // POST api/get_modalx_rates
        public string Post(FormDataCollection form)
        {
            try
            {
                HelperFuncs.writeToSiteErrors("get_ModalX_rates new ", "get_ModalX_rates new ");
                int CarrierCompID = 78573; // Wrong id
                SharedRail.Parameters parameters = new SharedRail.Parameters();
                SharedRail.setParameters(ref form, ref parameters, ref CarrierCompID);

                SharedRail.ICarrier carrier = new ModalX(parameters);

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

                return(SharedRail.getResultString(ref railResult));
            }
            catch (Exception e)
            {
                HelperFuncs.writeToSiteErrors("get_ModalX_rates", e.ToString());
                return("0");
            }
        }
Exemple #4
0
        // POST api/getcsxiinfo
        public string Post(FormDataCollection form)
        {
            #region Not used
            //#region Get form data

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

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

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

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

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

            //#endregion

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

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

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


            //}
            #endregion

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

                SharedRail.ICarrier carrier = new CSXI(parameters);

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

                return(SharedRail.getResultString(ref railResult));
            }
            catch (Exception e)
            {
                HelperFuncs.writeToSiteErrors("get_CSXI_rates", e.ToString());
                return("0");
            }
        }
Exemple #5
0
    public IntermodalRater.railResult getRate()
    {
        try
        {
            HelperFuncs.writeToSiteErrors("LOUP new function", "LOUP new function");

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

            Web_client http = new Web_client();

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

            string doc = http.Make_http_request();

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

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

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

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

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

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

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

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

            //

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

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

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

            doc = http.Make_http_request();

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

            //

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

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

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

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

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

            //
            // Make missing requests

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

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

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

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

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

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

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


            //

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

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

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

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

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

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

            #region Locations requests

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

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

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

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

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

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

            #endregion

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

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

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

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

            doc = http.Make_http_request();

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

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

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

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

            #endregion
        }
    }
Exemple #6
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
        }
    }
Exemple #7
0
    public IntermodalRater.railResult getRate()
    {
        container = new CookieContainer();

        double transitTime = 10;

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

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

            railResultObj = new IntermodalRater.railResult();

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

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

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


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

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

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


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

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

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

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

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

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

            #endregion
        }
    }