public void UpdateMarkesList(WebMetodAnser webMetodAnser) { if (webMetodAnser.Status == "OK" && webMetodAnser.Error == null) { fillDataGridMarketsList(webMetodAnser.StringReturn); } else { MessageBox.Show(webMetodAnser.Error); } int marketRowIndex = MarketIDToMarketRowIndex(); if (marketRowIndex != -1) { dataGridMarketsList[1, marketRowIndex].Selected = true; dataGridMarketsList.CurrentCell = dataGridMarketsList[1, marketRowIndex]; UpdateCoinInfo(); dataGridMarketsList.Refresh(); } }
private WebMetodAnser GetWebResponse(WebMetodDescription webMetodDescription) { System.Net.ServicePointManager.Expect100Continue = false; WebMetodAnser webResponseAnser = new WebMetodAnser(); webResponseAnser.Error = null; ASCIIEncoding encoding = new ASCIIEncoding(); byte[] postData = encoding.GetBytes(webMetodDescription.PostData); WebRequest request = WebRequest.Create(webMetodDescription.URI); request.Method = "POST"; request.ContentLength = postData.Length; request.ContentType = "application/x-www-form-urlencoded"; if (proxyUse){ WebProxy webProxy = new WebProxy(proxyServer, proxyPort); webProxy.Credentials = new NetworkCredential(proxyLogin, proxyPassword); request.Proxy = webProxy; } if (webMetodDescription.AUTHConnection == eAUTH.Secury){ request.Headers.Add("Key", key); HMACSHA512 hashMaker = new HMACSHA512(Encoding.ASCII.GetBytes(secret)); request.Headers.Add("Sign", ByteArrayToString(hashMaker.ComputeHash(postData)).ToLower()); } try{ Stream stream = request.GetRequestStream(); stream.Write(postData, 0, postData.Length); stream.Close(); WebResponse response = request.GetResponse(); webResponseAnser.Status = ((HttpWebResponse)response).StatusDescription; stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); webResponseAnser.StringReturn = reader.ReadToEnd(); return webResponseAnser; } catch (Exception ex){ webResponseAnser.Error = ex.ToString(); } return webResponseAnser; }
private WebMetodAnser GetWebMetodData(eWebMetods webMetod) { List<KeyValuePair<string, string>> postParams = new List<KeyValuePair<string, string>>(); switch (webMetod) { case eWebMetods.GetMarketNA: case eWebMetods.GetMarketOrders: case eWebMetods.GetMyOrders: case eWebMetods.MarketTrades: postParams = AddMarketIDParams(postParams); break; case eWebMetods.CancelOrder: postParams = GetParamsForeCancelOrderA(postParams); break; case eWebMetods.CreateOrder: postParams = GetParamsForeCreateOrderA(postParams); break; } postParams.Add(new KeyValuePair<string, string>(webMetodsList[(int)webMetod].Key, webMetodsList[(int)webMetod].Value)); if (AuthMethod[(int)webMetod] == eAUTH.Secury) { postParams.Add(new KeyValuePair<string, string>("nonce", nonce.ToString())); nonce++; } WebMetodAnser res; try { res = GetWebServiceResponse(webMetod, postParams); } catch (Exception ex) { res = new WebMetodAnser(); MessageBox.Show(ex.ToString()); } return res; }
public void UpdateUserBalans(WebMetodAnser webMetodAnser) { if(webMetodAnser.Error == null && webMetodAnser.Status == "OK") { WebServiceInfoReturnClass userBalans = JsonConvert.DeserializeObject<WebServiceInfoReturnClass>(webMetodAnser.StringReturn); int coinFill = 0; foreach(KeyValuePair<string, string> currency in userBalans.BalansAvaible) { if(currency.Key == primaryCoinCode) { linkLabelPrimaryCoinAmount.Text = currency.Value; coinFill++; }; if(currency.Key == secondaryCoinCode) { linkLabelSecondaryCoinAmount.Text = currency.Value; linkLabelSecondaryCoinAmountBuy.Text = currency.Value; coinFill++; }; if(coinFill == 2) { break; } } } else { if (keepLogin) { AddToLigFile(webMetodAnser.Error); } } }
public void UpdateOrdersList(WebMetodAnser webMetodAnser) { if (webMetodAnser.Status == "OK" && webMetodAnser.Error == null) { updateOrdersGrid = true; FillDataGridOrders(webMetodAnser.StringReturn); updateOrdersGrid = false; SetCurrentPriceRow(); DetectMaxBids(webMetodAnser.StringReturn); } else{ if (keepLogin){ AddToLigFile(webMetodAnser.Error); } } UpdatePriceAmount(); }
public void UpdateMyOrdersList(WebMetodAnser webMetodAnser) { if(webMetodAnser.Status == "OK" && webMetodAnser.Error == null) { fillDataGridMyOrders(webMetodAnser.StringReturn); CheckMyCurrentOrders(); AddNewMyCurrentOrders(); } else { if (keepLogin){ AddToLigFile(webMetodAnser.Error); } } }
public void UpdateMarketTrades(WebMetodAnser webMetodAnser) { if(webMetodAnser.Status == "OK" && webMetodAnser.Error == null) { FillMarketTrades(webMetodAnser.StringReturn); } else { if (keepLogin) { AddToLigFile(webMetodAnser.Error); } } }
public void UpdateMarkesListCoinInfo(WebMetodAnser webMetodAnser) { if (webMetodAnser.Status == "OK" && webMetodAnser.Error == null) { DetermineCoinInfo(webMetodAnser.StringReturn); } else { if (keepLogin) { AddToLigFile(webMetodAnser.Error); } } }
public void UpdateCreatelOrder(WebMetodAnser webMetodAnser) { if (webMetodAnser.Status == "OK" && webMetodAnser.Error == null) { if (!CreateSpamTrade) { if (keepLogin) { AddToLigFile(webMetodAnser.StringReturn); } MessageBox.Show(webMetodAnser.StringReturn); } } else{ if (keepLogin) { AddToLigFile(webMetodAnser.Error); } MessageBox.Show(webMetodAnser.Error); } RequestMyOrdersList(); numericBuyAmount.Value = 0; numericSellAmount.Value = 0; }
public void UpdateCancelOrder(WebMetodAnser webMetodAnser) { if(webMetodAnser.Status == "OK" && webMetodAnser.Error == null) { if (keepLogin){ AddToLigFile(webMetodAnser.StringReturn); } MessageBox.Show(webMetodAnser.StringReturn); } else{ if (keepLogin) { AddToLigFile(webMetodAnser.StringReturn); } MessageBox.Show(webMetodAnser.Error); } RequestMyOrdersList(); }