public List <BaseHistoryRecord> GetHistoryRecords(DateTime dateTime) { if (Username == null || Password == null) { LastErrorInfo = "Not Authenticated"; return(new List <BaseHistoryRecord>()); } WebConector wc = new WebConector(); string api_name = "wallet_history"; List <Tuple <string, string> > heder = new List <Tuple <string, string> >(); string nonce = ((long)(DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds).ToString(); heder.Add(new Tuple <string, string>("Key", Username)); string data_for_encript = "nonce=" + nonce; heder.Add(new Tuple <string, string>("Sign", SignatureHelper.Sign(Password, data_for_encript))); var body = new NameValueCollection(); body.Add("nonce", nonce); string jsonRezalt = wc.ReqwestPostAsync(string.Format(base_url, api_name), heder, body).Result; var jsonRezaltArray = JObject.Parse(jsonRezalt); if (jsonRezaltArray.Count != 0) { List <BaseHistoryRecord> rezaltlist = new List <BaseHistoryRecord>(); foreach (var accountvalue in jsonRezaltArray["history"]) { BaseHistoryRecord bhr = new BaseHistoryRecord(); //bhr.Id = accountvalue[""]; bhr.Type = accountvalue["type"].ToString(); bhr.Time = Convert.ToDateTime(accountvalue["dt"].ToString()); bhr.Currency = accountvalue["curr"].ToString(); bhr.Status = accountvalue["status"].ToString(); bhr.Provaider = accountvalue["provider"].ToString(); bhr.Amount = accountvalue["amount"].ToString(); bhr.Account = accountvalue["account"].ToString(); bhr.Txit = accountvalue["txid"].ToString(); rezaltlist.Add(bhr); } LastErrorInfo = ""; return(rezaltlist); } else { LastErrorInfo = jsonRezaltArray["error"].ToString(); return(new List <BaseHistoryRecord>()); } }
public List <BaseHistoryRecord> GetHistoryRecords(DateTime dateTime) { if (Username == null || Password == null) { LastErrorInfo = "Not Autorizated"; return(new List <BaseHistoryRecord>()); } WebConector wc = new WebConector(); string api_name = "wapi/v3/depositHistory.html"; List <Tuple <string, string> > heder = new List <Tuple <string, string> >(); var jsontimestamp = wc.ReqwestGetAsync(string.Format("{0}/api/v3/time", base_url), new List <Tuple <string, string> >(), "").Result; string timestamp = (JObject.Parse(jsontimestamp))["serverTime"].ToString(); heder.Add(new Tuple <string, string>("X-MBX-APIKEY", Username)); string data_for_encript = "&startTime=" + dateTime.ToUnixTimestamp() + "&recvWindow=" + "50000" + "×tamp=" + timestamp; heder.Add(new Tuple <string, string>("signature", SignatureHelper.Sign(Password, data_for_encript, 256))); data_for_encript += "&signature=" + SignatureHelper.Sign(Password, data_for_encript, 256); string jsonRezalt = wc.ReqwestPostAsync(string.Format("{0}{1}", base_url, api_name), heder, data_for_encript).Result; var jarrayRezalt = JObject.Parse(jsonRezalt); var rezalt = new List <BaseHistoryRecord>(); if (jarrayRezalt["msg"] == null) { var jsonArrayRecords = JArray.Parse(jarrayRezalt["depositList"].ToString()); foreach (var record in jsonArrayRecords) { BaseHistoryRecord bhr = new BaseHistoryRecord(); bhr.Id = 0; bhr.Provaider = record["txId"].ToString(); bhr.Status = record["status"].ToString(); bhr.Time = (new DateTime()).FromUnixTimestamp(record["insertTime"].ToObject <Int64>()); bhr.Txit = record["txId"].ToString(); bhr.Type = "deposit"; bhr.Account = record["address"].ToString();; bhr.Amount = record["amount"].ToString();; bhr.Currency = record["asset"].ToString();; rezalt.Add(bhr); } } else { LastErrorInfo = jarrayRezalt["msg"].ToString(); return(new List <BaseHistoryRecord>()); } api_name = "/wapi/v3/withdrawHistory.html"; heder = new List <Tuple <string, string> >(); jsontimestamp = wc.ReqwestGetAsync(string.Format("{0}/api/v3/time", base_url), new List <Tuple <string, string> >(), "").Result; timestamp = (JObject.Parse(jsontimestamp))["serverTime"].ToString(); heder.Add(new Tuple <string, string>("X-MBX-APIKEY", Username)); data_for_encript = "&startTime=" + dateTime.ToUnixTimestamp() + "&recvWindow=" + "50000" + "×tamp=" + timestamp; heder.Add(new Tuple <string, string>("signature", SignatureHelper.Sign(Password, data_for_encript, 256))); data_for_encript += "&signature=" + SignatureHelper.Sign(Password, data_for_encript, 256); jsonRezalt = wc.ReqwestPostAsync(string.Format("{0}{1}", base_url, api_name), heder, data_for_encript).Result; jarrayRezalt = JObject.Parse(jsonRezalt); if (jarrayRezalt["msg"] == null) { var jsonArrayRecords = JArray.Parse(jarrayRezalt["withdrawList"].ToString()); foreach (var record in jsonArrayRecords) { BaseHistoryRecord bhr = new BaseHistoryRecord(); bhr.Id = 0; bhr.Provaider = record["txId"].ToString(); bhr.Status = record["status"].ToString(); bhr.Time = (new DateTime()).FromUnixTimestamp(record["insertTime"].ToObject <Int64>()); bhr.Txit = record["txId"].ToString(); bhr.Type = "withdraw"; bhr.Account = record["address"].ToString();; bhr.Amount = record["amount"].ToString();; bhr.Currency = record["asset"].ToString();; rezalt.Add(bhr); } } else { LastErrorInfo += jarrayRezalt["msg"].ToString(); return(new List <BaseHistoryRecord>()); } throw new NotImplementedException(); }
public List <BaseHistoryRecord> GetHistoryRecords(DateTime dateTime) { if (Username == null || Password == null) { LastErrorInfo = "Not Autorizated"; return(null); } List <BaseHistoryRecord> rezalt = new List <BaseHistoryRecord>(); WebConector wc = new WebConector(); string api_name = "private/WithdrawStatus"; Int64 nonce = DateTime.Now.Ticks; string data_transmit = string.Format("nonce={0}", nonce); var signature = SignatureFormat(api_name, data_transmit, nonce); List <Tuple <string, string> > heder = new List <Tuple <string, string> >(); heder.Add(new Tuple <string, string>("API-Key", Username)); heder.Add(new Tuple <string, string>("API-Sign", signature)); var jsonRezalt = wc.ReqwestPostAsync(string.Format(base_url, api_name), heder, data_transmit).Result; var jsonRezaltArray = JArray.Parse(jsonRezalt); if (jsonRezaltArray["error"] == null) { LastErrorInfo = ""; foreach (var record in jsonRezaltArray.Children <JObject>()) { BaseHistoryRecord bhr = new BaseHistoryRecord(); bhr.Time = UnixTimestampToDateTime(double.Parse(record["time"].ToString())); bhr.Type = "Withdraw"; bhr.Id = int.Parse(record["refid"].ToString()); bhr.Currency = ""; bhr.Status = record["status"].ToString(); bhr.Provaider = record["info "].ToString(); bhr.Amount = record["amount"].ToString(); bhr.Account = ""; bhr.Txit = record["txid"].ToString(); } } else { LastErrorInfo = jsonRezaltArray["error"].ToString(); return(null); } api_name = "private/DepositStatus"; nonce = DateTime.Now.Ticks; data_transmit = string.Format("nonce={0}", nonce); signature = SignatureFormat(api_name, data_transmit, nonce); heder = new List <Tuple <string, string> >(); heder.Add(new Tuple <string, string>("API-Key", Username)); heder.Add(new Tuple <string, string>("API-Sign", signature)); jsonRezalt = wc.ReqwestPostAsync(string.Format(base_url, api_name), heder, data_transmit).Result; jsonRezaltArray = JArray.Parse(jsonRezalt); if (jsonRezaltArray["error"] == null) { foreach (var record in jsonRezaltArray.Children <JObject>()) { BaseHistoryRecord bhr = new BaseHistoryRecord(); bhr.Time = UnixTimestampToDateTime(double.Parse(record["time"].ToString())); bhr.Type = "Deposit"; bhr.Id = int.Parse(record["refid"].ToString()); bhr.Currency = ""; bhr.Status = record["status"].ToString(); bhr.Provaider = record["info "].ToString(); bhr.Amount = record["amount"].ToString(); bhr.Account = ""; bhr.Txit = record["txid"].ToString(); } } else { LastErrorInfo += jsonRezaltArray["error"].ToString(); return(null); } return(rezalt); }