private void startRepinByKeyword()
		{
			try
			{
				if (PDGlobals.listAccounts.Count > 0)
				{
					try
					{
						string SingleUser_RepinByKeyword = string.Empty;
						string SingleMsg_RepinByKeyword = string.Empty;
						try
						{
							if (chkSingleUser_RepinByKeyword.Active == true) 
							{
								ClGlobul.lstRepinByKeyword.Clear();
								ClGlobul.lstMsgRepinByKeyword.Clear();
								if (string.IsNullOrEmpty(txtKeywordBoard.Text))
								{
									GlobusLogHelper.log.Info("Please Enter Keyword To Repin");									
									return;
								}
								else
								{
									SingleUser_RepinByKeyword=txtKeywordBoard.Text.Trim();
									ClGlobul.lstRepinByKeyword.Add(SingleUser_RepinByKeyword);
									GlobusLogHelper.log.Info("[ " + DateTime.Now + " => [ Keyword To Repin Enter :" + ClGlobul.lstRepinByKeyword.Count);	
									if (!string.IsNullOrEmpty(txtMessage_RepinByKeyword.Text)) 
									{
										SingleMsg_RepinByKeyword=txtMessage_RepinByKeyword.Text.Trim();
										ClGlobul.lstMsgRepinByKeyword.Add(SingleMsg_RepinByKeyword);
										GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Total Message Enter :" + ClGlobul.lstMsgRepinByKeyword.Count + " ]");	
									}
								}
							}
							if (string.IsNullOrEmpty(txtKeywordBoard.Text))
							{
								GlobusLogHelper.log.Info("[ " + DateTime.Now + " => [ Please Upload Keyword To Repin  ]");									
								return;
							}
						}
						catch (Exception ex)
						{
							Console.WriteLine (ex.StackTrace);

						}      
					}
					catch (Exception ex)
					{
						Console.WriteLine (ex.StackTrace);
					}

					clsSettingDB Database = new clsSettingDB();

					objRepinByKeywordManager.isStopRepinByKeyword = false;
					objRepinByKeywordManager.lstThreadsRepinByKeyword.Clear();
					if (objRepinByKeywordManager._IsfevoriteRepinByKeyword)
					{
						objRepinByKeywordManager._IsfevoriteRepinByKeyword = false;
					}

					Regex checkNo = new Regex("^[0-9]*$");

					int processorCount = objUtils.GetProcessor();

					int threads = 25;

					int maxThread = 25 * processorCount;

					try
					{
						try
						{
							objRepinByKeywordManager.minDelayRepinByKeyword = Convert.ToInt32(txtMinDelay_RepinByKeyword.Text);
							objRepinByKeywordManager.maxDelayRepinByKeyword = Convert.ToInt32(txtMaxDelay_RepinByKeyword.Text);
							objRepinByKeywordManager.NoOfThreadsRepinByKeyword = Convert.ToInt32(txtThread_RepinByKeyword.Text);
							objRepinByKeywordManager.MaxCountRepinByKeyword = Convert.ToInt32(txtCount_RepinByKeyword.Text);
						}
						catch (Exception ex)
						{
							GlobusLogHelper.log.Info("Enter in Correct Format");
							return;
						}

						if (!string.IsNullOrEmpty(txtThread_RepinByKeyword.Text) && checkNo.IsMatch(txtThread_RepinByKeyword.Text))
						{
							threads = Convert.ToInt32(txtThread_RepinByKeyword.Text);
						}

						if (threads > maxThread)
						{
							threads = 25;
						}
						objRepinByKeywordManager.NoOfThreadsRepinByKeyword = threads;

						GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Process Starting ] ");

						Thread BoardsThread = new Thread(objRepinByKeywordManager.StartRepinKeyword);
						BoardsThread.Start();
					}

					catch (Exception ex)
					{
						Console.Write(ex.Message);
					}
				}
				else
				{
					GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Please Load Accounts ! ]");
					//GlobusLogHelper.log.Debug("Please Load Accounts !");

				}
			}
			catch (Exception ex)
			{
				Console.Write(ex.Message);
			}
		}
		public void startRePin()
		{
			try
			{
				if (PDGlobals.listAccounts.Count > 0)
				{
					objRePinManager.isStopRePin = false;
					objRePinManager.lstThreadsRePin.Clear();
					clsSettingDB Database = new clsSettingDB();
					Database.UpdateSettingData("Repin", "RepinMsgFile", StringEncoderDecoder.Encode(txtRepinMessage_Repin.Text));
					Database.UpdateSettingData("Repin", "RepinNO", StringEncoderDecoder.Encode(txtRepinNo_Repin.Text));

					ClGlobul.lstPins.Clear();

					int processorCount = objUtils.GetProcessor();

					int threads = 25;

					int maxThread = 25 * processorCount;
					try
					{
						try
						{
							objRePinManager.minDelayRePin = Convert.ToInt32(txtMinDelay_Repin.Text);
							objRePinManager.maxDelayRePin = Convert.ToInt32(txtMaxDelay_Repin.Text);
							objRePinManager.Nothread_RePin = Convert.ToInt32(txtThread_Repin.Text);
							objRePinManager.maxNoOfRePinCount = Convert.ToInt32(txtCount_Repin.Text);
						}
						catch (Exception ex)
						{
							GlobusLogHelper.log.Info("Enter in Correct Format");
							return;
						}
						Regex checkNo = new Regex("^[0-9]*$");

						if (!string.IsNullOrEmpty(txtThread_Repin.Text) && checkNo.IsMatch(txtThread_Repin.Text))
						{
							threads = Convert.ToInt32(txtThread_Repin.Text);
						}

						if (threads > maxThread)
						{
							threads = 25;
						}
						GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Process Starting ] ");
						objRePinManager.NoOfThreadsRePin = threads;

						Thread RePinThread = new Thread(objRePinManager.StartRepin);
						RePinThread.Start();
					}

					catch (Exception ex)
					{
						Console.Write(ex.Message);
					}
				}
				else
				{
					GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => Please Load Accounts ! ]");
					//GlobusLogHelper.log.Debug("Please Load Accounts !");
				}
			}
			catch (Exception ex)
			{
				Console.Write (ex.Message);
			}
		}    
		public void startEditDescription()
		{
			try
			{
				if (PDGlobals.listAccounts.Count > 0)
				{
					try
					{
						string SingleUser_EditPinDesc = string.Empty;
						try
						{
							if (chkSingleUser_EditPinDesc.Active == true) 
							{
								ClGlobul.CommentNicheMessageList.Clear();
								if (string.IsNullOrEmpty(txtPinDescription.Text))
								{
									GlobusLogHelper.log.Info("Please Enter Description");									
									return;
								}
								else
								{
									SingleUser_EditPinDesc=txtPinDescription.Text.Trim();
									ClGlobul.CommentNicheMessageList.Add(SingleUser_EditPinDesc);
									GlobusLogHelper.log.Info("[ " + DateTime.Now + " => [ Description Enter :" + ClGlobul.CommentNicheMessageList.Count);	
								}
							}
							if (string.IsNullOrEmpty(txtPinDescription.Text))
							{
								GlobusLogHelper.log.Info("[ " + DateTime.Now + " => [ Please Upload Description  ]");									
								return;
							}
						}
						catch (Exception ex)
						{
							Console.WriteLine (ex.StackTrace);

						}       
					}
					catch (Exception ex)
					{
						Console.Write (ex.Message);
					}
					objEditPinDiscriptionManager.isStopEditPinDisc = false;
					objEditPinDiscriptionManager.lstThreadsEditPinDisc.Clear();

					if (objEditPinDiscriptionManager._IsfevoriteEditPinDes)
					{
						objEditPinDiscriptionManager._IsfevoriteEditPinDes = false;
					}

					Regex checkNo = new Regex("^[0-9]*$");

					int processorCount = objUtils.GetProcessor();

					int threads = 25;

					int maxThread = 25 * processorCount;
					try
					{
						try
						{
							objEditPinDiscriptionManager.minDelayEditPinDisc = Convert.ToInt32(txtMinDelay_EditPinDesc.Text);
							objEditPinDiscriptionManager.maxDelayEditPinDisc = Convert.ToInt32(txtMaxDelay_EditPinDesc.Text);
							objEditPinDiscriptionManager.Nothread_EditPinDisc = Convert.ToInt32(txtThread_EditPinDesc.Text);
							objEditPinDiscriptionManager.NoOfPagesEditPinDisc = Convert.ToInt32(txtNoOfPages_EditPinDisc.Text);
						}
						catch (Exception ex)
						{
							GlobusLogHelper.log.Info("Enter in Correct Format");
							return;
						}


						if (ClGlobul.CommentNicheMessageList.Count > 0)
						{
							clsSettingDB Database = new clsSettingDB();
							Database.UpdateSettingData("PinDescription", "PinDescriptionMessage", StringEncoderDecoder.Encode(txtPinDescription.Text));
							GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Start Edit Description ]");
							ClGlobul.lstPins.Clear();

						}
						if (!string.IsNullOrEmpty(txtThread_EditPinDesc.Text) && checkNo.IsMatch(txtThread_EditPinDesc.Text))
						{
							threads = Convert.ToInt32(txtThread_EditPinDesc.Text);
						}

						if (threads > maxThread)
						{
							threads = 25;
						}
						GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Process Starting ] ");
						objEditPinDiscriptionManager.NoOfThreadsEditPinDisc = threads;

						Thread EditPinDiscThread = new Thread(objEditPinDiscriptionManager.StartEditPinDisc);
						EditPinDiscThread.Start();
					}

					catch (Exception ex)
					{
						Console.Write (ex.Message);
					}
				}
				else
				{
					GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Please Load Accounts ! ]");
					//GlobusLogHelper.log.Debug("Please Load Accounts !");

				}
			}
			catch (Exception ex)
			{
				Console.Write (ex.Message);
			}
		}
		private void StartAddUserToBoard()
		{
			try
			{
				string singleUser = string.Empty;
				btnStop_AddUserToBoard.Sensitive = true;
				if (PDGlobals.listAccounts.Count > 0)
				{
					try
					{
						if (chkSingleUser_AddUserToBoard.Active == true) 
						{
							ClGlobul.lstAddToBoardUserNames.Clear();
							if (string.IsNullOrEmpty(txtEmail_AddUserToBoard.Text)) 
							{
								Addtologger("Please Upload BoardName And Email ");										
								return;
							}
							else{
							try
								{
								    singleUser=txtEmail_AddUserToBoard.Text.Trim();
									ClGlobul.lstAddToBoardUserNames.Add(singleUser);
									Addtologger("[ " + DateTime.Now + " ] => [ Board Name Enter :" + ClGlobul.lstAddToBoardUserNames.Count);	
								}
								catch(Exception Ex)  
								{
									Console.Write(Ex.Message);
								}
							}
						}
						else  if (string.IsNullOrEmpty(txtBoardName_AddBoard.Text))
						{
							Addtologger("Please Upload BoardName And Email ");										
							return;
						}
					}
					catch (Exception ex)
					{
						Console.Write(ex.Message);
					}

					//objAddUsersToBoardManager.BoardName = txtBoardName.Text.Trim();

					objAddUsersToBoardManager.isStopAddUserToBoard = false;
					objAddUsersToBoardManager.lstThreadsAddUserToBoard.Clear();
					if (objAddUsersToBoardManager._IsfevoriteAddUserToBoard)
					{
						objAddUsersToBoardManager._IsfevoriteAddUserToBoard = false;
					}

					Regex checkNo = new Regex("^[0-9]*$");

					int processorCount = objUtils.GetProcessor();

					int threads = 25;

					int maxThread = 25 * processorCount;

					try
					{
						try
						{
							objAddUsersToBoardManager.minDelayAddUserToBoard = Convert.ToInt32(txtMinDelay_AddUserToBoard.Text);
							objAddUsersToBoardManager.maxDelayAddUserToBoard = Convert.ToInt32(txtMAxDElay_AddUserToBoard.Text);
							objAddUsersToBoardManager.NoOfThreadsAddUserToBoard = Convert.ToInt32(txtThread_AddUsersToBoard.Text);
						}
						catch (Exception ex)
						{
							Addtologger("Enter in Correct Format");
							return;
						}

						if (!string.IsNullOrEmpty(txtThread_AddUsersToBoard.Text) && checkNo.IsMatch(txtThread_AddUsersToBoard.Text))
						{
							threads = Convert.ToInt32(txtThread_AddUsersToBoard.Text);
						}

						if (threads > maxThread)
						{
							threads = 25;
						}
						objAddUsersToBoardManager.NoOfThreadsAddUserToBoard = threads;

						clsSettingDB Database = new clsSettingDB();
						//Database.UpdateSettingData("UserToBoard", "UserToBoard", StringEncoderDecoder.Encode(txtEmailOrUserNames.Text));

						Addtologger("[ " + DateTime.Now + " ] => [ Process Starting ] ");

						Thread AddUserToBoardThread = new Thread(objAddUsersToBoardManager.StartAddUsersToBoard);
						btnStart_AddUsersToBoard.Sensitive = true;
						AddUserToBoardThread.Start();
					}

					catch (Exception ex)
					{
						Console.Write (ex.Message);
					}
				}
				else
				{
					Addtologger("Please Load Accounts !");
				}
			}
			catch(Exception ex) 
			{
				Console.Write (ex.Message);
			}
		}
		private void startCommentProcess()
		{
			try
			{
				string singleUser = string.Empty;
				btnStop_Comment.Sensitive = true;
				objCommentManager.isStopComment = false;

				if (PDGlobals.listAccounts.Count > 0)
				{
					try
					{
						if (chkSingleUser_Comment.Active == true) 
						{
							ClGlobul.CommentMessagesList.Clear();
							if (string.IsNullOrEmpty(txtMsg_Comment.Text))
							{
								Addtologger("Please Enter Message");									
								return;
							}
							else
							{
								singleUser=txtMsg_Comment.Text.Trim();
								ClGlobul.CommentMessagesList.Add(singleUser);
								Addtologger("[ " + DateTime.Now + "] => [ Message Enter :" + ClGlobul.CommentMessagesList.Count);	
							}
						}
						if (string.IsNullOrEmpty(txtMsg_Comment.Text))
						{
							Addtologger("[ " + DateTime.Now + "] => [ Please Upload Message");									
							return;
						}
					}
					catch (Exception ex)
					{
						Console.WriteLine (ex.StackTrace);

					}

					clsSettingDB Database = new clsSettingDB();

					//Database.UpdateSettingData("Board", "AddBoardMessage", StringEncoderDecoder.Encode(txtMsg_Board.Text));


					objCommentManager.lstThreadsComment.Clear();
					if (objCommentManager._IsfevoriteComment)
					{
						objCommentManager._IsfevoriteComment = false;
					}

					Regex checkNo = new Regex("^[0-9]*$");

					int processorCount = objUtils.GetProcessor();

					int threads = 25;

					int maxThread = 25 * processorCount;

					try
					{
						try
						{
							CommentManagers.minDelayComment = Convert.ToInt32(txtMinDelay_Comment.Text);
							CommentManagers.maxDelayComment = Convert.ToInt32(txtMaxDelay_comment.Text);
							objCommentManager.NoOfThreadsComment = Convert.ToInt32(txtThread_Comment.Text);
							CommentManagers.MaxComment = Convert.ToInt32(txtCount_comment.Text);
						}
						catch (Exception ex)
						{
							Addtologger("[ " + DateTime.Now + "] => [ Enter in Correct Format");
							return;
						}

						if (!string.IsNullOrEmpty(txtThread_Comment.Text) && checkNo.IsMatch(txtThread_Comment.Text))
						{
							threads = Convert.ToInt32(txtThread_Comment.Text);
						}

						if (threads > maxThread)
						{
							threads = 25;
						}
						objCommentManager.NoOfThreadsComment = threads;

						Addtologger("[ " + DateTime.Now + "] => [ Process Starting ] ");

						Thread BoardsThread = new Thread(objCommentManager.StartComment);
						btnStart_Comment.Sensitive = true;
						BoardsThread.Start();
					}

					catch (Exception ex)
					{
						Console.WriteLine (ex.StackTrace);

					}
				}
				else
				{
					Addtologger("[ " + DateTime.Now + "] => [ Please Load Accounts !");
				}

			}
			catch(Exception ex) 
			{
				Console.Write (ex.Message);
			}
		}
		private void startProcess()
		{
			try
			{
				if (PDGlobals.listAccounts.Count > 0)
				{
					try
					{	
						string SingleBoardUrl = string.Empty;
						string SingleMsg =  string.Empty;
						if (rdbsingleUserBoard.Active == true) 
						{
							ClGlobul.lstListOfBoardNames.Clear();
							ClGlobul.lstBoardRepinMessage.Clear();

							SingleBoardUrl = txtBoardUrl.Text.Trim();
							ClGlobul.lstListOfBoardNames.Add(SingleBoardUrl);
							Addtologger("[ " + DateTime.Now + " ] => [ Board Url Loaded : " + ClGlobul.lstListOfBoardNames.Count + " ]");

							SingleMsg = txtMsgBoard.Text.Trim();
							ClGlobul.lstBoardRepinMessage.Add(SingleMsg);
							Addtologger("[ " + DateTime.Now + " ] => [ Message Loaded : " + ClGlobul.lstBoardRepinMessage.Count + " ]");
						}
						else if(string.IsNullOrEmpty(txtBoardUrl.Text))
						{
							Addtologger("[ " + DateTime.Now + " ] => [ Please Upload Board Url ]");	
							return;
						}
					}
					catch (Exception ex)
					{
						Console.Write (ex.Message);
					}

					try
					{
					clsSettingDB Database = new clsSettingDB();
					Database.UpdateSettingData("Board", "AddBoardMessage", StringEncoderDecoder.Encode(txtMsgBoard.Text));

					objBoardManager.isStopBoards = false;
					objBoardManager.lstThreadsBoards.Clear();
					if (objBoardManager._IsfevoriteBoards)
					{
						objBoardManager._IsfevoriteBoards = false;
					}
					}
					catch{};

					Regex checkNo = new Regex("^[0-9]*$");

					int processorCount = objUtils.GetProcessor();

					int threads = 25;

					int maxThread = 25 * processorCount;

					try
					{
						try
						{
							objBoardManager.minDelayBoards = Convert.ToInt32(txtMinDelayBoard.Text);
							objBoardManager.maxDelayBoards = Convert.ToInt32(txtMaxDelayBoard.Text);
							objBoardManager.NoOfThreadsBoards = Convert.ToInt32(txtThreadBoard.Text);
							objBoardManager.MaxRePinCount = Convert.ToInt32(txtMaxCountBoard.Text);
						}
						catch (Exception ex)
						{
							Addtologger("Enter in Correct Format");
							return;
						}

						if (!string.IsNullOrEmpty(txtThreadBoard.Text) && checkNo.IsMatch(txtThreadBoard.Text))
						{
							threads = Convert.ToInt32(txtThreadBoard.Text);
						}

						if (threads > maxThread)
						{
							threads = 25;
						}
						objBoardManager.NoOfThreadsBoards = threads;

						Addtologger("[ " + DateTime.Now + " ] => [ Process Starting ] ");


						try
						{
						Thread BoardsThread = new Thread(objBoardManager.StartBoards);
						BoardsThread.Start();
						btnStopBoard.Sensitive =  true;
						}
						catch{};
					}

					catch (Exception ex)
					{
						Console.Write (ex.Message);
					}
				}
				else
				{
					Addtologger("Please Load Accounts !");				
				}
			}
			catch (Exception ex)
			{
				Console.Write (ex.Message);
			}
		}
		private void StartAddBoardName()
		{
			try
			{
				btnStop_AddBoard.Sensitive = true;
				objAddBoardManager.isStopAddBoardName = false;
				string singleUser=string.Empty;
				if (PDGlobals.listAccounts.Count > 0)
				{
					try
					{
						if(chkSingleUser_AddBoard.Active == true)
						{
							singleUser=txtBoardName_AddBoard.Text.Trim();
							ClGlobul.lstBoardNames.Add(singleUser);
						}

						if (string.IsNullOrEmpty(txtBoardName_AddBoard.Text))
						{
							Addtologger("[ " + DateTime.Now + " ] => [ Please Upload Board Name With Niche ]");
							//ModernDialog.ShowMessage("Please Upload Board Name With Niche", "Upload Board Name With Niche", MessageBoxButton.OK);
							return;
						}


					}
					catch (Exception ex)
					{
						Console.Write (ex.Message);
					}

					clsSettingDB Database = new clsSettingDB();
					Database.UpdateSettingData("Board", "AddBoardName", StringEncoderDecoder.Encode(txtBoardName_AddBoard.Text));

					objAddBoardManager.isStopAddBoardName = false;
					objAddBoardManager.lstThreadsAddBoardName.Clear();
					if (objAddBoardManager._Isfevorite)
					{
						objAddBoardManager._Isfevorite = false;
					}

					Regex checkNo = new Regex("^[0-9]*$");

					int processorCount = objUtils.GetProcessor();

					int threads = 25;

					int maxThread = 25 * processorCount;
					try
					{
						try
						{
							objAddBoardManager.minDelayAddBoardName = Convert.ToInt32(txtMinDelay_AddBoard.Text);
							objAddBoardManager.maxDelayAddBoardName = Convert.ToInt32(txtMaxDelay_AddBoard.Text);
							objAddBoardManager.Nothread_AddBoardName = Convert.ToInt32(txtThread_AddBoard.Text);
						}
						catch (Exception ex)
						{
							Addtologger("Enter in Correct Format");
							return;
						}

						if (!string.IsNullOrEmpty(txtThread_AddBoard.Text) && checkNo.IsMatch(txtThread_AddBoard.Text))
						{
							threads = Convert.ToInt32(txtThread_AddBoard.Text);
						}

						if (threads > maxThread)
						{
							threads = 25;
						}
						objAddBoardManager.NoOfThreadsAddBoardName = threads;

						Addtologger("[ " + DateTime.Now + " ] => [ Process Starting ] ");

						Thread AddBoardNameThread = new Thread(objAddBoardManager.StartAddBoardName);
						btnStart_AddBoard.Sensitive = true;
						AddBoardNameThread.Start();
					}

					catch (Exception ex)
					{
						Console.Write (ex.Message);
					}
				}
				else
				{
					Addtologger("Please Load Accounts !");

				}
			}
			catch(Exception ex) 
			{
				Console.Write (ex.Message);
			}
		}
        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 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);
            }
          
        }
        public void StartActionMultithreadRePin(ref PinInterestUser objPinUserRepin, List<string> Usercount)
        {
 
            try
            {
                try
                {
                    lstThreadsRePin.Add(Thread.CurrentThread);
                    lstThreadsRePin.Distinct().ToList();
                    Thread.CurrentThread.IsBackground = true;
                }
                catch (Exception ex)
                { };
                PinInterestUser objPinUser = (PinInterestUser)objPinUserRepin;
                string screen_Name = objPinUser.ScreenName;
                clsSettingDB db = new clsSettingDB();
                if (ObjAccountManager.Boards.Count <= 0)
                {
                    try
                    {
                        GetBoardsForRepinUpdated(ref objPinUser, screen_Name);
                        //new Thread(() => GetBoardsForRepinUpdated(ref objPinUser, screen_Name)).Start(); // Not returning only Board but Pics also
                        //GetBoardsForRepinUpdated(ref objPinUser, screen_Name);
                    }
                    catch (Exception Ex)
                    {

                    }
                }
                if (objPinUser.Boards.Count > 0 || objPinUser.Boards.Count == 0) 
                {
                    Random Boardrnd = new Random();
                    int BoardNum = 0;

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

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

                    int RepinCount = 0;

                    if (!rdbUsePinNo)
                    {
                        try
                        {
                            if (rdbRepinNormalType == true)
                            {
								GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Getting Normal Pins From Account ]");
                                lstAllPins = objLikeManager.GetPins(ref objPinUser, maxNoOfRePinCount);
                                Random Pinrnd = new Random();
                                ClGlobul.lstPins = lstAllPins.OrderBy(x => Pinrnd.Next()).ToList();
                            }
                            else
                            {
                                try
                                {
									GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Getting Random Users Pins From Account ]");

                                    string userName = objPinUser.ScreenName;
                                    userName = screen_Name;

                                    //lstFollowings = objScrape.GetUserFollowing_new(userName, 1, maxNoOfRePinCount);//GetUserFollowing
                                    lstFollowings = GetUserFollowing(userName, 1, maxNoOfRePinCount);
                                    foreach (string FollowName in lstFollowings)
                                    {
                                            try
                                            {
                                                Random rnd = new Random();
                                                int FollowingNum = rnd.Next(0, lstFollowings.Count - 1);
                                                FollowingName = lstFollowings[FollowingNum];
                                                ClGlobul.lstPins.Clear();
                                                List<string> lstRepinPin = UserPins_Repin(FollowingName, ref objPinUser);
                                                ClGlobul.lstPins.AddRange(lstRepinPin);
                                                ClGlobul.lstPins = ClGlobul.lstPins.Distinct().ToList();
                                                if (maxNoOfRePinCount < ClGlobul.lstPins.Count)
                                                {
                                                    break;
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                                            }                                        
                                    }

                                    // ClGlobul.lstPins = UserPins_Repin(FollowingName, ref objPinUser);
                                    //ClGlobul.lstPins = objLikeManager.GetPins(ref objPinUser, maxNoOfRePinCount);
                                    //checklogin = objPinUser.globusHttpHelper.getHtmlfromUrl(new Uri("https://www.pinterest.com"));
                                }
                                catch (Exception ex)
                                {
                                    GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
                                }
                            }

                            string Message = string.Empty;
                            string[] lstPinsArray = ClGlobul.lstPins.ToArray();

                            foreach (string Pin in lstPinsArray)
                            {
                                try
                                {
                                    if (NumberHelper.ValidateNumber(Pin))
                                    {
                                        try
                                        {
                                            if (maxNoOfRePinCount == RepinCount)
                                            {
                                                break;
                                            }
                                            if (maxNoOfRePinCount >= RepinCount)
                                            {
                                                Random Messagernd = new Random();
                                                int MessageNum = 0;

                                                if (ClGlobul.RepinMessagesList.Count == 2)
                                                {
                                                    try
                                                    {
                                                        foreach (var itemMsg in ClGlobul.RepinMessagesList)
                                                        {
                                                            if (Message == itemMsg)
                                                            {
                                                                continue;
                                                            }
                                                            else
                                                            {
                                                                Message = itemMsg;
                                                                break;
                                                            }
                                                        }
														GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Message :" + Message + " ]");
                                                    }
                                                    catch (Exception ex)
                                                    {

                                                    }
                                                }
                                                else if (ClGlobul.RepinMessagesList.Count > 0)
                                                {
                                                    try
                                                    {
                                                        MessageNum = Messagernd.Next(0, ClGlobul.RepinMessagesList.Count - 1);
                                                        Message = ClGlobul.RepinMessagesList[MessageNum].Trim();
														GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Message :" + Message + " ]");
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        //GlobusFileHelper.AppendStringToTextfileNewLine("Error --> StartRepinMultiThreaded() 2--> " + ex.Message, ApplicationData.ErrorLogFile);
                                                    }
                                                }

                                                try
                                                {
                                                    string NoOfPages = "0";//No use as far as I know
                                                    try
                                                    {
                                                        int index = ClGlobul.lstPins.Where(x => x == Pin).Select(x => ClGlobul.lstPins.IndexOf(x)).Single<int>();
                                                        NoOfPages = Convert.ToString(index / 25);
                                                    }
                                                    catch { }

                                                    try
                                                    {
                                                        Random rndBoard = new Random();
                                                        int NumBoard = rndBoard.Next(0, objPinUser.Boards.Count - 1);
                                                        BoardNumber = objPinUser.Boards[NumBoard];
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                    }

                                                    string Url = "https://www.pinterest.com/" + objPinUser.ScreenName;
                                                    if (string.IsNullOrEmpty(oneTimePagesource))
                                                    {
                                                        try
                                                        {
                                                            GlobusHttpHelper objHttp = new GlobusHttpHelper();
                                                            oneTimePagesource = objHttp.getHtmlfromUrl(new Uri(Url), "", "", "");
                                                        }
                                                        catch { };
                                                    }
                                                    if (arrBoardName == null)
                                                    {
                                                        try
                                                        {
                                                            arrBoardName = Regex.Split(oneTimePagesource, "board\", \"id\"");
                                                        }
                                                        catch { };
                                                    }
                                                    foreach (var itemBoardName in arrBoardName)
                                                    {
                                                        try
                                                        {
                                                            if (itemBoardName.Contains(BoardNumber))//&&itemBoardName.Contains("board\", \"id\""))
                                                            {
                                                                BoardName = Utils.Utils.getBetween(itemBoardName, "name", "}").Replace(":", "").Replace("\"", "").Trim();
                                                            }
                                                        }
                                                        catch (Exception ex)
                                                        {

                                                        }
                                                    }

                                                    BoardName = BoardName.Replace(" ", "-").ToLower().Replace("(", "").Replace(")", "").Replace("!", "").Trim();

                                                    bool IsRePined = RepinwithMessage(Pin, Message, BoardNumber, NoOfPages, ref objPinUser);
                                                    if (IsRePined)
                                                    {
                                                        #region AccountReport

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

                                                        #endregion

                                                        db.insertRePinRecord(objPinUser.Username, objPinUser.Niches, Pin);
                                                        RepinCount++;

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

                                                        }
                                                    }
                                                    else
                                                    {
                                                        RepinCount++;

                                                    }
                                                    if (rdbDivideGivenByUser_RePin == true)
                                                    {
                                                        CountGivenByUser_RePin--;
                                                        if (CountGivenByUser_RePin < 0)
                                                        {
                                                            break;
                                                        }
                                                    }

                                                    int delay = RandomNumberGenerator.GenerateRandom(minDelayRePin, maxDelayRePin);
													GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Delay For " + delay + " Seconds ]");
                                                    Thread.Sleep(delay * 1000);
                                                }
                                                catch (Exception ex)
                                                {
                                                    //GlobusFileHelper.AppendStringToTextfileNewLine("Error --> StartRepinMultiThreaded() 3--> " + ex.Message, ApplicationData.ErrorLogFile);
                                                }
                                            }

                                           
                                        }
                                        catch (Exception ex)
                                        {
                                            // GlobusFileHelper.AppendStringToTextfileNewLine("Error --> StartRepinMultiThreaded() 4--> " + ex.Message, ApplicationData.ErrorLogFile);
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {

                                }
                            }                          
                        }
                        catch (Exception ex)
                        {

                        }
                    }
                    else if (rdbUsePinNo == true)
                    {
                        try
                        {

                            if (ClGlobul.lstRepinUrl.Count < maxNoOfRePinCount)
                            {
								GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [Repin Count can't be greater than uploaded Pins.]");
                                return;
                            }
							GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Repining Uploaded Pins ]");
                            int RepinCount_ListRepin_New = maxNoOfRePinCount;

                            foreach (string RepinUrl in Usercount)
                            {
                                try
                                {                              
                                        if (RepinCount_ListRepin_New <= 0)
                                        {
                                            break;
                                        }
                                    //}
                                }
                                catch { };
                              
                                string NoOfPages = "0";

                                try
                                {

                                    int index = ClGlobul.lstRepinUrl.Where(x => x == RepinUrl).Select(x => ClGlobul.lstRepinUrl.IndexOf(x)).Single<int>();
                                    NoOfPages = Convert.ToString(index / 25);
                                }
                                catch { };


                                string Message = string.Empty;
                                if (ClGlobul.RepinMessagesList.Count > 1)
                                {
                                    Message = ClGlobul.RepinMessagesList[RandomNumberGenerator.GenerateRandom(0, ClGlobul.RepinMessagesList.Count - 1)];
                                }
                                else if (ClGlobul.RepinMessagesList.Count == 1)
                                {
                                    Message = ClGlobul.RepinMessagesList[0];
                                }
                                else
                                {
                                    Message = "";
                                }

                                Thread.Sleep(1000);
                                bool IsRepinned = RepinwithMessage(RepinUrl.Replace(" ", ""), Message, BoardNumber, NoOfPages, ref objPinUser);

                                if (IsRepinned)
                                {
                                    #region AccountReport

//                                    string module = "RePin";
//                                    string status = "Repined";
//                                    Qm.insertAccRePort(objPinUser.Username, module, "https://www.pinterest.com/pin/" + RepinUrl, "", "", Message, "", "", status, "", "", DateTime.Now);
//                                    objRepinDelegate();

                                    #endregion

									GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Repin Pin : " + RepinUrl + " ]");
                                    db.insertRePinRecord(objPinUser.Username, objPinUser.Niches, RepinUrl);
                                    RepinCount++;
                                    RepinCount_ListRepin_New--;
                                    try
                                    {
                                        string CSV_Header = "UserName" + "," + "RepinUrl" + "," + "Message" + "," + "Board Number" + "," + "Date";
                                        string CSV_Data = objPinUser.Username + "," + "https://www.pinterest.com/pin/" + RepinUrl + "," + Message + "," + "Board No. : " + BoardNumber + "," + System.DateTime.Now.ToString();
                                        string path = PDGlobals.FolderCreation(PDGlobals.Pindominator_Folder_Path, "Repin");
                                        PDGlobals.ExportDataCSVFile(CSV_Header, CSV_Data, path + "\\UsePin.csv");
                                    }
                                    catch (Exception ex)
                                    {

                                    }
                                }
                                else
                                {
									GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Not Repin Pin : " + RepinUrl + " ]");
                                }
                                int Delay = RandomNumberGenerator.GenerateRandom(minDelayRePin, maxDelayRePin);
								GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ Delay for " + Delay + " Seconds ]");
                                Thread.Sleep(Delay * 1000);

                            }
                        }

                        catch (Exception ex)
                        { };

                    }
                    else
                    {
						GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ No Boards Found in Account :" + objPinUser.Username + " ]");
                    }
                }

            }
            catch(Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
            finally
            {
                RePindata_count--;              
                try
                {
                    if (countThreadControllerRePin >= NoOfThreadsRePin)
                    {
                        lock (RePinObjThread)
                        {
                            Monitor.Pulse(RePinObjThread);
                        }
                    }
                }
                catch (Exception Ex)
                {

                }
                countThreadControllerRePin--;

                if (RePindata_count == 0 || CountGivenByUser_RePin < 0)
                {                  
					GlobusLogHelper.log.Info("[ " + DateTime.Now + "] => [ PROCESS COMPLETED ]");
                GlobusLogHelper.log.Info("-------------------------------------------------------------------------------------");
                }
            }
        }
        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--;


            }
        
        }
       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);
           }
       }
        public void startRepinByKeyword()
        {
            try
            {
                if (PDGlobals.listAccounts.Count > 0)
                {
                    try
                    {
                        if (objRepinByKeywordManager.rdbSingleUserRepinByKeyword == true || objRepinByKeywordManager.rdbMultipleUserRepinByKeyword == true)
                        {
                            if (objRepinByKeywordManager.rdbSingleUserRepinByKeyword == true)
                            {
                                try
                                {
                                }
                                catch (Exception ex)
                                {
                                    GlobusLogHelper.log.Info("Error :" + ex.StackTrace);
                                }
                            }//end of single user
                            if (objRepinByKeywordManager.rdbMultipleUserRepinByKeyword == true)
                            {
                                try
                                {
                                    if (string.IsNullOrEmpty(txtKeywordBoard.Text))
                                    {
                                        GlobusLogHelper.log.Info("Please Enter Keyword");
                                        ModernDialog.ShowMessage("Please Enter Keyword", "Enter Keyword", MessageBoxButton.OK);
                                        return;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    GlobusLogHelper.log.Info("Error :" + ex.StackTrace);
                                }
                            }//end of multiple user
                        }
                        else
                        {
                            MessageBox.Show("Please Select Use Single User or Use Multiple User");
                            return;
                        }

                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                    }

                    clsSettingDB Database = new clsSettingDB();
                    // Database.UpdateSettingData("Board", "AddBoardUrl", StringEncoderDecoder.Encode(txtBoardName.Text));
                    //Database.UpdateSettingData("Board", "AddBoardMessage", StringEncoderDecoder.Encode(txtMessage.Text));

                    objRepinByKeywordManager.isStopRepinByKeyword = false;
                    objRepinByKeywordManager.lstThreadsRepinByKeyword.Clear();
                    if (objRepinByKeywordManager._IsfevoriteRepinByKeyword)
                    {
                        objRepinByKeywordManager._IsfevoriteRepinByKeyword = false;
                    }

                    Regex checkNo = new Regex("^[0-9]*$");

                    int processorCount = objUtil.GetProcessor();

                    int threads = 25;

                    int maxThread = 25 * processorCount;

                    try
                    {
                        try
                        {
                            objRepinByKeywordManager.minDelayRepinByKeyword = Convert.ToInt32(txtRepinByKeyword_DelayMin.Text);
                            objRepinByKeywordManager.maxDelayRepinByKeyword = Convert.ToInt32(txtRepinByKeyword_DelayMax.Text);
                            objRepinByKeywordManager.NoOfThreadsRepinByKeyword = Convert.ToInt32(txtRepinByKeyword_NoOfThreads.Text);
                            objRepinByKeywordManager.MaxCountRepinByKeyword = Convert.ToInt32(txtNoOfPinRepin_RepinByKeyword.Text);
                        }
                        catch (Exception ex)
                        {
                            GlobusLogHelper.log.Info("Enter in Correct Format");
                            return;
                        }

                        if (!string.IsNullOrEmpty(txtRepinByKeyword_NoOfThreads.Text) && checkNo.IsMatch(txtRepinByKeyword_NoOfThreads.Text))
                        {
                            threads = Convert.ToInt32(txtRepinByKeyword_NoOfThreads.Text);
                        }

                        if (threads > maxThread)
                        {
                            threads = 25;
                        }
                        objRepinByKeywordManager.NoOfThreadsRepinByKeyword = threads;

                        GlobusLogHelper.log.Info(" => [ Process Starting ] ");

                        Thread BoardsThread = new Thread(objRepinByKeywordManager.StartRepinKeyword);
                        BoardsThread.Start();
                    }

                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                    }
                }
                else
                {
                    GlobusLogHelper.log.Info("Please Load Accounts !");
                    GlobusLogHelper.log.Debug("Please Load Accounts !");

                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
        }
        public void startEditDescription()
        {
            try
            {
                if (PDGlobals.listAccounts.Count > 0)
                {
                    try
                    {
                        if (objEditPinDiscriptionManager.rdbSingleUserEditPinDisc == true || objEditPinDiscriptionManager.rdbMultipleUserEditPinDisc == true)
                        {
                            if (objEditPinDiscriptionManager.rdbSingleUserEditPinDisc == true)
                            {
                                try
                                {                                  
                                }
                                catch (Exception ex)
                                {
                                    GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                }
                            }//end of single User
                            if (objEditPinDiscriptionManager.rdbMultipleUserEditPinDisc == true)
                            {
                                try
                                {
                                    if (string.IsNullOrEmpty(txtPinDescription.Text))
                                    {
                                        GlobusLogHelper.log.Info("Please Upload Description");
                                        ModernDialog.ShowMessage("Please Upload Description", "Upload Description", MessageBoxButton.OK);
                                        return;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                                }
                            }//end of multiple user
                        }
                        else
                        {
                            GlobusLogHelper.log.Info("Please Select Use Single User or Use Multiple User");
                            ModernDialog.ShowMessage("Please Select Use Single User or Use Multiple User", "Select Use Single User or Use Multiple User", MessageBoxButton.OK);
                            return;
                        }

                    }
                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                    }
                    objEditPinDiscriptionManager.isStopEditPinDisc = false;
                    objEditPinDiscriptionManager.lstThreadsEditPinDisc.Clear();

                    if (objEditPinDiscriptionManager._IsfevoriteEditPinDes)
                    {
                        objEditPinDiscriptionManager._IsfevoriteEditPinDes = false;
                    }

                    Regex checkNo = new Regex("^[0-9]*$");

                    int processorCount = objUtils.GetProcessor();

                    int threads = 25;

                    int maxThread = 25 * processorCount;
                    try
                    {
                        try
                        {
                            objEditPinDiscriptionManager.minDelayEditPinDisc = Convert.ToInt32(txtEditPinDescription_DelayMin.Text);
                            objEditPinDiscriptionManager.maxDelayEditPinDisc = Convert.ToInt32(txtEditPinDescription_DelayMax.Text);
                            objEditPinDiscriptionManager.Nothread_EditPinDisc = Convert.ToInt32(txtEditPinDescription_NoOfThreads.Text);
                            objEditPinDiscriptionManager.NoOfPagesEditPinDisc = Convert.ToInt32(txtNoOfPages_EditPinDisc.Text);
                        }
                        catch (Exception ex)
                        {
                            GlobusLogHelper.log.Info("Enter in Correct Format");
                            return;
                        }


                        if (ClGlobul.CommentNicheMessageList.Count > 0)
                        {
                            clsSettingDB Database = new clsSettingDB();
                            Database.UpdateSettingData("PinDescription", "PinDescriptionMessage", StringEncoderDecoder.Encode(txtPinDescription.Text));
                            GlobusLogHelper.log.Info(" => [ Start Edit Description ]");
                            ClGlobul.lstPins.Clear();

                        }
                        if (!string.IsNullOrEmpty(txtEditPinDescription_NoOfThreads.Text) && checkNo.IsMatch(txtEditPinDescription_NoOfThreads.Text))
                        {
                            threads = Convert.ToInt32(txtEditPinDescription_NoOfThreads.Text);
                        }

                        if (threads > maxThread)
                        {
                            threads = 25;
                        }
                        GlobusLogHelper.log.Info(" => [ Process Starting ] ");
                        objEditPinDiscriptionManager.NoOfThreadsEditPinDisc = threads;

                        Thread EditPinDiscThread = new Thread(objEditPinDiscriptionManager.StartEditPinDisc);
                        EditPinDiscThread.Start();
                    }

                    catch (Exception ex)
                    {
                        GlobusLogHelper.log.Error("Error : " + ex.StackTrace);
                    }
                }
                else
                {
                    GlobusLogHelper.log.Info("Please Load Accounts !");
                    GlobusLogHelper.log.Debug("Please Load Accounts !");

                }
            }
            catch (Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
        }
        public void  StartActionMultithreadUnFollow(ref PinInterestUser objPinUser)
        {
            try
            {
                try
                {
                    lstThreadsUnFollow.Add(Thread.CurrentThread);
                    lstThreadsUnFollow.Distinct().ToList();
                    Thread.CurrentThread.IsBackground = true;
                }
                catch (Exception ex)
                { };
                string ScreenName = objPinUser.ScreenName; //ObjAccountManager.Getscreen_NameRepin(ref objPinUser);
                List<string> lstNonFollowing = new List<string>();
                if (!chkUploadUnFollowList)
                {
                    if (!chkNoOFDays_UnFollow)
                    {
                        List<string> lstUsers = new List<string>();
                        try
                        {
                            lstUsers = objScrape.GetUserFollowing_new(ScreenName, NoOfPage, Globals.followingCountLogin);
                            lstUsers.Reverse();
                            lstUsers = lstUsers.Distinct().ToList();
                            if (lstUsers.Count > 0)
                            {
                                ClGlobul.lstFollowing_UnFollow.AddRange(lstUsers);
                            }

                            ClGlobul.lstFollowing_UnFollow = ClGlobul.lstFollowing_UnFollow.Distinct().ToList();
                        }
                        catch (Exception ex)
                        {
                            GlobusLogHelper.log.Info(" => [ Not Fetched User List ]");
                        }

                        //lstNonFollowing = lstUsers.Except(lstFollowers).ToList();
                        lstNonFollowing.AddRange(lstUsers);
                    }
                    else if (chkNoOFDays_UnFollow == true)
                    {
                        clsSettingDB DataBase = new clsSettingDB();
                        DataTable dt = DataBase.SelectUnfollowsToday(objPinUser.Username);
                        foreach (DataRow rd in dt.Rows)
                        {
                            DateTime dt1 = DateTime.Parse(rd[3].ToString());
                            DateTime dt2 = DateTime.Today;
                            TimeSpan span = dt2 - dt1;
                            int DayDiffrence = (int)span.Days;
                            if (DayDiffrence >= NOofDays)
                            {
                                NonFollowing.Add("http://pinterest.com/" + rd[2].ToString() + "/");
                            }
                        }
                        lstNonFollowing = NonFollowing.Distinct().ToList();
                    }
                }
                if (chkUploadUnFollowList == true)
                {
                    try
                    {
                        lstNonFollowing.AddRange(ClGlobul.lstUploadUnFollowList);
                    }
                    catch(Exception ex)
                    {
                        GlobusLogHelper.log.Error(" Error ;" + ex.StackTrace);
                    }
                }

                if (lstNonFollowing.Count() > 0)
                {
                    int UnFollowCount = 0;
                    foreach (string UnFollowUrl in lstNonFollowing)
                    {
                        string url = string.Empty;
                        try
                        {                          
                            if (!UnFollowUrl.Contains("http://pinterest.com"))
                            {
                                url = "https://pinterest.com/" + UnFollowUrl + "/";
                            }
                            else
                            {
                                url = UnFollowUrl;
                            }
                   
                            bool IsUnFollowed = UnFollow_New(url, ref objPinUser);

                            if (IsUnFollowed)
                            {
                                #region AccountReport
                                string Username = Utils.Utils.getBetween(url, ".com/", "/");
                                string module = "UnFollow";
                                string status = "UnFollowed";
                                Qm.insertAccRePort(objPinUser.Username, module, "", "", Username, "", "", "", status, "", "", DateTime.Now);
                                objUnFollowDelegate();

                                #endregion

                                GlobusLogHelper.log.Info(" => [ Unfollowed : " + url + " From " + objPinUser.Username + " ]");
                                UnFollowCount++;
                               // MaxUnFollowCount--;
                            }
                            else
                            {
                                GlobusLogHelper.log.Info(" => [ Not Unfollowed : " + url + " From " + objPinUser.Username + " ]");
                            }

                            int Delay = RandomNumberGenerator.GenerateRandom(minDelayUnFollow, maxDelayUnFollow);
                            GlobusLogHelper.log.Info(" => [ Delay For " + Delay + " Seconds ]");
                            Thread.Sleep(Delay * 1000);

                        }
                        catch (Exception ex)
                        {
                           // GlobusFileHelper.AppendStringToTextfileNewLine("Error --> UnFollowUserMultiThreaded() 1--> " + ex.Message, ApplicationData.ErrorLogFile);
                        }
                        if (MaxUnFollowCount == UnFollowCount)
                        {
                            break;
                        }

                    }
                    GlobusLogHelper.log.Info(" => [ PROCESS COMPLETED " + " For " + objPinUser.Username + " ]");
                    GlobusLogHelper.log.Info("-----------------------------------------------------------------------------------");
                }
                else
                {
                    GlobusLogHelper.log.Info(" => [ No Users to UnFollow ]");
                }
            }
            catch(Exception ex)
            {
                GlobusLogHelper.log.Error(" Error :" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    if (countThreadControllerUnFollow > Nothread_UnFollow)
                    {
                        lock (UnFollowObjThread)
                        {
                            Monitor.Pulse(UnFollowObjThread);
                        }
                        UnFollowdata_count--;
                    }

                }
                catch (Exception ex)
                {
                    GlobusLogHelper.log.Error(" Error : " + ex.StackTrace);
                }
                countThreadControllerUnFollow--;

                //if (MaxUnFollowCount == 0)  //|| DivideByUserinput < 0)                
                //{
                //    GlobusLogHelper.log.Info(" [ PROCESS COMPLETED  ] ");
                //    GlobusLogHelper.log.Info("------------------------------------------------------");

                //}
            }
        }