修正客户端登录时没有提交进程Id的问题;优化页面显示

This commit is contained in:
大石头 2024-07-11 15:50:09 +08:00
parent 6a25c7dafa
commit 9a38c05363
6 changed files with 27 additions and 20 deletions

View File

@ -72,7 +72,7 @@ public class AppService
online.CompileTime = model.Compile;
online.Save();
WriteHistory(app, autoReg ? "注册" : "登录", true, $"[{model.Code}/{model.Secret}]在[{model.ClientId}]登录[{app}]成功");
WriteHistory(app, autoReg ? "注册" : "登录", true, $"[{model.Code}/{model.Secret}]在[{model.ClientId}]登录[{app}]成功", ip);
var rs = new LoginResponse { Name = app.Name };
if (autoReg) rs.Secret = app.Secret;

View File

@ -436,7 +436,7 @@ public class JobService(AppService appService, ICacheProvider cacheProvider, ITr
task.Error++;
//ji.Message = err.Message;
SetJobError(job, task);
SetJobError(job, task, ip);
// 出错时判断如果超过最大错误数,则停止作业
CheckMaxError(app, job);
@ -502,7 +502,7 @@ public class JobService(AppService appService, ICacheProvider cacheProvider, ITr
//job.Save();
}
private JobError SetJobError(Job job, JobTask task)
private JobError SetJobError(Job job, JobTask task, String ip)
{
using var span = _tracer?.NewSpan(nameof(SetJobError), new { job.Name, task.DataTime });
@ -519,6 +519,8 @@ public class JobService(AppService appService, ICacheProvider cacheProvider, ITr
ProcessID = task.ProcessID,
Client = task.Client,
CreateIP = ip,
UpdateIP = ip,
CreateTime = DateTime.Now,
UpdateTime = DateTime.Now,
};

View File

@ -2,6 +2,7 @@
using AntJob.Data.Entity;
using NewLife.Cube;
using NewLife.Cube.Extensions;
using NewLife.Cube.ViewModels;
using NewLife.Web;
namespace AntJob.Web.Areas.Ant.Controllers;
@ -16,6 +17,9 @@ public class AppHistoryController : AntEntityController<AppHistory>
{
AppOnline.Meta.Table.DataTable.InsertOnly = true;
ListFields.RemoveField("Id", "Version", "CompileTime", "");
ListFields.AddListField("Remark", null, "TraceId");
ListFields.TraceUrl();
}

View File

@ -12,10 +12,10 @@ namespace AntJob.Web.Areas.Ant.Controllers;
[Menu(0, false)]
public class JobErrorController : AntEntityController<JobError>
{
//static JobErrorController() => MenuOrder = 60;
static JobErrorController()
{
ListFields.AddListField("Message", null, "TraceId");
ListFields.TraceUrl();
}

View File

@ -71,20 +71,19 @@ public class AntClient : ClientBase
/// <returns></returns>
public override ILoginRequest BuildLoginRequest()
{
var request = base.BuildLoginRequest();
if (request is LoginModel model)
{
var asmx = AssemblyX.Entry;
var title = asmx?.Asm.GetCustomAttribute<AssemblyTitleAttribute>();
var dis = asmx?.Asm.GetCustomAttribute<DisplayNameAttribute>();
var des = asmx?.Asm.GetCustomAttribute<DescriptionAttribute>();
var dname = title?.Title ?? dis?.DisplayName ?? des?.Description;
var request = new LoginModel();
FillLoginRequest(request);
model.DisplayName = dname;
model.Machine = Environment.MachineName;
model.ProcessId = Process.GetCurrentProcess().Id;
model.Compile = asmx.Compile;
}
var asmx = AssemblyX.Entry;
var title = asmx?.Asm.GetCustomAttribute<AssemblyTitleAttribute>();
var dis = asmx?.Asm.GetCustomAttribute<DisplayNameAttribute>();
var des = asmx?.Asm.GetCustomAttribute<DescriptionAttribute>();
var dname = title?.Title ?? dis?.DisplayName ?? des?.Description;
request.DisplayName = dname;
request.Machine = Environment.MachineName;
request.ProcessId = Process.GetCurrentProcess().Id;
request.Compile = asmx.Compile;
return request;
}

View File

@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using AntJob;
using NewLife;
using NewLife.Security;
namespace HisAgent;
@ -21,9 +22,10 @@ internal class HelloJob : Handler
// 当前任务时间
var time = ctx.Task.DataTime;
WriteLog("新生命蚂蚁调度系统!当前任务时间:{0}", time);
if (!ctx.Task.Data.IsNullOrEmpty()) WriteLog("数据:{0}", ctx.Task.Data);
// 一定几率抛出异常
if (Rand.Next(2) == 0) throw new Exception("Error");
//// 一定几率抛出异常
//if (Rand.Next(2) == 0) throw new Exception("Error");
// 成功处理数据量
return 1;