public void StartRetweetProcess(DataSet CompaignsDataSet, String CampaignName) { try { DataRow[] drModelDetails = CompaignsDataSet.Tables[0].Select("CampaignName = '" + CampaignName + "'"); if (drModelDetails.Count() == 0) { } //Get 1st row from arrey DataRow DrCampaignDetails = drModelDetails[0]; string AcFilePath = DrCampaignDetails.ItemArray[2].ToString(); string _retweetKeyword = DrCampaignDetails.ItemArray[3].ToString(); bool _IsUsername = (Convert.ToInt32(DrCampaignDetails.ItemArray[5]) == 1) ? true : false; bool _IsUniqueMessage = (Convert.ToInt32(DrCampaignDetails.ItemArray[19]) == 1) ? true : false; bool _IsRetweetParDay = (Convert.ToInt32(DrCampaignDetails.ItemArray[8]) == 1) ? true : false; int _NoofRetweetParDay = Convert.ToInt32(DrCampaignDetails.ItemArray[9]); int _NoofRetweetParAc = Convert.ToInt32(DrCampaignDetails.ItemArray[10]); bool IsSchedulDaily = (Convert.ToInt32(DrCampaignDetails.ItemArray[12]) == 1) ? true : false; DateTime SchedulerStartTime = Convert.ToDateTime(DrCampaignDetails.ItemArray[13].ToString()); DateTime SchedulerEndTime = Convert.ToDateTime(DrCampaignDetails.ItemArray[14].ToString()); int DelayStar = Convert.ToInt32(DrCampaignDetails.ItemArray[15]); int DelayEnd = Convert.ToInt32(DrCampaignDetails.ItemArray[16]); int NoOfThreads = Convert.ToInt32(DrCampaignDetails.ItemArray[17]); List <string> _lstUserAccounts = new List <string>(); List <List <CampTwitterDataScrapper.StructTweetIDs> > list_lstTargetTweetMessages = new List <List <CampTwitterDataScrapper.StructTweetIDs> >(); classes.Cls_AccountsManager Obj_AccManger = new Cls_AccountsManager(); //Checking Account File is Exist or not if (!File.Exists(AcFilePath)) { ReTweetUserControlLog("[ " + DateTime.Now + " ] => [ Account File Doesn't Exist. Please Update Account File of Campaign " + CampaignName + " ]"); return; } // Get User ID and pass from File ... _lstUserAccounts = Globussoft.GlobusFileHelper.ReadLargeFile(AcFilePath); _lstUserAccounts = _lstUserAccounts.Distinct().ToList(); if (_lstUserAccounts.Count == 0) { MessageBox.Show("Account File is Empty."); return; } if (string.IsNullOrEmpty(_retweetKeyword)) { MessageBox.Show("Re-Tweet key word is not mention."); return; } CampaignTweetAccountContainer objCampaignReTweetAccountContainer = Obj_AccManger.AccountManager(_lstUserAccounts); ReTweetUserControlLog("[ " + DateTime.Now + " ] => [ " + objCampaignReTweetAccountContainer.dictionary_CampaignAccounts.Count + " Accounts Uploaded. ]"); //get All tweets from entered user name //Scrap Tweets using Username List <CampTwitterDataScrapper.StructTweetIDs> lst_Struct_TweetData = new List <CampTwitterDataScrapper.StructTweetIDs>(); CampTwitterDataScrapper CamptweetScrapper = new CampTwitterDataScrapper(); int noOfRecordsForUniqueMessage = (_NoofRetweetParAc * (objCampaignReTweetAccountContainer.dictionary_CampaignAccounts.Count)); //List<string> _lstTweetMessageForUnique = new List<string>(); int splitNo = 0; //Get details according to enter keyword is user name or keyword ReTweetUserControlLog("[ " + DateTime.Now + " ] => [ Getting Tweets from " + _retweetKeyword + " KeyWord. ]"); CamptweetScrapper.noOfRecords = (_NoofRetweetParAc * (objCampaignReTweetAccountContainer.dictionary_CampaignAccounts.Count)); if (_IsUsername) { lst_Struct_TweetData = CamptweetScrapper.TweetExtractor_ByUserName_New(_retweetKeyword); } else if (_IsUniqueMessage) { lst_Struct_TweetData = CamptweetScrapper.GetTweetData_New_ForCampaign(_retweetKeyword, noOfRecordsForUniqueMessage); splitNo = lst_Struct_TweetData.Count / _lstUserAccounts.Count; if (splitNo == 0) { splitNo = RandomNumberGenerator.GenerateRandom(0, lst_Struct_TweetData.Count - 1); } list_lstTargetTweetMessages = Split(lst_Struct_TweetData, splitNo); } else { lst_Struct_TweetData = CamptweetScrapper.GetTweetData_New_ForCampaign(_retweetKeyword, _NoofRetweetParAc); } ReTweetUserControlLog("[ " + DateTime.Now + " ] => [ " + lst_Struct_TweetData.Count + " Tweet Founded. ]"); if (lst_Struct_TweetData.Count == 0) { ReTweetUserControlLog("[ " + DateTime.Now + " ] => [ " + lst_Struct_TweetData.Count + " Tweet Founded. ]"); MessageBox.Show("No records Found from " + _retweetKeyword + " Keywored."); return; } MixedCampaignManager.CustomUserControls.retweetusercontrols Objretweetusercontrol = new CustomUserControls.retweetusercontrols(); Objretweetusercontrol.retweetusercontrolslogEvents.addToLogger += new EventHandler(logEvents_addToLogger); ThreadPool.SetMaxThreads(NoOfThreads, NoOfThreads); int LstCounter = 0; foreach (var Account in objCampaignReTweetAccountContainer.dictionary_CampaignAccounts) { ((CampaignAccountManager)Account.Value).logEvents.addToLogger += new EventHandler(logEvents_addToLogger); if (_IsUniqueMessage) { lst_Struct_TweetData = list_lstTargetTweetMessages[LstCounter]; } if (counterThreadsCampaignRetweet >= NoOfThreads) { lock (lockerThreadsCamapignRetweet) { Monitor.Wait(lockerThreadsCamapignRetweet); } } #region New Licensing Feature Added by Sonu try { if (Globals.IsBasicVersion || Globals.IsProVersion || Globals.IsFreeVersion) { string queryCheckDataBaseEmpty = "select * from tb_FBAccount"; DataSet DS1 = DataBaseHandler.SelectQuery(queryCheckDataBaseEmpty, "tb_FBAccount"); if (!(DS1.Tables[0].Rows.Count == 0)) { DataTable DT = DS1.Tables[0]; bool check = DT.Select().Any(x => x.ItemArray[0].ToString() == Account.Key); if (!check) { System.Windows.Forms.MessageBox.Show("Please Upload this Account in Account Manager"); return; } else { Thread threadGetStartProcessForRetweet = new Thread(startRetweeting); threadGetStartProcessForRetweet.Name = CampaignName + "_" + Account.Key; threadGetStartProcessForRetweet.IsBackground = true; threadGetStartProcessForRetweet.Start(new object[] { Account, lst_Struct_TweetData, _IsRetweetParDay, _NoofRetweetParDay, _NoofRetweetParAc, DelayStar, DelayEnd, CampaignName, IsSchedulDaily, SchedulerEndTime }); } } else { System.Windows.Forms.MessageBox.Show("Please Upload this Account in Account Manager"); return; } } else { Thread threadGetStartProcessForRetweet = new Thread(startRetweeting); threadGetStartProcessForRetweet.Name = CampaignName + "_" + Account.Key; threadGetStartProcessForRetweet.IsBackground = true; threadGetStartProcessForRetweet.Start(new object[] { Account, lst_Struct_TweetData, _IsRetweetParDay, _NoofRetweetParDay, _NoofRetweetParAc, DelayStar, DelayEnd, CampaignName, IsSchedulDaily, SchedulerEndTime }); } } catch { }; #endregion #region old Code //Thread threadGetStartProcessForRetweet = new Thread(startRetweeting); //threadGetStartProcessForRetweet.Name = CampaignName + "_" + Account.Key; //threadGetStartProcessForRetweet.IsBackground = true; //threadGetStartProcessForRetweet.Start(new object[] { Account, lst_Struct_TweetData, _IsRetweetParDay, _NoofRetweetParDay, _NoofRetweetParAc, DelayStar, DelayEnd, CampaignName, IsSchedulDaily, SchedulerEndTime }); #endregion Thread.Sleep(1000); LstCounter++; } } catch (Exception Err) { ReTweetUserControlLog("[ " + DateTime.Now + " ] => [ There is some error,Retweet Process cannot be started ]"); } }
public void StartProcess(String CampaignName, String featurName, DataRow CampRow) { try { string val = string.Empty; try { try { val = CampRow["indx"].ToString(); } catch { } if (string.IsNullOrEmpty(val)) { DataRow[] drModelDetails = null; DataSet CompaignsDataSet = cls_variables.LoadCampaignTemp(); drModelDetails = CompaignsDataSet.Tables[0].Select("CampaignName = '" + CampaignName + "'"); try { //if (drModelDetails.Count() > 3) { CampRow = drModelDetails[0]; } } catch { }; } } catch { } //DataRow[] drModelDetails = CompaignsDataSet.Tables[0].Select("CampaignName = '" + CampaignName + "'"); //if (drModelDetails.Count() == 0) //{ //} //Get 1st row from arrey DataRow DrCampaignDetails = CampRow; //Set all Details string AcFilePath = DrCampaignDetails.ItemArray[2].ToString(); string FollowFilePath = DrCampaignDetails.ItemArray[3].ToString(); bool divideEql = (Convert.ToInt32(DrCampaignDetails.ItemArray[5]) == 1) ? true : false; bool dividebyUser = (Convert.ToInt32(DrCampaignDetails.ItemArray[6]) == 1) ? true : false; int NoOfUsersDivid = Convert.ToInt32(DrCampaignDetails.ItemArray[7]); bool IsfastFollow = (Convert.ToInt32(DrCampaignDetails.ItemArray[8]) == 1) ? true : false; int NoOfFollowPerAc = Convert.ToInt32(DrCampaignDetails.ItemArray[9]); bool IsSchedulDaily = (Convert.ToInt32(DrCampaignDetails.ItemArray[12]) == 1) ? true : false; DateTime SchedulerStartTime = Convert.ToDateTime(DrCampaignDetails.ItemArray[13].ToString()); DateTime SchedulerEndTime = Convert.ToDateTime(DrCampaignDetails.ItemArray[14].ToString()); int DelayStar = Convert.ToInt32(DrCampaignDetails.ItemArray[15]); int DelayEnd = Convert.ToInt32(DrCampaignDetails.ItemArray[16]); int NoOfThreads = Convert.ToInt32(DrCampaignDetails.ItemArray[17]); List <string> _lstUserAccounts = new List <string>(); List <string> _lstFollowersName = new List <string>(); List <List <string> > list_lstTargetUsers = new List <List <string> >(); classes.Cls_AccountsManager Obj_AccManger = new Cls_AccountsManager(); //Check Files is existing... if (!File.Exists(FollowFilePath)) { Log("[ " + DateTime.Now + " ] => [ Followers Users File Doesn't Exixst. Please change account File. ]"); if (cls_variables.lstCampaignStartShedular.Contains(CampaignName)) { try { cls_variables.lstCampaignStartShedular.Remove(CampaignName); } catch { }; } return; } else if (!File.Exists(AcFilePath)) { Log("[ " + DateTime.Now + " ] => [ Account File Doesn't Exixst. Please change account File. ]"); if (cls_variables.lstCampaignStartShedular.Contains(CampaignName)) { try { cls_variables.lstCampaignStartShedular.Remove(CampaignName); } catch { }; } return; } // Get User ID and pass from File ... _lstUserAccounts = Globussoft.GlobusFileHelper.ReadLargeFile(AcFilePath); Log("[ " + DateTime.Now + " ] => [ " + _lstUserAccounts.Count + " Accounts is uploaded. ]"); //Get Followers Name _lstFollowersName = Globussoft.GlobusFileHelper.ReadLargeFile(FollowFilePath); _lstFollowersName = _lstFollowersName.Distinct().ToList(); Log("[ " + DateTime.Now + " ] => [ " + _lstFollowersName.Count + " Followers uploaded. ]"); if (_lstFollowersName.Count == 0) { Log("[ " + DateTime.Now + " ] => [ Please Upload correct Followers File. ]"); 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); } return; } CampaignTweetAccountContainer objCampaignFollowAccountContainer = Obj_AccManger.AccountManager(_lstUserAccounts); if (dividebyUser || divideEql) { int splitNo = 0; if (divideEql) { splitNo = _lstFollowersName.Count / _lstUserAccounts.Count; } else if (dividebyUser) { if (NoOfUsersDivid != 0) { int res = Convert.ToInt32(NoOfUsersDivid); splitNo = res; } } if (splitNo == 0) { splitNo = RandomNumberGenerator.GenerateRandom(0, _lstFollowersName.Count - 1); } list_lstTargetUsers = Split(_lstFollowersName, splitNo); } //create logger Event object for accessing log MSG's .. CustomUserControls.followusecontrols.CampaignFollowerLogEvents.addToLogger += new EventHandler(logEvents_addToLogger); //set Max thread ThreadPool.SetMaxThreads(NoOfThreads, NoOfThreads); int LstCounter = 0; foreach (var item in objCampaignFollowAccountContainer.dictionary_CampaignAccounts) { try { //check list for breaking loop //if list of follow members list is completed. if (LstCounter == list_lstTargetUsers.Count && (dividebyUser || divideEql)) { Log("[ " + DateTime.Now + " ] => [ Account is grater than List of users. ]"); break; } List <string> list_lstTargetUsers_item = new List <string>(); if (dividebyUser || divideEql) { list_lstTargetUsers_item = list_lstTargetUsers[LstCounter]; } else { list_lstTargetUsers_item = _lstFollowersName; } //get event from accountmanager class // and create Event for printing log messages ((CampaignAccountManager)item.Value).logEvents.addToLogger += new EventHandler(logEvents_addToLogger); //Manage no of threads if (counterThreadsCampaignFollow >= NoOfThreads) { lock (lockerThreadsCampaignFollow) { Monitor.Wait(lockerThreadsCampaignFollow); } } #region New Licencing Feature Added by Sonu try { if (Globals.IsBasicVersion || Globals.IsProVersion || Globals.IsFreeVersion) { string queryCheckDataBaseEmpty = "select * from tb_FBAccount"; DataSet DS1 = DataBaseHandler.SelectQuery(queryCheckDataBaseEmpty, "tb_FBAccount"); if (!(DS1.Tables[0].Rows.Count == 0)) { DataTable DT = DS1.Tables[0]; bool check = DT.Select().Any(x => x.ItemArray[0].ToString() == item.Key); if (!check) { System.Windows.Forms.MessageBox.Show("Please Upload this Account in Account Manager"); return; } else { Thread threadGetStartProcessForFollow = new Thread(GetStartProcessForFollow); threadGetStartProcessForFollow.Name = CampaignName + "_" + item.Key; threadGetStartProcessForFollow.IsBackground = true; threadGetStartProcessForFollow.Start(new object[] { item, list_lstTargetUsers_item, NoOfFollowPerAc, DelayStar, DelayEnd, CampaignName, IsSchedulDaily, SchedulerEndTime, divideEql, dividebyUser, FollowFilePath }); } } else { System.Windows.Forms.MessageBox.Show("Please Upload this Account in Account Manager"); return; } } else { Thread threadGetStartProcessForFollow = new Thread(GetStartProcessForFollow); threadGetStartProcessForFollow.Name = CampaignName + "_" + item.Key; threadGetStartProcessForFollow.IsBackground = true; threadGetStartProcessForFollow.Start(new object[] { item, list_lstTargetUsers_item, NoOfFollowPerAc, DelayStar, DelayEnd, CampaignName, IsSchedulDaily, SchedulerEndTime, divideEql, dividebyUser, FollowFilePath }); } } catch { }; #endregion #region Old Code //Thread threadGetStartProcessForFollow = new Thread(GetStartProcessForFollow); //threadGetStartProcessForFollow.Name = CampaignName + "_" + item.Key; //threadGetStartProcessForFollow.IsBackground = true; //threadGetStartProcessForFollow.Start(new object[] { item, list_lstTargetUsers_item, NoOfFollowPerAc, DelayStar, DelayEnd, CampaignName, IsSchedulDaily, SchedulerEndTime, divideEql, dividebyUser, FollowFilePath }); #endregion Thread.Sleep(1000); LstCounter++; } catch (Exception) { } } } catch (Exception) { } finally { } }
public CampaignTweetAccountContainer AccountManager(List <string> templist) { CampaignTweetAccountContainer objCampaignTweetAccountContainer = new CampaignTweetAccountContainer(); //List<CampaignTweetAccountContainer> lst_CampaignTweetAccount = new List<CampaignTweetAccountContainer>(); foreach (string item in templist) { string account = item; string[] AccArr = account.Split(':'); if (AccArr.Count() > 1) { string accountUser = account.Split(':')[0]; string accountPass = account.Split(':')[1]; string screanName = string.Empty; string IPAddress = string.Empty; string IPPort = string.Empty; string IPUsername = string.Empty; string IPpassword = string.Empty; string status = string.Empty; int DataCount = account.Split(':').Length; if (DataCount == 2) { //Globals.accountMode = AccountMode.NoIP; accountUser = account.Split(':')[0]; accountPass = account.Split(':')[1]; } else if (DataCount == 3) { //Globals.accountMode = AccountMode.PublicIP; screanName = account.Split(':')[2]; } else if (DataCount == 4) { //Globals.accountMode = AccountMode.PublicIP; accountUser = account.Split(':')[0]; accountPass = account.Split(':')[1]; IPAddress = account.Split(':')[2]; IPPort = account.Split(':')[3]; } else if (DataCount == 5) { //Globals.accountMode = AccountMode.PublicIP; screanName = account.Split(':')[2]; IPAddress = account.Split(':')[3]; IPPort = account.Split(':')[4]; } else if (DataCount > 5 && DataCount < 7) { //Globals.accountMode = AccountMode.PrivateIP; accountUser = account.Split(':')[0]; accountPass = account.Split(':')[1]; IPAddress = account.Split(':')[2]; IPPort = account.Split(':')[3]; IPUsername = account.Split(':')[4]; IPpassword = account.Split(':')[5]; //dt.Rows.Add(accountUser, accountPass, string.Empty , string.Empty, IPAddress, IPPort, IPUsername, IPpassword, "", "0"); } else if (DataCount == 7) { //Globals.accountMode = AccountMode.PrivateIP; accountUser = account.Split(':')[0]; accountPass = account.Split(':')[1]; IPAddress = account.Split(':')[3]; IPPort = account.Split(':')[4]; IPUsername = account.Split(':')[5]; IPpassword = account.Split(':')[6]; //dt.Rows.Add(accountUser, accountPass, string.Empty , string.Empty, IPAddress, IPPort, IPUsername, IPpassword, "", "0"); } else if (DataCount == 9) { //Globals.accountMode = AccountMode.PrivateIP; accountUser = account.Split(':')[0]; accountPass = account.Split(':')[1]; IPAddress = account.Split(':')[2]; IPPort = account.Split(':')[3]; IPUsername = account.Split(':')[4]; IPpassword = account.Split(':')[5]; //dt.Rows.Add(accountUser, accountPass, string.Empty , string.Empty, IPAddress, IPPort, IPUsername, IPpassword, "", "0"); } //if (Globals.IsFreeVersion) //{ // if (dt.Rows.Count >= 5) // { // FrmFreeTrial frmFreeTrial = new FrmFreeTrial(); // frmFreeTrial.TopMost = true; // frmFreeTrial.BringToFront(); // frmFreeTrial.ShowDialog(); // break; // } //} //dt.Rows.Add(accountUser, accountPass, screanName, string.Empty, IPAddress, IPPort, IPUsername, IPpassword, "", "0"); try { CampaignAccountManager twitter = new CampaignAccountManager(); twitter.Username = accountUser; twitter.Password = accountPass; twitter.IPAddress = IPAddress; twitter.IPPort = IPPort; twitter.IPUsername = IPUsername; twitter.IPpassword = IPpassword; twitter.Screen_name = screanName; // twitter.profileStatus = 0; twitter.AccountStatus = ""; objCampaignTweetAccountContainer.dictionary_CampaignAccounts.Add(twitter.Username, twitter); //lst_CampaignTweetAccount.Add(objCampaignTweetAccountContainer); } catch { } //string profileStatus = "0"; } else { // AddToListBox("Account has some problem : " + item); } } return(objCampaignTweetAccountContainer); }