public List<StockQuote> GetStockQuotes(List<string> StockSymbols)
        {
            if (StockSymbols == null || StockSymbols.Count == 0)
            {
                return new List<StockQuote>();
            }

            var symbolsFormatted = StockSymbols.Select(x => "\"" + x + "\"").ToList();
            var yqlQuery = "select * from yahoo.finance.quotes where symbol in (" + string.Join(",", symbolsFormatted) + ")";

            var requestUrl = this.BaseAPIUrl + "?q=" + Uri.EscapeDataString(yqlQuery);
            requestUrl += "&format=json&env=http://datatables.org/alltables.env";

            if (StockSymbols.Count > 1)
            {
                var quotes = new HttpRequestHelper().PerformRequest<YahooFinanceStockQuoteResponseMultiple>(requestUrl);
                if (quotes == null || quotes.query == null || quotes.query.results == null)
                {
                    return null;
                }
                return quotes.query.results.quote;
            }
            else
            {
                var quotes = new HttpRequestHelper().PerformRequest<YahooFinanceStockQuoteResponseSingle>(requestUrl);
                if (quotes == null || quotes.query == null || quotes.query.results == null || quotes.query.results.quote == null)
                {
                    return null;
                }
                return new List<StockQuote> { quotes.query.results.quote };
            }
        }
 public Task <Brand> GetBrandAsync(int brandId)
 {
     try
     {
         SetCache();
         string url = string.Format("http://{0}/api/{1}/GetBrandAsync" +
                                    "?brandId={2}", WebServiceAddress, ApiControllerName, brandId);
         return(HttpRequestHelper.GetUrlResultAsync <Brand>(url));
     }
     catch (Exception ex)
     {
         Logger.Error(ex, "API:GetBrandAsync", brandId);
         return(null);
     }
 }
        //根据微信小程序登录返回code取用户信息
        private IDictionary <string, object> GetOpenId(string jsCode)
        {
            string appId     = AppConfigurtaionHelper.Configuration.GetValue <string>("AuthSetting:AppID");
            string appSecret = AppConfigurtaionHelper.Configuration.GetValue <string>("AuthSetting:AppSecret");
            string url       = $"https://api.weixin.qq.com/sns/jscode2session";
            IDictionary <string, object> data = new Dictionary <string, object>();

            data.Add("appid", appId);
            data.Add("secret", appSecret);
            data.Add("js_code", jsCode);
            data.Add("grant_type", "authorization_code");
            string res = HttpRequestHelper.Request(url, "get", "", data);

            return(JsonConvert.DeserializeObject <IDictionary <string, object> >(res));
        }
Esempio n. 4
0
        /// <summary>
        /// Returns the Web proxy that Writer is configured to use.
        /// </summary>
        public static IWebProxy GetWriterProxy()
        {
            IWebProxy proxy = HttpRequestHelper.GetProxyOverride();

            if (proxy == null)
            // TODO: Some plugins (like Flickr4Writer) cast this to a WebProxy
            // Since the fix for this returns an explicit IWebProxy, we'll need to have
            // the Flickr4Writer plugin fixed, then alter this to use the correct call.
#pragma warning disable 612,618
            {
                proxy = System.Net.WebProxy.GetDefaultProxy();
            }
#pragma warning restore 612, 618
            return(proxy);
        }
Esempio n. 5
0
        public async Task <IActionResult> GoodsShelve(GoodsIdModel model)
        {
            var applicationUser = await _userManager.GetUserAsync(new System.Security.Claims.ClaimsPrincipal(User.Identity));

            if (applicationUser == null || string.IsNullOrEmpty(applicationUser.OrganizationId))
            {
                return(new JsonResult(new { Code = "400", Message = "用户登录异常,请先登录。" }));
            }
            var url = "http://goodsservice.gooios.com/api/goods/v1/shelvegoods";

            var jsonObj = JsonConvert.SerializeObject(model);
            await HttpRequestHelper.PutNoResultAsync(url, jsonObj, "63e960bff18111e79916012cc8e9f005", applicationUser.Id);

            return(new JsonResult(new { Code = "200", Message = "上架成功。" }));
        }
Esempio n. 6
0
        public async Task <IActionResult> OrderDetail(string id = null)
        {
            var applicationUser = await _userManager.GetUserAsync(new System.Security.Claims.ClaimsPrincipal(User.Identity));

            if (applicationUser == null || string.IsNullOrEmpty(applicationUser.OrganizationId))
            {
                return(RedirectToAction("Login", "Account"));
            }


            OrderModel model = string.IsNullOrEmpty(id) ? null : await HttpRequestHelper.GetAsync <OrderModel>($"http://orderservice.gooios.com/api/order/v1/orderid/{id}", "", "77e960be918111e709189226c7e9f002", applicationUser.Id);


            return(View(model));
        }
 public Task <StorePagedList <Brand> > GetBrandsByStoreIdWithPagingAsync(int storeId, bool?isActive, int page = 1, int pageSize = 25)
 {
     try
     {
         SetCache();
         string url = string.Format("http://{0}/api/{1}/GetBrandsByStoreIdWithPagingAsync" +
                                    "?storeId={2}&isActive={3}page={4}pageSize={5}", WebServiceAddress, ApiControllerName, storeId, isActive, page, pageSize);
         return(HttpRequestHelper.GetUrlPagedResultsAsync <Brand>(url));
     }
     catch (Exception ex)
     {
         Logger.Error(ex, "API:GetBrandsByStoreIdWithPagingAsync", storeId, isActive, page, pageSize);
         return(null);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 获取用户基本信息,返回JSON数据包
        /// </summary>
        /// <param name="access_token">访问令牌</param>
        /// <param name="openid">普通用户的标识,对当前公众号唯一</param>
        /// <returns>UserModel</returns>
        public static UserModel GetUserInfo(string access_token, string openid)
        {
            if (string.IsNullOrEmpty(access_token) || string.IsNullOrEmpty(openid))
            {
                return(new UserModel());
            }
            string url    = string.Format("https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}", access_token, openid);
            string result = HttpRequestHelper.Request(url, HttpRequestHelper.Method.GET);

            if (!string.IsNullOrEmpty(result))
            {
                return(JsonHelper.DeSerialize <UserModel>(result));
            }
            return(new UserModel());
        }
 public Task <StorePagedList <ProductCategory> > GetProductCategoriesByStoreIdAsync(int storeId, string type, bool?isActive, int page, int pageSize = 25)
 {
     try
     {
         SetCache();
         string url = string.Format("http://{0}/api/{1}/GetProductCategoriesByStoreIdAsync?storeId={2}&type={3}&isActive={4}&page={5}&pageSize={6}",
                                    WebServiceAddress, ApiControllerName, storeId, type, isActive, page, pageSize);
         return(HttpRequestHelper.GetUrlPagedResultsAsync <ProductCategory>(url));
     }
     catch (Exception ex)
     {
         Logger.Error(ex, ex.Message);
         return(null);
     }
 }
Esempio n. 10
0
        public void TestMethod2()
        {
            //EUC-KR
            var url = "http://www.bktech.co.kr/";
            var res = HttpRequestHelper.GetData(url);

            Assert.IsTrue(res.IsSuccessful && res.StatusCode == HttpStatusCode.OK);

            var encoding = HttpHelper.GetEncoding(res.RawBytes, res.ContentType);

            Assert.IsTrue(Equals(encoding, Encoding.GetEncoding("EUC-KR")));
            var content = encoding.GetString(res.RawBytes);

            Assert.IsTrue(content.Contains("(주)부광테크"));
        }
        private async void PopulateView()
        {
            try
            {
                var user = JsonConvert.DeserializeObject <User>(await HttpRequestHelper.GetUserByEmailRemote(ViewBag.Email));

                if (user != null)
                {
                    this.PopulateTransactions(user);
                }
            }
            catch
            {
            }
        }
Esempio n. 12
0
        public async Task <IActionResult> ServicerDelete(ServicerIdModel model)
        {
            var applicationUser = await _userManager.GetUserAsync(new System.Security.Claims.ClaimsPrincipal(User.Identity));

            if (applicationUser == null || string.IsNullOrEmpty(applicationUser.OrganizationId))
            {
                return(new JsonResult(new { Code = "400", Message = "用户登录异常,请先登录。" }));
            }
            var url = $"http://fancyservice.gooios.com/api/servicer/v1/suspend?id={model.Id}";

            var jsonObj = JsonConvert.SerializeObject(model);
            await HttpRequestHelper.PutNoResultAsync(url, jsonObj, "768960bff18111e79916016898e9f885", applicationUser.Id);

            return(new JsonResult(new { Code = "200", Message = "删除成功。" }));
        }
Esempio n. 13
0
        public void PostJsonGetJsonWithHttpRequestHelperWcfHelloWorldWithArgsInOut()
        {
            Uri uri = NormalizeUri("TestAjaxService.svc/HelloWorldWithArgsInOut");
            Dictionary <string, object> postData = new Dictionary <string, object>();

            // if you have a reference to the type expected you can serialize an instance
            // or just simply create an anonymous type that is shaped like the type expected...
            postData.Add("args", new { Message = "HI!" });

            string json = HttpRequestHelper.AjaxTxt(uri, postData, null);

            Assert.AreEqual(
                "{\"d\":{\"__type\":\"HelloWorldArgs:#CassiniDev.FixtureExamples.TestWeb\",\"Message\":\"you said: HI!\"}}",
                json);
        }
Esempio n. 14
0
        private BlockInfoResult GetBlockInfo(string chainId, ulong height)
        {
            var jsonRpcArg = new JsonRpcArg <BlockInfoArg>();

            jsonRpcArg.Method = "get_block_info";
            jsonRpcArg.Params = new BlockInfoArg
            {
                BlockHeight = height,
                IncludeTxs  = false
            };

            var blockInfo = HttpRequestHelper.Request <JsonRpcResult <BlockInfoResult> >(ServiceUrlHelper.GetRpcAddress(chainId) + "/chain", jsonRpcArg);

            return(blockInfo.Result);
        }
Esempio n. 15
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            //drawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
            //LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
            //View contentView = inflater.Inflate(Resource.Layout.Reciept, null, false);
            //drawerLayout.AddView(contentView);
            SetContentView(Resource.Layout.Reciept);
            TextView      storeUsernameText = FindViewById <TextView>(Resource.Id.txtUsername);
            SessionHelper sessionHelper     = new SessionHelper(this);
            string        Username          = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERNAME_KEY);
            string        UserID            = sessionHelper.GetSessionKey(SessionKeys.SESSION_USERID_KEY);
            string        AuthToken         = sessionHelper.GetSessionKey(SessionKeys.SESSION_TOKEN_KEY);

            storeUsernameText.Text = "Hello " + Username;

            EditText recieptName   = FindViewById <EditText>(Resource.Id.editrecieptTxt);
            Button   btnAddReciept = FindViewById <Button>(Resource.Id.addreciept);

            JsonValue jsonReciept = await HttpRequestHelper <RecieptEntity> .GetRequest(ServiceTypes.GetReciepts, "/" + AuthToken + "/" + UserID);

            ParseRecieptJSON(jsonReciept);

            btnAddReciept.Click += async(sender, e) =>
            {
                try
                {
                    RecieptDTO recieptDTO = new RecieptDTO();
                    recieptDTO.CreatedOn = DateTime.Now.ToString();
                    recieptDTO.Name      = recieptName.Text;
                    recieptDTO.StoreID   = Convert.ToInt32(UserID);
                    recieptDTO.Status    = ((int)ReceiptStatusEnum.New).ToString();
                    RecieptEntity recieptEntity = new RecieptEntity {
                        AuthToken = AuthToken, recieptDTO = recieptDTO
                    };
                    JsonValue json = await HttpRequestHelper <RecieptEntity> .POSTreq(ServiceTypes.AddReciept, recieptEntity);

                    ParseJSON(json);

                    JsonValue jsonReciept1 = await HttpRequestHelper <RecieptEntity> .GetRequest(ServiceTypes.GetReciepts, "/" + AuthToken + "/" + UserID);

                    ParseRecieptJSON(jsonReciept1);
                }
                catch (Exception ex)
                {
                }
            };
        }
        public void DefaultDIConstructor()
        {
            // Arrange
            var uri         = new Uri("http://tempuri.org");
            var credentials = new EsendexCredentials("username", "password");
            IHttpRequestHelper  httpRequestHelper  = new HttpRequestHelper();
            IHttpResponseHelper httpResponseHelper = new HttpResponseHelper();

            IHttpClient httpClient = new HttpClient(credentials, uri, httpRequestHelper, httpResponseHelper);

            // Act
            var restClientInstance = new RestClient(httpClient);

            // Assert
            Assert.That(restClientInstance.HttpClient, Is.InstanceOf <HttpClient>());
        }
Esempio n. 17
0
        public void TestMethod3()
        {
            //BIG5 Transfer-Encoding: chunked
            var url = "http://www.wenweipo.com/";
            var res = HttpRequestHelper.GetData(url);

            Assert.IsTrue(res.IsSuccessful && res.StatusCode == HttpStatusCode.OK);

            var encoding = HttpHelper.GetEncoding(res.RawBytes, res.ContentType);

            Assert.IsTrue(Equals(encoding, Encoding.GetEncoding("BIG5")));

            var content = encoding.GetString(res.RawBytes);

            Assert.IsTrue(content.Contains("香港文匯網"));
        }
Esempio n. 18
0
        public static ApplicationUserLogin CreateUserLogin(string accessToken)
        {
            var resp = HttpRequestHelper.GetAsync($"https://www.googleapis.com/plus/v1/people/me?fields=id%2Cemails%2Fvalue&access_token={accessToken}").Result;

            var json      = resp.Content.ReadAsStringAsync().Result;
            var googleDto = JsonConvert.DeserializeObject <GoogleDto>(json);

            var userLogin = new ApplicationUserLogin
            {
                Provider         = ProviderName,
                ProviderUserId   = googleDto.Id,
                ProviderUsername = googleDto.Emails.FirstOrDefault()?.Value
            };

            return(userLogin);
        }
Esempio n. 19
0
        public async Task <UpdatePushTokenResponse> SendPushToServer(string token)
        {
            UpdatePushTokenResponse updateDeviceTokenResponse = new UpdatePushTokenResponse();

            if (!String.IsNullOrEmpty(SessionHelper.AccessToken))
            {
                UpdatePushTokenRequest updateDeviceTokenRequest = new UpdatePushTokenRequest();
                updateDeviceTokenRequest.DevicePushToken = token;
                updateDeviceTokenRequest.DeviceType      = Device.RuntimePlatform;
                updateDeviceTokenRequest.AuthToken       = SessionHelper.AccessToken;
                System.Json.JsonValue updateUserResponse = await HttpRequestHelper <UpdatePushTokenRequest> .POSTreq(ServiceTypes.UpdatePushToken, updateDeviceTokenRequest);

                updateDeviceTokenResponse = JsonConvert.DeserializeObject <UpdatePushTokenResponse>(updateUserResponse.ToString());
            }
            return(updateDeviceTokenResponse);
        }
Esempio n. 20
0
        //
        // GET: /Tribune/

        public ActionResult Index()
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            //dic.Add("secretKey", "8a90899456fd0bdd0156fd4a1db6001b");
            //dic.Add("userNo", "000091");
            dic.Add("param", "000091");
            HttpWebResponse res = HttpRequestHelper.CreatePostHttpResponse("http://localhost:8010/Portal/KeepAlive/KeepAlivePage.aspx/KeepAliveData", dic, null, "", Encoding.UTF8, null);
            //HttpWebResponse res = HttpRequestHelper.CreatePostHttpResponse("http://localhost:56403/Tribune/HttpTest", dic, null, "", Encoding.UTF8, null);
            Stream stream = res.GetResponseStream();
            //StreamReader类的Read方法依次读取网页源程序代码每一行的内容,直至行尾(读取的编码格式:UTF8)
            StreamReader respStreamReader = new StreamReader(stream, Encoding.UTF8);
            string       s = respStreamReader.ReadToEnd();

            return(View());
        }
Esempio n. 21
0
        /// <summary>
        /// 获取国家对应的经济指标集合(不分大项)
        /// </summary>
        /// <param name="countryId"></param>
        /// <param name="addpar"></param>
        /// <returns></returns>
        public ReturnModel GetIndicaByCountryId(int countryId)
        {
            var rm = new ReturnModel();

            try
            {
                Dictionary <string, object> parms = new Dictionary <string, object>();
                parms.Add("countryId", countryId);
                rm = HttpRequestHelper.GetRequest <ReturnModel>(HttpApiHelper.CreateHttpApiCall(CustomConfig.ApiMacroeData, apiIndicaByCountryId), parms);
            }
            catch (Exception ex)
            {
                rm.bodyMessage = ex.Message;
            }
            return(rm);
        }
Esempio n. 22
0
        internal static void SendMessage(string accessToken, MassJsonMessage msg)
        {
            string url  = string.Format("https://api.weixin.qq.com/cgi-bin/message/mass/send?access_token={0}", accessToken);
            var    json = msg.GetJson();

            Log.Debug("\r\n群发消息 json 数据:>>\r\n{0}", json);
            var resultJson = HttpRequestHelper.PostHttp_ForamtByJson(url, json);

            Log.Debug("\r\n群发消息 json 返回值:>>\r\n{0}", resultJson);
            var returnCode = GlobalReturnCode.GetReturnCode(resultJson);

            if (!returnCode.IsRequestSuccess)
            {
                throw new WeixinRequestApiException(string.Format("发送群发消息失败\r\n全局返回值:{0}\r\n对应说明:{1}\r\nJson:{2}\r\n请求路径:{3}", returnCode.ErrCode, returnCode.Msg, returnCode.Json, url), returnCode);
            }
        }
Esempio n. 23
0
        /// <summary>
        /// 根据ID获取经济指标详情数据
        /// </summary>
        /// <param name="mainItemId"></param>
        /// <returns></returns>
        public ReturnModel GetEcoItemDetails(string mainItemId)
        {
            var rm = new ReturnModel();

            try
            {
                Dictionary <string, object> parms = new Dictionary <string, object>();
                parms.Add("mainItemId", mainItemId);
                rm = HttpRequestHelper.GetRequest <ReturnModel>(HttpApiHelper.CreateHttpApiCall(CustomConfig.ApiMacroeData, apiGetEcoItemDetails), parms);
            }
            catch (Exception ex)
            {
                rm.bodyMessage = ex.Message;
            }
            return(rm);
        }
Esempio n. 24
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static string CommSendMessageTest(string data)
        {
            string accessToken = CommMsgParam.GetAccessToken();
            string result      = string.Empty;

            try
            {
                string url = string.Format("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}", accessToken);
                return(HttpRequestHelper.HttpPostWebRequest(url, 100000, data));//post发送数据
            }
            catch (Exception ex)
            {
                Log4NetHelper.WriteExceptionLog("发送消息异常", ex, data, result);//记录异常
                return("异常");
            }
        }
Esempio n. 25
0
        public static ApplicationUserLogin CreateUserLogin(string accessToken)
        {
            var resp = HttpRequestHelper.GetAsync($"https://graph.facebook.com/v2.8/me?access_token={accessToken}&fields=id,email").Result;

            var json        = resp.Content.ReadAsStringAsync().Result;
            var facebookDto = JsonConvert.DeserializeObject <FacebookDto>(json);

            var userLogin = new ApplicationUserLogin
            {
                Provider         = ProviderName,
                ProviderUserId   = facebookDto.Id,
                ProviderUsername = facebookDto.Email
            };

            return(userLogin);
        }
Esempio n. 26
0
        private void DownloadAndInstall(Tree tree, GitObject plugin)
        {
            var name        = plugin.name.ToLower().Replace("plugin", "");
            var url         = tree.url;
            var folder      = HttpRequestHelper.Get <GitTreeRoot>(url);
            var fileDetails = HttpRequestHelper.Get <GitTreeRoot>(folder.tree.FirstOrDefault().url);
            var file        = HttpRequestHelper.Get <GitFile>(fileDetails.url);
            var bytes       = Convert.FromBase64String(file.content);

            File.WriteAllBytes($"{Configuration.BaseDirectory}/Plugins/{plugin.name}.dll", bytes);
            Configuration.Reload();
            var isSuccess = Configuration.Domains.Any(a => a.FriendlyName.Contains(plugin.name));
            var message   = isSuccess ? "Success" : "Failed";

            _consoleWriter.Write($"\rInstalling {name} Plugin...{message}\r\n");
        }
        /// <summary>
        /// Delete current user
        /// </summary>
        public void DeleteUser()
        {
            if (UserToken.Token == "")
            {
                return;
            }

            var httpResponse = HttpRequestHelper.DeleteAsync(Endpoint, UserToken.Token).Result;
            var body         = HttpRequestHelper.GetContent(httpResponse).Result;
            var statusCode   = HttpRequestHelper.GetStatusCode(httpResponse);

            if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.NoContent)
            {
                throw new Exception(body);
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Delete the game identified by the given hash id
        /// </summary>
        /// <param name="gameHashId"></param>
        public void DeleteGame(string gameHashId)
        {
            if (string.IsNullOrWhiteSpace(gameHashId))
            {
                return;
            }

            var httpResponse = HttpRequestHelper.DeleteAsync(Endpoint + "/one/" + gameHashId, UserToken.Token).Result;
            var body         = HttpRequestHelper.GetContent(httpResponse).Result;
            var statusCode   = HttpRequestHelper.GetStatusCode(httpResponse);

            if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.NoContent)
            {
                throw new Exception(body);
            }
        }
        public InventoryResponse GetInventory(long userId, int appId)
        {
            var url      = $"{_apiUrl}/{userId}/{appId}/2";
            var response = new HttpRequestHelper().SendGet(url);

            if (!string.IsNullOrEmpty(response))
            {
                return(JsonConvert.DeserializeObject <InventoryResponse>(response));
            }
            else
            {
                //TOOD: log it
                Console.WriteLine("An error occured while inventory fetch");
                return(null);
            }
        }
Esempio n. 30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="postData"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public async Task <T> PostRequestAsync <T>(Uri uri, string postData)
        {
            _trace.TraceEvent(TraceEventType.Verbose, 0, "RequestHandler.Deserialize:Start");
            string data;

            try {
                data = await HttpRequestHelper.PostRequestAsync(uri, postData).ConfigureAwait(false);
            }
            catch (WebException e) {
                throw new EveLibWebException("A request caused a WebException.", e.InnerException as WebException);
            }
            var val = Serializer.Deserialize <T>(data);

            _trace.TraceEvent(TraceEventType.Verbose, 0, "RequestHandler.Deserialize:Complete");
            return(val);
        }
Esempio n. 31
0
        /// <summary>
        /// 获得品种详情信息
        /// </summary>
        /// <param name="plate"></param>
        /// <param name="pagesize"></param>
        /// <param name="pageindex"></param>
        /// <returns></returns>
        public ReturnModel GetQueryMarketDetail(int marketid)
        {
            var rm = new ReturnModel();

            try
            {
                Dictionary <string, object> parms = new Dictionary <string, object>();
                parms.Add("marketid", marketid);
                rm = HttpRequestHelper.GetRequest <ReturnModel>(HttpApiHelper.CreateHttpApiCall(CustomConfig.ApiQuote, apiQueryQuote, "QueryMarketDetail"), parms);
            }
            catch (Exception ex)
            {
                rm.bodyMessage = ex.Message;
            }
            return(rm);
        }
        public void GetWebFormWithHttpRequestHelperAndParseWithMSHTML()
        {
            Uri requestUri = NormalizeUri("default.aspx");

            string responseText = HttpRequestHelper.Get(requestUri, null, null);
            Assert.IsTrue(responseText.IndexOf("This is the default document of the TestWebApp") > 0);
            using (HttpRequestHelper browser = new HttpRequestHelper())
            {
                // parse the html in internet explorer
                IHTMLDocument2 doc = browser.ParseHtml(responseText);
                // get the resultant html
                string content = doc.body.outerHTML;
                Assert.IsTrue(content.IndexOf("This is the default document of the TestWebApp") > 0);
                IHTMLElement form = browser.FindElementByID("form1");
                Assert.IsNotNull(form);
            }
        }
        public void GetHtmlWithHttpRequestHelperAndParseWithMSHTMLAndVerifyJavascriptExecution()
        {
            Uri jsUri = NormalizeUri("TestJavascript.htm");

            string responseText = HttpRequestHelper.Get(jsUri, null, null);
            using (HttpRequestHelper browser = new HttpRequestHelper())
            {
                // parse the html in internet explorer
                IHTMLDocument2 doc = browser.ParseHtml(responseText);

                // get the resultant html
                string content = doc.body.outerHTML;

                Assert.IsTrue(content.IndexOf("HEY IM IN A SCRIPT") > 0, "inline script document.write not executed");
                Assert.IsTrue(content.IndexOf("this is some text from javascript") == -1,
                              "if failed then event driven script document.appendChile executed!");
            }
        }
 public FreeSsLinkScrapper()
 {
     _requestHelper = new HttpRequestHelper();
     TheServerInfos = new List<SsServerInfo>();
 }
Esempio n. 35
0
 public WeatherForecastModel GetWeatherForecast(int zipCode)
 {
     var requestUrl = this.BaseAPIUrl + "forecast?zip=" + zipCode + ",us&appid=" + this.APIKey + "&cnt=12";
     var weather = new HttpRequestHelper().PerformRequest<WeatherForecastModel>(requestUrl);
     return weather;
 }
Esempio n. 36
0
 public CurrentWeatherModel GetCurrentWeather(int zipCode)
 {
     var requestUrl = this.BaseAPIUrl + "weather?zip=" + zipCode + ",us&appid=" + this.APIKey;
     var weather = new HttpRequestHelper().PerformRequest<CurrentWeatherModel>(requestUrl);
     return weather;
 }
Esempio n. 37
0
        private string GetCurrentUserID()
        {
            string token = HttpContext.Current.Request.Headers.Get("accessToken");
            if (string.IsNullOrWhiteSpace(token))
            {
                return null;
            }


            string id;
            if (!useridcache.TryGetValue(token, out id))
            {
                var requestUrl = Constants.ExternalAPIs.Facebook.GetUserRequestUrl(token);

                var userobj = new HttpRequestHelper().PerformRequest<FacebookUserInfo>(requestUrl);
                if (userobj == null || userobj.id == null)
                {
                    return null;
                }
                id = userobj.id;

                lock (useridcache)
                {
                    if (!useridcache.ContainsKey(token))
                        useridcache.Add(token, id);
                }
            }
            return id;
        }
 public FreeiShadowsocksScrapper()
 {
     _requestHelper = new HttpRequestHelper();
     TheServerInfos = new List<SsServerInfo>();
 }