Esempio n. 1
0
        //检查登录状态。若未登录,弹出登录框。登录后,设定机器人
        private void CheckLogin()
        {
            if (!blnAuthorized)
            {
                frmLogin login = new frmLogin();
                if (login.ShowDialog() == DialogResult.OK)
                {
                    blnAuthorized = true;
                    SinaMBCrawler crawler = new SinaMBCrawler(SysArgFor.USER_RELATION);
                    crawler.SleepTime = 0;  //这里不等待
                    oCurrentUser = crawler.GetCurrentUserInfo();
                    if(oCurrentUser.user_id==0)
                        MessageBox.Show("Getting User Information Failed. Please try later.", "Sinawler");
                    if (oCurrentUser.user_id == -1)
                        MessageBox.Show("Service is forbidden now. Maybe your request is too frequent. Please try later.", "Sinawler");
                    else
                        ShowCurrentUser();
                    oSearchedUser = oCurrentUser;

                    btnStartByCurrent.Enabled = true;
                    btnStartBySearch.Enabled = true;

                    if (robotUserInfo == null)
                        robotUserInfo = new UserInfoRobot();

                    if (robotUserRelation == null)
                        robotUserRelation = new UserRelationRobot();

                    if (robotUserTag == null)
                        robotUserTag = new UserTagRobot();

                    if (robotStatus == null)
                        robotStatus = new StatusRobot();

                    if (robotComment == null)
                        robotComment = new CommentRobot();
                }
            }
        }
Esempio n. 2
0
 private void btnSearchOnline_Click(object sender, EventArgs e)
 {
     string strUserID = txtUserID.Text.Trim();
     string strScreenName = txtUserName.Text.Trim();
     if (strUserID != "" && strScreenName != "")
     {
         MessageBox.Show("Please select either UserID or Nickname to fill, but not both of them.", "Sinawler");
         return;
     }
     CheckLogin();
     if (blnAuthorized)
     {
         if (txtUserID.Text.Trim() == "" && txtUserName.Text.Trim() == "")
         {
             MessageBox.Show("UserID or Nickname Required.", "Sinawler");
             txtUserID.Focus();
             return;
         }
         
         long lBuffer;
         if (strUserID != "" && !long.TryParse(strUserID, out lBuffer))
         {
             MessageBox.Show("Invalid UserID.", "Sinawler");
             return;
         }
         SinaMBCrawler crawler = new SinaMBCrawler(SysArgFor.USER_RELATION);
         crawler.SleepTime = 0;  //这里不等待
         if (strUserID != "" && strScreenName == "")
             oSearchedUser = crawler.GetUserInfo(Convert.ToInt64(strUserID));
         if (strUserID == "" && strScreenName != "")
             oSearchedUser = crawler.GetUserInfo(strScreenName);                
         if (oSearchedUser.user_id == 0)
             MessageBox.Show("User not found.", "Sinawler");
         if (oSearchedUser.user_id == -1)
             MessageBox.Show("Service is forbidden now. Maybe your request is too frequent. Please try later.", "Sinawler");
         else
             ShowSearchedUser();
     }
     else
     {
         btnSearchOnline.Enabled = true;
         btnSearchOffLine.Enabled = true;
         btnStartByCurrent.Enabled = false;
         btnStartBySearch.Enabled = false;
         btnStartByLast.Enabled = true;
     }
 }