Exemplo n.º 1
0
 public static void LogCritical(this IJobLogger logger, string message)
 {
     logger.Log(JobLogLevel.Critical, null, message);
 }
Exemplo n.º 2
0
 public static void LogCritical(this IJobLogger logger, Exception exception, string message)
 {
     logger.Log(JobLogLevel.Critical, exception, message);
 }
Exemplo n.º 3
0
 public static void LogError(this IJobLogger logger, string message)
 {
     logger.Log(JobLogLevel.Error, null, message);
 }
Exemplo n.º 4
0
 public static void LogError(this IJobLogger logger, Exception exception, string message)
 {
     logger.Log(JobLogLevel.Error, exception, message);
 }
Exemplo n.º 5
0
 public static void LogWarning(this IJobLogger logger, string message)
 {
     logger.Log(JobLogLevel.Warning, null, message);
 }
Exemplo n.º 6
0
 public static void LogWarning(this IJobLogger logger, Exception exception, string message)
 {
     logger.Log(JobLogLevel.Warning, exception, message);
 }
Exemplo n.º 7
0
 public static void LogInformation(this IJobLogger logger, string message)
 {
     logger.Log(JobLogLevel.Information, null, message);
 }
Exemplo n.º 8
0
 public static void LogDebug(this IJobLogger logger, Exception ex, string message)
 {
     logger.Log(JobLogLevel.Debug, ex, message);
 }
Exemplo n.º 9
0
 public static void LogDebug(this IJobLogger logger, string message)
 {
     logger.Log(JobLogLevel.Debug, null, message);
 }
Exemplo n.º 10
0
 public static void LogTrace(this IJobLogger logger, string message)
 {
     logger.Log(JobLogLevel.Trace, null, message);
 }
Exemplo n.º 11
0
        private void StartTask()
        {
            if (_cancellationTokenSource != null)
            {
                return; //running
            }
            _cancellationTokenSource = new CancellationTokenSource();
            var ct = _cancellationTokenSource.Token;

            _runTask = Task.Factory.StartNew(async() =>
            {
                //ct.ThrowIfCancellationRequested();

                while (!ct.IsCancellationRequested)
                {
                    if (TASK_QUEUE.IsEmpty)
                    {
                        //_logger.LogInformation("task queue is empty!");
                        break;
                    }

                    ReturnT result            = null;
                    TriggerParam triggerParam = null;
                    try
                    {
                        if (TASK_QUEUE.TryDequeue(out triggerParam))
                        {
                            if (!ID_IN_QUEUE.TryRemove(triggerParam.LogId, out _))
                            {
                                _logger.LogWarning("remove queue failed,logId={logId},jobId={jobId},exists={exists}"
                                                   , triggerParam.LogId, triggerParam.JobId, ID_IN_QUEUE.ContainsKey(triggerParam.LogId));
                            }
                            //set log file;
                            _jobLogger.SetLogFile(triggerParam.LogDateTime, triggerParam.LogId);

                            _jobLogger.Log("<br>----------- xxl-job job execute start -----------<br>----------- Param:{0}", triggerParam.ExecutorParams);

                            result = await Executor.Execute(triggerParam, ct);

                            _jobLogger.Log("<br>----------- xxl-job job execute end(finish) -----------<br>----------- ReturnT:" + result.Code);
                        }
                        else
                        {
                            _logger.LogWarning("Dequeue Task Failed");
                        }
                    }
                    catch (Exception ex)
                    {
                        result = ReturnT.Failed("Dequeue Task Failed:" + ex.Message);
                        _jobLogger.Log("<br>----------- JobThread Exception:" + ex.Message + "<br>----------- xxl-job job execute end(error) -----------");
                    }

                    if (triggerParam != null)
                    {
                        CallBack?.Invoke(this, new HandleCallbackParam(triggerParam, result ?? ReturnT.FAIL));
                    }
                }


                _cancellationTokenSource?.Dispose();
                _cancellationTokenSource = null;
            }, _cancellationTokenSource.Token);
        }