Exemplo n.º 1
0
 public void UpdateFacebookAccounts()
 {
     while (true)
     {
         try
         {
             DatabaseRepository dbr = new DatabaseRepository();
             List <Domain.Socioboard.Models.Facebookaccounts> lstFbAcc = dbr.Find <Domain.Socioboard.Models.Facebookaccounts>(t => t.IsAccessTokenActive && t.FbProfileType == Domain.Socioboard.Enum.FbProfileType.FacebookProfile).ToList();
             FbFeeds fbfeeds = new FbFeeds();
             foreach (var item in lstFbAcc)
             {
                 try
                 {
                     Console.WriteLine(item.FbUserName + "Updating Started");
                     fbfeeds.updateFacebookFeeds(item);
                     Console.WriteLine(item.FbUserName + "Updated");
                 }
                 catch
                 {
                     Thread.Sleep(600000);
                 }
             }
             Thread.Sleep(600000);
         }
         catch (Exception ex)
         {
             Console.WriteLine("issue in web api calling" + ex.StackTrace);
             Thread.Sleep(600000);
         }
     }
 }
Exemplo n.º 2
0
        public void UpdateFacebookAccounts()
        {
            while (true)
            {
                try
                {
                    int count    = 1;
                    var dbr      = new DatabaseRepository();
                    var lstFbAcc = dbr.Find <Domain.Socioboard.Models.Facebookaccounts>(t => t.IsAccessTokenActive && t.FbProfileType == Domain.Socioboard.Enum.FbProfileType.FacebookProfile).ToList();
                    //lstFbAcc = lstFbAcc.Where(t => t.FbUserId.Contains("127471161024815")).ToList();

                    var fbfeeds = new FbFeeds();
                    Parallel.ForEach(lstFbAcc, new ParallelOptions {
                        MaxDegreeOfParallelism = 100
                    }, item =>
                    {
                        try
                        {
                            Console.WriteLine(item.FbUserName + "Updating Started");
                            fbfeeds.updateFacebookFeeds(item);
                            Console.WriteLine(item.FbUserName + "Updated");
                            Console.WriteLine(count++);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                            Thread.Sleep(600000);
                        }
                    });
                    Thread.Sleep(600000);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("issue in web api calling" + ex.StackTrace);
                    Thread.Sleep(600000);
                }
            }
        }