public void ReTweetAndFollow(ref Globussoft.GlobusHttpHelper globusHttpHelper, string pgSrc, string postAuthenticityToken, string tweetID, string tweetMessage, string UserID, out string status) { Follower.Follower objFollower = new Follower.Follower(); try { string TweetId = tweetID;// "197682704844734464"; string ReTweetData = "authenticity_token=" + postAuthenticityToken + "&id=" + tweetID; string ReTweetPostUrl = "https://twitter.com/i/tweet/retweet"; string res_Post_Retweet = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "https://twitter.com/", postAuthenticityToken, "XMLHttpRequest", "true", ""); string pagesource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com"), "", ""); //string TweetId = tweetID;// "197682704844734464"; //string ReTweetData = "post_authenticity_token=" + postAuthenticityToken; //string ReTweetPostUrl = "https://api.twitter.com/1/statuses/retweet/" + TweetId + ".json"; //string res_Post_Retweet = globusHttpHelper.postFormData(new Uri(ReTweetPostUrl), ReTweetData, "https://api.twitter.com/receiver.html", postAuthenticityToken, "XMLHttpRequest", "true", ""); status = "posted"; objFollower.FollowUsingProfileID_New(ref globusHttpHelper, pgSrc, postAuthenticityToken, UserID, out status); } catch (Exception ex) { status = "not posted"; //Log("Method>>ReTweet --- class>>Tweeter.cs : ReTweet Exception " + ex.Message); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweeter() - ReTweet --> " + ex.Message, Globals.Path_TweetingErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> Tweeter() - ReTweet --> " + ex.Message, Globals.Path_TwtErrorLogs); } }
public void GetStartProcessForFollow(object param) { string CampaignName = string.Empty; try { Interlocked.Increment(ref counterThreadsCampaignFollow); Array paramsArray = new object[5]; paramsArray = (Array)param; KeyValuePair <string, MixedCampaignManager.classes.CampaignAccountManager> keyValuePair = (KeyValuePair <string, MixedCampaignManager.classes.CampaignAccountManager>)paramsArray.GetValue(0); List <string> TargetedUser = (List <string>)paramsArray.GetValue(1); int NoOfFollowPerAc = (int)paramsArray.GetValue(2); int DelayStart = (int)paramsArray.GetValue(3); int DelayEnd = (int)paramsArray.GetValue(4); CampaignName = (string)paramsArray.GetValue(5); bool IsSchedulDaily = (bool)paramsArray.GetValue(6); DateTime SchedulerEndTime = (DateTime)paramsArray.GetValue(7); bool divideEql = (bool)paramsArray.GetValue(8); bool dividebyUser = (bool)paramsArray.GetValue(9); string tempDeleteFollowFilePath = (string)paramsArray.GetValue(10); //Initialize Values in Local Variable string accKey = (string)keyValuePair.Key; MixedCampaignManager.classes.CampaignAccountManager campACCManager = (MixedCampaignManager.classes.CampaignAccountManager)keyValuePair.Value; //Add List Of Working thread //we are using this list when we stop/abort running camp processes.. try { MixedCampaignManager.classes.cls_variables.Lst_WokingThreads.Add(CampaignName + "_" + campACCManager.Username, Thread.CurrentThread); } catch (Exception) { } count_AccountforCampaignFollower = CampaignAccountsList.dictionary_CampaignAccounts.Count(); //get account logging if (!(CampaignManager.CampaignAccountsList.dictionary_CampaignAccounts).Keys.Contains(accKey)) { campACCManager.Login(); try { CampaignManager.CampaignAccountsList.dictionary_CampaignAccounts.Add(accKey, campACCManager); } catch { }; } else { try { campACCManager = null; bool values = (CampaignManager.CampaignAccountsList.dictionary_CampaignAccounts).TryGetValue(accKey, out campACCManager); } catch (Exception) { } } //check account is logged in if (campACCManager.IsLoggedIn) { //check account is suspended if (campACCManager.IsNotSuspended) { Follower.Follower Objfollower = new Follower.Follower(); int follow_count = 0; List <string> _TargetUser = new List <string>(); _TargetUser.AddRange(TargetedUser); foreach (var TargetedUser_item in TargetedUser) { long FollowerId = 0; string Followername = string.Empty; //Get status from follow process string status = string.Empty; String FollowerStatus = string.Empty; //check follower count par account if ((follow_count == NoOfFollowPerAc) && !divideEql && !dividebyUser) { Log("[ " + DateTime.Now + " ] => [ Finish Follow Limit " + NoOfFollowPerAc + "Today ]"); break; } //Check Scheduled Task end time //If task is scheduled if (IsSchedulDaily) { if (SchedulerEndTime.Hour == DateTime.Now.Hour && DateTime.Now.Minute >= SchedulerEndTime.Minute) { _IsFollowProcessStart = true; new Thread(() => { //frm_mixcampaignmanager frmcamp = new frm_mixcampaignmanager(); //frmcamp.StoprunningCampaign(CampaignName); //frmcamp.StartFollowCampaign(CampaignName, ""); RaiseCampaignSearchLogEvents(campName); RaiseCampaignStartLogEvents(campName); }).Start(); break; } } //Get Follower ID From Name try { string followerDetails = classes.CampTwitterDataScrapper.GetUserIDFromUsername_New(TargetedUser_item, out FollowerStatus, ref campACCManager.globusHttpHelper); if (String.IsNullOrEmpty(followerDetails)) { Log("[ " + DateTime.Now + " ] => [ User :- " + TargetedUser_item + " Suspended. Which is not followed By :- " + accKey + " ]"); RemoveFollwerFromTxtFile(tempDeleteFollowFilePath, TargetedUser_item); continue; } if (BaseLib.NumberHelper.ValidateNumber(followerDetails)) { //FollowerId = Int32.Parse(followerDetails); FollowerId = ((long.Parse(followerDetails))); Followername = TargetedUser_item; } else { //FollowerId = Convert.ToInt32(TargetedUser_item); FollowerId = (long.Parse(TargetedUser_item)); Followername = followerDetails; } //call Follow Method by object follower class .. Objfollower.FollowUsingProfileID_New(ref campACCManager.globusHttpHelper, "", campACCManager.postAuthenticityToken, TargetedUser_item, out status); if (status == "followed") { RemoveFollwerFromTxtFile(tempDeleteFollowFilePath, TargetedUser_item); follow_count++; try { //Insert details in Report table RepositoryClasses.ReportTableRepository.InsertReport(CampaignName, accKey, Followername, FollowerId, "", "", "", ""); } catch { }; //Logg current status of Follow process Log("[ " + DateTime.Now + " ] => [ " + TargetedUser_item + " Followed by :- " + accKey + " ]"); //Delay after every Follow.. int delay = BaseLib.RandomNumberGenerator.GenerateRandom(DelayStart, DelayEnd); Log("[ " + DateTime.Now + " ] => [ Delay :- " + delay + " seconds ]"); Thread.Sleep(delay * 1000); } //Code added by Lijo John for protected accounts else if (status == "pending") { RemoveFollwerFromTxtFile(tempDeleteFollowFilePath, TargetedUser_item); follow_count++; try { //Insert details in Report table RepositoryClasses.ReportTableRepository.InsertReport(CampaignName, accKey, Followername, FollowerId, "", "", "", ""); } catch { }; //Logg current status of Follow process Log("[ " + DateTime.Now + " ] => [ Follow request sent by :- " + accKey + " awaiting for approval since " + TargetedUser_item + " is protected]"); //Delay after every Follow.. int delay = BaseLib.RandomNumberGenerator.GenerateRandom(DelayStart, DelayEnd); Log("[ " + DateTime.Now + " ] => [ Delay :- " + delay + " seconds ]"); Thread.Sleep(delay * 1000); } else if (status == "Already Followed") { RemoveFollwerFromTxtFile(tempDeleteFollowFilePath, TargetedUser_item); follow_count++; Log("[ " + DateTime.Now + " ] => [ " + TargetedUser_item + " Already Followed by :- " + accKey + " ]"); } else { Log("[ " + DateTime.Now + " ] => [ " + TargetedUser_item + " could not Followed by :- " + accKey + " ]"); } //Delay after every Follow.. //int delay = BaseLib.RandomNumberGenerator.GenerateRandom(DelayStar * 1000, DelayEnd * 1000); //Log("[ " + DateTime.Now + " ] => [ Delay :- " + TimeSpan.FromMilliseconds(delay).Seconds + " seconds ]"); //Thread.Sleep(delay); } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error -->GetStartProcessForFollow()---> Get Follower ID From Name --> " + ex.Message, Globals.Path_FollowerErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error -->GetStartProcessForFollow()---> Get Follower ID From Name --> " + ex.Message, Globals.Path_FollowerErroLog); } } } } } catch (Exception) { } finally { //count_AccountforCampaignFollower--; Interlocked.Decrement(ref counterThreadsCampaignFollow); lock (lockerThreadsCampaignFollow) { Monitor.Pulse(lockerThreadsCampaignFollow); } if (counterThreadsCampaignFollow == 0) { _IsFollowProcessStart = true; if (cls_variables.lstCampaignStartShedular.Contains(CampaignName)) { try { cls_variables.lstCampaignStartShedular.Remove(CampaignName); } catch { }; } if (MixedCampaignManager.classes.cls_variables.Lst_WokingThreads.ContainsKey(CampaignName)) { MixedCampaignManager.classes.cls_variables.Lst_WokingThreads.Remove(CampaignName); } //frm_mixcampaignmanager objfrm = new frm_mixcampaignmanager(); //objfrm.controlStartButtonImage(CampaignName); RaiseCampaignFineshedEvent(CampaignName); Log("[ " + DateTime.Now + " ] => [ Process is completed for Campaign " + CampaignName + " ]"); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(CampaignName + ": " + DateTime.Now, Globals.path_LogCampaignCompleted); } } }
public void GetStartProcessForFollow(object param) { string CampaignName = string.Empty; try { Interlocked.Increment(ref counterThreadsCampaignFollow); Array paramsArray = new object[5]; paramsArray = (Array)param; KeyValuePair<string, MixedCampaignManager.classes.CampaignAccountManager> keyValuePair = (KeyValuePair<string, MixedCampaignManager.classes.CampaignAccountManager>)paramsArray.GetValue(0); List<string> TargetedUser = (List<string>)paramsArray.GetValue(1); int NoOfFollowPerAc = (int)paramsArray.GetValue(2); int DelayStart = (int)paramsArray.GetValue(3); int DelayEnd = (int)paramsArray.GetValue(4); CampaignName = (string)paramsArray.GetValue(5); bool IsSchedulDaily = (bool)paramsArray.GetValue(6); DateTime SchedulerEndTime = (DateTime)paramsArray.GetValue(7); bool divideEql= (bool) paramsArray.GetValue(8); bool dividebyUser= (bool) paramsArray.GetValue(9); string tempDeleteFollowFilePath = (string)paramsArray.GetValue(10); //Initialize Values in Local Variable string accKey = (string)keyValuePair.Key; MixedCampaignManager.classes.CampaignAccountManager campACCManager = (MixedCampaignManager.classes.CampaignAccountManager)keyValuePair.Value; //Add List Of Working thread //we are using this list when we stop/abort running camp processes.. try { MixedCampaignManager.classes.cls_variables.Lst_WokingThreads.Add(CampaignName + "_" + campACCManager.Username, Thread.CurrentThread); } catch (Exception) { } count_AccountforCampaignFollower = CampaignAccountsList.dictionary_CampaignAccounts.Count(); //get account logging if (!(CampaignManager.CampaignAccountsList.dictionary_CampaignAccounts).Keys.Contains(accKey)) { campACCManager.Login(); try { CampaignManager.CampaignAccountsList.dictionary_CampaignAccounts.Add(accKey, campACCManager); } catch { }; } else { try { campACCManager = null; bool values = (CampaignManager.CampaignAccountsList.dictionary_CampaignAccounts).TryGetValue(accKey, out campACCManager); } catch (Exception) { } } //check account is logged in if (campACCManager.IsLoggedIn) { //check account is suspended if (campACCManager.IsNotSuspended) { Follower.Follower Objfollower = new Follower.Follower(); int follow_count = 0; List<string> _TargetUser = new List<string>(); _TargetUser.AddRange(TargetedUser); foreach (var TargetedUser_item in TargetedUser) { long FollowerId = 0; string Followername = string.Empty; //Get status from follow process string status = string.Empty; String FollowerStatus = string.Empty; //check follower count par account if ((follow_count == NoOfFollowPerAc) && !divideEql && !dividebyUser) { Log("[ " + DateTime.Now + " ] => [ Finish Follow Limit " + NoOfFollowPerAc + "Today ]"); break; } //Check Scheduled Task end time //If task is scheduled if (IsSchedulDaily) { if (SchedulerEndTime.Hour == DateTime.Now.Hour && DateTime.Now.Minute >= SchedulerEndTime.Minute) { _IsFollowProcessStart = true; new Thread(() => { //frm_mixcampaignmanager frmcamp = new frm_mixcampaignmanager(); //frmcamp.StoprunningCampaign(CampaignName); //frmcamp.StartFollowCampaign(CampaignName, ""); RaiseCampaignSearchLogEvents(campName); RaiseCampaignStartLogEvents(campName); }).Start(); break; } } //Get Follower ID From Name try { string followerDetails = classes.CampTwitterDataScrapper.GetUserIDFromUsername_New(TargetedUser_item, out FollowerStatus, ref campACCManager.globusHttpHelper); if (String.IsNullOrEmpty(followerDetails)) { Log("[ " + DateTime.Now + " ] => [ User :- " + TargetedUser_item + " Suspended. Which is not followed By :- " + accKey + " ]"); RemoveFollwerFromTxtFile(tempDeleteFollowFilePath, TargetedUser_item); continue; } if (BaseLib.NumberHelper.ValidateNumber(followerDetails)) { //FollowerId = Int32.Parse(followerDetails); FollowerId = ((long.Parse(followerDetails))); Followername = TargetedUser_item; } else { //FollowerId = Convert.ToInt32(TargetedUser_item); FollowerId = (long.Parse(TargetedUser_item)); Followername = followerDetails; } //call Follow Method by object follower class .. Objfollower.FollowUsingProfileID_New(ref campACCManager.globusHttpHelper, "", campACCManager.postAuthenticityToken, TargetedUser_item, out status); if (status == "followed") { RemoveFollwerFromTxtFile(tempDeleteFollowFilePath, TargetedUser_item); follow_count++; try { //Insert details in Report table RepositoryClasses.ReportTableRepository.InsertReport(CampaignName, accKey, Followername, FollowerId, "", "", "", ""); } catch { }; //Logg current status of Follow process Log("[ " + DateTime.Now + " ] => [ " + TargetedUser_item + " Followed by :- " + accKey + " ]"); //Delay after every Follow.. int delay = BaseLib.RandomNumberGenerator.GenerateRandom(DelayStart, DelayEnd); Log("[ " + DateTime.Now + " ] => [ Delay :- " + delay + " seconds ]"); Thread.Sleep(delay * 1000); } //Code added by Lijo John for protected accounts else if (status == "pending") { RemoveFollwerFromTxtFile(tempDeleteFollowFilePath, TargetedUser_item); follow_count++; try { //Insert details in Report table RepositoryClasses.ReportTableRepository.InsertReport(CampaignName, accKey, Followername, FollowerId, "", "", "", ""); } catch { }; //Logg current status of Follow process Log("[ " + DateTime.Now + " ] => [ Follow request sent by :- " + accKey + " awaiting for approval since " + TargetedUser_item + " is protected]"); //Delay after every Follow.. int delay = BaseLib.RandomNumberGenerator.GenerateRandom(DelayStart, DelayEnd); Log("[ " + DateTime.Now + " ] => [ Delay :- " + delay + " seconds ]"); Thread.Sleep(delay * 1000); } else if (status == "Already Followed") { RemoveFollwerFromTxtFile(tempDeleteFollowFilePath, TargetedUser_item); follow_count++; Log("[ " + DateTime.Now + " ] => [ " + TargetedUser_item + " Already Followed by :- " + accKey + " ]"); } else { Log("[ " + DateTime.Now + " ] => [ " + TargetedUser_item + " could not Followed by :- " + accKey + " ]"); } //Delay after every Follow.. //int delay = BaseLib.RandomNumberGenerator.GenerateRandom(DelayStar * 1000, DelayEnd * 1000); //Log("[ " + DateTime.Now + " ] => [ Delay :- " + TimeSpan.FromMilliseconds(delay).Seconds + " seconds ]"); //Thread.Sleep(delay); } catch (Exception ex) { Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error -->GetStartProcessForFollow()---> Get Follower ID From Name --> " + ex.Message, Globals.Path_FollowerErroLog); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error -->GetStartProcessForFollow()---> Get Follower ID From Name --> " + ex.Message, Globals.Path_FollowerErroLog); } } } } } catch (Exception) { } finally { //count_AccountforCampaignFollower--; Interlocked.Decrement(ref counterThreadsCampaignFollow); lock (lockerThreadsCampaignFollow) { Monitor.Pulse(lockerThreadsCampaignFollow); } if (counterThreadsCampaignFollow == 0) { _IsFollowProcessStart = true; if (cls_variables.lstCampaignStartShedular.Contains(CampaignName)) { try { cls_variables.lstCampaignStartShedular.Remove(CampaignName); } catch { }; } if (MixedCampaignManager.classes.cls_variables.Lst_WokingThreads.ContainsKey(CampaignName)) { MixedCampaignManager.classes.cls_variables.Lst_WokingThreads.Remove(CampaignName); } //frm_mixcampaignmanager objfrm = new frm_mixcampaignmanager(); //objfrm.controlStartButtonImage(CampaignName); RaiseCampaignFineshedEvent(CampaignName); Log("[ " + DateTime.Now + " ] => [ Process is completed for Campaign " + CampaignName + " ]"); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(CampaignName +": "+DateTime.Now, Globals.path_LogCampaignCompleted); } } }