コード例 #1
0
      private bool ProcessDatabase(Database db)
      {
         bool success;
         try
         {
            var args = new HistoryCollectorPipelineArgs(db);
            CorePipeline.Run("historycollector", args);
            success = args.Success;
         }
         catch (Exception exception)
         {
            success = false;
            Log.Error("Historian.Handler failed when calling historyCollector pipeline", exception);
         }

         Log.Info("Historian.Handler returned with '{0}'".FormatWith(success), this);
         return success;
      }
コード例 #2
0
      public void Process(HistoryCollectorPipelineArgs args)
      {
         Assert.ArgumentNotNull(args, "HistoryCollectorPipelineArgs cannot be null");

         var database = args.Database;

         if (database.Engines.HistoryEngine == null ||
             database.Engines.HistoryEngine.Storage == null)
         {
            Log.Error("HistoryCollector. History engine for database '{0}' is not configured. ".FormatWith(database.Name), this);
            args.Success = false;
            return;
         }

         var lastUpdateDate = GetLastUpdateDate(database);

         var utcNow = DateTime.UtcNow;

         if (ProcessEntries(database, lastUpdateDate, utcNow))
         {
            Log.Info("HistoryCollector. Collecting Urls. Total: {0}".FormatWith(_validEntries.Count), this);
            var urls = CollectTokens(database);
            Log.Info("HistoryCollector. Starting Processing Urls. Total: {0}...".FormatWith(urls.Count), this);

            try
            {
               var result = ProcessUrls(urls);
               database.Properties[LastUpdateKey] = DateUtil.ToIsoDate(utcNow);

               Log.Info("HistoryCollector. Processing Urls Done. Returned with {0}".FormatWith(result), this);
               args.Success = true;
               return;
            }
            catch (Exception)
            {
               Log.Info("HistoryCollector. ProcessUrls failed.", this);
               args.Success = false;
               return;
            }
         }

         Log.Info("HistoryCollector. ProcessEntries failed.", this);
         args.Success = false;
      }