/// <summary> /// 执行 /// </summary> /// <param name="context">执行上下文</param> public async Task Execute(Qz.IJobExecutionContext context) { using (var scope = Ioc.BeginScope()) { try { //get tenant and switch var jobDataMap = context.JobDetail.JobDataMap; var tenantName = jobDataMap.GetString(nameof(Tenant)); if (!string.IsNullOrWhiteSpace(tenantName)) { TenantContext.SwitchDatabase(scope, tenantName); } //execute await Execute(context, scope); } catch (Exception ex) { var type = context.JobInstance; ExceptionLogs.Write(ex, type.GetType().Name); } } }