Merge branch 'master' into v3.1大石头 authored at 2024-07-13 19:03:18
diff --git a/Samples/TestA/TestA.csproj b/Samples/TestA/TestA.csproj
index fcfb156..5941a00 100644
--- a/Samples/TestA/TestA.csproj
+++ b/Samples/TestA/TestA.csproj
@@ -18,7 +18,7 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="NewLife.Core" Version="10.10.2024.710-beta0951" />
+ <PackageReference Include="NewLife.Core" Version="10.10.2024.713-beta0409" />
</ItemGroup>
</Project>
diff --git a/Samples/TestB/TestB.csproj b/Samples/TestB/TestB.csproj
index f117e01..c518ca5 100644
--- a/Samples/TestB/TestB.csproj
+++ b/Samples/TestB/TestB.csproj
@@ -18,7 +18,7 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="NewLife.Core" Version="10.10.2024.710-beta0951" />
+ <PackageReference Include="NewLife.Core" Version="10.10.2024.713-beta0409" />
</ItemGroup>
</Project>
diff --git a/Stardust.Data/Nodes/Model.xml b/Stardust.Data/Nodes/Model.xml
index 3e92cf1..0c019a4 100644
--- a/Stardust.Data/Nodes/Model.xml
+++ b/Stardust.Data/Nodes/Model.xml
@@ -126,6 +126,7 @@
<Column Name="SessionID" DataType="String" Description="会话" />
<Column Name="NodeID" DataType="Int32" Description="节点" />
<Column Name="Name" DataType="String" Master="True" Description="名称" />
+ <Column Name="ProductCode" DataType="String" Description="产品。产品编码,用于区分不同类型节点" />
<Column Name="IP" DataType="String" Length="200" Description="本地IP" />
<Column Name="Category" DataType="String" Description="分类" />
<Column Name="ProvinceID" DataType="Int32" Description="省份" />
diff --git a/Stardust.Data/Nodes/Stardust.htm b/Stardust.Data/Nodes/Stardust.htm
index 5aa29a1..7871e02 100644
--- a/Stardust.Data/Nodes/Stardust.htm
+++ b/Stardust.Data/Nodes/Stardust.htm
@@ -826,6 +826,17 @@
</tr>
<tr>
+ <td>ProductCode</td>
+ <td>产品</td>
+ <td>String</td>
+ <td>50</td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td>产品编码,用于区分不同类型节点</td>
+ </tr>
+
+ <tr>
<td>IP</td>
<td>本地IP</td>
<td>String</td>
diff --git "a/Stardust.Data/Nodes/\350\212\202\347\202\271.Biz.cs" "b/Stardust.Data/Nodes/\350\212\202\347\202\271.Biz.cs"
index 6470d5b..3b10392 100644
--- "a/Stardust.Data/Nodes/\350\212\202\347\202\271.Biz.cs"
+++ "b/Stardust.Data/Nodes/\350\212\202\347\202\271.Biz.cs"
@@ -1,5 +1,6 @@
using NewLife;
using NewLife.Data;
+using Stardust.Data.Platform;
using Stardust.Models;
using System;
using System.Collections.Generic;
@@ -81,7 +82,7 @@ public partial class Node : Entity<Node>
/// <summary>城市名</summary>
[Map(__.CityID)]
- public String CityName => City?.Path;
+ public String CityName => City?.Path ?? Province?.Path;
/// <summary>最后地址。IP=>Address</summary>
[DisplayName("最后地址")]
@@ -372,6 +373,32 @@ public partial class Node : Entity<Node>
return FindAll(exp, page);
}
+ public static IList<Node> Search(Int32 projectId, Boolean? global, String category, String product, Boolean? enable, String key, PageParameter page)
+ {
+ var exp = new WhereExpression();
+
+ if (global != null)
+ {
+ // 找到全局项目,然后再找到所有节点。如果项目不存在,则也不会有节点
+ var prjs = GalaxyProject.FindAllWithCache().Where(e => e.IsGlobal == global.Value).Select(e => e.Id).ToList();
+ if (projectId > 0 && !prjs.Contains(projectId)) prjs.Add(projectId);
+ if (prjs.Count == 0) return [];
+
+ exp &= _.ProjectId.In(prjs);
+ }
+ else if (projectId >= 0)
+ exp &= _.ProjectId == projectId;
+
+ if (!category.IsNullOrEmpty()) exp &= _.Category == category | _.Category.IsNullOrEmpty();
+ if (!product.IsNullOrEmpty()) exp &= _.ProductCode == product;
+
+ if (enable != null) exp &= _.Enable == enable.Value;
+
+ if (!key.IsNullOrEmpty()) exp &= _.Code.Contains(key) | _.Name.Contains(key) | _.Category.Contains(key) | _.MachineName.Contains(key) | _.UserName.Contains(key);
+
+ return FindAll(exp, page);
+ }
+
public static IList<Node> SearchGroup(DateTime start, String selects, FieldItem groupField)
{
var exp = new WhereExpression();
diff --git "a/Stardust.Data/Nodes/\350\212\202\347\202\271\345\216\206\345\217\262.Biz.cs" "b/Stardust.Data/Nodes/\350\212\202\347\202\271\345\216\206\345\217\262.Biz.cs"
index ec0c38a..a833ce8 100644
--- "a/Stardust.Data/Nodes/\350\212\202\347\202\271\345\216\206\345\217\262.Biz.cs"
+++ "b/Stardust.Data/Nodes/\350\212\202\347\202\271\345\216\206\345\217\262.Biz.cs"
@@ -61,7 +61,7 @@ namespace Stardust.Data.Nodes
/// <summary>城市名</summary>
[Map(__.CityID)]
- public String CityName => City?.Path;
+ public String CityName => City?.Path ?? Province?.Path;
#endregion
#region 扩展查询
diff --git "a/Stardust.Data/Nodes/\350\212\202\347\202\271\345\234\250\347\272\277.Biz.cs" "b/Stardust.Data/Nodes/\350\212\202\347\202\271\345\234\250\347\272\277.Biz.cs"
index 86d8e18..3a4ae82 100644
--- "a/Stardust.Data/Nodes/\350\212\202\347\202\271\345\234\250\347\272\277.Biz.cs"
+++ "b/Stardust.Data/Nodes/\350\212\202\347\202\271\345\234\250\347\272\277.Biz.cs"
@@ -69,7 +69,7 @@ public partial class NodeOnline : Entity<NodeOnline>
/// <summary>城市名</summary>
[Map(__.CityID)]
- public String CityName => City?.Path;
+ public String CityName => City?.Path ?? Province?.Path;
#endregion
#region 扩展查询
diff --git "a/Stardust.Data/Nodes/\350\212\202\347\202\271\345\234\250\347\272\277.cs" "b/Stardust.Data/Nodes/\350\212\202\347\202\271\345\234\250\347\272\277.cs"
index d3af24e..89f5661 100644
--- "a/Stardust.Data/Nodes/\350\212\202\347\202\271\345\234\250\347\272\277.cs"
+++ "b/Stardust.Data/Nodes/\350\212\202\347\202\271\345\234\250\347\272\277.cs"
@@ -66,6 +66,14 @@ public partial class NodeOnline
[BindColumn("Name", "名称", "", Master = true)]
public String Name { get => _Name; set { if (OnPropertyChanging("Name", value)) { _Name = value; OnPropertyChanged("Name"); } } }
+ private String _ProductCode;
+ /// <summary>产品。产品编码,用于区分不同类型节点</summary>
+ [DisplayName("产品")]
+ [Description("产品。产品编码,用于区分不同类型节点")]
+ [DataObjectField(false, false, true, 50)]
+ [BindColumn("ProductCode", "产品。产品编码,用于区分不同类型节点", "")]
+ public String ProductCode { get => _ProductCode; set { if (OnPropertyChanging("ProductCode", value)) { _ProductCode = value; OnPropertyChanged("ProductCode"); } } }
+
private String _IP;
/// <summary>本地IP</summary>
[DisplayName("本地IP")]
@@ -399,6 +407,7 @@ public partial class NodeOnline
"SessionID" => _SessionID,
"NodeID" => _NodeID,
"Name" => _Name,
+ "ProductCode" => _ProductCode,
"IP" => _IP,
"Category" => _Category,
"ProvinceID" => _ProvinceID,
@@ -449,6 +458,7 @@ public partial class NodeOnline
case "SessionID": _SessionID = Convert.ToString(value); break;
case "NodeID": _NodeID = value.ToInt(); break;
case "Name": _Name = Convert.ToString(value); break;
+ case "ProductCode": _ProductCode = Convert.ToString(value); break;
case "IP": _IP = Convert.ToString(value); break;
case "Category": _Category = Convert.ToString(value); break;
case "ProvinceID": _ProvinceID = value.ToInt(); break;
@@ -546,6 +556,9 @@ public partial class NodeOnline
/// <summary>名称</summary>
public static readonly Field Name = FindByName("Name");
+ /// <summary>产品。产品编码,用于区分不同类型节点</summary>
+ public static readonly Field ProductCode = FindByName("ProductCode");
+
/// <summary>本地IP</summary>
public static readonly Field IP = FindByName("IP");
@@ -684,6 +697,9 @@ public partial class NodeOnline
/// <summary>名称</summary>
public const String Name = "Name";
+ /// <summary>产品。产品编码,用于区分不同类型节点</summary>
+ public const String ProductCode = "ProductCode";
+
/// <summary>本地IP</summary>
public const String IP = "IP";
diff --git a/Stardust.Server/Services/NodeService.cs b/Stardust.Server/Services/NodeService.cs
index 25d6d49..e060d3d 100644
--- a/Stardust.Server/Services/NodeService.cs
+++ b/Stardust.Server/Services/NodeService.cs
@@ -425,6 +425,7 @@ public class NodeService
var olt = GetOrAddOnline(node, token, ip);
olt.Name = node.Name;
olt.ProjectId = node.ProjectId;
+ olt.ProductCode = node.ProductCode;
olt.Category = node.Category;
olt.Version = node.Version;
olt.CompileTime = node.CompileTime;
@@ -543,6 +544,7 @@ public class NodeService
olt.ProjectId = node.ProjectId;
olt.NodeID = node.ID;
olt.Name = node.Name;
+ olt.ProductCode = node.ProductCode;
olt.IP = node.IP;
olt.Category = node.Category;
olt.ProvinceID = node.ProvinceID;
diff --git a/Stardust.Web/Areas/Deployment/Views/AppDeployNode/_Form_Body.cshtml b/Stardust.Web/Areas/Deployment/Views/AppDeployNode/_Form_Body.cshtml
index b463e9c..5daac58 100644
--- a/Stardust.Web/Areas/Deployment/Views/AppDeployNode/_Form_Body.cshtml
+++ b/Stardust.Web/Areas/Deployment/Views/AppDeployNode/_Form_Body.cshtml
@@ -13,6 +13,8 @@
var fields = ViewBag.Fields as FieldCollection;
var isNew = (entity as IEntity).IsNullKey;
+ var projectId = entity.Deploy?.ProjectId ?? 0;
+
var set = CubeSetting.Current;
var cls = set.FormGroupClass;
if (cls.IsNullOrEmpty()) { cls = "form-group col-xs-12 col-sm-6 col-lg-4"; }
@@ -26,7 +28,7 @@
<div class="@cls">
<label class="control-label col-xs-3 col-sm-3">节点</label>
<div class="input-group col-xs-9 col-sm-9">
- @await Html.PartialAsync("_SelectNode", new SelectNodeModel { Id = "nodeId", NodeId = entity.NodeId, Product="StarAgent" })
+ @await Html.PartialAsync("_SelectNode", new SelectNodeModel { Id = "nodeId", NodeId = entity.NodeId, ProjectId = projectId, Product = "StarAgent" })
</div>
</div>
}
diff --git a/Stardust.Web/Areas/Nodes/Controllers/NodeController.cs b/Stardust.Web/Areas/Nodes/Controllers/NodeController.cs
index d193697..e5e596e 100644
--- a/Stardust.Web/Areas/Nodes/Controllers/NodeController.cs
+++ b/Stardust.Web/Areas/Nodes/Controllers/NodeController.cs
@@ -140,7 +140,7 @@ public class NodeController : EntityController<Node>
/// <param name="category"></param>
/// <param name="key"></param>
/// <returns></returns>
- public ActionResult NodeSearch(String category, String product, String key = null)
+ public ActionResult NodeSearch(Int32 projectId, String category, String product, String key = null)
{
var page = new PageParameter { PageSize = 20 };
@@ -151,18 +151,28 @@ public class NodeController : EntityController<Node>
page.Desc = true;
}
- var list = SearchByCategory(category, product, true, key, page);
+ // 优先本项目节点,再全局节点
+ var list = Node.Search(projectId, true, category, product, true, key, page);
+ list = list.OrderByDescending(e => e.ProjectId == projectId).ThenByDescending(e => e.LastActive).ToList();
return Json(0, null, list.Select(e => new
{
e.ID,
e.Code,
e.Name,
+ e.ProjectName,
e.Category,
e.IP,
}).ToArray());
}
+ protected override String OnJsonSerialize(Object data)
+ {
+ var rs = base.OnJsonSerialize(data);
+
+ return rs;
+ }
+
public async Task<ActionResult> Trace(Int32 id)
{
var node = FindByID(id);
diff --git a/Stardust.Web/Areas/Nodes/Controllers/NodeOnlineController.cs b/Stardust.Web/Areas/Nodes/Controllers/NodeOnlineController.cs
index 914361f..dc51878 100644
--- a/Stardust.Web/Areas/Nodes/Controllers/NodeOnlineController.cs
+++ b/Stardust.Web/Areas/Nodes/Controllers/NodeOnlineController.cs
@@ -24,7 +24,7 @@ public class NodeOnlineController : ReadOnlyEntityController<NodeOnline>
var list = ListFields;
list.Clear();
- var allows = new[] { "ID", "Name", "Category", "CityName", "PingCount", "WebSocket", "Version", "OSKind", "IP", "AvailableMemory", "MemoryUsed", "AvailableFreeSpace", "SpaceUsed", "CpuRate", "ProcessCount", __.Signal, "UplinkSpeed", "DownlinkSpeed", "LocalTime", "CreateTime", "CreateIP", "UpdateTime" };
+ var allows = new[] { "ID", "ProjectName", "Name", "Category", "ProductCode", "CityName", "PingCount", "WebSocket", "Version", "OSKind", "IP", "AvailableMemory", "MemoryUsed", "AvailableFreeSpace", "SpaceUsed", "CpuRate", "ProcessCount", __.Signal, "UplinkSpeed", "DownlinkSpeed", "LocalTime", "CreateTime", "CreateIP", "UpdateTime" };
foreach (var item in allows)
{
list.AddListField(item);
diff --git a/Stardust.Web/Models/SelectNodeModel.cs b/Stardust.Web/Models/SelectNodeModel.cs
index c2c5d8c..ac191d7 100644
--- a/Stardust.Web/Models/SelectNodeModel.cs
+++ b/Stardust.Web/Models/SelectNodeModel.cs
@@ -4,6 +4,8 @@ public class SelectNodeModel
{
public String Id { get; set; }
+ public Int32 ProjectId { get; set; }
+
public String Category { get; set; }
public String Product { get; set; }
diff --git a/Stardust.Web/Views/Shared/_SelectNode.cshtml b/Stardust.Web/Views/Shared/_SelectNode.cshtml
index a4205bd..15873ab 100644
--- a/Stardust.Web/Views/Shared/_SelectNode.cshtml
+++ b/Stardust.Web/Views/Shared/_SelectNode.cshtml
@@ -31,9 +31,9 @@
<script type="text/javascript">
$(function () {
$("#@(id)_select").bsSuggest({
- url: "/Nodes/Node/NodeSearch?category=@Model.Category&product=@Model.Product&key=",
- getDataMethod:"url",
- effectiveFieldsAlias: { id: "编号", code: "代码", name: "名称", ip: "地址" },
+ url: "/Nodes/Node/NodeSearch?projectId=@Model.ProjectId&category=@Model.Category&product=@Model.Product&key=",
+ getDataMethod: "url",
+ effectiveFieldsAlias: { id: "编号", code: "代码", name: "名称", projectName: "项目", category: "分类", ip: "地址" },
ignorecase: true,
showHeader: true,
delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时,延迟到有输入/获取到焦点时才请求数据
diff --git a/Stardust/Stardust.csproj b/Stardust/Stardust.csproj
index 3fd3ebb..945f701 100644
--- a/Stardust/Stardust.csproj
+++ b/Stardust/Stardust.csproj
@@ -115,7 +115,7 @@
<PackageReference Include="NewLife.Remoting" Version="3.0.2024.710-beta1226" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'!='net40'">
- <PackageReference Include="NewLife.Core" Version="10.10.2024.0710-beta0951" />
+ <PackageReference Include="NewLife.Core" Version="10.10.2024.0713-beta0409" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net40'">
<PackageReference Include="NewLife.Core" Version="10.10.2024.0701-net40" />
diff --git a/Test/Test.csproj b/Test/Test.csproj
index 580869a..0ebd5be 100644
--- a/Test/Test.csproj
+++ b/Test/Test.csproj
@@ -30,7 +30,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Win32.SystemEvents" Version="8.0.0" />
- <PackageReference Include="NewLife.Core" Version="10.10.2024.710-beta0951" />
+ <PackageReference Include="NewLife.Core" Version="10.10.2024.713-beta0409" />
<PackageReference Include="SSH.NET" Version="2024.1.0" />
</ItemGroup>