Exemplo n.º 1
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (txtKey.Text.Trim().Length < 2)
     {
         MessageBox.Show("输入关键字长度必须大于1");
         txtKey.Text = "";
     }
     if (!string.IsNullOrEmpty(txtKey.Text.Trim()))
     {
         checkedListBox1.Items.Clear();
         btnSearch.Enabled = false;
         btnSearch.Text    = "正在检索...";
         try
         {
             string key = NetHelper.GetMD5(Myinfo.username + "fangyuan888");
             var    f   = new StringBuilder();
             f.AppendFormat("username={0}&", Myinfo.username);
             f.AppendFormat("key={0}&", key);
             f.AppendFormat("word={0}&", txtKey.Text.Trim());
             string main1 = NetHelper.HttpPost("http://vip.hsoow.com/index.php?m=member&c=index&a=caiji", f.ToString(), "");
             if (main1 == "")
             {
                 MessageBox.Show("暂未搜到相关词"); return;
             }
             JObject jo    = (JObject)JsonConvert.DeserializeObject(main1);
             string  code  = jo["code"].ToString();
             string  count = jo["count"].ToString();
             string  data  = jo["data"].ToString();
             if (code == "0")//失败
             {
                 MessageBox.Show(data); return;
             }
             else if (code == "1")//成功
             {
                 label2.Text = "共搜索到" + count + "个词";
                 foreach (var w in jo["data"])
                 {
                     checkedListBox1.Items.Add(w["word"]);
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("暂未搜到相关数据");
         }
         btnSearch.Text = "搜索";
         //label2.Text = "共" + listBox1.Items.Count + "行";
         btnSearch.Enabled = true;
     }
 }
Exemplo n.º 2
0
        private void LoginServer(string name, string pass)
        {
            string   realmList = "";      //目前所有站
            string   realmNameInfo = "";  //权限站
            string   expirationTime = ""; //到期时间
            DateTime s, n;

            s = DateTime.Now;
            n = DateTime.Now;

            string key = NetHelper.GetMD5(name + "100dh888");
            string dosubmit = "1";
            //var obj = new
            //{
            //    username = name,
            //    password = pass,
            //    dosubmit,
            //    key
            //};
            //string postDataStr = JsonConvert.SerializeObject(obj);
            StringBuilder strpost = new StringBuilder();

            strpost.AppendFormat("username={0}&", name);
            strpost.AppendFormat("password={0}&", pass);
            strpost.AppendFormat("dosubmit={0}&", dosubmit);
            strpost.AppendFormat("key={0}&", key);
            try
            {
                string login_json = NetHelper.HttpPost("http://tool.100dh.cn/LoginHandler.ashx?action=Login", strpost.ToString());
                if (login_json != "")
                {
                    // list = (List<CategoryJson>)HttpHelper.JsonToObject<List<CategoryJson>>(main1);
                    JObject jo   = (JObject)JsonConvert.DeserializeObject(login_json);
                    string  code = jo["code"].ToString();
                    string  msg  = jo["msg"].ToString();
                    if (code == "0")//失败
                    {
                        MessageBox.Show("登录失败," + msg); return;
                    }
                    else if (code == "1")//成功
                    {
                        string data = jo["detail"].ToString();
                        expirationTime = jo["detail"]["cmUser"]["expirationTime"].ToString(); //到期时间
                        DateTime.TryParse(expirationTime, out s);
                        realmNameInfo = jo["detail"]["cmUser"]["realmNameInfo"].ToString();   //此账号下绑定的域名
                        realmList     = jo["detail"]["realmList"].ToString();
                        //rjlist = (List<ReleaseJson>)HttpHelper.JsonToObject<List<ReleaseJson>>(release);
                        List <realmNameInfo> rjlist = (List <realmNameInfo>)HttpHelper.JsonToObject <List <realmNameInfo> >(realmList);
                        if (rjlist.Count > 0)
                        {
                            List <realmNameInfo> rList = new List <realmNameInfo>();
                            foreach (realmNameInfo rj in rjlist)
                            {
                                //rj.path = joo[item.Key]["path"].ToString();路径,暂时未加
                                if (realmNameInfo.Contains(rj.Id) && rj.isUseing == true)
                                {
                                    rList.Add(rj);
                                }
                            }
                            Myinfo.rjlist = rList;
                        }
                        if (s <= n)
                        {
                            MessageBox.Show("授权已到期!");
                        }
                        else
                        {
                            Myinfo.softtime      = s - n;
                            Myinfo.realmNameInfo = realmNameInfo;
                            Myinfo.username      = name;
                            Myinfo.password      = pass;
                            if (ckbremenber.Checked)
                            {
                                AShelp.Save(this.txtName.Text, this.txtPwd.Text, "", "", "user");
                                Myinfo.username = this.txtName.Text;
                            }
                            frmMain f = new frmMain(name, pass);
                            f.Show();
                            Myinfo.myfmain = f;
                            Myinfo.mylogin = this;
                            this.Hide();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("出现错误,请联系作者!" + ex);
            }
        }