Пример #1
0
        private void StartFollowingMultithreaded(object parameters)
        {
            TweetAccountManager tweetAccountManager = new TweetAccountManager();
            try
            {
                Array paramsArray = new object[3];

                paramsArray = (Array)parameters;

                KeyValuePair<string, TweetAccountManager> keyValue = (KeyValuePair<string, TweetAccountManager>)paramsArray.GetValue(0);

                List<string> list_userIDsToFollow = (List<string>)paramsArray.GetValue(1);

                bool OtherUser = (bool)paramsArray.GetValue(2);
                int strMinDelay = (int)paramsArray.GetValue(3);
                int strMaxDelay = (int)paramsArray.GetValue(4);

                int intMinDelay = strMinDelay;
                int intMaxDelay = strMaxDelay;

                List<string> lstFollowers = new List<string>();
                List<string> lstFollowings = new List<string>();

                AddToLog_Follower("[ " + DateTime.Now + " ] => [ Starting Follower For Account : " + keyValue.Key + " ]");

                tweetAccountManager = keyValue.Value;
                TweetAccountManager.FileFollowUrlPath = txtPathUserIDs.Text.ToString();

                if (chkboxUseGroups.Checked)
                {
                    if (tweetAccountManager.GroupName != txtUseGroup.Text)
                    {
                        AddToLog_Follower("[ " + DateTime.Now + " ] => [ " + keyValue.Key + " Group Name Does Not Match ]");
                        return;
                    }
                }

                //Add to Threads Dictionary
                AddThreadToDictionary(strModule(Module.Follow), tweetAccountManager.Username);
                tweetAccountManager.follower.logEvents.addToLogger += new EventHandler(logEvents_Follower_addToLogger);
                tweetAccountManager.logEvents.addToLogger += logEvents_Follower_addToLogger;

                if (!tweetAccountManager.IsLoggedIn)
                {
                    tweetAccountManager.Login();
                }

                if (tweetAccountManager.AccountStatus == "Account Suspended")
                {
                    clsDBQueryManager database = new clsDBQueryManager();
                    database.UpdateSuspendedAcc(tweetAccountManager.Username);
                    return;
                }

                try
                {
                    AddToLog_Follower("[ " + DateTime.Now + " ] => [ " + list_userIDsToFollow.Count() + " user id in List ]");
                }
                catch (Exception)
                {
                }

                if (list_userIDsToFollow.Count > 0)
                {

                    tweetAccountManager.FollowUsingURLs(list_userIDsToFollow, intMinDelay, intMaxDelay, OtherUser);
                }
                else
                {
                    AddToLog_Follower("[ " + DateTime.Now + " ] => [ No ID's To Follow ]");
                }

                // tweetAccountManager.follower.logEvents.addToLogger -= logEvents_Follower_addToLogger;
                //tweetAccountManager.logEvents.addToLogger -= logEvents_Follower_addToLogger;
            }
            catch (Exception ex)
            {
                ErrorLogger.AddToErrorLogText(ex.Message);
                GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> StartFollowingMultithreaded() --> " + ex.Message, Globals.Path_FollowerErroLog);
                GlobusFileHelper.AppendStringToTextfileNewLine("Error --> StartFollowingMultithreaded() --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }

            finally
            {
                counter_AccountFollwer--;
                //TweetAccountManager tweetAccountManager = new TweetAccountManager();
                tweetAccountManager.follower.logEvents.addToLogger -= new EventHandler(logEvents_Follower_addToLogger);
                tweetAccountManager.logEvents.addToLogger -= logEvents_Follower_addToLogger;

                if (counter_AccountFollwer == 0)
                {
                    if (btnStartFollowing.InvokeRequired)
                    {
                        btnStartFollowing.Invoke(new MethodInvoker(delegate
                        {
                            Globals.FollowerRunningText = string.Empty;
                            GlobusFileHelper.AppendStringToTextfileNewLine("Module Follow count Total: " + Globals.totalcountFollower , Globals.path_CountNoOfProcessDone);
                            AddToLog_Follower("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED ]");
                            AddToLog_Follower("---------------------------------------------------------------------------------------------------------------------------");

                        }));
                    }
                }
            }
        }