コード例 #1
0
ファイル: User.cs プロジェクト: own2pwn/Purchase
        public async Task AddtoCart(Product product)
        {
            var client          = Utilities.HttpClient("https://secure-store.nike.com", Cookies);
            var responseMessage = await client.SendAsync(RequestMessageBuilder.BuildAddProductRequest(this));

            responseMessage.EnsureSuccessStatusCode();
            // "https://secure-store.nike.com/ap/services/jcartService?callback=nike_Cart_handleJCartResponse&action=addItem&lang_locale=zh_CN&country=CN&catalogId=4&productId=10873886&price=1599&siteId=null&line1=Kobe+XI+Elite+Low+BHM&line2=%E7%94%B7%E5%AD%90%E7%AF%AE%E7%90%83%E9%9E%8B&passcode=null&sizeType=null&skuAndSize=15848073%3A42.5&qty=1&rt=json&view=3&skuId=15848073&displaySize=42.5&_=1453400314000"
        }
コード例 #2
0
        public async Task GetProductInfo(User currentUser = null, string url = null)
        {
            var producUrl = url ?? Url;
            var client    = Utilities.HttpClient("http://store.nike.com", new CookieContainer());
            var response  = await client.SendAsync(RequestMessageBuilder.BuildProductInfoRequest(producUrl));

            response.EnsureSuccessStatusCode();
            FillProductInfo(await response.Content.ReadAsStringAsync());
        }
コード例 #3
0
ファイル: User.cs プロジェクト: own2pwn/Purchase
        public async Task GetCartInfo()
        {
            var client = Utilities.HttpClient("https://secure-store.nike.com", Cookies);

            var responseMessage = await client.SendAsync(RequestMessageBuilder.BuildCartInfoRequest(this));

            responseMessage.EnsureSuccessStatusCode();
            Cookies.ReadCookies(responseMessage);
        }
コード例 #4
0
ファイル: User.cs プロジェクト: own2pwn/Purchase
        public async Task GetUserInfo()
        {
            var cookieContainer = new CookieContainer();
            var client          = Utilities.HttpClient("https://www.nike.com", cookieContainer);
            var option          = await client.SendAsync(RequestMessageBuilder.BuildOptionGetUserInfoRequest(Id));

            option.EnsureSuccessStatusCode();

            client = Utilities.HttpClient("https://www.nike.com", Cookies);
            var info = await client.SendAsync(RequestMessageBuilder.BuildGetUserInfoRequest(Id));

            info.EnsureSuccessStatusCode();
            _userInfoContent = JObject.Parse(await info.Content.ReadAsStringAsync());
            FillUserInfo();
        }
コード例 #5
0
        /// <summary>
        /// GetRtmLmps
        /// </summary>
        /// <returns></returns>
        public List <Lmp> GetRtmLmps()
        {
            LogDebug("Calling GetRtmLmps() method...");
            _marketCallType = MarketInfoCallType.LMPs;
            try
            {
                RequestMessageBuilder requestBuilder = new RequestMessageBuilder(SOURCE, CLIENT_CERT_USER_ID);

                /*******************************************************
                *  StartTime and EndTime must be in Central Standard Time.
                *  The conversion will automatically account for Daylight
                *  Savings Time.
                *******************************************************/
                RequestMessage requestmsg = requestBuilder.GetRtmLMPs(
                    TimeZoneInfo.ConvertTime(DateTime.Now.AddMinutes(LMP_REPORT_STARTTIME_OFFSET_MINUTES), TimeZoneInfo.Local, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time")),
                    TimeZoneInfo.ConvertTime(DateTime.Now.AddMinutes(LMP_REPORT_ENDTIME_OFFSET_MINUTES), TimeZoneInfo.Local, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time")), true, true);

                //This is where the rubber meets the road. Calling the service asynchronously with the help of a Task
                LogDebug("Attempting to call Ercot Get LMPs service...");
                //Task serviceTask = new Task(() => _ercotClient.MarketInfoAsync(requestmsg));
                // serviceTask.Start();
                // LogDebug("Ercot Get LMPs service task started...");
                ResponseMessage response = _ercotClient.MarketInfo(requestmsg);
                return(ProcessLMPsCallResults(response.Payload));
            }
            catch (System.Web.Services.Protocols.SoapHeaderException she)
            {
                LogError(she);
                LogDebug(she);
                throw new Exception($"From {System.Reflection.MethodBase.GetCurrentMethod().ToString()}: SOAP Header Exception...");
            }

            catch (System.Reflection.TargetInvocationException te)
            {
                LogError(te);
                LogDebug(te);
                throw new Exception($"From {System.Reflection.MethodBase.GetCurrentMethod().ToString()}: SOAP Header Exception...");
            }

            catch (Exception ex)
            {
                LogError(ex);
                LogDebug(ex);
                throw new Exception($"From {System.Reflection.MethodBase.GetCurrentMethod().ToString()}: SOAP Header Exception...");
            }
        } // end GetRtmLmps() method
コード例 #6
0
        } // end GetRtmLmps() method

        public string GetReport(string reportTypeID)
        {
            LogDebug("Calling GetReport() method...");
            _marketCallType = MarketInfoCallType.Report;
            try
            {
                RequestMessageBuilder requestBuilder = new RequestMessageBuilder(SOURCE, CLIENT_CERT_USER_ID);
                RequestMessage        requestmsg     = requestBuilder.GetReports(null, null, reportTypeID);


                LogDebug("Attempting to call Ercot GetReports service...");

                ResponseMessage response = _ercotClient.MarketInfo(requestmsg);
                LogDebug("Calling ExtractReportFromResponsePayload() method...");
                Report report = ExtractReportFromResponsePayload(response.Payload);
                LogDebug("Creating ScreenScraper object...");
                ScreenScraper sc = new ScreenScraper();
                LogDebug("Extracting csv report contents from zip file...");
                string csv_report_contents = sc.ExtractCsvFileForReportInMemory(report);
                return(csv_report_contents);
            }
            catch (System.Web.Services.Protocols.SoapHeaderException she)
            {
                LogError(she);
                LogDebug(she);
                throw new Exception($"From {System.Reflection.MethodBase.GetCurrentMethod().ToString()}: SOAP Header Exception...");
            }

            catch (System.Reflection.TargetInvocationException te)
            {
                LogError(te);
                LogDebug(te);
                throw new Exception($"From {System.Reflection.MethodBase.GetCurrentMethod().ToString()}: SOAP Header Exception...");
            }

            catch (Exception ex)
            {
                LogError(ex);
                LogDebug(ex);
                throw new Exception($"From {System.Reflection.MethodBase.GetCurrentMethod().ToString()}: SOAP Header Exception...");
            }
        }
コード例 #7
0
ファイル: User.cs プロジェクト: own2pwn/Purchase
        //    public bool Login()
        //    {
        //      var client = new RestClient("https://www.nike.com");
        //      var request = Request.Login(this);
        //      var response = client.Execute(request);
        //      if (response.StatusCode == HttpStatusCode.OK)
        //      {
        //        _content = JObject.Parse(response.Content);
        //        Id = _content["entity"]["id"].ToString();
        //        NikePlusId = _content["entity"]["nikePlusId"].ToString();
        //        ExternalUserId = _content["entity"]["externalUserId"].ToString();
        //        Cookies = response.Cookies;
        //        return true;
        //      }
        //      return false;
        //    }

        public async Task LoginByHttpHandler()
        {
            HttpClient client  = Utilities.HttpClient("https://www.nike.com", Cookies);
            var        content = new FormUrlEncodedContent(new[]
            {
                new KeyValuePair <string, string>("login", Username),
                new KeyValuePair <string, string>("password", Password),
                new KeyValuePair <string, string>("rememberMe", "false"),
            });

            var option = await client.SendAsync(RequestMessageBuilder.BuildOptionLoginRequest());

            option.EnsureSuccessStatusCode();

            var post = await client.SendAsync(RequestMessageBuilder.BuildPostLoginRequest(content));

            post.EnsureSuccessStatusCode();
            Cookies.ReadCookies(post);
            _content = JObject.Parse(await post.Content.ReadAsStringAsync());
            FillUserId();
        }
コード例 #8
0
        public List <Lmp> GetRtmLmps()
        {
            LogDebug("Calling GetRtmLmps() method...");
            _marketCallType = MarketInfoCallType.LMPs;
            try
            {
                RequestMessageBuilder requestBuilder = new RequestMessageBuilder(SOURCE, CLIENT_CERT_USER_ID);
                RequestMessage        requestmsg     = requestBuilder.GetRtmLMPs(DateTime.Now.AddMinutes(-1.00), DateTime.Now);

                //This is where the rubber meets the road. Calling the service asynchronously with the help of a Task
                LogDebug("Attempting to call Ercot Get LMPs service...");
                //Task serviceTask = new Task(() => _ercotClient.MarketInfoAsync(requestmsg));
                // serviceTask.Start();
                // LogDebug("Ercot Get LMPs service task started...");
                ResponseMessage response = _ercotClient.MarketInfo(requestmsg);
                return(ProcessLMPsCallResults(response.Payload));
            }
            catch (System.Web.Services.Protocols.SoapHeaderException she)
            {
                LogError(she);
                LogDebug(she);
            }

            catch (System.Reflection.TargetInvocationException te)
            {
                LogError(te);
                LogDebug(te);
            }

            catch (Exception ex)
            {
                LogError(ex);
                LogDebug(ex);
            }

            return(_lmpList);
        }
コード例 #9
0
 public void TestSetup()
 {
     buffer  = new byte[128];
     builder = new RequestMessageBuilder(buffer);
 }