Esempio n. 1
0
        public static LogErrModel GetLogErrModelByRow(string line)
        {
            if (String.IsNullOrEmpty(line))
            {
                return(null);
            }

            var arr = line.Split(new[] { LogConfig.LogSplit }, StringSplitOptions.RemoveEmptyEntries);

            if (arr.Length != 7)
            {
                return(null);
            }

            LogErrModel model = new LogErrModel();

            model.JobName        = arr[0];
            model.JobGroupName   = arr[1];
            model.JobType        = arr[2];
            model.JobData        = arr[3];
            model.CronExpression = arr[4];
            model.ErrDateTime    = arr[5];
            model.ErrMessage     = arr[6];

            return(model);
        }
        public void LogErr(IJobExecutionContext context, string err)
        {
            LogErrModel model = new LogErrModel();

            if (context.Trigger is ICronTrigger)
            {
                var cTrigger = (ICronTrigger)context.Trigger;
                model.CronExpression = cTrigger.CronExpressionString ?? "-";
            }
            else
            {
                model.CronExpression = "-";
            }
            model.ErrDateTime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            model.JobName      = context.JobDetail.Key.Name;
            model.JobGroupName = context.JobDetail.Key.Group;
            model.JobType      = context.JobDetail.JobType.FullName;
            model.JobData      = JobUtils.GetJobDataString(context.JobDetail.JobDataMap);
            model.ErrMessage   = err;

            lock (LockHelper)
            {
                _queueErrInfo.Enqueue(model);
            }
        }
Esempio n. 3
0
        private static string GetStringLineErr(LogErrModel model)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(model.JobName).Append(LogConfig.LogSplit);
            sb.Append(model.JobGroupName).Append(LogConfig.LogSplit);
            sb.Append(model.JobType).Append(LogConfig.LogSplit);
            sb.Append(model.JobData).Append(LogConfig.LogSplit);
            sb.Append(model.CronExpression).Append(LogConfig.LogSplit);

            sb.Append(model.ErrDateTime).Append(LogConfig.LogSplit);
            sb.Append(model.ErrMessage);

            return(sb.ToString());
        }