[fix] 修正应用编译时间取值,不能所有情况都从Version计算编译时间,那样可能丢失时分秒

This commit is contained in:
大石头 2025-06-28 17:44:39 +08:00
parent cfcf662b3e
commit d9769a8e48
5 changed files with 11 additions and 7 deletions

View File

@ -11,7 +11,6 @@ using NewLife.Reflection;
using Stardust.Data.Nodes;
using Stardust.Models;
using XCode;
using XCode.Membership;
namespace Stardust.Data;
@ -38,7 +37,7 @@ public partial class AppOnline : Entity<AppOnline>
/// <param name="isNew">是否插入</param>
public override void Valid(Boolean isNew)
{
if (!Version.IsNullOrEmpty() && !Dirtys[nameof(Compile)])
if (Compile.Year < 2000 && !Version.IsNullOrEmpty())
{
var dt = AssemblyX.GetCompileTime(Version);
if (dt.Year > 2000) Compile = dt;

View File

@ -48,7 +48,7 @@ public partial class App : Entity<App>
if (isNew && !Dirtys[__.AutoActive]) AutoActive = true;
if (Period == 0) Period = 60;
if (!Version.IsNullOrEmpty() && !Dirtys[nameof(Compile)])
if (Compile.Year < 2000 && !Version.IsNullOrEmpty())
{
var dt = AssemblyX.GetCompileTime(Version);
if (dt.Year > 2000) Compile = dt;

View File

@ -326,7 +326,7 @@ public partial class Node : Entity<Node>
/// <returns></returns>
public static IList<Node> SearchByIP(String ip)
{
if (ip.IsNullOrEmpty()) return new List<Node>();
if (ip.IsNullOrEmpty()) return [];
var ips = ip.Split(',', StringSplitOptions.RemoveEmptyEntries);

View File

@ -115,10 +115,15 @@ public class AppController : BaseController
return rs;
}
/// <summary>应用注册。旧版客户端登录接口新版已废弃改用Login</summary>
/// <param name="inf"></param>
/// <returns></returns>
[HttpPost(nameof(Register))]
public String Register(AppModel inf)
{
var online = _registryService.SetOnline(_app, inf, UserHost, inf.ClientId, Token);
var ip = UserHost;
var online = _registryService.SetOnline(_app, inf, ip, inf.ClientId, Token);
_app.WriteHistory(nameof(Register), true, inf.ToJson(), inf.Version, ip, inf.ClientId);
_deployService.UpdateDeployNode(online);

View File

@ -159,8 +159,6 @@ public class RegistryService
app.UpdateIP = ip;
app.Update();
app.WriteHistory(nameof(Register), true, inf.ToJson(), inf.Version, ip, clientId);
if (!inf.ClientId.IsNullOrEmpty()) clientId = inf.ClientId;
// 更新在线记录
@ -173,6 +171,8 @@ public class RegistryService
if (node != null) online.NodeId = node.ID;
if (!inf.Version.IsNullOrEmpty()) online.Version = inf.Version;
var compile = inf.Compile.ToDateTime().ToLocalTime();
if (compile.Year > 2000) online.Compile = compile;
}
online.Update();