public void startTweetusingthreadPool_AfterStop(object parameters)
        {

            //Add List Of Working thread
            //we are using this list when we stop/abort running camp processes..
            try
            {
                Array paramsArray = new object[2];
                paramsArray = (Array)parameters;
                string CampaignName = (string)paramsArray.GetValue(0);
                string featurName = (string)paramsArray.GetValue(1);
                try
                {
                    MixedCampaignManager.classes.cls_variables.Lst_WokingThreads.Add(CampaignName, Thread.CurrentThread);
                }
                catch (Exception ex)
                {
                    ErrorLogger.AddToErrorLogText("26.startTweetusingthreadPool_AfterStop :" + ex.Message);
                }


                //Get Detals from Data Set table by Campaign Name
                DataRow[] drModelDetails;
                lock (this)
                {
                    drModelDetails = CompaignsDataSet.Tables[0].Select("CampaignName = '" + CampaignName + "'");

                }

                if (drModelDetails.Count() == 0)
                {
                    return;
                }

                //Get 1st row from arrey 
                DataRow DrCampaignDetails = drModelDetails[0];
                bool IsSchedulDaily = (Convert.ToInt32(DrCampaignDetails.ItemArray[12]) == 1) ? true : false;
                DateTime SchedulerStartTime = Convert.ToDateTime(DrCampaignDetails.ItemArray[13].ToString());
                DateTime SchedulerEndTime = Convert.ToDateTime(DrCampaignDetails.ItemArray[14].ToString());

                //Create Object of tweetProcess class 

                classes.Cls_StartTweetProcess ObjTweetProcess = new Cls_StartTweetProcess();

                ObjTweetProcess.CampaignTweetLogEvents.addToLogger += new EventHandler(logEvents_addToLogger);

                if (IsSchedulDaily)
                {
                    if (_tempcount == 0)
                    {
                        //MessageBox.Show(CampaignName + " task is scheduled. Task start timing  :- " + SchedulerStartTime);
                    }
                    _tempcount++;
                    AddToCampaignLoggerListBox("[ " + DateTime.Now + " ] => [ " + CampaignName + " task is scheduled. Task start timing :- " + SchedulerStartTime + " ]");

                    foreach (DataGridViewRow dRow in dgv_campaign.Rows)
                    {
                        string dgv_CampaignName = dRow.Cells["CampaignName"].Value.ToString();
                        //string dgv_Module = dRow.Cells["Module"].Value.ToString();

                        if (CampaignName == dgv_CampaignName)
                        {
                            //dRow.Cells["CampaignName"].Value = "HardCoded";
                            //if (classes.cls_variables._IsScheduledDaily == 1)
                            {
                                dgv_campaign.Invoke(new MethodInvoker(delegate
                                {
                                    dRow.Cells["BtnOnOff"].Value = (System.Drawing.Image)Properties.Resources.on;
                                }));
                            }


                            //dgv_campaign.Refresh();
                        }
                    }

                    while (true)
                    {
                        //Update dataset
                        lock (this)
                        {
                            //modified date [11-02-15]
                            try
                            {
                                string query = "Select indx, CampaignName, AcFilePath, FollowingFilePath, '0' as Image,DividEql, DivideByUser, NoOfUser, FastFollow, NoOfFollowPerAc, '0' as TweetPac, '0' as TweetWImg, ScheduledDaily, StartTime, EndTime, DelayFrom, DelayTo, Threads, Module,'0' as IsUniqueMessage,'0' as TweetUploadUserFilePath,'0' as IsUploadUserFilePath,'0' as IsDuplicate, '0' as IsMentionUserScrapedList,'0' as TweetMentionUserNameScrapedList,'0' as IsTweetFollowerScrapedList,'0' as IsTweetFollowingScrapedList,'0' as NoOfTweetMentionUserScrapedList,'0' as NoOfTweetScrapedUserScrapedLIst from Campaign_follow "
                         + " UNION ALL "
                         + "Select indx, CampaignName, AcFilePath, TweetMsgFilePath,TweetImageFolderPath as Image,DuplicateMsg, AllTweetParAc as DivideByUser, HashTag as NoOfUser, TweetParDay, NoOfTweetParDay, NoOfTweetPerAc as TweetPac,TweetWithImage as TweetWImg, ScheduledDaily, StartTime, EndTime, DelayFrom, DelayTo, Threads, Module,'' as IsUniqueMessage, TweetUploadUserFilePath, IsUploadUserFilePath, '0' as IsDuplicate,IsTweetMentionUserScrapedList,TweetMentionUserNameScrapedList,IsTweetFollowersScrapedList,IsTweetFollowingScrapedList,NoOfTweetMentionUserScrapedList,NoOfScrapedUserScrapedList,NoOfDayTweetedByUser,IsTweetedInLastSpecificDay from Campaign_tweet "
                         + " UNION ALL "
                         + " SELECT  indx, CampaignName, AcFilePath, Keyword, '0' as Image,IsUsername,'0' as DivideByUser,'0' as NoOfUser, RetweetParDay, NoofRetweetParDay, NoofRetweetParAc as TweetPac, '0' as TweetWImg, ScheduledDaily, StartTime, EndTime, DelayFrom, DelayTo, Threads, Module,UniqueMessage as IsUniqueMessage,'0' as TweetUploadUserFilePath,'0' as IsUploadUserFilePath, '0' as IsDuplicate ,'0' as IsMentionUserScrapedList,'0' as TweetMentionUserNameScrapedList,'0' as IsTweetFollowerScrapedList,'0' as IsTweetFollowingScrapedList,'0' as NoOfTweetMentionUserScrapedList,'0' as NoOfTweetScrapedUserScrapedLIst from Campaign_retweet "
                         + " UNION ALL "
                         + " SELECT  indx, CampaignName, AcFilePath, ReplyFilePath, Keyword as Image,  IsUsername,'0' as DivideByUser,'0' as NoOfUser, ReplyParDay, NoofReplyParDay, NoofReplyParAc as TweetPac, '0' as TweetWImg, ScheduledDaily, StartTime, EndTime, DelayFrom, DelayTo, Threads, Module,UniqueMessage as IsUniqueMessage,'0' as TweetUploadUserFilePath,'0' as IsUploadUserFilePath, IsDuplicateMessage, '0' as IsMentionUserScrapedList,'0' as TweetMentionUserNameScrapedList,'0' as IsTweetFollowerScrapedList,'0' as IsTweetFollowingScrapedList,'0' as NoOfTweetMentionUserScrapedList,'0' as NoOfTweetScrapedUserScrapedLIst from Campaign_reply ";

                                CompaignsDataSet = RepositoryClasses.cls_DbRepository.selectQuery(query, "Union");
                            }
                            catch (Exception)
                            {

                            }

                            drModelDetails = CompaignsDataSet.Tables[0].Select("CampaignName = '" + CampaignName + "'");
                            if (drModelDetails.Count() == 0)
                            {
                                return;
                            }
                        }

                        DrCampaignDetails = drModelDetails[0];
                        IsSchedulDaily = (Convert.ToInt32(DrCampaignDetails.ItemArray[12]) == 1) ? true : false;
                        SchedulerStartTime = Convert.ToDateTime(DrCampaignDetails.ItemArray[13].ToString());
                        SchedulerEndTime = Convert.ToDateTime(DrCampaignDetails.ItemArray[14].ToString());

                        int startTime = SchedulerStartTime.Hour * 60 + SchedulerStartTime.Minute;
                        int sysTime = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
                        int endTime = SchedulerEndTime.Hour * 60 + SchedulerEndTime.Minute;

                        if ((SchedulerStartTime.Hour) == (DateTime.Now.Hour) && SchedulerStartTime.Minute == (DateTime.Now.Minute))
                        //if (startTime <= sysTime && endTime >= sysTime && (Cls_FollowStart._IsFollowProcessStart == true))
                        {


                            foreach (DataGridViewRow dRow in dgv_campaign.Rows)
                            {
                                string dgv_CampaignName = dRow.Cells["CampaignName"].Value.ToString();
                                //string dgv_Module = dRow.Cells["Module"].Value.ToString();

                                if (CampaignName == dgv_CampaignName)
                                {
                                    //dRow.Cells["CampaignName"].Value = "HardCoded";
                                    //if (classes.cls_variables._IsScheduledDaily == 1)
                                    {
                                        dgv_campaign.Invoke(new MethodInvoker(delegate
                                        {
                                            dRow.Cells["BtnOnOff"].Value = (System.Drawing.Image)Properties.Resources.off;
                                        }));
                                    }


                                    //dgv_campaign.Refresh();
                                }
                            }



                            Cls_StartTweetProcess.campName = CampaignName;
                            //ObjTweetProcess._IsTweetProcessStart = false;
                            ObjTweetProcess._IsTweetProcessStart = false;
                            ObjTweetProcess.startTweeting(CampaignName, featurName, DrCampaignDetails);
                            break;

                        }
                        Thread.Sleep(15 * 1000);
                    }


                }
                else
                {

                    //Start Process
                    ObjTweetProcess.startTweeting(CampaignName, featurName, DrCampaignDetails);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.AddToErrorLogText("27.startTweetusingthreadPool_AfterStop :" + ex.Message);
            }
        }
        public void startTweet(String CampaignName, String featurName)
        {

            //Add List Of Working thread
            //we are using this list when we stop/abort running camp processes..
            try
            {
                try
                {
                    MixedCampaignManager.classes.cls_variables.Lst_WokingThreads.Add(CampaignName, Thread.CurrentThread);
                }
                catch (Exception ex)
                {
                    ErrorLogger.AddToErrorLogText("22.startTweet :" + ex.Message);
                }
                string query = "Select indx, CampaignName, AcFilePath, FollowingFilePath, '0' as Image,DividEql, DivideByUser, NoOfUser, FastFollow, NoOfFollowPerAc, '0' as TweetPac, '0' as TweetWImg, ScheduledDaily, StartTime, EndTime, DelayFrom, DelayTo, Threads, Module,'0' as IsUniqueMessage,'0' as TweetUploadUserFilePath,'0' as IsUploadUserFilePath,'0' as IsDuplicate, '0' as IsMentionUserScrapedList,'0' as TweetMentionUserNameScrapedList,'0' as IsTweetFollowerScrapedList,'0' as IsTweetFollowingScrapedList,'0' as NoOfTweetMentionUserScrapedList,'0' as NoOfTweetScrapedUserScrapedLIst,'0' as NoOfDayTweetedByUser, '0' as IsTweetedInLastSpecificDay  from Campaign_follow "
                 + " UNION ALL "
                 + "Select indx, CampaignName, AcFilePath, TweetMsgFilePath,TweetImageFolderPath as Image,DuplicateMsg, AllTweetParAc as DivideByUser, HashTag as NoOfUser, TweetParDay, NoOfTweetParDay, NoOfTweetPerAc as TweetPac,TweetWithImage as TweetWImg, ScheduledDaily, StartTime, EndTime, DelayFrom, DelayTo, Threads, Module,'' as IsUniqueMessage, TweetUploadUserFilePath, IsUploadUserFilePath, '0' as IsDuplicate,IsTweetMentionUserScrapedList,TweetMentionUserNameScrapedList,IsTweetFollowersScrapedList,IsTweetFollowingScrapedList,NoOfTweetMentionUserScrapedList,NoOfScrapedUserScrapedList,NoOfDayTweetedByUser,IsTweetedInLastSpecificDay from Campaign_tweet "
                 + " UNION ALL "
                 + " SELECT  indx, CampaignName, AcFilePath, Keyword, '0' as Image,IsUsername,'0' as DivideByUser,'0' as NoOfUser, RetweetParDay, NoofRetweetParDay, NoofRetweetParAc as TweetPac, '0' as TweetWImg, ScheduledDaily, StartTime, EndTime, DelayFrom, DelayTo, Threads, Module,UniqueMessage as IsUniqueMessage,'0' as TweetUploadUserFilePath,'0' as IsUploadUserFilePath, '0' as IsDuplicate ,'0' as IsMentionUserScrapedList,'0' as TweetMentionUserNameScrapedList,'0' as IsTweetFollowerScrapedList,'0' as IsTweetFollowingScrapedList,'0' as NoOfTweetMentionUserScrapedList,'0' as NoOfTweetScrapedUserScrapedLIst,'0' as NoOfDayTweetedByUser, '0' as IsTweetedInLastSpecificDay from Campaign_retweet "
                 + " UNION ALL "
                 + " SELECT  indx, CampaignName, AcFilePath, ReplyFilePath, Keyword as Image,  IsUsername,'0' as DivideByUser,'0' as NoOfUser, ReplyParDay, NoofReplyParDay, NoofReplyParAc as TweetPac, '0' as TweetWImg, ScheduledDaily, StartTime, EndTime, DelayFrom, DelayTo, Threads, Module,UniqueMessage as IsUniqueMessage,'0' as TweetUploadUserFilePath,'0' as IsUploadUserFilePath, IsDuplicateMessage, '0' as IsMentionUserScrapedList,'0' as TweetMentionUserNameScrapedList,'0' as IsTweetFollowerScrapedList,'0' as IsTweetFollowingScrapedList,'0' as NoOfTweetMentionUserScrapedList,'0' as NoOfTweetScrapedUserScrapedLIst,'0' as NoOfDayTweetedByUser, '0' as IsTweetedInLastSpecificDay from Campaign_reply ";

                CompaignsDataSet = RepositoryClasses.cls_DbRepository.selectQuery(query, "Union");
                //Get Detals from Data Set table by Campaign Name
                DataRow[] drModelDetails = CompaignsDataSet.Tables[0].Select("CampaignName = '" + CampaignName + "'");

                if (drModelDetails.Count() == 0)
                {
                    return;
                }

                //Get 1st row from arrey 
                DataRow DrCampaignDetails = drModelDetails[0];
                bool IsSchedulDaily = (Convert.ToInt32(DrCampaignDetails.ItemArray[12]) == 1) ? true : false;
                DateTime SchedulerStartTime = Convert.ToDateTime(DrCampaignDetails.ItemArray[13].ToString());
                DateTime SchedulerEndTime = Convert.ToDateTime(DrCampaignDetails.ItemArray[14].ToString());

                //Create Object of tweetProcess class 

                classes.Cls_StartTweetProcess ObjTweetProcess = new Cls_StartTweetProcess();

                ObjTweetProcess.CampaignTweetLogEvents.addToLogger += new EventHandler(logEvents_addToLogger);

                if (IsSchedulDaily)
                {
                    if (_tempcount == 0)
                    {
                        //MessageBox.Show(CampaignName + " task is scheduled. Task start timing  :- " + SchedulerStartTime);
                    }
                    _tempcount++;
                    AddToCampaignLoggerListBox("[ " + DateTime.Now + " ] => [ " + CampaignName + " task is scheduled. Task start timing :- " + SchedulerStartTime + " ]");

                    while (true)
                    {
                        if ((SchedulerStartTime.Hour) == (DateTime.Now.Hour) && SchedulerStartTime.Minute == (DateTime.Now.Minute) && (ObjTweetProcess._IsTweetProcessStart == true))
                        {
                            Cls_StartTweetProcess.campName = CampaignName;
                            //ObjTweetProcess._IsTweetProcessStart = false;
                            ObjTweetProcess._IsTweetProcessStart = false;
                            ObjTweetProcess.startTweeting(CampaignName, featurName, DrCampaignDetails);
                            break;
                        }
                        Thread.Sleep(15 * 1000);
                    }


                }
                else
                {

                    //Start Process
                    ObjTweetProcess.startTweeting(CampaignName, featurName, DrCampaignDetails);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.AddToErrorLogText("23.startTweet :" + ex.Message);
            }
        }