示例#1
0
        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;
        }
示例#2
0
        private WebMetodAnser GetWebServiceResponse(eWebMetods webMetod, List<KeyValuePair<string, string>> postParams)
        {
            WebMetodDescription webMetodDescription = new WebMetodDescription();
            webMetodDescription.URI = webServices[(int)AuthMethod[(int)webMetod]];
            webMetodDescription.AUTHConnection = AuthMethod[(int)webMetod];

            webMetodDescription.PostData = PostParamsToPostData(postParams);

            WebMetodAnser webMetodAnser = GetWebResponse(webMetodDescription);

            if (webMetodAnser.Error != null || webMetodAnser.Status != "OK"){
                webMetodAnser.StringReturn	= null;
            }
            else{
                try{
                    webMetodAnser.StringReturn	= JObject.Parse(webMetodAnser.StringReturn)["return"].ToString();
                }
                catch{
                    try{
                        webMetodAnser.Error = JObject.Parse(webMetodAnser.StringReturn)["error"].ToString();
                    }
                    catch{
                        webMetodAnser.StringReturn = Regex.Replace(
                            JObject.Parse(webMetodAnser.StringReturn)["moreinfo"].ToString(), "<[^>]+>", string.Empty);
                    }
                }
            }

            return webMetodAnser;
        }
示例#3
0
文件: Class1.cs 项目: vgick/bst
        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:
                    postParams = AddMarketIDParams(postParams);
                    break;
                case eWebMetods.CancelOrder:
                    postParams = GetParamsForeCancelOrderA(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()));
            }

            return GetWebServiceResponse(webMetod, postParams);
        }