Exemplo n.º 1
0
        public void StartActionMultithreadCommentByKeyword(ref PinInterestUser objPinUser, List <string> UserCount_CommentByKeyword)
        {
            try
            {
                try
                {
                    lstThreadsCommentByKeyword.Add(Thread.CurrentThread);
                    lstThreadsCommentByKeyword.Distinct().ToList();
                    Thread.CurrentThread.IsBackground = true;
                }
                catch (Exception ex)
                { };
                int      counter   = 0;
                string[] arrayItem = new string[100];

                foreach (string newItem in UserCount_CommentByKeyword)
                {
                    try
                    {
                        arrayItem = Regex.Split(newItem, "::");
                        if (arrayItem.Length == 3 && arrayItem[0] == objPinUser.Niches)
                        {
                            if (arrayItem.Length == 3)
                            {
                                string[] Keywordarrray = Regex.Split(arrayItem[1], ",");
                                foreach (string KeywordsItem in Keywordarrray)
                                {
                                    lock (this)
                                    {
                                        try
                                        {
                                            Keyword = KeywordsItem + "::" + arrayItem[2].ToString();
                                            lstCommnet.Add(Keyword);
                                            List <string> LstPins = new List <string>();
                                            LstPins = KeywordPins_New(KeywordsItem, MaxCommentByKeyword, ref objPinUser);
                                            //PinterestComments Comments = new PinterestComments();
                                            keyword = Utils.Utils.getBetween(KeywordsItem, "", "::");
                                            GlobusLogHelper.log.Info(" => [ Finding Pins On Keyword : " + KeywordsItem + " For " + objPinUser.Username + " ]");
                                            GlobusLogHelper.log.Info(" => [ " + LstPins.Count + " Pins On Keyword :" + KeywordsItem + " For " + objPinUser.Username + " ]");
                                            List <string> lstofPin = new List <string>();
                                            lstofPin = LstPins.Distinct().ToList();
                                            string[] lstCommnet_strlist = Regex.Split(newItem, "::");//lstCommnet.ToArray();
                                            foreach (string pin in lstofPin)
                                            {
                                                try
                                                {
                                                    clsSettingDB Db   = new clsSettingDB();
                                                    string       user = PinterestPins.getUserNameFromPinId(pin, ref objPinUser);

                                                    if (counter >= MaxCommentByKeyword)
                                                    {
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        #region Commented
                                                        //comment = lstCommnet[RandomNumberGenerator.GenerateRandom(0, lstCommnet.Count)];

                                                        //if (comment.Contains("::"))
                                                        //{
                                                        //    comment = Regex.Split(comment, "::")[1];
                                                        //}
                                                        //else if (comment.Contains(":"))
                                                        //{
                                                        //    if (comment.Contains("http:"))
                                                        //    {
                                                        //        comment = comment.Split(':')[comment.Split(':').Count() - 1];
                                                        //        comment = "http:" + comment.Split(':')[comment.Split(':').Count() - 1];
                                                        //    }
                                                        //    else
                                                        //    {
                                                        //        comment = comment.Split(':')[comment.Split(':').Count() - 1];
                                                        //    }
                                                        //}
                                                        #endregion
                                                        #region
                                                        try
                                                        {
                                                            DataSet   DS = QM.selectCommentedPinDetails(objPinUser.Username, pin);
                                                            DataTable Dt = DS.Tables[0];

                                                            string   dateTime         = Dt.Rows[Dt.Rows.Count - 1].ItemArray[3].ToString();
                                                            DateTime previousDateTime = Convert.ToDateTime(dateTime);
                                                            DateTime currentDate      = DateTime.Today;
                                                            TimeSpan dt_Difference    = currentDate.Subtract(previousDateTime);
                                                            double   dt_Difference1   = dt_Difference.Days;
                                                            if (dt_Difference1 < 30)
                                                            {
                                                                continue;
                                                            }
                                                        }
                                                        catch (Exception Ex)
                                                        {
                                                            //CommentAddToLogger("Error ==> " + Ex.StackTrace);
                                                        }

                                                        #endregion
                                                        Thread.Sleep(1 * 1000);
                                                        bool IsCommented = objCommentManagers.Comment_new(ref objPinUser, pin, lstCommnet_strlist[2]);
                                                        if (IsCommented)
                                                        {
                                                            #region AccountReport

                                                            string module = "CommentByKeyword";
                                                            string status = "Commented";
                                                            Qm.insertAccRePort(objPinUser.Username, module, "https://www.pinterest.com/pin/" + pin, "", "", lstCommnet_strlist[2], KeywordsItem, "", status, "", "", DateTime.Now);
                                                            objCommentByKeywordDelegate();

                                                            #endregion
                                                            counter++;
                                                            GlobusLogHelper.log.Info(" => [ Commneted on Pin : " + pin + " From " + objPinUser.Username + " ]");
                                                            clsSettingDB Databse = new clsSettingDB();
                                                            Databse.insertMessageDate(objPinUser.Username, user.Replace("/", ""), pin, KeywordsItem, comment);
                                                            try
                                                            {
                                                                QueryManager.insertCommentedPinDetails(objPinUser.Username, pin, DateTime.Now.ToString());
                                                            }
                                                            catch { };

                                                            try
                                                            {
                                                                string CSV_Header = "Date" + "," + "UserName" + "," + "Comment" + "," + "Keyword" + "," + "Niche" + "," + "PinUrl";
                                                                string CSV_Data   = System.DateTime.Now.ToString() + "," + objPinUser.Username + "," + comment + "," + KeywordsItem + "," + objPinUser.Niches + "," + "https://www.pinterest.com/pin/" + pin;
                                                                string path       = PDGlobals.FolderCreation(PDGlobals.Pindominator_Folder_Path, "Comment");
                                                                PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Data, path + "\\CommentBykeyword.csv");
                                                            }
                                                            catch (Exception ex)
                                                            {
                                                            }
                                                        }
                                                        else
                                                        {
                                                            GlobusLogHelper.log.Info(" => [ Not Commneted on Pin : " + pin + " From " + objPinUser.Username + " ]");
                                                        }

                                                        //if (rdbDivideGivenByUserCommentByKeyword == true)
                                                        //{
                                                        //    CountGivenByUserCommentByKeyword--;
                                                        //    if (CountGivenByUserCommentByKeyword < 0)
                                                        //    {
                                                        //        break;
                                                        //    }
                                                        //}

                                                        int delay = RandomNumberGenerator.GenerateRandom(minDelayCommentByKeyword, maxDelayCommentByKeyword);
                                                        GlobusLogHelper.log.Info(" => [ Delay For " + delay + " Seconds ]");
                                                        Thread.Sleep(delay * 1000);
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    GlobusLogHelper.log.Error(" Error : 3.4" + ex.StackTrace);
                                                }
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            GlobusLogHelper.log.Error(" Error : 3.4" + ex.StackTrace);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error(" Error : 3.4" + ex.StackTrace);
                    }

                    #region Comment
                    // }
                    //string[] lstCommnet_strlist = lstCommnet.ToArray();
                    //if (objPinUser.Niches == arrayItem[0])
                    //{
                    //    foreach (string FindKeyword in lstCommnet_strlist)
                    //    {

                    //        try
                    //        {
                    //            List<string> LstPins = KeywordPins_New(FindKeyword, MaxCommentByKeyword, ref objPinUser);
                    //            //PinterestComments Comments = new PinterestComments();
                    //            keyword = Utils.Utils.getBetween(FindKeyword, "", "::");
                    //            GlobusLogHelper.log.Info(" => [ Finding Pins On Keyword : " + FindKeyword + " For " + objPinUser.Username + " ]");
                    //            GlobusLogHelper.log.Info(" => [ " + LstPins.Count + " Pins On Keyword :" + FindKeyword + " For " + objPinUser.Username + " ]");
                    //            List<string> lstofPin = LstPins;
                    //            foreach (string pin in lstofPin)
                    //            {
                    //                clsSettingDB Db = new clsSettingDB();
                    //                string user = PinterestPins.getUserNameFromPinId(pin, ref objPinUser);

                    //                if (counter >= MaxCommentByKeyword)
                    //                {
                    //                    GlobusLogHelper.log.Info(" => [ PROCESS COMPLETED " + " For " + objPinUser.Username + " ]");
                    //                    GlobusLogHelper.log.Info("---------------------------------------------------------------------------------------------------------------------------");
                    //                    break;
                    //                }
                    //                else
                    //                {
                    //                    comment = lstCommnet[RandomNumberGenerator.GenerateRandom(0, lstCommnet.Count)];
                    //                    if (comment.Contains("::"))
                    //                    {
                    //                        comment = Regex.Split(comment, "::")[1];
                    //                    }
                    //                    else if (comment.Contains(":"))
                    //                    {
                    //                        if (comment.Contains("http:"))
                    //                        {
                    //                            comment = comment.Split(':')[comment.Split(':').Count() - 1];
                    //                            comment = "http:" + comment.Split(':')[comment.Split(':').Count() - 1];
                    //                        }
                    //                        else
                    //                        {
                    //                            comment = comment.Split(':')[comment.Split(':').Count() - 1];
                    //                        }
                    //                    }

                    //                    #region
                    //                    try
                    //                    {
                    //                        DataSet DS = QM.selectCommentedPinDetails(objPinUser.Username, pin);
                    //                        DataTable Dt = DS.Tables[0];

                    //                        string dateTime = Dt.Rows[Dt.Rows.Count - 1].ItemArray[3].ToString();
                    //                        DateTime previousDateTime = Convert.ToDateTime(dateTime);
                    //                        DateTime currentDate = DateTime.Today;
                    //                        TimeSpan dt_Difference = currentDate.Subtract(previousDateTime);
                    //                        double dt_Difference1 = dt_Difference.Days;
                    //                        if (dt_Difference1 < 30)
                    //                        {
                    //                            continue;
                    //                        }

                    //                    }
                    //                    catch (Exception Ex)
                    //                    {
                    //                        //CommentAddToLogger("Error ==> " + Ex.StackTrace);
                    //                    }

                    //                    #endregion

                    //                    bool IsCommented = objCommentManagers.Comment_new(ref objPinUser, pin, comment);
                    //                    if (IsCommented)
                    //                    {
                    //                        #region AccountReport

                    //                        string module = "CommentByKeyword";
                    //                        string status = "Commented";
                    //                        Qm.insertAccRePort(objPinUser.Username, module, pin, "", "", comment, keyword, "", status, "", "", DateTime.Now);
                    //                        objCommentByKeywordDelegate();

                    //                        #endregion

                    //                        GlobusLogHelper.log.Info(" => [ Commneted on Pin : " + pin + " From " + objPinUser.Username + " ]");
                    //                        clsSettingDB Databse = new clsSettingDB();
                    //                        Databse.insertMessageDate(objPinUser.Username, user.Replace("/", ""), pin, keyword, comment);
                    //                        try
                    //                        {
                    //                            QueryManager.insertCommentedPinDetails(objPinUser.Username, pin, DateTime.Now.ToString());
                    //                        }
                    //                        catch { };
                    //                        counter++;

                    //                        try
                    //                        {
                    //                            string CSV_Header = "Date" + "," + "UserName" + "," + "Comment" + "," + "Keyword" + "," + "Niche" + "," + "PinUrl";
                    //                            string CSV_Data = System.DateTime.Now.ToString() + "," + objPinUser.Username + "," + comment + "," + keyword + "," + objPinUser.Niches + "," + "https://www.pinterest.com/pin/" + pin;
                    //                            string path = PDGlobals.FolderCreation(PDGlobals.Pindominator_Folder_Path, "Comment");
                    //                            PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Data, path + "\\CommentBykeyword.csv");
                    //                        }
                    //                        catch (Exception ex)
                    //                        {

                    //                        }
                    //                    }
                    //                    else
                    //                    {
                    //                        GlobusLogHelper.log.Info(" => [ Not Commneted on Pin : " + pin + " From " + objPinUser.Username + " ]");
                    //                    }

                    //                    //if (rdbDivideGivenByUserCommentByKeyword == true)
                    //                    //{
                    //                    //    CountGivenByUserCommentByKeyword--;
                    //                    //    if (CountGivenByUserCommentByKeyword < 0)
                    //                    //    {
                    //                    //        break;
                    //                    //    }
                    //                    //}

                    //                    int delay = RandomNumberGenerator.GenerateRandom(minDelayCommentByKeyword, maxDelayCommentByKeyword);
                    //                    GlobusLogHelper.log.Info(" => [ Delay For " + delay + " Seconds ]");
                    //                    Thread.Sleep(delay * 1000);
                    //                }
                    //            }
                    //        }
                    //        catch (Exception ex)
                    //        {
                    //            GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                    //        }

                    //    }
                    ////}
                    #endregion
                }
                GlobusLogHelper.log.Info(" => [ PROCESS COMPLETED " + " For " + objPinUser.Username + " ]");
                GlobusLogHelper.log.Info("---------------------------------------------------------------------------------------------------------------------------");
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    if (countThreadControllerCommentByKeyword > Nothread_CommentByKeyword)
                    {
                        lock (CommentByKeywordObjThread)
                        {
                            Monitor.Pulse(CommentByKeywordObjThread);
                        }
                        CommentByKeyworddata_count--;
                    }
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error : " + ex.StackTrace);
                }
                countThreadControllerCommentByKeyword--;
            }
        }
Exemplo n.º 2
0
        public void ThreadRepinMethod(Pins pin, PinInterestUser objPinUser)
        {
            try
            {
                try
                {
                    lstThreadsAddPinWithNewBoard.Add(Thread.CurrentThread);
                    lstThreadsAddPinWithNewBoard.Distinct().ToList();
                    Thread.CurrentThread.IsBackground = true;
                }
                catch (Exception ex)
                { };

                Board = Regex.Split(pin.Board, ":")[0];
                if (!string.IsNullOrEmpty(Board))
                {
                    //Board = pin.Board;
                    BoardNumber = objAddNewPinManager.GetBoardId(Board, ref objPinUser);
                    if (string.IsNullOrEmpty(BoardNumber))
                    {
                        GlobusLogHelper.log.Info(" => [ " + Board + " Not Found. Creating Board ]");
                        BoardNumber = CreateBoard_new(Board, "Other", ref objPinUser);
                        BoardNumber = objAddNewPinManager.GetBoardId(Board, ref objPinUser);
                    }
                }
                else
                {
                    if (objPinUser.Boards.Count <= 0)
                    {
                        objAddNewPinManager.GetBoards(ref objPinUser);
                    }
                    if (objPinUser.Boards.Count > 0)
                    {
                        Random Boardrnd = new Random();
                        int    BoardNum = 0;

                        try
                        {
                            BoardNum    = Boardrnd.Next(0, objPinUser.Boards.Count - 1);
                            BoardNumber = objPinUser.Boards[BoardNum];
                        }
                        catch (Exception ex)
                        {
                            //GlobusFileHelper.AppendStringToTextfileNewLine("Error --> StartNewPinCreationMultiThreaded() 1--> " + ex.Message, ApplicationData.ErrorLogFile);
                        }
                    }
                }

                ImageUrl = pin.ImageUrl;
                Desc     = pin.Description;

                string Data = objAddNewPinManager.NewPin(BoardNumber, Desc, ImageUrl, ref objPinUser);
                if (Data.Equals("true"))
                {
                    #region AccountReport

                    string module = "AddPinWithNewBoard";
                    string status = "Added";
                    objqm.insertAccRePort(objPinUser.Username, module, "", Board, "", Desc, "", ImageUrl, status, "", "", DateTime.Now);
                    objAddPinWithBoardDelegate();

                    #endregion

                    //GlobusLogHelper.log.Info(" => [ Pin Added To " + Board + " From " + objPinUser.Username + " ]");
                    try
                    {
                        string CSV_Header = "Date" + "," + "UserName" + "," + "Board" + "," + "Description" + "," + "ImageUrl";
                        string CSV_Data   = System.DateTime.Now.ToString() + "," + objPinUser.Username + "," + Board.Replace(",", " ").Replace("'", "") + "," + Desc.Replace(",", " ").Replace("'", "") + "," + ImageUrl.Replace(",", " ").Replace("'", "");

                        PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Data, Pinpath + "\\NewPin.csv");
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                    GlobusLogHelper.log.Info(" => [ Pin Not Added To " + Board + " From " + objPinUser.Username + " ]");
                }
            }
            catch (Exception ex)
            {
                //GlobusFileHelper.AppendStringToTextfileNewLine("Error --> StartNewPinCreationMultiThreaded() 2 --> " + ex.Message, ApplicationData.ErrorLogFile);
            }
            finally
            {
                try
                {
                    if (countThreadControllerAddPinWithNewBoard > Nothread_AddPinWithNewBoard)
                    {
                        lock (AddPinWithNewBoardObjThread)
                        {
                            Monitor.Pulse(AddPinWithNewBoardObjThread);
                        }
                        AddPinWithNewBoarddata_count--;
                    }
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error : " + ex.StackTrace);
                }
                countThreadControllerAddPinWithNewBoard--;
                GlobusLogHelper.log.Info(" => [ PROCESS COMPLETED " + " For " + objPinUser.Username + " ]");
                GlobusLogHelper.log.Info("---------------------------------------------------------------------------------------------------------------------------");
            }
        }
        public void ExportAccReportScraper()
        {
            try
            {
                if (dgvScraper_AccountsReport.Items.Count == 1)
                {
                    GlobusLogHelper.log.Info("=> [ Data Is Not Found In Account Report ]");
                    ModernDialog.ShowMessage("Data Is Not Found In Account Report", "Data Is Not Found", MessageBoxButton.OK);
                    return;
                }
                else if (dgvScraper_AccountsReport.Items.Count > 1)
                {
                    try
                    {
                        string CSV_Header  = string.Join(",", "ModuleName", "UserName", "Status", "Date&Time");
                        string CSV_Content = "";
                        var    result      = ModernDialog.ShowMessage("Are you want to Export Report Data ", " Export Report Data ", MessageBoxButton.YesNo);

                        if (result == MessageBoxResult.Yes)
                        {
                            try
                            {
                                string FilePath = string.Empty;
                                FilePath = Utils.Utils.UploadFolderData(PDGlobals.Pindominator_Folder_Path);
                                FilePath = FilePath + "\\Scraper.csv";
                                GlobusLogHelper.log.Info("Export Data File Path :" + FilePath);
                                GlobusLogHelper.log.Debug("Export Data File Path :" + FilePath);
                                string ExportDataLocation = FilePath;
                                PDGlobals.Pindominator_Folder_Path = FilePath;
                                DataSet ds = QM.SelectAddReportScrapeUser("Scraper");
                                foreach (DataRow item in ds.Tables[0].Rows)
                                {
                                    try
                                    {
                                        string ModuleName  = item.ItemArray[2].ToString();
                                        string UserName    = item.ItemArray[5].ToString();
                                        string Status      = item.ItemArray[9].ToString();
                                        string DateAndTime = item.ItemArray[12].ToString();
                                        CSV_Content = string.Join(",", ModuleName.Replace("'", ""), UserName.Replace("'", ""), Status.Replace("'", ""), DateAndTime.Replace("'", ""));
                                        PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Content, ExportDataLocation);
                                    }
                                    catch (Exception ex)
                                    {
                                        GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                            }
                        }
                    }
                    catch (Exception Ex)
                    {
                        GlobusLogHelper.log.Error(" Error :" + Ex.StackTrace);
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
        }
        public void EditPins(ref PinInterestUser objPinUser)
        {
            try
            {
                List <string> lstOfBoardURLs = GetAllBoardNames_new1(objPinUser.ScreenName, ref objPinUser);
                foreach (var itemBoardUrl in ClGlobul.lstBoardUrls)
                {
                    string url = "https://www.pinterest.com" + itemBoardUrl;
                    lstBoardUrlsPin.Add(url);
                }

                List <string> lstPinsfromBoards = new List <string>();

                foreach (var itemBoardUrl in lstBoardUrlsPin)
                {
                    string pageSource = objPinUser.globusHttpHelper.getHtmlfromUrl(new Uri(itemBoardUrl), "", "", objPinUser.UserAgent);

                    if (!string.IsNullOrEmpty(pageSource) && pageSource.Contains("/pin/"))
                    {
                        string data = Utils.Utils.getBetween(pageSource, "/pin/", "class=").Replace("\\", "").Replace("\"", "").Replace("/", "");

                        if (!string.IsNullOrEmpty(data) && !lstPinsfromBoards.Contains(data))
                        {
                            lstPinsfromBoards.Add(data);
                        }
                    }
                }
                int count = 0;
                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Extarcting User Pins For Edit ]");
                List <string> lstAllPins = GetAllPinsNewCode(ref objPinUser);
                Random        Pinrnd     = new Random();
                List <string> lstPins    = new List <string>();
                try
                {
                    lstPins = lstAllPins.OrderBy(X => Pinrnd.Next()).ToList();
                }
                catch { };
                lstPins.Reverse();
                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ " + lstPins.Count + " Pins From " + objPinUser.Username + " ]");

                foreach (string Pin in lstPins)
                {
                    clsSettingDB DB = new clsSettingDB();
                    DataTable    dt = DB.SelectPinDesc(Pin, objPinUser.Username);
                    if (dt.Rows.Count <= 0)
                    {
                        string pageSource          = objPinUser.globusHttpHelper.getHtmlfromUrl(new Uri("http://pinterest.com/pin/" + Pin + "/edit/"), "", "", objPinUser.UserAgent);
                        string PinDesc             = string.Empty;
                        string csrfmiddlewaretoken = string.Empty;
                        string link  = string.Empty;
                        string board = string.Empty;

                        try
                        {
                            int    startindex = pageSource.IndexOf("description_html");
                            string start      = pageSource.Substring(startindex).Replace("description_html", "");
                            int    endIndex   = start.IndexOf(",");
                            //string end = start.Substring(0, endIndex).Replace("\"", "").Replace(":", "").Replace("","+");
                            string end = Utils.Utils.getBetween(start, "\": \"", "</a>");
                            PinDesc = end;
                        }
                        catch (Exception ex)
                        {
                        }

                        if (string.IsNullOrEmpty(PinDesc))
                        {
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ No Desc In Pin :" + Pin + " ]");
                        }
                        else
                        {
                            PinCommnet = CommentList[RandomNumberGenerator.GenerateRandom(0, CommentList.Count)];

                            PinDesc = PinCommnet;
                            try
                            {
                                int    startindex = pageSource.IndexOf("\"board_id\":");
                                string start      = pageSource.Substring(startindex).Replace("\"board_id\":", "").Replace("boardRepSubtitle", "");
                                int    endIndex   = start.IndexOf(",");
                                string end        = start.Substring(0, endIndex);
                                board = end.Replace("\"", "").Replace(">", "");
                                board = board.Trim();
                            }
                            catch (Exception ex)
                            {
                            }

                            try
                            {
                                int    startindex = pageSource.IndexOf("link\": \"http:");
                                string start      = pageSource.Substring(startindex).Replace("link\":", "");
                                int    endIndex   = start.IndexOf(",");
                                string end        = start.Substring(0, endIndex).Replace("value=", "").Replace("\"", "");
                                string Link       = Utils.Utils.getBetween(start, "Link=", "");
                                link = end.Trim().Replace(":", "%3A").Replace("/", "%2F").Replace("?", "%3F").Replace("=", "%3D");
                            }
                            catch (Exception ex)
                            {
                            }
                            Thread.Sleep(1 * 1000);
                            try
                            {
                                string postdata = "board_id=" + board + "&description=" + PinDesc + "&link=" + link + "&id=" + Pin;

                                #region PostData

                                string pinUrl  = "https://www.pinterest.com/pin/" + Pin + "/";
                                string BoardId = string.Empty;

                                string getPinPageSource = objPinUser.globusHttpHelper.getHtmlfromUrl(new Uri(pinUrl), "", "", "");

                                if (getPinPageSource.Contains("\"price_currency\""))
                                {
                                    link = Utils.Utils.getBetween(getPinPageSource, "serving_link\":", ", \"is_promoted").Replace("\"", "").Trim();
                                    link = link.Replace(":", "%3A").Replace("/", "%2F").Replace("?", "%3F").Replace("=", "%3D").Replace("&", "%26");
                                }
                                if (getPinPageSource.Contains("board")) //("board_id")
                                {
                                    // BoardId = Utils.Utils.getBetween(getPinPageSource, "board\", \"id\":", ",").Replace("\"", "").Trim();
                                    BoardId = Utils.Utils.getBetween(getPinPageSource, "board\", \"id\":", "\",").Replace("\"", "").Trim();//"board", "id":
                                }
                                #endregion

                                string postPageSOurce = string.Empty;

                                string Checking = objPinUser.globusHttpHelper.getHtmlfromUrl(new Uri("https://www.pinterest.com"));
                                if (Checking.Contains("profileName"))
                                {
                                }
                                else
                                {
                                    ObjAccountManager.LoginPinterestAccount(ref objPinUser);
                                }
                                string redirectDomain = GlobusHttpHelper.valueURl.Split('.')[0];
                                string newHomePageUrl = redirectDomain + "." + "pinterest.com";
                                postdata = "source_url=%2Fpin%2F" + Pin + "%2F&data=%7B%22options%22%3A%7B%22board_id%22%3A%22" + BoardId + "%22%2C%22description%22%3A%22" + PinDesc + "%22%2C%22link%22%3A%22" + link + "%22%2C%22place%22%3A0%2C%22id%22%3A%22" + Pin + "%22%7D%2C%22context%22%3A%7B%7D%7D&module_path=App%3ECloseup%3EPinActionBar%3EShowModalButton(module%3DPinEdit)%23App%3EModalManager%3EModal(state_isVisible%3Dtrue%2C+showCloseModal%3Dtrue%2C+state_mouseDownInModal%3Dfalse%2C+state_showModalMask%3Dtrue%2C+state_showContainer%3Dfalse%2C+state_showPositionElement%3Dtrue)";
                                string postUrl = redirectDomain + ".pinterest.com/resource/PinResource/update/";

                                try
                                {
                                    postPageSOurce = objPinUser.globusHttpHelper.postFormDataProxywithCSRFToken(new Uri(postUrl), postdata, newHomePageUrl, "", 0, "", "");
                                }
                                catch
                                {
                                    Thread.Sleep(1 * 1000);
                                    postPageSOurce = objPinUser.globusHttpHelper.postFormDataProxywithCSRFToken(new Uri(postUrl), postdata, newHomePageUrl, "", 0, "", ""); //"Go0h31yGfnvXLZCw0B06nbmbxnqLj5Wj");
                                }
                                if (postPageSOurce.Contains(PinDesc))                                                                                                       //PinDesc
                                {
                                    try
                                    {
                                        GlobusFileHelper.AppendStringToTextfileNewLine(Pin + ": Desc -> " + PinDesc, PDGlobals.path_PinDescription);
                                        DB.InsertPinDesc(Pin, PinDesc, objPinUser.Username);

                                        #region AccountReport

//                                        string module = "EditPinDiscription";
//                                        string status = "Edited";
//                                        objQm.insertAccRePort(objPinUser.Username, module, "https://www.pinterest.com/pin/" + Pin, "", "", PinDesc, "", "", status, "", "", DateTime.Now);
//                                        objEditPinDescriptionDelegate();

                                        #endregion

                                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ " + Pin + " >>> " + PinDesc + " for " + objPinUser.Username + " ]");

                                        try
                                        {
                                            string CSV_Header = "Date" + "," + "UserName" + "," + "Pin Description" + "," + "Pin";
                                            string CSV_Data   = System.DateTime.Now.ToString() + "," + objPinUser.Username + "," + PinDesc.Replace(",", "") + "," + Pin;
                                            string path       = PDGlobals.FolderCreation(PDGlobals.Pindominator_Folder_Path, "EditPin");
                                            PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Data, path + "\\EditPinDescription.csv");
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }
                                    catch (Exception ex)
                                    { }
                                }
                                else
                                {
                                    GlobusFileHelper.AppendStringToTextfileNewLine(Pin + ": Not Edited Description", PDGlobals.path_PinDescription);
                                    GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Description Not Edited " + Pin + ">>>>" + objPinUser.Username + " ]");
                                }
                            }

                            catch (Exception ex)
                            { };
                        }

                        int Delay = RandomNumberGenerator.GenerateRandom(minDelayEditPinDisc, maxDelayEditPinDisc);
                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Delay For " + Delay + " ]");
                        Thread.Sleep(Delay * 1000);
                    }
                    else
                    {
                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Already Edited " + Pin + " From " + objPinUser.Username + " ]");
                    }

                    if (NoOfPagesEditPinDisc == count)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
        }
        public void StartActionMultithreadLike(ref PinInterestUser objPinUser, List <string> UserLikecount)
        {
            try
            {
                try
                {
                    lstThreadsLike.Add(Thread.CurrentThread);
                    lstThreadsLike.Distinct().ToList();
                    Thread.CurrentThread.IsBackground = true;
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                }
                int LikeCount = 0;
                if (rbListLikePinUrls == true)
                {
                    ClGlobul.lstPins = UserLikecount;
                    if (MaxLike == ClGlobul.lstPins.Count)
                    {
                        ClGlobul.lstPins.Add("1");
                    }
                }
                else
                {
                    if (rdbDivideByUser == true)
                    {
                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Using Random Url to Like ]");
                        int countLoadEmails = PDGlobals.loadedAccountsDictionary.Count();
                        lstAllPins = GetPins(ref objPinUser, MaxLike);
                        Random Pinrnd = new Random();
                        ClGlobul.lstPins = lstAllPins.OrderBy(X => Pinrnd.Next()).ToList();
                    }
                    else
                    {
                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Using Random Url to Like ]");
                        int countLoadEmails = PDGlobals.loadedAccountsDictionary.Count();
                        lstAllPins = GetPins(ref objPinUser, MaxLike);
                        Random Pinrnd = new Random();
                        ClGlobul.lstPins = lstAllPins.OrderBy(X => Pinrnd.Next()).ToList();
                    }
                }
                #region foreach
                foreach (string Pin in ClGlobul.lstPins)
                {
                    if (MaxLike > LikeCount)
                    {
                        try
                        {
                            DataSet dt            = DataBaseHandler.SelectQuery("SELECT * FROM LikeUsingUrl Where LikeUrl = '" + Pin + "' and UserName = '******' ", "LikeUsingUrl");
                            int     count_NO_RoWs = dt.Tables[0].Rows.Count;
                            if (count_NO_RoWs == 0)
                            {
                                bool IsLiked = Like_New(ref objPinUser, Pin);

                                if (IsLiked)
                                {
                                    #region AccountReport

                                    string module = "Like";
                                    string status = "Liked";
                                    Qm.insertAccRePort(objPinUser.Username, module, "https://www.pinterest.com/pin/" + Pin, "", "", "", "", "", status, "", "", DateTime.Now);
                                    objLikeDelegate();

                                    #endregion

                                    GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Liked : " + Pin + " From " + objPinUser.Username + " ]");

                                    try
                                    {
                                        if (!string.IsNullOrEmpty(Pin) && !string.IsNullOrEmpty(objPinUser.Username))
                                        {
                                            string query = "INSERT INTO  LikeUsingUrl (LikeUrl,UserName) VALUES ('" + Pin + "' ,'" + objPinUser.Username + "') ";
                                            DataBaseHandler.InsertQuery(query, "LikeUsingUrl");
                                        }

                                        try
                                        {
                                            string CSV_Header = "Username" + "," + "Pin" + "," + "" + "Date";
                                            string CSV_Data   = objPinUser.Username + "," + "https://www.pinterest.com/pin/" + Pin + "/" + "," + System.DateTime.Now.ToString();
                                            string path       = PDGlobals.FolderCreation(PDGlobals.Pindominator_Folder_Path, "Like");
                                            PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Data, path + "\\NormalLike.csv");
                                        }
                                        catch (Exception ex)
                                        {
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                    }
                                }
                                else
                                {
                                    GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Not Liked : " + Pin + " From " + objPinUser.Username + " ]");
                                }
                                int Delay = RandomNumberGenerator.GenerateRandom(minDelayLike, maxDelayLike);
                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Delay For " + Delay + " Seconds ]");
                                Thread.Sleep(Delay * 1000);
                            }
                            else
                            {
                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Already Liked : " + Pin + " From " + objPinUser.Username + " ]");
                                int Delay = RandomNumberGenerator.GenerateRandom(minDelayLike, maxDelayLike);
                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Delay For " + Delay + " Seconds ]");
                                Thread.Sleep(Delay * 1000);
                            }
                        }
                        catch (Exception ex)
                        {
                            GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                        }
                        LikeCount++;
                    }
                    else
                    {
                        break;
                    }
                }
                #endregion
                if (MaxLike <= LikeCount)
                {
                    GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] [ PROCESS COMPLETED " + " For " + objPinUser.Username + " ]");
                    GlobusLogHelper.log.Info("--------------------------------------------------------------------------------------------------------");
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
            }
        }
        public void BoardMethod(string BoardName, string BoardUrl, ref PinInterestUser objPinInUser)
        {
            try
            {
                try
                {
                    lstThreadsBoards.Add(Thread.CurrentThread);
                    lstThreadsBoards.Distinct().ToList();
                    Thread.CurrentThread.IsBackground = true;
                }
                catch (Exception ex)
                { };
                lock (this)
                {
                    string           BoardId      = string.Empty;
                    AddNewPinManager objaddnewPin = new AddNewPinManager();
                    RePinManager     objRepin     = new RePinManager();
                    try
                    {
                        boardinput.Add(Thread.CurrentThread);
                        boardinput.Distinct();
                        Thread.CurrentThread.IsBackground = true;
                    }
                    catch (Exception ex)
                    { };

                    if (string.IsNullOrEmpty(BoardName))
                    {
                        try
                        {
                            List <string> baordnames = GetAllBoardNames_new(ref objPinInUser);
                            BoardName = baordnames[RandomNumberGenerator.GenerateRandom(0, baordnames.Count - 1)];
                            BoardId   = objaddnewPin.GetBoardId(BoardName, ref objPinInUser);
                        }
                        catch (Exception ex)
                        { };
                    }
                    else
                    {
                        //testing

                        GlobusHttpHelper objHttp = new GlobusHttpHelper();

                        try
                        {
                            BoardId = objaddnewPin.GetBoardId_Board(BoardName, ref objPinInUser);
                        }
                        catch (Exception ex)
                        {
                            Console.Write(ex.Message);
                        }
                    }

                    if (string.IsNullOrEmpty(BoardId))
                    {
                        BoardId = objaddnewPin.GetBoardId(BoardName, ref objPinInUser);
                    }

                    int counter      = 0;
                    int RepinCounter = 0;
                    if (!BoardId.Contains("failure"))
                    {
                        if (!string.IsNullOrEmpty(BoardId))
                        {
                            if (PDGlobals.ValidateNumber(BoardId))
                            {
                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Adding Pins From Board :" + BoardUrl + " ]");

                                clsSettingDB  db      = new clsSettingDB();
                                List <string> lstPins = new List <string>();
                                lstPins = GetBoardPinsNew(BoardId, BoardUrl, 10, ref objPinInUser);
                                lstPins.Distinct();
                                List <string> lstOfRepin = new List <string>();
                                lstOfRepin.AddRange(lstPins);

                                string[] lstPinNo = null;
                                lstPinNo = lstPins.ToArray();
                                //getting lstPins length
                                int lenOFlstPins = lstOfRepin.Count;

                                foreach (string Pins in lstPinNo)
                                {
                                    if (MaxRePinCount > RepinCounter)
                                    {
                                        string Message = string.Empty;
                                        if (ClGlobul.lstBoardRepinMessage.Count > 0)
                                        {
                                            if (counter < ClGlobul.lstBoardRepinMessage.Count)
                                            {
                                                Message = ClGlobul.lstBoardRepinMessage[counter];
                                            }
                                            else
                                            {
                                                counter = 0;
                                                Message = ClGlobul.lstBoardRepinMessage[counter];
                                            }
                                        }

                                        bool IsReppined = false;
                                        if (!Pins.Contains("n"))
                                        {
                                            try
                                            {
                                                int index = lstOfRepin.Where(x => x == Pins).Select(x => lstOfRepin.IndexOf(x)).Single <int>();

                                                string NoOfPages = Convert.ToString(index / lenOFlstPins);

                                                IsReppined = objRepin.RepinwithMessage(Pins, Message, BoardId, NoOfPages, ref objPinInUser);
                                            }

                                            catch { }
                                            if (IsReppined)
                                            {
                                                //GlobusLogHelper.log.Info("[ => [ Repin Id : " + Pins + " ]");
                                                #region AccountReport

                                                string module = "Boards";
                                                string status = "Repined";
                                                Qm.insertAccRePort(objPinInUser.Username, module, "https://www.pinterest.com/pin/" + Pins, BoardName, "", "", "", "", status, "", "", DateTime.Now);
                                                objBoardDelegate();

                                                #endregion

                                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Repin Pin : " + Pins + " to Account : " + objPinInUser.Username + " In " + BoardName + " ]");
                                                try
                                                {
                                                    string CSV_Header = "Date" + "," + "UserName" + "," + "Message" + "," + "Pin" + "Board Id";
                                                    string CSV_Data   = System.DateTime.Now.ToString() + "," + objPinInUser.Username + "," + Message + "," + "https://www.pinterest.com/pin/" + Pins + "," + BoardId;

                                                    PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Data, Boardpath + "\\Board.csv");
                                                    RepinCounter++;
                                                }
                                                catch (Exception ex)
                                                {
                                                    Console.Write(ex.Message);
                                                }

                                                //kept here
                                                int delay = RandomNumberGenerator.GenerateRandom(minDelayBoards, maxDelayBoards);
                                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Delay for " + delay + " Seconds ]");
                                                Thread.Sleep(delay * 1000);
                                            }
                                            else
                                            {
                                            }

                                            counter++;
                                        }
                                    }
                                    else
                                    {
                                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED " + " For " + objPinInUser.Username + " In " + BoardName + "]");
                                        GlobusLogHelper.log.Info("-----------------------------------------------------------------------------");
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        GlobusLogHelper.log.Info("[ " + DateTime.Now + " ]  => [ You already have a board with that name. " + objPinInUser.Username + " ]");
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
        }
Exemplo n.º 7
0
        public void StartActionMultithreadLikeByKeyword(ref PinInterestUser objPinUser)
        {
            try
            {
                try
                {
                    lstThreadsLikeByKeyword.Add(Thread.CurrentThread);
                    lstThreadsLikeByKeyword.Distinct().ToList();
                    Thread.CurrentThread.IsBackground = true;
                }
                catch (Exception ex)
                { };

                int      counter   = 0;
                string[] arrayItem = new string[100];
                foreach (string newItem in ClGlobul.lstLikeByKeyword)
                {
                    try
                    {
                        arrayItem = Regex.Split(newItem, "::");
                        if (arrayItem.Length == 2 && arrayItem[0] == objPinUser.Niches)
                        {
                            if (arrayItem.Length == 2)
                            {
                                string[] Keywordarrray = Regex.Split(arrayItem[1], ",");
                                foreach (string KeywordsItem in Keywordarrray)
                                {
                                    lock (this)
                                    {
                                        try
                                        {
                                            lstLike.Add(KeywordsItem);
                                            List <string> LstPins = new List <string>();
                                            LstPins = KeywordPins_New(KeywordsItem, MaxLikeByKeyword, ref objPinUser);
                                            LstPins = LstPins.Distinct().ToList();
                                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Finding Pins On Keyword : " + KeywordsItem + " For " + objPinUser.Username + " ]");
                                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ " + LstPins.Count + " Pins On Keyword :" + KeywordsItem + " For " + objPinUser.Username + " ]");
                                            string[] lstofPinLike = null;
                                            lstofPinLike = LstPins.ToArray();

                                            #region foreach
                                            foreach (string Pin in lstofPinLike)
                                            {
                                                if (MaxLikeByKeyword > counter)
                                                {
                                                    try
                                                    {
                                                        DataSet dt            = DataBaseHandler.SelectQuery("SELECT * FROM LikeUsingUrl Where LikeUrl = '" + Pin + "' and UserName = '******' ", "LikeUsingUrl");
                                                        int     count_NO_RoWs = dt.Tables[0].Rows.Count;
                                                        if (count_NO_RoWs == 0)
                                                        {
                                                            bool IsLiked = objLikeManagers.Like_New(ref objPinUser, Pin);

                                                            if (IsLiked)
                                                            {
                                                                #region AccountReport

                                                                string module = "LikeByKeyword";
                                                                string status = "Liked";
                                                                QM.insertAccRePort(objPinUser.Username, module, "https://www.pinterest.com/pin/" + Pin, "", "", "", KeywordsItem, "", status, "", "", DateTime.Now);
                                                                objLikeByKeywordDelegate();

                                                                #endregion
                                                                counter++;
                                                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Liked : " + Pin + " From " + objPinUser.Username + " ]");

                                                                try
                                                                {
                                                                    if (!string.IsNullOrEmpty(Pin) && !string.IsNullOrEmpty(objPinUser.Username))
                                                                    {
                                                                        string query = "INSERT INTO  LikeUsingUrl (LikeUrl,UserName) VALUES ('" + Pin + "' ,'" + objPinUser.Username + "') ";
                                                                        DataBaseHandler.InsertQuery(query, "LikeUsingUrl");
                                                                    }

                                                                    try
                                                                    {
                                                                        string CSV_Header = "Username" + "," + "Pin" + "," + "" + "Date";
                                                                        string CSV_Data   = objPinUser.Username + "," + "https://www.pinterest.com/pin/" + Pin + "/" + "," + System.DateTime.Now.ToString();
                                                                        string path       = PDGlobals.FolderCreation(PDGlobals.Pindominator_Folder_Path, "Like");
                                                                        PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Data, path + "\\LikeByKeyword.csv");
                                                                    }
                                                                    catch (Exception ex)
                                                                    {
                                                                    }
                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                                                }
                                                            }
                                                            else
                                                            {
                                                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Not Liked : " + Pin + " From " + objPinUser.Username + " ]");
                                                            }
                                                            int Delay = RandomNumberGenerator.GenerateRandom(minDelayLikeByKeyword, maxDelayLikeByKeyword);
                                                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Delay For " + Delay + " Seconds ]");
                                                            Thread.Sleep(Delay * 1000);
                                                        }
                                                        else
                                                        {
                                                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Already Liked : " + Pin + " From " + objPinUser.Username + " ]");
                                                            int Delay = RandomNumberGenerator.GenerateRandom(minDelayLikeByKeyword, maxDelayLikeByKeyword);
                                                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Delay For " + Delay + " Seconds ]");
                                                            Thread.Sleep(Delay * 1000);
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                                    }
                                                }
                                                else
                                                {
                                                    break;
                                                }
                                            }
                                            #endregion
                                            if (MaxLikeByKeyword == counter)
                                            {
                                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED " + " For " + objPinUser.Username + " ]");
                                                GlobusLogHelper.log.Info("-----------------------------------------------------------------------------------");
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            GlobusLogHelper.log.Error(" Error : 3.4" + ex.StackTrace);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error(" Error : 3.4" + ex.StackTrace);
                    }
                }
                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ PROCESS COMPLETED " + " For " + objPinUser.Username + " ]");
                GlobusLogHelper.log.Info("---------------------------------------------------------------------------------------------------------------------------");
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    if (countThreadControllerLikeByKeyword > Nothread_LikeByKeyword)
                    {
                        lock (LikeByKeywordObjThread)
                        {
                            Monitor.Pulse(LikeByKeywordObjThread);
                        }
                        LikeByKeyworddata_count--;
                    }
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error : " + ex.StackTrace);
                }
                countThreadControllerLikeByKeyword--;
            }
        }
        public void StartActionMultithreadFollowByKeyword(ref PinInterestUser objPinUser)
        {
            try
            {
                try
                {
                    lstThreadsFollowByKeyword.Add(Thread.CurrentThread);
                    lstThreadsFollowByKeyword.Distinct().ToList();
                    Thread.CurrentThread.IsBackground = true;
                }
                catch (Exception ex)
                { };
                DataTable FollowedCount = QM.SelectFollowsToday(objPinUser.Username);
                int       TotalFollow   = NoOfUserFollowByKeyword;
                //int CountLeft = NoOfUserFollowByKeyword - FollowedCount.Rows.Count;
                int FollowData = 0;
                if (TotalFollow > 0)
                {
                    int Time  = AccPerDayUserFollowByKeyword;
                    int delay = (Time * 60 * 60) / TotalFollow;
                    foreach (string comment in ClGlobul.lstkeyword)
                    {
                        string[] arraykey = Regex.Split(comment, "::");
                        if (arraykey.Length == 2)
                        {
                            if (arraykey[0] == objPinUser.Niches)
                            {
                                string[] keywordArray = Regex.Split(arraykey[1], ",");

                                bool OverFollow = false;
                                foreach (string PinSearch in keywordArray)
                                {
                                    try
                                    {
                                        Pins = getUserKeywordSearch_New(PinSearch, NoOfUserFollowByKeyword, ref objPinUser);

                                        foreach (string FollowUser in Pins)
                                        {
                                            try
                                            {
                                                DataTable dt  = QM.SelectFollowsToday(objPinUser.Username);
                                                DataTable dt1 = QM.SelectFollowsCheck(objPinUser.Username, FollowUser);
                                                if (FollowData >= TotalFollow)
                                                {
                                                    GlobusLogHelper.log.Info(" => [ Followed " + dt.Rows.Count + " Users ]");
                                                    OverFollow  = true;
                                                    TotalFollow = TotalFollow + NoOfUserFollowByKeyword;
                                                    break;
                                                }
                                                if (dt1.Rows.Count == 0)
                                                {
                                                    string User = FollowPeople_New(ref objPinUser, FollowUser, PinSearch);


                                                    if (User == "Followed")
                                                    {
                                                        string CSV_Header = "UserName" + "," + "Follow User" + "," + "Date";
                                                        string CSV_Data   = objPinUser.Username + "," + FollowUser + "," + System.DateTime.Now.ToString();
                                                        string path       = PDGlobals.FolderCreation(PDGlobals.Pindominator_Folder_Path, "Follow");
                                                        PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Data, path + "\\FollowByKeyword.csv");
                                                        QM.insertFollowDate(objPinUser.Username, FollowUser, PinSearch);
                                                        OverFollow = false;
                                                        FollowData++;
                                                        GlobusLogHelper.log.Info(" => [ Successfully Followed " + FollowUser + ">>>" + objPinUser.Username + " ]");
                                                    }
                                                    else if (User == "exceeded the maximum rate")
                                                    {
                                                        GlobusLogHelper.log.Info(" => [ Rate Limit Exceeded ]");
                                                    }
                                                    else if (User == "NotFollowed")
                                                    {
                                                        GlobusLogHelper.log.Info(" => [ Follow Process Failed User " + FollowUser + ">>>" + objPinUser.Username + " ]");
                                                    }
                                                    else if (User == "Unfollow")
                                                    {
                                                        GlobusLogHelper.log.Info(" => [ Already Followed " + FollowUser + " from " + objPinUser.Username + "]");
                                                    }
                                                    int RandomDelayAdd = RandomNumberGenerator.GenerateRandom(minDelayFollowByKeyword, maxDelayFollowByKeyword);
                                                    GlobusLogHelper.log.Info(" => [ Delay For " + RandomDelayAdd + " Seconds ]");
                                                    int totaldelay = (RandomDelayAdd * 1000);
                                                    Thread.Sleep(totaldelay);
                                                }
                                                else
                                                {
                                                    GlobusLogHelper.log.Info(" => [ Already Followed " + FollowUser + " from " + objPinUser.Username + "]");
                                                }
                                                if (OverFollow)
                                                {
                                                    break;
                                                }
                                            }

                                            catch (Exception ex)
                                            {
                                                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    { }
                                }
                            }
                        }
                    }
                    GlobusLogHelper.log.Info(" => [ PROCESS COMPLETED " + " For " + objPinUser.Username + " ]");
                    GlobusLogHelper.log.Info("----------------------------------------------------------------------------------------------------");
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
        }
        public void UserFollowes(ref PinInterestUser objPinUser, List <string> myList)
        {
            try
            {
                List <string> Followerlist = new List <string>();
                if (rbFollowFollowers == true)
                {
                    objPinUser.lstUserFollowers = myList;
                    Followerlist = myList;
                }
                if (rbFollowUser == true)
                {
                    Followerlist = myList;
                    Followerlist = Followerlist.Distinct().ToList();
                }
                try
                {
                    int CountToday  = 0;
                    int CountByUser = 0;
                    foreach (var itemlist in Followerlist)
                    {
                        string FollowUrl = itemlist.ToString();
                        try
                        {
                            bool followedAlready = false;

                            if (followedAlready)
                            {
                                GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ User " + FollowUrl + " already followed ]");
                            }
                            else
                            {
                                string IsFollowed = FollowPeople_New(FollowUrl, ref objPinUser);

                                if (IsFollowed == "Followed")
                                {
                                    #region AccountReport

                                    string module = "FollowByUsername";
                                    string status = "Followed";
                                    QM.insertAccRePort(objPinUser.Username, module, "", "", FollowUrl, "", "", "", status, "", "", DateTime.Now);
                                    objFollowByUsernameDelegate();

                                    #endregion

                                    GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Followed " + FollowUrl + " From " + objPinUser.Username + " ]");
                                    FollowCount++;
                                    CountToday++;
                                    clsSettingDB Db = new clsSettingDB();
                                    Db.insertFollowDate(objPinUser.Username, FollowUrl, "");

                                    try
                                    {
                                        string CSV_Header = "UserName" + "," + "Follow Url" + "," + "Date";
                                        string CSV_Data   = objPinUser.Username + "," + "https://www.pinterest.com/" + FollowUrl + "," + System.DateTime.Now.ToString();
                                        string path       = PDGlobals.FolderCreation(PDGlobals.Pindominator_Folder_Path, "Follow");
                                        PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Data, path + "\\FollowUserFollowers.csv");
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                }
                                else if (IsFollowed == " ")
                                {
                                    GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Already Followed " + FollowUrl + " From " + objPinUser.Username + " ]");
                                }
                                else
                                {
                                    GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Could Not Follow " + FollowUrl + " From " + objPinUser.Username + " ]");
                                    Thread.Sleep(1000);
                                    continue;
                                }
                            }
                            if (MaxFollowCount == CountToday)
                            {
                                break;
                            }
                            int Delay = RandomNumberGenerator.GenerateRandom(minDelayFollowByUsername, maxDelayFollowByUsername);
                            GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Delay For " + Delay + " Seconds ]");
                            Thread.Sleep(Delay * 1000);
                        }
                        catch (Exception ex)
                        {
                            GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                        }
                    }
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
        }
Exemplo n.º 10
0
        private void btnExpoxtActiveAcc_AccountChecker_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (objAccountChecker.lstOfActiveAccount.Count > 0)
                {
                    try
                    {
                        string CSV_Header  = string.Join(",", "UserName", "Password", "Niche", "ProxyAddress", "ProxyPort", "ProxyUsername", "ProxyPassword", "Date&Time");
                        string CSV_Content = "";
                        var    result      = ModernDialog.ShowMessage("Are you want to Export Report Data ", " Export Report Data ", MessageBoxButton.YesNo);

                        if (result == MessageBoxResult.Yes)
                        {
                            try
                            {
                                string FilePath = string.Empty;
                                FilePath = Utils.Utils.UploadFolderData(PDGlobals.Pindominator_Folder_Path);
                                FilePath = FilePath + "\\ActiveAccount.csv";
                                GlobusLogHelper.log.Info("Export Data File Path :" + FilePath);
                                GlobusLogHelper.log.Debug("Export Data File Path :" + FilePath);
                                string ExportDataLocation = FilePath;
                                PDGlobals.Pindominator_Folder_Path = FilePath;

                                foreach (string item in objAccountChecker.lstOfActiveAccount)
                                {
                                    try
                                    {
                                        string[] item_Data     = Regex.Split(item, ":");
                                        string   UserName      = item_Data[0].ToString();
                                        string   Password      = item_Data[1].ToString();
                                        string   Niche         = item_Data[2].ToString();
                                        string   ProxyAddress  = item_Data[3].ToString();
                                        string   ProxyPort     = item_Data[4].ToString();
                                        string   ProxyUsername = item_Data[5].ToString();
                                        string   ProxyPassword = item_Data[6].ToString();
                                        string   DateAndTime   = DateTime.Now.ToString();
                                        CSV_Content = string.Join(",", UserName.Replace("'", ""), Password.Replace("'", ""), Niche.Replace("'", ""), ProxyAddress.Replace("'", ""), ProxyPort.Replace("'", ""), ProxyUsername.Replace("'", ""), ProxyPassword.Replace("'", ""), DateAndTime.Replace("'", ""));

                                        PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Content, ExportDataLocation);
                                    }
                                    catch (Exception ex)
                                    {
                                        GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                    }
                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
        }