Пример #1
0
        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));
        }
Пример #2
0
            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);
            }
Пример #3
0
        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);
        }
Пример #4
0
        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));
            }
        }