예제 #1
0
        public void RetweetDataExtractor()
        {
            try
            {
                if (!string.IsNullOrEmpty(txtRetweetCount.Text) && NumberHelper.ValidateNumber(txtRetweetCount.Text))
                {
                    RetweetExtractCount = Convert.ToInt32(txtRetweetCount.Text);
                    TwitterDataScrapper.RetweetExtractcount = RetweetExtractCount;
                }
                else
                {
                    AddToTweetCreatorLogs("Entered Count incorrect.Setting Default Count 10");
                }

                TwitterDataScrapper DataScraper = new TwitterDataScrapper();
                foreach (string item in lstUserId_Retweet)
                {
                    AddToTweetCreatorLogs("Extracting ReTweets For " + item);
                    List<string> TweetData = DataScraper.GetRetweetData_Scrape(item);
                    AddToTweetCreatorLogs(TweetData.Count + " Retweet From User : "******":");
                                if (arry.Length == 3)
                                {
                                    AddToTweetCreatorLogs("---------------------------------------------------------");
                                    AddToTweetCreatorLogs(arry[0] + " : " + arry[1]);
                                    AddToTweetCreatorLogs(arry[2]);
                                    clsDBQueryManager DataBase = new clsDBQueryManager();
                                    DataBase.InsertDataRetweet(arry[0], arry[1], arry[2]);
                                }
                                else
                                {

                                }
                            }
                        }).Start();
                    }
                    else
                    {
                        AddToTweetCreatorLogs("Sorry No ReTweets For " + item);
                    }
                }
                AddToTweetCreatorLogs("Finished Extracting ReTweets");
                AddToTweetCreatorLogs("ReTweets Stored In -" + Globals.Path_RETweetExtractor);
                if (txtRetweetSingle.InvokeRequired)
                {
                    txtRetweetSingle.Invoke(new MethodInvoker(delegate
                    {
                        txtRetweetSingle.Text = "";
                    }));
                }
                if (txtRetweetFile.InvokeRequired)
                {
                    txtRetweetFile.Invoke(new MethodInvoker(delegate
                    {
                        txtRetweetFile.Text = "";
                    }));
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> RetweetDataExtractor() --> " + ex.Message, Globals.Path_TweetCreatorErroLog);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> RetweetDataExtractor() --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
        }
예제 #2
0
        public void RetweetDataExtractor()
        {
            try
            {
                if (!string.IsNullOrEmpty(txtRetweetCount.Text) && NumberHelper.ValidateNumber(txtRetweetCount.Text))
                {
                    RetweetExtractCount = Convert.ToInt32(txtRetweetCount.Text);
                    TwitterDataScrapper.RetweetExtractcount = RetweetExtractCount;
                }
                else
                {
                    AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ Entered Count incorrect.Setting Default Count 10 ]");
                }

                TwitterDataScrapper DataScraper = new TwitterDataScrapper();
                foreach (string item in lstUserId_Retweet)
                {
                    AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ Extracting ReTweets For " + item + " ]");
                    string ReturnStatus = string.Empty;
                    List<string> TweetData = DataScraper.GetRetweetData_Scrape(item, out ReturnStatus);

                    if (ReturnStatus.Contains("No Error"))
                    {
                        AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ " + TweetData.Count + " Retweet From User : "******" ]");
                        if (TweetData.Count > 0)
                        {
                            //new Thread(() =>
                            //{
                            foreach (string newItem in TweetData)
                            {
                                string[] arry = Regex.Split(newItem, ":");
                                if (arry.Length == 3)
                                {
                                    //AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ " + arry[0] + " : " + arry[1] + " ]");
                                    //AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ " + arry[2] + " ]");
                                    clsDBQueryManager DataBase = new clsDBQueryManager();
                                    DataBase.InsertDataRetweet(arry[0], arry[1], arry[2]);
                                }
                                AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ " + newItem + " ]");
                            }
                            //}).Start();
                        }
                        else
                        {
                            AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ Sorry No ReTweets For " + item + " ]");
                        }
                    }
                    else if (ReturnStatus.Contains("Rate limit exceeded"))
                    {
                        AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ Rate limit exceeded ]");
                        break;
                    }
                    else if (ReturnStatus.Contains("Sorry, that page does not exist"))
                    {
                        AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ " + item + " >>> Sorry, that page does not exist ]");
                    }
                    else if (ReturnStatus.Contains("Empty"))
                    {
                        AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ " + item + " >>>> Return Empty ]");
                    }
                    else
                    {
                        //AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ " + item + " >>> Errror in Request ]");
                        AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ No item Found From User " + item + " ]");
                    }
                }

                AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ ReTweets Stored In -" + Globals.Path_RETweetExtractor + " ]");
                AddToTweetCreatorLogs("[ " + DateTime.Now + " ] => [ Finished Extracting ReTweets ]");
                AddToTweetCreatorLogs("-----------------------------------------------------------------------------------------------------------------------");

                if (txtRetweetFile.InvokeRequired)
                {
                    txtRetweetFile.Invoke(new MethodInvoker(delegate
                    {
                        txtRetweetFile.Text = "";
                    }));
                }
            }
            catch (Exception ex)
            {
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> RetweetDataExtractor() --> " + ex.Message, Globals.Path_TweetCreatorErroLog);
                Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine("Error --> RetweetDataExtractor() --> " + ex.Message, Globals.Path_TwtErrorLogs);
            }
        }