public void StartActionMultiThreadedComment(ref PinInterestUser objPinUser)
        {
            try
            {
                try
                {
                    lstThreadsComment.Add(Thread.CurrentThread);
                    lstThreadsComment.Distinct().ToList();
                    Thread.CurrentThread.IsBackground = true;
                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                }
                List<string> lstPinComment = new List<string>();
                //List<string> lstAllPins = objLikeManagers.GetPins(ref objPinUser, MaxComment);

                string userName = objPinUser.ScreenName;
               // userName = screen_Name;

                List<string> lstAllPins = GetUserFollowing_newComment(userName, 1, MaxComment);
                string Checking = objPinUser.globusHttpHelper.getHtmlfromUrl(new Uri("https://www.pinterest.com"));
                List<string> followinglstAllPins = lstAllPins;
             
                foreach (string FollowName in followinglstAllPins)
                {
                    try
                    {
                        Random rnd = new Random();
                        int FollowingNum = rnd.Next(0, followinglstAllPins.Count - 1);
                        string FollowingName = followinglstAllPins[FollowingNum].Trim();

                        List<string> lstRepinPin = objRepin_Comments_UserPins_Repin(FollowingName, ref objPinUser);
                        //checklogin = objPinUser.globusHttpHelper.getHtmlfromUrl(new Uri("https://www.pinterest.com"));
                        lstPinComment.AddRange(lstRepinPin);
                        lstPinComment = lstPinComment.Distinct().ToList();
                        if (MaxComment < lstPinComment.Count)
                        {
                            break;
                        }
                    }
                    catch(Exception ex)
                    {
                        GlobusLogHelper.log.Error("  Error : " + ex.StackTrace);
                    }
                }
                //Random Pinrnd = new Random();
                
               // ClGlobul.lstPins = lstPinComment.OrderBy(X => Pinrnd.Next()).ToList();

                List<string> TempCommentMessageList = new List<string>();
                TempCommentMessageList.AddRange(ClGlobul.CommentMessagesList);
                int Count = 0;
                #region foreach

                foreach (string Pin in lstPinComment)
                {
                    try
                    {
                        if (MaxComment > Count)
                        {
                            string[] arrCommentList = ClGlobul.CommentMessagesList.ToArray();
                            string Message = string.Empty;

                            foreach (string items in TempCommentMessageList)
                            {
                                int rndNo = RandomNumberGenerator.GenerateRandom(0, ClGlobul.CommentMessagesList.Count);
                                Message = arrCommentList[rndNo];
								GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Message : " + Message + " ]");
                                break;
                            }

                            try
                            {

                                //bool IsCommented = pinterestComment.Comment(Pin, Message, ref accountManager);
                                
                                bool IsCommented = Comment_new(ref objPinUser, Pin, Message);
                                if (IsCommented)
                                {
                                    #region AccountReport

                                    string module = "Comment";
                                    string status = "Commented";
                                    Qm.insertAccRePort(objPinUser.Username, module, "https://www.pinterest.com/pin/" + Pin, "", "", Message, "", "", status, "", "", DateTime.Now);
                                    objCommentDelegate();

                                    #endregion

									GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Commented on Pin : " + Pin + " From " + objPinUser.Username + " ]");
                                    string user = PinterestPins.getUserNameFromPinId(Pin, ref objPinUser);
                                    clsSettingDB Databse = new clsSettingDB();
                                    Databse.insertMessageDate(objPinUser.Username, user, Pin.Replace("/", ""), "", Message);

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

                                    }
                                    Count++;
                                }
                                else if (!IsCommented)
                                {
									GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Not Commented on Pin : " + Pin + " From " + objPinUser.Username + " ]");
                                }

                                int Delay = RandomNumberGenerator.GenerateRandom(minDelayComment, maxDelayComment);
								GlobusLogHelper.log.Info("[ " + DateTime.Now + " ] => [ Delay For " + Delay + " Seconds ]");
                                Thread.Sleep(Delay * 1000);
                            }
                            catch (Exception ex)
                            {
                                GlobusLogHelper.log.Error(" => Error : " + ex.StackTrace);
                            }
                         
                        }
                        else if (MaxComment == Count)
                        {
                            ///Count = CommentCount;
                            break;
                        }
                    }
                    catch (Exception ex)
                    {

                    }
                }

                #endregion

            }
            catch(Exception ex)
            {
                GlobusLogHelper.log.Error("  Error : " + ex.StackTrace);
            }
        }     
        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--;


            }
        
        }