예제 #1
0
 /// <summary>
 /// 调度框架使用
 /// </summary>
 /// <param name="batch"></param>
 /// <param name="config"></param>
 public static void RunBatch(IBatch batch, BatchConfig config)
 {
     batch.SetBatchConfig(config);
     if (!batch.IsRun())
     {
         return;
     }
     batch.Prepare();
     batch.Execute();
     batch.Clear();
 }
예제 #2
0
        public AbstractSpanServer()
        {
            _batchConfig = new BatchConfig {
                BatchName = typeof(T).Name
            };

            var currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += (sender, args) =>
            {
                var ex = (AggregateException)args.ExceptionObject;
                Log.Error(string.Format("Runtime terminating: {0}", args.IsTerminating));
                EmailErr(ex);
            };
        }
예제 #3
0
        public AbstractJobServer()
        {
            _batch       = new T();
            _timeSpan    = _batch.GetSleepTimeSpan();
            _batchConfig = new BatchConfig {
                BatchName = typeof(T).Name
            };

            var currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += (sender, args) =>
            {
                var ex = (AggregateException)args.ExceptionObject;
                Log.Error($"Runtime terminating: {args.IsTerminating}");
                EmailErr(ex);
            };
        }
예제 #4
0
        /// <summary>
        /// 单独运行使用
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="config"></param>
        public static void RunBatch <T>(BatchConfig config)
            where T : IBatch, new()
        {
            IBatch batch = new T();

            batch.SetBatchConfig(config);
            if (!batch.IsRun())
            {
                return;
            }
            batch.Prepare();
            batch.Execute();
            batch.Clear();
            var timeSpan = batch.GetSleepTimeSpan();

            batch.UpdateTimeStamp(timeSpan);
        }
예제 #5
0
 public void SetBatchConfig(BatchConfig batchConfig)
 {
     BatchConfig = batchConfig;
     Log.Info($"任务{BatchConfig.BatchId}({BatchConfig.BatchName ?? GetType().Name})上次执行时间{BatchConfig.LastSchedulerTime}本次调度时间{BatchConfig.SchedulerTime}本次执行日期{BatchConfig.SchedulerDate}");
 }