Example #1
0
 private static void Main(string[] args)
 {
     using (Process p = Process.GetCurrentProcess())
         p.PriorityClass = ProcessPriorityClass.Idle;
     while (true)
     {
         try
         {
             using (var ctx = new Db())
             {
                 var     haveWork = false;
                 Article a;
                 if ((a = ctx.Articles.FirstOrDefault(x => x.Processed == ProcessState.Waiting)) != null)
                 {
                     ShingleLogic.ProcessArticle(a.ID);
                     haveWork = true;
                 }
                 if (haveWork)
                 {
                     continue;
                 }
                 Console.WriteLine("................");
                 System.Threading.Tasks.Task.Delay(60000);
             }
         }
         catch (Exception e)
         {
             DataLayer.LogException(e);
         }
     }
 }
Example #2
0
        private static void ProcessArticles()
        {
            var ctx = new Db();

            Article ea;

            while ((ea = ctx.Articles.FirstOrDefault(x => x.Processed == ProcessState.Waiting)) != null)
            {
                var sw = Stopwatch.StartNew();
                ShingleLogic.ProcessArticle(ea.ID);
                sw.Stop();
                DataLayer.LogMessage(LogLevel.AnalyzedArticle, $"{sw.ElapsedMilliseconds}ms {ea.ID} {ea.Title}");

                //RssLogic.ScoreArticle(ea, ctx);
                //ea.ProcessedScore = ProcessState.Done;
                ctx.SaveChanges();
                ctx.Dispose();
                ctx = new Db();
            }
        }
Example #3
0
 private void PerformArticleProcessing(object state)
 {
     try
     {
         using (var ctx = new Db())
         {
             ctx.Database.CommandTimeout = 120;
             ArticlesToProcess           = ShingleLogic.GetNextArticles(ctx);
             if (ArticlesToProcess == null || ArticlesToProcess.Count == 0)
             {
                 System.Threading.Tasks.Task.Delay(20000);
             }
             //                        Thread.Sleep(20000);
             else
             {
                 foreach (var a in ArticlesToProcess)
                 {
                     var sw = Stopwatch.StartNew();
                     ShingleLogic.ProcessArticle(a);
                     RssLogic.ScoreArticle(a);
                     var    ea     = ctx.Articles.Include("Feed").Single(x => x.ID == a);
                     string ticker = string.IsNullOrEmpty(ea.Ticker) ? "" : "Ticker:" + ea.Ticker + " ";
                     DataLayer.LogMessage(LogLevel.Article, $"A {sw.ElapsedMilliseconds}ms ID:{a} Score:{100 * (ea.ScoreMin + ea.ScoreMax)} {ticker}{ea.Title}");
                 }
             }
         }
     }
     catch (Exception e)
     {
         DataLayer.LogException(e);
     }
     finally
     {
         thProcessArticles.timer.Start();
     }
 }