using Rhea.Common; using Sundial; using System; using Tiger.IBusiness; using Tiger.Model; namespace Tiger.Business { /// /// 作业基类 /// public class TigerJobBase { public string Id { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public string Tag { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } public string Name { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } /// /// 保存日志 /// public static ApiAction SaveLog(JobExecutingContext context,string remark) { ApiAction action = new ApiAction(); Type type = Type.GetType(context.JobDetail.JobType, throwOnError: true); var job = Biz.Db.Queryable().Where(x=>x.JobName == context.JobId && x.JobType == type.Name).First(); var logentity = new TSK_LOG { JobId = job.ID, TriggerType =context.JobDetail.JobType, AssemblyName = context.JobDetail.AssemblyName, Args = context.Trigger.Args, Operation = context.Trigger.Status.ToString(), Status = "Successed", StartTime = context.Trigger.StartTime, EndTime = context.Trigger.EndTime, ElapsedTime = context.Trigger.ElapsedTime, Remark = remark }; var db = Business.Biz.Db; //保存到数据库 var dbTran = db.UseTran(() => { db.Insertable(logentity).ExecuteCommand(); }); if (!dbTran.IsSuccess) { action.GetResponse().CatchExceptionWithLog(dbTran.ErrorException, $"作业保存到数据库异常"); } return action; } } }