public void LoadAccounts() { try { DataSet ds; DataTable dt = new DataTable(); 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) { DateTime sTime = DateTime.Now; dt.Columns.Add("UserName"); dt.Columns.Add("Password"); dt.Columns.Add("Niches"); dt.Columns.Add("ProxyAddress"); dt.Columns.Add("ProxyPort"); dt.Columns.Add("ProxyUserName"); dt.Columns.Add("ProxyPassword"); //dt.Columns.Add("Useragent"); // dt.Columns.Add("BoardsName"); dt.Columns.Add("ScreenName"); dt.Columns.Add("LoginStatus"); ds = new DataSet(); ds.Tables.Add(dt); List<string> templist = GlobusFileHelper.ReadFile(dlg.FileName); if (templist.Count > 0) { PDGlobals.loadedAccountsDictionary.Clear(); PDGlobals.listAccounts.Clear(); } if (Globals.IsBasicVersion) { try { string selectQuery = "select count(UserName) from tb_emails"; DataSet DS = DataBaseHandler.SelectQuery(selectQuery, "tb_emails"); int countLoadedAccounts = Convert.ToInt32(DS.Tables[0].Rows[0].ItemArray[0].ToString()); if (countLoadedAccounts >= 5) { AccounLoad(); MessageBox.Show("You Are Using PD Basic Version 5 Accounts allready loaded.."); return; } else { int RemainingAccount = 5 - countLoadedAccounts; templist.RemoveRange(RemainingAccount, templist.Count - RemainingAccount); } } catch { } } if (Globals.IsProVersion) { try { string selectQuery = "select count(UserName) from tb_emails"; DataSet DS = DataBaseHandler.SelectQuery(selectQuery, "tb_emails"); int countLoadedAccounts = Convert.ToInt32(DS.Tables[0].Rows[0].ItemArray[0].ToString()); if (countLoadedAccounts >= 15) { AccounLoad(); MessageBox.Show("You Are Using PD Pro Version 15 Accounts allready loaded.."); 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 niches = string.Empty; string proxyAddress = string.Empty; string proxyPort = string.Empty; string proxyUserName = string.Empty; string proxyPassword = string.Empty; //string Useragent = string.Empty; string Followers = string.Empty; string Following = string.Empty; // string Boards = string.Empty; string BoardsName = string.Empty; string ScreenName = string.Empty; string LoginStatus = string.Empty; int DataCount = account.Split(':').Length; if (DataCount == 3) { niches = account.Split(':')[2]; } else if (DataCount == 5) { niches = account.Split(':')[2]; proxyAddress = account.Split(':')[3]; proxyPort = account.Split(':')[4]; } else if (DataCount == 7) { niches = account.Split(':')[2]; proxyAddress = account.Split(':')[3]; proxyPort = account.Split(':')[4]; proxyUserName = account.Split(':')[5]; proxyPassword = account.Split(':')[6]; //BoardsName = account.Split(':')[7]; } dt.Rows.Add(accountUser, accountPass, proxyAddress, proxyPort, proxyUserName, proxyPassword); //Qm.DeleteAccounts(accountUser); LoginStatus = "NotChecked"; Qm.AddAccountInDataBase(accountUser, accountPass, niches, proxyAddress, proxyPort, proxyUserName, proxyPassword, ScreenName, LoginStatus); try { AccountNotifyPropertyChanged objAccountNotifyPropertyChanged = new AccountNotifyPropertyChanged(); objAccountNotifyPropertyChanged.Username = accountUser; objAccountNotifyPropertyChanged.Password = accountPass; objAccountNotifyPropertyChanged.Niche = niches; objAccountNotifyPropertyChanged.ScreenName = ScreenName; objAccountNotifyPropertyChanged.FollowerCount = Followers; objAccountNotifyPropertyChanged.FollowingCount = Following; objAccountNotifyPropertyChanged.ProxyAddress = proxyAddress; objAccountNotifyPropertyChanged.ProxyPassword = proxyPassword; objAccountNotifyPropertyChanged.ProxyPort = proxyPort; objAccountNotifyPropertyChanged.ProxyUserName = proxyUserName; 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 = ""; this.Dispatcher.Invoke(new Action(delegate { AccountViewModel._listOfAccount.Add(objAccountNotifyPropertyChanged); })); } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } try { PinInterestUser objPinInterestUser = new PinInterestUser(); objPinInterestUser.Username = accountUser; objPinInterestUser.Password = accountPass; objPinInterestUser.Niches = niches; objPinInterestUser.ProxyAddress = proxyAddress; objPinInterestUser.ProxyPort = proxyPort; objPinInterestUser.ProxyUsername = proxyUserName; objPinInterestUser.ProxyPassword = proxyPassword; //objPinInterestUser.UserAgent = Useragent; objPinInterestUser.BoardsName = BoardsName; objPinInterestUser.ScreenName = ScreenName; objPinInterestUser.LoginStatus = LoginStatus; PDGlobals.loadedAccountsDictionary.Add(objPinInterestUser.Username, objPinInterestUser); PDGlobals.listAccounts.Add(objPinInterestUser.Username + ":" + objPinInterestUser.Password + ":" + objPinInterestUser.Niches + ":" + objPinInterestUser.ProxyAddress + ":" + objPinInterestUser.ProxyPort + ":" + objPinInterestUser.ProxyUsername + ":" + objPinInterestUser.ProxyPassword); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } // Set this to "0" if loading unprofiled accounts; string profileStatus = "0"; } 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 = dt.DefaultView; dv.AllowNew = false; try { AccounLoad(); } 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 = dt.Rows.Count.ToString(); })); GlobusLogHelper.log.Debug("Accounts Loaded : " + dt.Rows.Count.ToString() + " In " + timeSpan + " Seconds"); //GlobusLogHelper.log.Info("Accounts Loaded : " + dt.Rows.Count.ToString() + " In " + timeSpan + " Seconds"); } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } Application.Current.Dispatcher.Invoke((Action)(() => { LoadAccountProgressBar.IsIndeterminate = false; })); }
public void AccountReport_Comments() { try { int id = 0; int count = 0; string AccountName = string.Empty; string ModuleName = string.Empty; string Pin = string.Empty; string Msg = string.Empty; string Status = string.Empty; string DateAndTime = string.Empty; this.Dispatcher.Invoke(new Action(delegate { AccountViewModel._listAccReportComment.Clear(); })); DataSet DS = null; DataTable dt = new DataTable(); dt.Columns.Add("AccountName"); dt.Columns.Add("ModuleName"); dt.Columns.Add("Pin"); dt.Columns.Add("Message"); dt.Columns.Add("Status"); dt.Columns.Add("Date&Time"); DS = new DataSet(); DS.Tables.Add(dt); try { DS = QM.SelectAddReport("Comment"); } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } foreach (DataRow dt_item in DS.Tables[0].Rows) { try { count++; id = int.Parse(dt_item.ItemArray[0].ToString()); AccountName = dt_item.ItemArray[1].ToString(); ModuleName = dt_item.ItemArray[2].ToString(); Pin = dt_item.ItemArray[3].ToString(); Msg = dt_item.ItemArray[6].ToString(); Status = dt_item.ItemArray[9].ToString(); DateAndTime = dt_item.ItemArray[12].ToString(); dt.Rows.Add(AccountName, ModuleName, Pin, Msg, Status, DateAndTime); } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } try { AccountNotifyPropertyChanged objAccountNotifyPropertyChanged = new AccountNotifyPropertyChanged(); objAccountNotifyPropertyChanged.ID = count; objAccountNotifyPropertyChanged.AccName = AccountName; objAccountNotifyPropertyChanged.ModuleName = ModuleName; objAccountNotifyPropertyChanged.PinNo = Pin; objAccountNotifyPropertyChanged.Message = Msg; objAccountNotifyPropertyChanged.Status = Status; objAccountNotifyPropertyChanged.DateTime = DateAndTime; this.Dispatcher.Invoke(new Action(delegate { if (!AccountViewModel._listAccReportComment.Contains(objAccountNotifyPropertyChanged)) { AccountViewModel._listAccReportComment.Add(objAccountNotifyPropertyChanged); } })); } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } } try { DataView dv; this.Dispatcher.Invoke(new Action(delegate { dgvComment_AccountsReport.ItemsSource = AccountViewModel._listAccReportComment; //dgvComment_AccountsReport.ItemsSource = dt.DefaultView; })); } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } }
public void AccounLoad() { try { string accountUser = string.Empty; string accountPass = string.Empty; string niches = string.Empty; string proxyAddress = string.Empty; string proxyPort = string.Empty; string proxyUserName = string.Empty; string proxyPassword = string.Empty; //string Useragent = string.Empty; string BoardsName = string.Empty; string ScreenName = string.Empty; string LoginStatus = string.Empty; string Followers = string.Empty; string Following = string.Empty; QueryExecuter QME = new QueryExecuter(); DataSet ds = QME.getAccount(); this.Dispatcher.Invoke(new Action(delegate { AccountViewModel._listOfAccount.Clear(); })); if (ds.Tables[0].Rows.Count != 0) { PDGlobals.listAccounts.Clear(); for (int noRow = 0; noRow < ds.Tables[0].Rows.Count; noRow++) { 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() + ":" + ds.Tables[0].Rows[noRow].ItemArray[6].ToString() + ":" + ds.Tables[0].Rows[noRow].ItemArray[7].ToString(); PDGlobals.listAccounts.Add(account); // dv.AllowNew = false; accountUser = ds.Tables[0].Rows[noRow].ItemArray[0].ToString(); accountPass = ds.Tables[0].Rows[noRow].ItemArray[1].ToString(); niches = ds.Tables[0].Rows[noRow].ItemArray[2].ToString(); proxyAddress = ds.Tables[0].Rows[noRow].ItemArray[3].ToString(); proxyPort = ds.Tables[0].Rows[noRow].ItemArray[4].ToString(); proxyUserName = ds.Tables[0].Rows[noRow].ItemArray[5].ToString(); proxyPassword = ds.Tables[0].Rows[noRow].ItemArray[6].ToString(); ScreenName = ds.Tables[0].Rows[noRow].ItemArray[9].ToString(); Followers = ds.Tables[0].Rows[noRow].ItemArray[7].ToString(); Following = ds.Tables[0].Rows[noRow].ItemArray[8].ToString(); LoginStatus = ds.Tables[0].Rows[noRow].ItemArray[10].ToString(); // Accounts objPinInterestUser = new Accounts(); PinInterestUser objPinInterestUser = new PinInterestUser("", "", "", ""); objPinInterestUser.Username = accountUser; objPinInterestUser.Password = accountPass; objPinInterestUser.Niches = niches; objPinInterestUser.ProxyAddress = proxyAddress; objPinInterestUser.ProxyPort = proxyPort; objPinInterestUser.ProxyUsername = proxyUserName; objPinInterestUser.ProxyPassword = proxyPassword; // objPinInterestUser.LoginStatus = LoginStatus; try { AccountNotifyPropertyChanged objAccountNotifyPropertyChanged = new AccountNotifyPropertyChanged(); objAccountNotifyPropertyChanged.Username = accountUser; objAccountNotifyPropertyChanged.Password = accountPass; objAccountNotifyPropertyChanged.Niche = niches; objAccountNotifyPropertyChanged.ScreenName = ScreenName; objAccountNotifyPropertyChanged.FollowerCount = Followers; objAccountNotifyPropertyChanged.FollowingCount = Following; objAccountNotifyPropertyChanged.ProxyAddress = proxyAddress; objAccountNotifyPropertyChanged.ProxyPassword = proxyPassword; objAccountNotifyPropertyChanged.ProxyPort = proxyPort; objAccountNotifyPropertyChanged.ProxyUserName = proxyUserName; 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 = ""; this.Dispatcher.Invoke(new Action(delegate { AccountViewModel._listOfAccount.Add(objAccountNotifyPropertyChanged); })); } } catch (Exception ex) { GlobusLogHelper.log.Error(" Error :" + ex.StackTrace); } try { PDGlobals.loadedAccountsDictionary.Add(objPinInterestUser.Username, objPinInterestUser); try { this.Dispatcher.Invoke(new Action(delegate { // dgvAccounts.ItemsSource = ds.Tables[0].DefaultView; dgvAccounts.ItemsSource = AccountViewModel._listOfAccount; // AccountViewModel._listOfAccount.Clear(); })); } catch (Exception ex) { }; } catch (Exception ex) { }; } try { this.Dispatcher.Invoke(new Action(delegate { // dgvAccounts.ItemsSource = ds.Tables[0].DefaultView; dgvAccounts.ItemsSource = AccountViewModel._listOfAccount; //AccountViewModel._listOfAccount.Clear(); })); } catch { }; GlobusLogHelper.log.Info(" => [ " + PDGlobals.listAccounts.Count + " Accounts Loaded ]"); } else { this.Dispatcher.Invoke(new Action(delegate { //dgvAccounts.ItemsSource = ds.Tables[0].DefaultView; dgvAccounts.ItemsSource = AccountViewModel._listOfAccount; // AccountViewModel._listOfAccount.Clear(); })); GlobusLogHelper.log.Info(" [ No Accounts Loaded ]"); } } catch(Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } }