private void LoadAccounts() { this.Dispatcher.Invoke(new Action(delegate { AccountViewModel._listOfAccount.Clear(); })); DataSet ds; DataTable dt = new DataTable(); DateTime sTime = DateTime.Now; try { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".txt"; dlg.Filter = "Text documents (.txt)|*.txt"; Nullable<bool> result = dlg.ShowDialog(); string Path = dlg.ToString().Replace("Microsoft.Win32.OpenFileDialog: Title: , FileName", ""); if (result == true) { dt.Columns.Add("UserName"); dt.Columns.Add("Password"); dt.Columns.Add("ProxyAddress"); dt.Columns.Add("ProxyPort"); dt.Columns.Add("ProxyUserName"); dt.Columns.Add("ProxyPassword"); ds = new DataSet(); ds.Tables.Add(dt); List<string> templist = GlobusFileHelper.ReadFile(dlg.FileName); if (templist.Count > 0) { IGGlobals.loadedAccountsDictionary.Clear(); } if (Globals.IsBasicVersion) { try { string selectQuery = "select count(UserName) from AccountInfo"; DataSet DS = DataBaseHandler.SelectQuery(selectQuery, "AccountInfo"); int countLoadedAccounts = Convert.ToInt32(DS.Tables[0].Rows[0].ItemArray[0].ToString()); if (countLoadedAccounts >= 5) { LoadAccountsFromDataBase(); GlobusLogHelper.log.Info("You Are Using ID Basic Version 5 Accounts allready loaded.."); // MessageBox.Show("You Are Using ID Basic Version 5 Accounts allready loaded.."); // AccounLoad(); // LoadAccountProgressBar.IsIndeterminate = false; // ModernDialog.ShowMessage("You Are Using ID Basic Version 5 Accounts allready loaded..", "Message", MessageBoxButton.OK); this.Dispatcher.Invoke(new Action(delegate { LoadAccountProgressBar.IsIndeterminate = false; })); return; } else { int RemainingAccount = 5 - countLoadedAccounts; templist.RemoveRange(RemainingAccount, templist.Count - RemainingAccount); } } catch { } } if (Globals.IsProVersion) { try { string selectQuery = "select count(UserName) from AccountInfo"; DataSet DS = DataBaseHandler.SelectQuery(selectQuery, "AccountInfo"); int countLoadedAccounts = Convert.ToInt32(DS.Tables[0].Rows[0].ItemArray[0].ToString()); if (countLoadedAccounts >= 15) { LoadAccountsFromDataBase(); MessageBox.Show("You Are Using ID Pro Version 15 Accounts allready loaded.."); AccounLoad(); LoadAccountProgressBar.IsIndeterminate = false; return; } else { int RemainingAccount = 15 - countLoadedAccounts; templist.RemoveRange(RemainingAccount, templist.Count - RemainingAccount); } } catch { } } int counter = 0; foreach (string item in templist) { if (Globals.CheckLicenseManager == "fdfreetrial" && counter == 5) { break; } counter = counter + 1; try { string account = item; string[] AccArr = account.Split(':'); if (AccArr.Count() > 1) { string accountUser = account.Split(':')[0]; string accountPass = account.Split(':')[1]; string proxyAddress = string.Empty; string proxyPort = string.Empty; string proxyUserName = string.Empty; string proxyPassword = string.Empty; string status = string.Empty; string LogInStatus = string.Empty; int DataCount = account.Split(':').Length; LogInStatus = "Not Checked"; // new Thread(() => //{ if (DataCount == 2) { //Globals.accountMode = AccountMode.NoProxy; } else if (DataCount == 4) { proxyAddress = account.Split(':')[2]; proxyPort = account.Split(':')[3]; } else if (DataCount > 5 && DataCount < 7) { proxyAddress = account.Split(':')[2]; proxyPort = account.Split(':')[3]; proxyUserName = account.Split(':')[4]; proxyPassword = account.Split(':')[5]; } else if (DataCount == 7) { proxyAddress = account.Split(':')[2]; proxyPort = account.Split(':')[3]; proxyUserName = account.Split(':')[4]; proxyPassword = account.Split(':')[5]; } dt.Rows.Add(accountUser, accountPass, proxyAddress, proxyPort, proxyUserName, proxyPassword); Qm.DeleteAccounts(accountUser); Qm.AddAccountInDataBase(accountUser, accountPass, proxyAddress, proxyPort, proxyUserName, proxyPassword, Path, LogInStatus); // }).Start(); try { GramDominator.ViewModule.AccountNotifyPropertyChanged objAccountNotifyPropertyChanged = new GramDominator.ViewModule.AccountNotifyPropertyChanged(); objAccountNotifyPropertyChanged.Username = accountUser; objAccountNotifyPropertyChanged.Password = accountPass; objAccountNotifyPropertyChanged.LoginStatus = LogInStatus; objAccountNotifyPropertyChanged.ProxyAddress = proxyAddress; objAccountNotifyPropertyChanged.ProxyPassword = proxyPassword; objAccountNotifyPropertyChanged.ProxyPort = proxyPort; objAccountNotifyPropertyChanged.ProxyUserName = proxyUserName; objAccountNotifyPropertyChanged.Status = status; if (LogInStatus.Contains("Success")) { objAccountNotifyPropertyChanged.LoginStatus = "Success"; objAccountNotifyPropertyChanged.BackgroundColor = "Green"; AccountViewModel._listOfAccount.Add(objAccountNotifyPropertyChanged); } else if (LogInStatus.Contains("Fail")) { objAccountNotifyPropertyChanged.LoginStatus = "Fail"; objAccountNotifyPropertyChanged.BackgroundColor = "Red"; AccountViewModel._listOfAccount.Add(objAccountNotifyPropertyChanged); } else if (LogInStatus.Contains("Not")) { objAccountNotifyPropertyChanged.LoginStatus = "Not Checked"; objAccountNotifyPropertyChanged.BackgroundColor = "Red"; this.Dispatcher.Invoke(new Action(delegate { AccountViewModel._listOfAccount.Add(objAccountNotifyPropertyChanged); })); } } catch (Exception ex) { } try { InstagramUser objInstagramUser = new InstagramUser("", "", "", ""); objInstagramUser.username = accountUser; objInstagramUser.password = accountPass; objInstagramUser.proxyip = proxyAddress; objInstagramUser.proxyport = proxyPort; objInstagramUser.proxyusername = proxyUserName; objInstagramUser.proxypassword = proxyPassword; objInstagramUser.globusHttpHelper = new GlobusHttpHelper(); objInstagramUser.globusHttpHelper.proxyAddress = proxyAddress; try { objInstagramUser.globusHttpHelper.port = int.Parse(proxyPort); } catch { objInstagramUser.globusHttpHelper.port = 80; }; objInstagramUser.globusHttpHelper.proxyUsername = proxyUserName; objInstagramUser.globusHttpHelper.proxyPassword = proxyPassword; IGGlobals.loadedAccountsDictionary.Add(objInstagramUser.username, objInstagramUser); IGGlobals.listAccounts.Add(objInstagramUser.username + ":" + objInstagramUser.password + ":" + objInstagramUser.proxyip + ":" + objInstagramUser.proxyport + ":" + objInstagramUser.proxyusername + ":" + objInstagramUser.proxypassword); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } ///Set this to "0" if loading unprofiled accounts /// string profileStatus = "0"; GlobusLogHelper.log.Info("Account Inserted In Database : " + item); } else { GlobusLogHelper.log.Info("Account has some problem : " + item); GlobusLogHelper.log.Debug("Account has some problem : " + item); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } try { DateTime eTime = DateTime.Now; string timeSpan = (eTime - sTime).TotalSeconds.ToString(); Application.Current.Dispatcher.Invoke(new Action(() => { lblaccounts_ManageAccounts_LoadsAccountsCount.Content = IGGlobals.listAccounts.Count; })); GlobusLogHelper.log.Debug("Accounts Loaded : " + IGGlobals.listAccounts.Count + " In " + timeSpan + " Seconds"); GlobusLogHelper.log.Info("Accounts Loaded : " + dt.Rows.Count.ToString() + " In " + timeSpan + " Seconds"); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } AccounLoad(); Application.Current.Dispatcher.Invoke((Action)(() => { LoadAccountProgressBar.IsIndeterminate = false; })); }
public void AccounLoadaCCOUNTcHEKER() { try { this.Dispatcher.Invoke(new Action(delegate { AccountViewModel._listOfAccount.Clear(); })); NoOfAccountLoading++; string accountUser = string.Empty; string accountPass = string.Empty; string proxyAddress = string.Empty; string proxyPort = string.Empty; string proxyUserName = string.Empty; string proxyPassword = string.Empty; string LogInStatus = string.Empty; string FollowerCount = string.Empty; string FollwingCount = string.Empty; string Authorized = string.Empty; string Post = string.Empty; string path = string.Empty; QueryExecuter QME = new QueryExecuter(); DataSet ds = QME.getAccount(); if (ds.Tables[0].Rows.Count != 0) { this.Dispatcher.Invoke(new Action(delegate { IGGlobals.listAccounts.Clear(); })); for (int noRow = 0; noRow < ds.Tables[0].Rows.Count; noRow++) { this.Dispatcher.Invoke(new Action(delegate { string account = ds.Tables[0].Rows[noRow].ItemArray[0].ToString() + ":" + ds.Tables[0].Rows[noRow].ItemArray[1].ToString() + ":" + ds.Tables[0].Rows[noRow].ItemArray[2].ToString() + ":" + ds.Tables[0].Rows[noRow].ItemArray[3].ToString() + ":" + ds.Tables[0].Rows[noRow].ItemArray[4].ToString() + ":" + ds.Tables[0].Rows[noRow].ItemArray[5].ToString(); IGGlobals.listAccounts.Add(account); accountUser = ds.Tables[0].Rows[noRow].ItemArray[0].ToString(); accountPass = ds.Tables[0].Rows[noRow].ItemArray[1].ToString(); proxyAddress = ds.Tables[0].Rows[noRow].ItemArray[2].ToString(); proxyPort = ds.Tables[0].Rows[noRow].ItemArray[3].ToString(); proxyUserName = ds.Tables[0].Rows[noRow].ItemArray[4].ToString(); proxyPassword = ds.Tables[0].Rows[noRow].ItemArray[5].ToString(); LogInStatus = ds.Tables[0].Rows[noRow].ItemArray[7].ToString(); FollowerCount = ds.Tables[0].Rows[noRow].ItemArray[9].ToString(); FollwingCount = ds.Tables[0].Rows[noRow].ItemArray[10].ToString(); path = ds.Tables[0].Rows[noRow].ItemArray[6].ToString(); Authorized = ds.Tables[0].Rows[noRow].ItemArray[11].ToString(); Post = ds.Tables[0].Rows[noRow].ItemArray[8].ToString(); InstagramUser objInstagramUser = new InstagramUser("", "", "", ""); objInstagramUser.username = accountUser; objInstagramUser.password = accountPass; objInstagramUser.proxyip = proxyAddress; objInstagramUser.proxyport = proxyPort; objInstagramUser.proxyusername = proxyUserName; objInstagramUser.proxypassword = proxyPassword; objInstagramUser.LogInStatus = LogInStatus; objInstagramUser.FollowerCount = FollowerCount; objInstagramUser.FollwingCount = FollwingCount; objInstagramUser.Path = path; objInstagramUser.Authorized = Authorized; objInstagramUser.Post = Post; try { GramDominator.ViewModule.AccountNotifyPropertyChanged objAccountNotifyPropertyChanged = new GramDominator.ViewModule.AccountNotifyPropertyChanged(); objAccountNotifyPropertyChanged.Username = accountUser; objAccountNotifyPropertyChanged.Password = accountPass; objAccountNotifyPropertyChanged.LoginStatus = LogInStatus; objAccountNotifyPropertyChanged.FollowerCount = FollowerCount; objAccountNotifyPropertyChanged.FollowingCount = FollwingCount; objAccountNotifyPropertyChanged.ProxyAddress = proxyAddress; objAccountNotifyPropertyChanged.ProxyPassword = proxyPassword; objAccountNotifyPropertyChanged.ProxyPort = proxyPort; objAccountNotifyPropertyChanged.ProxyUserName = proxyUserName; objAccountNotifyPropertyChanged.Authorized = Authorized; objAccountNotifyPropertyChanged.Post = Post; objAccountNotifyPropertyChanged.Path = path; if (LogInStatus.Contains("Success")) { objAccountNotifyPropertyChanged.LoginStatus = "Success"; objAccountNotifyPropertyChanged.BackgroundColor = "Green"; this.Dispatcher.Invoke(new Action(delegate { if (!AccountViewModel._listOfAccount.Contains(objAccountNotifyPropertyChanged)) { AccountViewModel._listOfAccount.Add(objAccountNotifyPropertyChanged); } })); } else if (LogInStatus.Contains("Fail")) { objAccountNotifyPropertyChanged.LoginStatus = "Fail"; objAccountNotifyPropertyChanged.BackgroundColor = "Red"; this.Dispatcher.Invoke(new Action(delegate { if (!AccountViewModel._listOfAccount.Contains(objAccountNotifyPropertyChanged)) { AccountViewModel._listOfAccount.Add(objAccountNotifyPropertyChanged); } })); } else if (LogInStatus.Contains("Not")) { objAccountNotifyPropertyChanged.LoginStatus = "Not Checked"; objAccountNotifyPropertyChanged.BackgroundColor = ""; this.Dispatcher.Invoke(new Action(delegate { if (!AccountViewModel._listOfAccount.Contains(objAccountNotifyPropertyChanged)) { AccountViewModel._listOfAccount.Add(objAccountNotifyPropertyChanged); } })); } } catch (Exception ex) { } try { IGGlobals.loadedAccountsDictionary.Add(objInstagramUser.username, objInstagramUser); try { this.Dispatcher.Invoke(new Action(delegate { grvAccounts_AccountCreator_AccountDetails.ItemsSource = AccountViewModel._listOfAccount; })); } catch { }; } catch { }; })); } try { this.Dispatcher.Invoke(new Action(delegate { grvAccounts_AccountCreator_AccountDetails.ItemsSource = AccountViewModel._listOfAccount; })); } catch { }; if (NoOfAccountLoading >= NoOfAccountLoaded) { GlobusLogHelper.log.Info("[ " + IGGlobals.listAccounts.Count + " Accounts Loaded ]"); } } else { this.Dispatcher.Invoke(new Action(delegate { grvAccounts_AccountCreator_AccountDetails.ItemsSource = ds.Tables[0].DefaultView; })); GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ No Accounts Loaded ]"); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error ==> " + ex.StackTrace); } }
public void LoadAccountsFromDataBase() { try { this.Dispatcher.Invoke(new Action(delegate { AccountViewModel._listOfAccount.Clear(); })); IGGlobals.loadedAccountsDictionary.Clear(); IGGlobals.listAccounts.Clear(); DataTable dt = new DataTable(); dt.Columns.Add("UserName"); dt.Columns.Add("Password"); dt.Columns.Add("proxyAddress"); dt.Columns.Add("proxyPort"); dt.Columns.Add("proxyUsername"); dt.Columns.Add("proxyPassword"); dt.Columns.Add("LogInStatus"); dt.Columns.Add("Posts"); dt.Columns.Add("Followers"); dt.Columns.Add("Followings"); dt.Columns.Add("Authorized"); dt.Columns.Add("Status"); dt.Columns.Add("Path"); int counter = 0; DataSet ds = null; try { ds = Qm.SelectAccounts(); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } foreach (DataRow ds_item in ds.Tables[0].Rows) { if (Globals.CheckLicenseManager == "fdfreetrial" && counter == 5) { break; } counter = counter + 1; try { string item = ds_item[1].ToString() + ":" + ds_item[2].ToString() + ":" + ds_item[3].ToString() + ":" + ds_item[4].ToString() + ":" + ds_item[5].ToString() + ":" + ds_item[6].ToString() + ":" + ds_item[7].ToString() + ":" + ds_item[8].ToString() + ":" + ds_item[9].ToString() + ":" + ds_item[10].ToString() + ":" + ds_item[11].ToString() + ":" + ds_item[12].ToString() + ":" + ds_item[13].ToString(); string account = item; string[] AccArr = account.Split(':'); if (AccArr.Count() > 1) { string accountUser = account.Split(':')[0]; string accountPass = account.Split(':')[1]; string proxyAddress = string.Empty; string proxyPort = string.Empty; string proxyUsername = string.Empty; string proxyPassword = string.Empty; string LogInStatus = string.Empty; string Posts = string.Empty; string Followers = string.Empty; string Followings = string.Empty; string Authorized = string.Empty; string Status = string.Empty; string Path = string.Empty; DataGridColumn newcolumn = new DataGridHyperlinkColumn(); int DataCount = account.Split(':').Length; if (DataCount == 2) { //Globals.accountMode = AccountMode.NoProxy; } else if (DataCount == 4) { proxyAddress = account.Split(':')[2]; proxyPort = account.Split(':')[3]; } else if (DataCount > 5 && DataCount < 7) { proxyAddress = account.Split(':')[2]; proxyPort = account.Split(':')[3]; proxyUsername = account.Split(':')[4]; proxyPassword = account.Split(':')[5]; } else if (DataCount >= 7) { proxyAddress = account.Split(':')[2]; proxyPort = account.Split(':')[3]; proxyUsername = account.Split(':')[4]; proxyPassword = account.Split(':')[5]; // Path = account.Split(':')[6]; LogInStatus = account.Split(':')[9]; if (LogInStatus == "") { LogInStatus = "Not Checked"; } // Posts = account.Split(':')[8]; // Followers = account.Split(':')[9]; // Followings = account.Split(':')[10]; Authorized = account.Split(':')[11]; Status = account.Split(':')[12]; } dt.Rows.Add(accountUser, accountPass, proxyAddress, proxyPort, proxyUsername, proxyPassword, Path, LogInStatus, Posts, Followers, Followings, Authorized, Status); try { InstagramUser obj_InstagramUser = new InstagramUser("", "", "", ""); obj_InstagramUser.username = accountUser; obj_InstagramUser.password = accountPass; obj_InstagramUser.proxyip = proxyAddress; obj_InstagramUser.proxyport = proxyPort; obj_InstagramUser.proxyusername = proxyUsername; obj_InstagramUser.proxypassword = proxyPassword; obj_InstagramUser.LogInStatus = LogInStatus; obj_InstagramUser.globusHttpHelper = new GlobusHttpHelper(); obj_InstagramUser.globusHttpHelper.proxyAddress = proxyAddress; try { obj_InstagramUser.globusHttpHelper.port = int.Parse(proxyPort); } catch { obj_InstagramUser.globusHttpHelper.port = 80; }; obj_InstagramUser.globusHttpHelper.proxyUsername = proxyUsername; obj_InstagramUser.globusHttpHelper.proxyPassword = proxyPassword; IGGlobals.loadedAccountsDictionary.Add(obj_InstagramUser.username, obj_InstagramUser); #region MyRegion //try //{ // if (cmbGroups_GroupCampaignManager_Accounts.InvokeRequired) // { // cmbScraper__fanscraper_Accounts.Invoke(new MethodInvoker(delegate // { // cmbScraper__fanscraper_Accounts.Items.Add(accountUser); // })); // } //} //catch (Exception ex) //{ // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); //} //try //{ // if (cmbScraper__CustomAudiencesScraper_Accounts.InvokeRequired) // { // cmbScraper__CustomAudiencesScraper_Accounts.Invoke(new MethodInvoker(delegate // { // cmbScraper__CustomAudiencesScraper_Accounts.Items.Add(accountUser); // })); // } //} //catch (Exception ex) //{ // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); //} //try //{ // //cmbCommentsOnPostSelectAccount // if (cmbCommentsOnPostSelectAccount.InvokeRequired) // { // cmbCommentsOnPostSelectAccount.Invoke(new MethodInvoker(delegate // { // cmbCommentsOnPostSelectAccount.Items.Add(accountUser + ":" + accountPass); // })); // } //} //catch (Exception ex) //{ // GlobusLogHelper.log.Error(ex.Message); //} //try //{ // if (cmbGroups_GroupCampaignManager_Accounts.InvokeRequired) // { // cmbGroups_GroupCampaignManager_Accounts.Invoke(new MethodInvoker(delegate // { // cmbGroups_GroupCampaignManager_Accounts.Items.Add(accountUser); // })); // } //} //catch (Exception ex) //{ // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); //} //try //{ // if (cmbScraper__GroupMemberScraper_Accounts.InvokeRequired) // { // cmbScraper__GroupMemberScraper_Accounts.Invoke(new MethodInvoker(delegate // { // cmbScraper__GroupMemberScraper_Accounts.Items.Add(accountUser); // })); // } //} //catch (Exception ex) //{ // GlobusLogHelper.log.Error("Error : " + ex.StackTrace); //} #endregion IGGlobals.listAccounts.Add(obj_InstagramUser.username + ":" + obj_InstagramUser.password + ":" + obj_InstagramUser.proxyip + ":" + obj_InstagramUser.proxyport + ":" + obj_InstagramUser.proxyusername + ":" + obj_InstagramUser.proxypassword); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } ///Set this to "0" if loading unprofiled accounts /// string profileStatus = "0"; try { GramDominator.ViewModule.AccountNotifyPropertyChanged objAccountNotifyPropertyChanged = new GramDominator.ViewModule.AccountNotifyPropertyChanged(); objAccountNotifyPropertyChanged.Username = accountUser; objAccountNotifyPropertyChanged.Password = accountPass; objAccountNotifyPropertyChanged.LoginStatus = LogInStatus; // objAccountNotifyPropertyChanged.FollowerCount = FollowerCount; // objAccountNotifyPropertyChanged.FollowingCount = FollwingCount; objAccountNotifyPropertyChanged.ProxyAddress = proxyAddress; objAccountNotifyPropertyChanged.ProxyPassword = proxyPassword; objAccountNotifyPropertyChanged.ProxyPort = proxyPort; objAccountNotifyPropertyChanged.ProxyUserName = proxyUsername; objAccountNotifyPropertyChanged.Status = status; // objAccountNotifyPropertyChanged.Authorized = GroupName; if (LogInStatus.Contains("Success")) { objAccountNotifyPropertyChanged.LoginStatus = "Success"; objAccountNotifyPropertyChanged.BackgroundColor = "Green"; this.Dispatcher.Invoke(new Action(delegate { AccountViewModel._listOfAccount.Add(objAccountNotifyPropertyChanged); })); } else if (LogInStatus.Contains("Fail")) { objAccountNotifyPropertyChanged.LoginStatus = "Fail"; objAccountNotifyPropertyChanged.BackgroundColor = "Red"; this.Dispatcher.Invoke(new Action(delegate { AccountViewModel._listOfAccount.Add(objAccountNotifyPropertyChanged); })); } else if (LogInStatus.Contains("Not")) { objAccountNotifyPropertyChanged.LoginStatus = "Not Checked"; objAccountNotifyPropertyChanged.BackgroundColor = "Red"; this.Dispatcher.Invoke(new Action(delegate { AccountViewModel._listOfAccount.Add(objAccountNotifyPropertyChanged); })); } } catch (Exception ex) { } } else { GlobusLogHelper.log.Info("Account has some problem : " + item); GlobusLogHelper.log.Debug("Account has some problem : " + item); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } //DataView dv = ds.Tables[0].DefaultView; //dv.AllowNew = false; this.Dispatcher.Invoke(new Action(delegate { grvAccounts_AccountCreator_AccountDetails.ItemsSource = AccountViewModel._listOfAccount; })); //GlobusLogHelper.log.Debug("Accounts Loaded : " + dt.Rows.Count); // GlobusLogHelper.log.Info("Accounts Loaded : " + dt.Rows.Count); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } }