示例#1
0
        protected StatusQueue queueStatus;                 //微博队列引用

        //构造函数,需要传入相应的新浪微博API和主界面
        public RobotBase(SysArgFor robotType)
        {
            crawler = new SinaMBCrawler(robotType);
            api     = GlobalPool.GetAPI(robotType);
            switch (robotType)
            {
            case SysArgFor.USER_INFO:
                if (iMinSleep < GlobalPool.MinSleepMsForUserInfo)
                {
                    iMinSleep = GlobalPool.MinSleepMsForUserInfo;
                }
                break;

            case SysArgFor.USER_TAG:
                if (iMinSleep < GlobalPool.MinSleepMsForUserTag)
                {
                    iMinSleep = GlobalPool.MinSleepMsForUserTag;
                }
                break;

            case SysArgFor.STATUS:
                if (iMinSleep < GlobalPool.MinSleepMsForStatus)
                {
                    iMinSleep = GlobalPool.MinSleepMsForStatus;
                }
                break;

            case SysArgFor.COMMENT:
                if (iMinSleep < GlobalPool.MinSleepMsForComment)
                {
                    iMinSleep = GlobalPool.MinSleepMsForComment;
                }
                break;

            default:
                if (iMinSleep < GlobalPool.MinSleepMsForUserRelation)
                {
                    iMinSleep = GlobalPool.MinSleepMsForUserRelation;
                }
                break;
            }
            AdjustRealFreq();
        }
示例#2
0
        protected StatusQueue queueStatus;                    //微博队列引用

        //构造函数,需要传入相应的新浪微博API和主界面
        public RobotBase(SysArgFor robotType)
        {
            crawler = new SinaMBCrawler(robotType);
            api = GlobalPool.GetAPI(robotType);
            switch (robotType)
            {
                case SysArgFor.USER_INFO:
                    if (iMinSleep < GlobalPool.MinSleepMsForUserInfo) iMinSleep = GlobalPool.MinSleepMsForUserInfo;
                    break;
                case SysArgFor.USER_TAG:
                    if (iMinSleep < GlobalPool.MinSleepMsForUserTag) iMinSleep = GlobalPool.MinSleepMsForUserTag;
                    break;
                case SysArgFor.STATUS:
                    if (iMinSleep < GlobalPool.MinSleepMsForStatus) iMinSleep = GlobalPool.MinSleepMsForStatus;
                    break;
                case SysArgFor.COMMENT:
                    if (iMinSleep < GlobalPool.MinSleepMsForComment) iMinSleep = GlobalPool.MinSleepMsForComment;
                    break;
                default:
                    if (iMinSleep < GlobalPool.MinSleepMsForUserRelation) iMinSleep = GlobalPool.MinSleepMsForUserRelation;
                    break;
            }
            AdjustRealFreq();
        }
示例#3
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();
                }
            }
        }
示例#4
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;
     }
 }