public new string PostRequest() { if (ReqJson == null) { if (!this.InitRequestJson()) { //return null; } } return(AccessWebServerClass.PostData(getUrl(), this.Req_PostData ?? "", Encoding.UTF8)); }
//public abstract bool InitRequestJson(); public string PostRequest() { if (ReqJson == null) { if (!InitRequestJson()) { //return null; } } string url = string.Format("{0}", ReqUrl); return(AccessWebServerClass.PostData(url, this.Req_PostData, Encoding.UTF8)); }
void SaveToServer(Dictionary <string, AssetInfoConfig> assets) { string strReq = "<config type='AssetUnits'>{0}</config>"; string[] list = assets.Select(a => string.Format("{0}", GlobalClass.writeXmlItems(a.Value.getStringDic(), a.Key, a.Value.value))).ToArray(); string urlModel = "http://www.wolfinv.com/pk10/app/UpdateUser.asp?"; string reqAsset = string.Format(strReq, string.Join("", list)); string encode = HttpUtility.UrlEncode(reqAsset, Encoding.UTF8); string url = urlModel; string strPost = string.Format("UserId={0}&AssetConfig={1}&dir=1", Program.UserId, encode); string succ = AccessWebServerClass.PostData(url, strPost, Encoding.UTF8); if (succ == "succ") { MessageBox.Show(succ); } }
public string GetRequest() { if (ReqJson == null) { if (!this.InitRequestJson()) { //return null; } } string url = ReqUrl + (ReqUrl.EndsWith("?")?"":"?") + ReqJson; if (url.Length >= 1024) { //this.Req_PostData = ReqJson; return(PostRequest()); } return(AccessWebServerClass.GetData(url, Encoding.UTF8)); }
public void ConnectToUrl() { DateTime begT = DateTime.Now; string reqdata = AccessWebServerClass.GetData(ConnUrl); DateTime endT = DateTime.Now; if (reqdata == null) { ret.Add(name, 0); return; } int rate = 0; if (reqdata.IndexOf("K彩在线娱乐") > 0 || reqdata.IndexOf("www.kcai") > 0) { rate = (int)(reqdata.Length / endT.Subtract(begT).TotalSeconds); } ret.Add(name, rate); }
protected override Dictionary <string, int> GetChanlesInfo(string NavUrl) { Dictionary <string, int> ret = new Dictionary <string, int>(); AccessWebServerClass wcc = new AccessWebServerClass(); string strHtml = AccessWebServerClass.GetData(NavUrl); if (strHtml == null) { return(ret); } Regex regTr = new Regex(@"www\.kcai(.*?)\.com"); MatchCollection mcs = regTr.Matches(strHtml); List <string> list = new List <string>(); string urlModel = "https://www.kcai{0}.com"; Task[] tasks = new Task[mcs.Count]; for (int i = 0; i < mcs.Count; i++) { string name = mcs[i].Value.Replace("www.kcai", "").Replace(".com", ""); DateTime begT = DateTime.Now; string url = string.Format(urlModel, name); ConnectClass cls = new ConnectClass(ret, name, url); //new Thread(new ThreadStart(cls.ConnectToUrl)).Start(); tasks[i] = new Task(cls.ConnectToUrl); tasks[i].Start(); ////string reqdata = AccessWebServerClass.GetData(url); ////DateTime endT = DateTime.Now; ////if(reqdata == null) ////{ //// ret.Add(name, 0); //// continue; ////} ////int rate = (int)(reqdata.Length/ endT.Subtract(begT).TotalSeconds); ////ret.Add(name, rate); } Task.WaitAll(tasks); return(ret); }
public static Dictionary <string, JdGoodSummayInfoItemClass> QueryWeb(string keyWord, int defaultReturnCnt = 10) { //AccessWebServerClass awc = new AccessWebServerClass(); Dictionary <string, JdGoodSummayInfoItemClass> ret = new Dictionary <string, JdGoodSummayInfoItemClass>(); try { string url = "https://union.jd.com/api/goods/search"; string strJson = JdUnion_GlbObject.getJsonText("jd.union.search.model"); if (string.IsNullOrEmpty(strJson)) { return(ret); } string strPostData = strJson.Replace("{0}", keyWord); string retJson = AccessWebServerClass.PostData(url, strPostData, Encoding.UTF8); JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); searchReturnData returnResult = javaScriptSerializer.Deserialize <searchReturnData>(retJson); if (returnResult.code != 200) { return(ret); } List <string> noMatchedList = new List <string>(); for (int i = 0; i < returnResult.data.unionGoods.Count; i++) { string id = returnResult.data.unionGoods[i][0].skuId; JdGoodSummayInfoItemClass ji = new JdGoodSummayInfoItemClass(); if (AllcommissionGoods == null) { AllcommissionGoods = new Dictionary <string, JdGoodSummayInfoItemClass>(); } if (AllcommissionGoods.ContainsKey(id)) { ji = AllcommissionGoods[id]; ret.Add(id, ji); } else { if (noMatchedList.Count < defaultReturnCnt) { noMatchedList.Add(id); } } } List <JdGoodSummayInfoItemClass> res = null; if (LoadPromotionGoodsinfo != null) { res = LoadPromotionGoodsinfo(noMatchedList); } else { res = getInfoBySukIds(noMatchedList); } res.ForEach(a => { if (!ret.ContainsKey(a.skuId)) { ret.Add(a.skuId, a); } }); return(ret); } catch (Exception ce) { } return(ret); }
private void btn_login_Click(object sender, EventArgs e) { this.btn_login.Enabled = false; this.Cursor = Cursors.WaitCursor; if (this.ddl_websites.SelectedIndex < 0) { MessageBox.Show("请选择平台!"); return; } if (Program.allGc == null) { Program.allGc = Program.gc.CopyTo <GlobalClass>(); } // GlobalClass.resetTypeDataPoints();//必须重新设置,每个平台投注品种不一样 Program.gc.ClientUserName = this.txt_user.Text.Trim(); Program.gc.ClientPassword = this.txt_password.Text.Trim(); Program.gc.ForWeb = this.ddl_websites.SelectedValue.ToString(); GlobalClass.SetConfig(); GlobalClass sgc = new GlobalClass(this.ddl_websites.SelectedValue.ToString()); if (sgc.loadSucc) { Program.gc = sgc; //Program.gc.ForWeb = this.ddl_websites.SelectedValue.ToString(); //return; } CommunicateToServer cts = new CommunicateToServer(); CommResult cr = cts.Login(GlobalClass.strLoginUrlModel, this.txt_user.Text, this.txt_password.Text); if (cr == null) { this.Cursor = Cursors.Default; MessageBox.Show("无法返回对象!"); this.btn_login.Enabled = true; return; } if (cr.Succ == false) { this.Cursor = Cursors.Default; MessageBox.Show(cr.Message); this.btn_login.Enabled = true; return; } this.Cursor = Cursors.WaitCursor; this.Hide(); UserInfoClass ret = cr.Result[0] as UserInfoClass; Program.UserId = ret.BaseInfo.UserId; Program.gc.ClientUserName = ret.BaseInfo.UserCode; Program.gc.ClientPassword = ret.BaseInfo.Password; Program.gc.Odds = ret.BaseInfo.Odds; Program.gc.WXLogNoticeUser = ret.BaseInfo.WXToUser; Program.gc.ClientAliasName = string.IsNullOrEmpty(ret.BaseInfo.AliasName)?ret.BaseInfo.UserCode:ret.BaseInfo.AliasName; XmlDocument xmldoc = new XmlDocument(); try { string strXml = HttpUtility.UrlDecode(ret.BaseInfo.AssetConfig, Encoding.UTF8); xmldoc.LoadXml(strXml); XmlNodeList items = xmldoc.SelectNodes("config[@type='AssetUnits']/item"); Dictionary <string, AssetInfoConfig> assetconfig = new Dictionary <string, AssetInfoConfig>(); if (items.Count > 0) { for (int i = 0; i < items.Count; i++) { string key = items[i].SelectSingleNode("@key").Value; //int val = int.Parse(items[i].SelectSingleNode("@value").Value); //if (!assetconfig.ContainsKey(key)) // assetconfig.Add(key, val); AssetInfoConfig aic = new AssetInfoConfig(GlobalClass.readXmlItems(items[i].OuterXml)); if (!assetconfig.ContainsKey(key)) { assetconfig.Add(key, aic); } } } Program.gc.AssetUnits = assetconfig; } catch (Exception ce) { //return; } if (Program.gc.SvrConfigUrl != null)//获取服务器默认配置 { string strConfig = AccessWebServerClass.GetData(string.Format(Program.gc.SvrConfigUrl, Program.gc.InstHost), Encoding.UTF8); if (strConfig != null && strConfig.Trim().Length > 0) { SvrConfigClass scc = new SvrConfigClass().getObjectByJsonString(strConfig); if (scc.DefaultExchangeHost != null) { Program.gc.LoginDefaultHost = scc.DefaultExchangeHost; } if (scc.WXSvrHost != null) { Program.gc.WXSVRHost = scc.WXSvrHost; } if (scc.DefaultNavHost != null) { Program.gc.NavHost = scc.DefaultNavHost; } } } try { //Program.gc.LoginDefaultHost = WebRuleBuilder.Create(Program.gc).GetChanle(Program.gc.WebNavUrl, Program.gc.LoginDefaultHost); ; GlobalClass.SetConfig(Program.gc.ForWeb); this.Hide(); this.Cursor = Cursors.Default; //必须重新指定登录用户 Program.wxl = new WolfInv.com.LogLib.WXLogClass(Program.gc.ClientAliasName, Program.gc.WXLogNoticeUser, Program.gc.WXLogUrl); MainWindow mw = new MainWindow(); //testWeb mw = new testWeb(); DialogResult res = mw.ShowDialog(); //////while ( res == DialogResult.OK)//如果frm退出是因为要求重启 //////{ ////// if (mw.ForceReboot) ////// { ////// mw.ForceReboot = false; ////// Program.Reboot = false; ////// mw = new MainWindow(); ////// res = mw.ShowDialog(); ////// } ////// //GC.SuppressFinalize(frm); //////} Application.Exit(); } catch (Exception ce1) { MessageBox.Show(string.Format("{0}:{1}", ce1.Message, ce1.StackTrace)); } }
public JdUnion_RequestClass() { awsobj = new AccessWebServerClass(); }