private void FormLoaded(object sender, RoutedEventArgs e)
        {
            // Setup account data
            Account.Account account = new Account.Account();
            account.accessToken = "secret-token-from-your-oanda-account";

            // Get candle data
            HttpGet httpGet = new HttpGet();

            httpGet.accessToken = account.accessToken;
            var data = httpGet.Get("https://api-fxpractice.oanda.com/v1/candles?instrument=EUR_USD&count=30&granularity=D");

            // Deserialize JSON into List<Candle> object
            CandlesResponse candlesResponse = JsonConvert.DeserializeObject <CandlesResponse>(data);

            //List<Candle> candles = new List<Candle>();
            candles = new List <Candle>();
            candles.AddRange(candlesResponse.candles);



            canGraph.Width  = this.ActualWidth;
            canGraph.Height = this.ActualHeight;

            // Draw the graph
            //DrawGraphOrig();
            DrawGraph();
        }
Beispiel #2
0
        public async void GetFollowers(int pageId, int pageSize)
        {
            HttpContent         http_content = mBuild.GetFollowers(pageId, pageSize);
            HttpResponseMessage rsp          = HttpGet.Get(
                RequestBuilderCommon.SocialFollowers + await http_content.ReadAsStringAsync());
            JObject jo = null;

            if (ResponseParserCommon.AreYouOk(rsp, ref jo))
            {
            }
        }
Beispiel #3
0
        private bool IsLogin()
        {
            var url = @"http://www.zhihu.com/settings/profile";

            var rsp = HttpGet.Get(url, false);

            if (rsp.StatusCode == HttpStatusCode.OK)
            {
                return(true);
            }
            return(false);
        }
Beispiel #4
0
        private bool GetCaptcha()
        {
            var   CapId  = rd.Next().ToString();
            var   capUrl = @"http://www.zhihu.com/captcha.gif?r=" + CapId;
            Image img    = Image.FromStream(HttpGet.Get(capUrl).Content.ReadAsStreamAsync().Result);

            img.Save(CapId + ".gif");

            Console.WriteLine("输入验证码");
            Cap = Console.ReadLine();
            return(true);
        }
Beispiel #5
0
        private async void Find()
        {
            string uri      = "http://openapi.aibang.com/bus/lines?alt=json&app_key=" + App.AiBangApi + "&city=" + App.City + "&q=" + Route;
            string response = await HttpGet.Get(uri);

            try
            {
                DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(BusRouteModel));
                MemoryStream  ms   = new MemoryStream(Encoding.UTF8.GetBytes(response));
                BusRouteModel line = ds.ReadObject(ms) as BusRouteModel;
                LineList = line.lines.line;
            }
            catch
            {
                Msg("亲,您输入线路名称可能有误.请您确定后再次尝试");
            }
        }
Beispiel #6
0
        private async void Find()
        {
            string uri      = "http://openapi.aibang.com/bus/stats?alt=json&app_key=" + App.AiBangApi + "&city=" + App.City + "&q=" + Station;
            string response = await HttpGet.Get(uri);

            try
            {
                DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(BusStationModel));
                MemoryStream    ms            = new MemoryStream(Encoding.UTF8.GetBytes(response));
                BusStationModel stationDemo   = ds.ReadObject(ms) as BusStationModel;
                StationList = stationDemo.stats.stat;
            }
            catch (InvalidCastException ex)
            {
                Msg("亲,您输入站点名称有误.");
            }
        }
Beispiel #7
0
        private async void Find()
        {
            string uri = "http://openapi.aibang.com/bus/stats_xy?alt=json&app_key=" + App.AiBangApi + "&city=" + App.City + "&lng=" + App.longitude + "&lat=" + App.latitude + "&dist=" + Number;

            string response = await HttpGet.Get(uri);


            try
            {
                DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(BusAroundModel));
                MemoryStream   ms             = new MemoryStream(Encoding.UTF8.GetBytes(response));
                BusAroundModel stationDemo    = ds.ReadObject(ms) as BusAroundModel;
                StationList = stationDemo.stats.stat;
            }
            catch
            {
                Msg(string.Format("亲,周边{0}米内无公交站点.请您扩大查询范围再试下!", Number));
            }
        }
Beispiel #8
0
        private void ParseUrl(KeyValuePair <string, int> url)
        {
            HtmlDocument doc = new HtmlDocument();

            try
            {
                doc.LoadHtml(HttpGet.Get(url.Key).Content.ReadAsStringAsync().Result);
            }
            catch (Exception)
            {
            }

            HtmlNodeCollection hrefs = doc.DocumentNode.SelectNodes(@"//a[@href and not(contains(@href, 'javascript'))]");

            if (hrefs == null)
            {
                return;
            }

            foreach (HtmlNode nodeA in hrefs)
            {
                var Ref = nodeA.Attributes["href"].Value.Trim();
                if (!Ref.StartsWith(Url.ToString()))
                {
                    Uri newUri = null;
                    if (Uri.TryCreate(Url, Ref, out newUri))
                    {
                        Ref = newUri.ToString();
                    }
                }

                if (!Urls.Contains(Ref))
                {
                    Urls.Add(Ref);
                    _To.OnNewUrl(Ref);

                    if (url.Value < MaxTire)
                    {
                        OnNewUrl(Ref, url.Value + 1);
                    }
                }
            }
        }
Beispiel #9
0
        private async void Find()
        {
            string uri      = "http://openapi.aibang.com/search?alt=json&to=200&rc=2&app_key=" + App.AiBangApi + "&city=" + App.City + "&lng=" + App.longitude + "&lat=" + App.latitude + "&q=" + parameter;
            string response = await HttpGet.Get(uri);

            Debug.WriteLine(response);
            try
            {
                DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(BusinessModel));
                MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(response));

                BusinessModel businessDemo = (BusinessModel)ds.ReadObject(ms);


                BusinessList = businessDemo.bizs.biz;
            }
            catch
            {
                Msg("亲,请您换个关键词试试");
            }
        }
Beispiel #10
0
        private void InvokerProc(string url)
        {
            HtmlDocument doc = new HtmlDocument();

            try
            {
                doc.LoadHtml(HttpGet.Get(url).Content.ReadAsStringAsync().Result);
            }
            catch (Exception)
            {
                // todo
            }

            var answersSet = ReadAllXPathNode(doc, AnsersPath);
            var asnwerSet  = ReadAllXPathNode(doc, AnserPath);

            if (answersSet != null)
            {
                foreach (var answers in answersSet)
                {
                    if (!Urls.Contains(answers))
                    {
                        Urls.Add(answers);
                        OnNewUrl(answers);
                    }
                }
            }

            if (asnwerSet != null)
            {
                foreach (var answer in asnwerSet)
                {
                    if (!Urls.Contains(answer))
                    {
                        Urls.Add(answer);
                        _To.OnNewUrl(answer);
                    }
                }
            }
        }
Beispiel #11
0
        private async void Find()
        {
            if (StartStop != null && EndStop != null)
            {
                string uri      = "http://openapi.aibang.com/bus/transfer?alt=json&app_key=" + App.AiBangApi + "&city=" + App.City + "&start_addr=" + StartStop + "&end_addr=" + EndStop;
                string response = await HttpGet.Get(uri);

                try
                {
                    DataContractJsonSerializer ds = new DataContractJsonSerializer(typeof(BusTransferModel));
                    MemoryStream     ms           = new MemoryStream(Encoding.UTF8.GetBytes(response));
                    BusTransferModel bus          = ds.ReadObject(ms) as BusTransferModel;


                    foreach (var item in bus.buses.bus)
                    {
                        buslist busdemo = new buslist();
                        busdemo.Start     = "起点站:" + item.segments.segment.FirstOrDefault().start_stat;
                        busdemo.End       = "终点站:" + item.segments.segment.FirstOrDefault().end_stat;
                        busdemo.Dist      = "距离: " + item.dist.ToString() + "米";
                        busdemo.Time      = "预计耗时: " + item.time.ToString() + "分";
                        busdemo.Line_name = "线路名称: " + item.segments.segment.FirstOrDefault().line_name;
                        busdemo.Stats     = "沿途站点: " + item.segments.segment.FirstOrDefault().stats;
                        BusDemoList.Add(busdemo);
                    }
                    ms.Dispose();
                    Buslist     = BusDemoList;
                    BusDemoList = new List <buslist>();
                }
                catch
                {
                    Msg("亲:请检查您输入的起点或终点名称是否有误.请尝试输入相似或者相近的站点名称");
                }
            }
            else
            {
                Msg("请您输入起点和终点!");
            }
        }
Beispiel #12
0
        static void Main()
        {
            var key = KeyParser.GetKeyString(FString.KEY_PATH);

            Console.WriteLine("Key: " + key);


            var l = TrafficParser
                    .GetTrafficList(
                HttpGet.Get(
                    Url.SERVER_ID_TRAFFIC(7269),
                    FString.HTTPGET_HEADER_KEY,
                    key,
                    10000,
                    FString.USER_AGENT)
                .ToJObject());

            long countIn  = 0;
            long countOut = 0;

            foreach (var i in l)
            {
                Console.WriteLine("==============================");
                Console.WriteLine("Date: " + i.Date);
                Console.WriteLine("In  : " + i.In);
                Console.WriteLine("Out : " + i.Out);
                Console.WriteLine("EFR : " + 100.0 * i.EFR + "%");
                countIn  += i.In;
                countOut += i.Out;
            }
            Console.WriteLine("==============================");
            Console.WriteLine("Total In : " + countIn);
            Console.WriteLine("Total Out: " + countOut);
            Console.WriteLine("Avg. EFR : " + 100.0 * countOut / countIn + "%");
            Console.WriteLine("==============================");
            Console.WriteLine("Finished! Press any key to exit...");
            Console.ReadKey();
        }
Beispiel #13
0
        private void InvokerProc(string url)
        {
            HtmlDocument doc = new HtmlDocument();

            try
            {
                doc.LoadHtml(Encoding.GetEncoding("GBK").GetString(HttpGet.Get(url).Content.ReadAsByteArrayAsync().Result));
            }
            catch (Exception)
            {
                // todo
            }

            var urls = ReadAllXPathNode(doc, XPath);

            if (urls != null)
            {
                foreach (var u in urls)
                {
                    _To.OnNewUrl(u);
                }
            }
        }
Beispiel #14
0
        private bool GetXSRF()
        {
            HtmlDocument doc = new HtmlDocument();

            try
            {
                doc.LoadHtml(HttpGet.Get(@"http://www.zhihu.com").Content.ReadAsStringAsync().Result);
            }
            catch (Exception)
            {
                // todo
            }

            var xsrfNode = doc.DocumentNode.SelectSingleNode(@"//input[@value and @name and @name='_xsrf']");

            if (xsrfNode == null)
            {
                return(false);
            }

            XSRF = xsrfNode.Attributes["value"].Value;
            return(!string.IsNullOrEmpty(XSRF));
        }
Beispiel #15
0
        private void InvokerProc(string url)
        {
            HtmlDocument doc = new HtmlDocument();

            try
            {
                doc.LoadHtml(Encoding.GetEncoding("GBK").GetString(HttpGet.Get(url).Content.ReadAsByteArrayAsync().Result));
            }
            catch (Exception)
            {
                // todo
            }

            var paletteSet = ReadAllXPathNode(doc, PeisePath);

            if (paletteSet != null)
            {
                foreach (var palette in paletteSet)
                {
                    _To.OnNewUrl(JsonConvert.SerializeObject(palette));
                }
            }
        }
Beispiel #16
0
        private async void GetCity()
        {
            string uri = "http://api.map.baidu.com/telematics/v3/reverseGeocoding?location=" + longitude + "," + latitude + "&output=json&ak=" + App.BaiDuApi;

            response = await HttpGet.Get(uri);

            JsonObject cityInfo   = JsonObject.Parse(response);
            string     cityString = cityInfo.GetNamedString("city").ToString();

            if (cityString == "")
            {
                Msg("抱歉,无法获取您的城市信息.这将导致您无法使用本应用的服务,恳请您向我反馈此信息");
                City     = "未知";
                App.City = "北京";
            }
            else
            {
                int i = 0;

                City     = cityString.Substring(0, 2);
                App.City = City;
            }
        }