public void UnFollowUsingURLs(List<string> list_user_id_toUnFollow, int minDelay, int maxDelay) { //Login(); try { if (!IsLoggedIn) { Login(); } if (IsNotSuspended) { if (IsLoggedIn) { int counter_Unfollow = 0; if (list_user_id_toUnFollow.Count > 0) { Log("[ " + DateTime.Now + " ] => [ You have selected : " + list_user_id_toUnFollow.Count() + " ID to be Unfollowed ]"); foreach (string _user_id_toUnFollow in list_user_id_toUnFollow) { string _ScreenName = string.Empty; string user_id_toUnFollow = string.Empty; if (_user_id_toUnFollow.Contains(":")) { try { _ScreenName = _user_id_toUnFollow.Split(':')[0]; user_id_toUnFollow = _user_id_toUnFollow.Split(':')[1]; } catch { }; } else { user_id_toUnFollow = _user_id_toUnFollow; } if (counter_Unfollow >= noOfUnfollows) { break; } string unFollowStatus; unFollower.UnFollowUsingProfileID(ref globusHttpHelper, pgSrc_Profile, postAuthenticityToken, user_id_toUnFollow, out unFollowStatus); int Delay = 10; try { if (Globals.IsGlobalDelay && Globals.IsCheckValueOfDelay) { Delay = RandomNumberGenerator.GenerateRandom(Globals.MinGlobalDelay, Globals.MaxGlobalDelay); } else { Delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); } } catch (Exception ex) { //GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingURLs() -- delay --> " + ex.Message, Globals.Path_FollowerErroLog); //GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- FollowUsingURLs() -- delay -- " + Username + " -- " + user_id_toFollow + " --> " + ex.Message, Globals.Path_TweetAccountManager); } if (unFollowStatus == "Unfollowed" || unFollowStatus == "Already Unfollowed") { counter_Unfollow++; if (unFollowStatus == "Already Unfollowed") { Log("[ " + DateTime.Now + " ] => [ >> Already Unfollowed >> " + user_id_toUnFollow + " by " + Username + " ]"); } else { Log("[ " + DateTime.Now + " ] => [ >> Unfollowed >> " + user_id_toUnFollow + " by " + Username + " ]"); } //Thread.Sleep(RandomNumberGenerator.GenerateRandom(3000, 5000)); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword + ":" + user_id_toUnFollow, Globals.path_SuccessfullyUnfollowAccounts); clsDBQueryManager queryManager = new clsDBQueryManager(); List<string> lst_AlreadyUserName = queryManager.SelectFollowDUsernameID_List(Username); bool isAlreadyFollowed = lst_AlreadyUserName.Exists(s => (s == user_id_toUnFollow)); if (isAlreadyFollowed) { queryManager.DeleteFollowDUsernameID_List(Username, user_id_toUnFollow); } try { string status = string.Empty; //get screen name or id if (NumberHelper.ValidateNumber(user_id_toUnFollow) && string.IsNullOrEmpty(_ScreenName)) { _ScreenName = TwitterDataScrapper.GetUserNameFromUserId_New(user_id_toUnFollow, out status, ref globusHttpHelper); } queryManager.InserOrUpdateUnfollower(Username, user_id_toUnFollow, _ScreenName); } catch (Exception) { } } else { Log("[ " + DateTime.Now + " ] => [ >> Couldn't Unfollow >> " + user_id_toUnFollow + " by " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword + ":" + user_id_toUnFollow, Globals.path_FailedToUnfollowAccounts); } Log("[ " + DateTime.Now + " ] => [ Unfollow Delayed For " + Delay + " Seconds ]"); Thread.Sleep(Delay * 1000); } } else { Log("[ " + DateTime.Now + " ] => [ No Users To UnFollow ]"); return; } } } else { Log("[ " + DateTime.Now + " ] => [ >> Account is suspended >>" + Username + " ]"); } } catch (Exception ex) { if (ex.Message == "Thread was being aborted.") { Log("[ " + DateTime.Now + " ] => [ Unfollowing Process Stopped ]"); } else { Log("[ " + DateTime.Now + " ] => [ Some exception in Method:UnFollowUsingURLs --> Class --> TweetAccountManager --> Unfollow: " + ex.Message + " ]"); } GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- UnFollowUsingURLs() --> " + ex.Message, Globals.Path_UnfollowerErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- UnFollowUsingURLs() --> " + ex.Message, Globals.Path_TweetAccountManager); } finally { Log("[ " + DateTime.Now + " ] => [ Finished Unfollowing For Username :"******" ]"); Log("------------------------------------------------------------------------------------------------------------------------------------------"); } }
private void StartRemovingFollowerlListFromDatabase() { try { if (string.IsNullOrEmpty(txtUnfollowerUserName.Text.Trim())) { MessageBox.Show("Please Enter User Name"); return; } if (string.IsNullOrEmpty(txtUnfollowerUploadFollowerName.Text.Trim()) || lstUnfollowerListForRemoveDataBase.Count == 0) { MessageBox.Show("Please Upload Follower Name"); return; } AddToLog_Unfollow("[ " + DateTime.Now + " ] => [ Process is Running .... ]"); clsDBQueryManager objclsDBQueryManager = new clsDBQueryManager(); foreach (string FollowerItem in lstUnfollowerListForRemoveDataBase) { objclsDBQueryManager.DeleteFollowDUsernameID_List(txtUnfollowerUserName.Text.Trim(), FollowerItem); objclsDBQueryManager.DeleteFollowDUsernameIDFromTb_User_Followr_Details(FollowerItem); } AddToLog_Unfollow("[ " + DateTime.Now + " ] => [ Process Completed. ]"); } catch { } }