Exemplo n.º 1
0
        public async static Task <List <ETH_USD_DTO> > List_ETH_USD()
        {
            List <ETH_USD_DTO> ls = new List <ETH_USD_DTO>();

            try
            {
                ETH_USD_DTO t      = new ETH_USD_DTO();
                HttpClient  client = new HttpClient();
                client.BaseAddress = new Uri("https://www.bitstamp.net/api/v2/ticker");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = await client.GetAsync(client.BaseAddress + "/ethusd");

                if (response.IsSuccessStatusCode)
                {
                    var         data = response.Content.ReadAsStringAsync().Result;
                    ETH_USD_DTO u    = JsonConvert.DeserializeObject <ETH_USD_DTO>(data);
                    ls.Add(u);
                }
            }
            catch (Exception)
            {
            }
            return(ls);
        }
Exemplo n.º 2
0
        public bool Insert_ETH_USD(ETH_USD_DTO dto)
        {
            string squery = string.Format("Insert into ETH_USD([Open],Last,Hight,Low,Volume,Time) values({0},{1},{2},{3},{4},GETDATE())", dto.open, dto.last, dto.high, dto.low, dto.volume);

            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(squery, conn);
                var        u   = cmd.ExecuteNonQuery();
                cmd.Dispose();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
        }
Exemplo n.º 3
0
 private void Insert_ETH_USD()
 {
     try
     {
         ETH_USD_DTO dto = new ETH_USD_DTO();
         dto.open   = double.Parse(dataGridView2.Rows[0].Cells[8].Value.ToString());
         dto.last   = double.Parse(dataGridView2.Rows[0].Cells[1].Value.ToString());
         dto.high   = double.Parse(dataGridView2.Rows[0].Cells[0].Value.ToString());
         dto.low    = double.Parse(dataGridView2.Rows[0].Cells[5].Value.ToString());
         dto.volume = double.Parse(dataGridView2.Rows[0].Cells[4].Value.ToString());
         ETH_USD_BUS bus = new ETH_USD_BUS();
         bus.Insert_ETH_USD(dto);
     }
     catch (Exception)
     {
         //timer1.Stop();
         //MessageBox.Show(" ETH/USD API Connecting has been stopped!");
         return;
     }
     finally
     {
         timer1.Start();
     }
 }
Exemplo n.º 4
0
        public bool Insert_ETH_USD(ETH_USD_DTO dto)
        {
            ETH_USD_DAO dao = new ETH_USD_DAO();

            return(dao.Insert_ETH_USD(dto));
        }