Ejemplo n.º 1
0
        private void LoadAccountsMod()
        {
            try
            {
                if (Globals.IsFreeVersion)
                {

                    // string DeleteQuery = "Delete from tb_FBAccount";
                    // DataBaseHandler.DeleteQuery(DeleteQuery, "tb_FBAccount");

                    LoadDataGrid();
                }

                //DataTable dt_Existing = objclsFBAccount.SelectAccoutsForGridView();

                //if (Globals.IsFreeVersion)
                //{
                //    if (dt_Existing.Rows.Count >= 5)
                //    {
                //        FrmFreeTrial frmFreeTrial = new FrmFreeTrial();
                //        frmFreeTrial.ShowDialog();
                //    }
                //}

                //DataSet ds = new DataSet();

                DataTable dt = new DataTable();


                using (OpenFileDialog ofd = new OpenFileDialog())
                {

                    ofd.Filter = "Text Files (*.txt)|*.txt";
                    ofd.InitialDirectory = Application.StartupPath;
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        dt.Columns.Add("UserName");
                        dt.Columns.Add("Password");
                        dt.Columns.Add("ScreenName");
                        dt.Columns.Add("FollowerCount");
                        dt.Columns.Add("ProxyAddress");
                        dt.Columns.Add("ProxyPort");
                        dt.Columns.Add("ProxyUserName");
                        dt.Columns.Add("ProxyPassword");
                        dt.Columns.Add("ProfileName");
                        dt.Columns.Add("ProfileStatus");
                        dt.Columns.Add("Group Name");
                        dt.Columns.Add("Status");
                        ds = new DataSet();
                        ds.Tables.Add(dt);

                        dgvAccounts.Invoke(new MethodInvoker(delegate
                        {
                            textBox12.Text = ofd.FileName;
                            clsDBQueryManager ObjclsDBQueryManager = new clsDBQueryManager();
                            ObjclsDBQueryManager.InsertOrUpdateSetting("LoadAccounts", "LoadAccounts", StringEncoderDecoder.Encode(textBox12.Text));
                            dgvAccounts.DataSource = null;
                        }));

                        lst_AccountForUpload = GlobusFileHelper.ReadFiletoStringList(ofd.FileName).Distinct().ToList();

                        if (Globals.IsFreeVersion)
                        {

                            try
                            {
                                lst_AccountForUpload.RemoveRange(5, lst_AccountForUpload.Count - 5);
                            }
                            catch { }

                        }
                        if (Globals.IsBasicVersion)
                        {


                            try
                            {
                                string selectQuery = "select count(UserName) from tb_FBAccount";
                                DataSet DS = DataBaseHandler.SelectQuery(selectQuery, "tb_FBAccount");
                                int countLoadedAccounts = Convert.ToInt32(DS.Tables[0].Rows[0].ItemArray[0].ToString());

                                if (countLoadedAccounts >= 5)
                                {
                                    LoadDataGrid();
                                    MessageBox.Show("You Are Using TD Basic Version 5 Accounts allready loaded..");
                                    return;
                                }
                                else
                                {
                                    int RemainingAccount = 5 - countLoadedAccounts;

                                    lst_AccountForUpload.RemoveRange(RemainingAccount, lst_AccountForUpload.Count - RemainingAccount);

                                }
                            }
                            catch { }
                        }

                        if (Globals.IsProVersion)
                        {
                            try
                            {
                                string selectQuery = "select count(UserName) from tb_FBAccount";
                                DataSet DS = DataBaseHandler.SelectQuery(selectQuery, "tb_FBAccount");
                                int countLoadedAccounts = Convert.ToInt32(DS.Tables[0].Rows[0].ItemArray[0].ToString());

                                if (countLoadedAccounts >= 15)
                                {
                                    LoadDataGrid();
                                    MessageBox.Show("You Are Using TD Pro Version 15 Accounts allready loaded..");
                                    return;
                                }
                                else
                                {
                                    int RemainingAccount = 15 - countLoadedAccounts;

                                    lst_AccountForUpload.RemoveRange(RemainingAccount, lst_AccountForUpload.Count - RemainingAccount);
                                }
                            }
                            catch { }
                        }
                        //try
                        //{
                        //    if (PnlPicLodder.Visible != true || PnlPicLodder.Visible != true)
                        //    {
                        //        PnlPicLodder.Invoke(new MethodInvoker(delegate
                        //        {
                        //            PnlPicLodder.Visible = true;
                        //        }));
                        //        PnlPicLodder.Invoke(new MethodInvoker(delegate
                        //        {
                        //            PicLodder.Visible = true;
                        //        }));
                        //    }
                        //}
                        //catch
                        //{

                        //}

                        foreach (string item in lst_AccountForUpload)
                        {
                            try
                            {
                                ThreadPool.SetMaxThreads(500, 300);
                                ThreadPool.QueueUserWorkItem(new WaitCallback(LoadAccountsModewithMultithreaded), new object[] { item });
                                Thread.Sleep(50);
                            }
                            catch { }
                        }


                        //LoadDataGridAfterAccountCreation();

                        //#region commented -- prabhat -- 15.02.14
                        //dgvAccounts.Invoke(new MethodInvoker(delegate
                        //{
                        //    dgvAccounts.DataSource = dt;
                        //}));

                        //AddToListBox("[ " + DateTime.Now + " ] => [ " + dt.Rows.Count + " Accounts Loaded ]");
                        //Log("[ " + DateTime.Now + " ] => [ " + dt.Rows.Count + " Accounts Loaded ]"); 
                        //#endregion
                    }

                    #region commented -- prabhat -- 15.02.14
                    //foreach (DataRow dRow in dt.Rows)
                    //{

                    //    string accountUser = dRow[0].ToString();
                    //    string accountPass = dRow[1].ToString();
                    //    string screanName = dRow[2].ToString();
                    //    string proxyAddress = dRow[4].ToString();
                    //    string proxyPort = dRow[5].ToString();
                    //    string proxyUserName = dRow[6].ToString();
                    //    string proxyPassword = dRow[7].ToString();
                    //    string profilename = dRow[8].ToString();
                    //    string profileStatus = dRow[9].ToString();
                    //    string groupname = dRow[10].ToString();
                    //    string status = dRow[11].ToString();
                    //    ///Insert new accounts in Database
                    //    try
                    //    {
                    //        //Add to Database
                    //        BaseLib.DataBaseHandler.InsertQuery("INSERT INTO tb_FBAccount (UserName, Password, Screen_Name, FollowerCount, ProxyAddress, ProxyPort, ProxyUserName, ProxyPassword, ProfileName, ProfileStatus, GroupName , Status) VALUES ('" + accountUser + "','" + accountPass + "', '" + screanName + "', '' , '" + proxyAddress + "','" + proxyPort + "','" + proxyUserName + "','" + proxyPassword + "','" + profilename + "' , '" + profileStatus + "' ,'" + groupname + "', '" + status + "')", "tb_FBAccount");
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        Console.WriteLine(ex.StackTrace);

                    //        GlobusFileHelper.AppendStringToTextfileNewLine("Method Name :- LoadAccountsMod   Error :- " + ex.StackTrace, Globals.Path_AccountUploadingErrorLog);
                    //    }

                    //} 
                    #endregion

                    try
                    {
                        PnlPicLodder.Invoke(new MethodInvoker(delegate
                        {
                            PnlPicLodder.Visible = false;
                        }));
                        PnlPicLodder.Invoke(new MethodInvoker(delegate
                        {
                            PicLodder.Visible = false;
                        }));
                    }
                    catch (Exception ex)
                    {
                        GlobusFileHelper.AppendStringToTextfileNewLine("Method Name :- LoadAccountsMod   Error :- " + ex.StackTrace, Globals.Path_AccountUploadingErrorLog);
                    }

                }
            }
            catch (Exception ex)
            {
                GlobusFileHelper.AppendStringToTextfileNewLine("Method Name :- LoadAccountsMod   Error :- " + ex.StackTrace, Globals.Path_AccountUploadingErrorLog);
            }
            finally
            {
                Thread.Sleep(100 * lst_AccountForUpload.Count);
                AddToListBox("[ " + DateTime.Now + " ] => [ " + lst_AccountForUpload.Count + " Accounts loaded ]");
            }
        }