改进模板,增加Data数据层

This commit is contained in:
智能大石头 2024-12-17 01:12:50 +08:00
parent a613d01832
commit 1565c7f9ab
44 changed files with 298 additions and 47 deletions

View File

@ -1,4 +1,4 @@
{
"author": "新生命团队",
"name": "新生命蚂蚁调度"
"name": "新生命AntJob大数据计算"
}

View File

@ -1,8 +1,9 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "NewLife",
"classifications": [ "NewLife", "Console", "Job" ],
"classifications": [ "NewLife", "Job" ],
"name": "NewLife AntJob",
"description": "蚂蚁调度系统子程序,编写数据处理等业务逻辑,连接蚂蚁调度中心,拉取作业任务来执行",
"identity": "NewLife.AntJob",
"shortName": "antjob",
"tags": {

View File

@ -1,4 +1,4 @@
{
"author": "新生命团队",
"name": "新生命客户端"
"name": "新生命IoT客户端"
}

View File

@ -1,8 +1,9 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "NewLife",
"classifications": [ "NewLife", "Console", "IoT" ],
"classifications": [ "NewLife", "IoT" ],
"name": "NewLife Client",
"description": "CS架构的客户端应用以后台服务工作一般由StarAgent负责守护",
"identity": "NewLife.Client",
"shortName": "client",
"tags": {

View File

@ -1,4 +1,4 @@
{
"author": "新生命团队",
"name": "新生命控制台"
"name": "新生命Console控制台"
}

View File

@ -0,0 +1,4 @@
{
"author": "新生命团队",
"name": "新生命XCode数据层"
}

View File

@ -0,0 +1,16 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "NewLife",
"classifications": [ "NewLife", "Common", "Library" ],
"name": "NewLife Data",
"description": "Web应用、微服务、应用服务、大数据计算等共用数据层主要包括数据层实体类。一般只用于服务端",
"identity": "NewLife.Data.2024",
"groupIdentity": "NewLife.Data",
"shortName": "data",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "Zero.Data",
"preferNameDirectory": true
}

View File

@ -1,4 +1,4 @@
{
"author": "新生命团队",
"name": "新生命控制台"
"name": "新生命GTK桌面应用"
}

View File

@ -3,6 +3,7 @@
"author": "NewLife",
"classifications": [ "NewLife", "Desktop" ],
"name": "NewLife GtkForm",
"description": "使用GTK#技术的跨平台桌面应用,给用户提供便捷操作,可对接硬件",
"identity": "NewLife.GtkForm",
"shortName": "gtkform",
"tags": {

View File

@ -1,8 +1,9 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "NewLife",
"classifications": [ "NewLife", "Console" ],
"classifications": [ "NewLife", "Server" ],
"name": "NewLife HttpServer",
"description": "轻量级Http服务器可用于追求简单Http服务的场景例如暴露硬件控制为Http接口如打印组件",
"identity": "NewLife.HttpServer",
"shortName": "http",
"tags": {

View File

@ -1,8 +1,9 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "NewLife",
"classifications": [ "NewLife", "Console" ],
"classifications": [ "NewLife", "Server" ],
"name": "NewLife NetServer",
"description": "高性能Tcp网络服务器单机最高400万连接可用于建立各种协议的网络服务器",
"identity": "NewLife.NetServer",
"shortName": "net",
"tags": {

View File

@ -41,6 +41,10 @@
<Content Include="..\Zero.Worker\**\*" Link=".\Worker\" PackagePath="content\Worker\" Exclude="..\Zero.Worker\**\bin\**;..\Zero.Worker\**\obj\**" />
<Content Include="Worker\**\*" />
</ItemGroup>
<ItemGroup>
<Content Include="..\Zero.Data\**\*" Link=".\Data\" PackagePath="content\Data\" Exclude="..\Zero.Data\**\bin\**;..\Zero.Data\**\obj\**" />
<Content Include="Data\**\*" />
</ItemGroup>
<ItemGroup>
<Content Include="..\Zero.Web\**\*" Link=".\Web\" PackagePath="content\Web\" Exclude="..\Zero.Web\**\bin\**;..\Zero.Web\**\obj\**" />
<Content Include="Web\**\*" />

View File

@ -1,8 +1,9 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "NewLife",
"classifications": [ "NewLife", "Console" ],
"classifications": [ "NewLife", "Server" ],
"name": "NewLife RpcServer",
"description": "高性能,长连接,数据接口",
"identity": "NewLife.RpcServer",
"shortName": "rpc",
"tags": {

View File

@ -1,4 +1,4 @@
{
"author": "新生命团队",
"name": "新生命后台服务"
"name": "新生命Service后台服务"
}

View File

@ -1,8 +1,9 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "NewLife",
"classifications": [ "NewLife", "Console" ],
"classifications": [ "NewLife", "Agent" ],
"name": "NewLife Service",
"description": "数据处理、定时任务、MQ生产消费、系统监控等超长独立工作的后台任务",
"identity": "NewLife.Service",
"shortName": "service",
"tags": {

View File

@ -1,7 +1,7 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "NewLife",
"classifications": [ "NewLife", "Common", "Web", "Api", "Web Api" ],
"classifications": [ "NewLife", "Common", "Web", "API", "Web API" ],
"name": "NewLife WebApi",
"description": "数据接口带有Swagger的标准WebApi接口项目",
"identity": "NewLife.WebApi.2024",

View File

@ -1,8 +1,9 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "NewLife",
"classifications": [ "NewLife", "Console" ],
"classifications": [ "NewLife", "Server" ],
"name": "NewLife WebSocket",
"description": "轻量级WebSocket服务可用于网页与终端本地硬件保持长连接通信",
"identity": "NewLife.WebSocket",
"shortName": "websocket",
"tags": {

View File

@ -1,4 +1,4 @@
{
"author": "新生命团队",
"name": "新生命WebView"
"name": "新生命WebView窗体应用"
}

View File

@ -1,8 +1,9 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "NewLife",
"classifications": [ "NewLife", "Windows", "WinForm", "Desktop" ],
"classifications": [ "NewLife", "Windows", "WinForms", "Desktop" ],
"name": "NewLife WebView",
"description": "嵌入Web的客户端桌面应用给用户提供便捷操作可对接硬件",
"identity": "NewLife.WebView",
"shortName": "webview",
"tags": {

View File

@ -1,4 +1,4 @@
{
"author": "新生命团队",
"name": "新生命窗口应用"
"name": "新生命Windows窗体应用"
}

View File

@ -1,8 +1,9 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "NewLife",
"classifications": [ "NewLife", "Windows", "WinForm", "Desktop" ],
"classifications": [ "NewLife", "Windows", "WinForms", "Desktop" ],
"name": "NewLife WinForm",
"description": "CS架构的客户端桌面应用给用户提供便捷操作可对接硬件",
"identity": "NewLife.WinForm",
"shortName": "nwinform",
"tags": {

View File

@ -1,4 +1,4 @@
{
"author": "新生命团队",
"name": "新生命后台"
"name": "新生命Worker"
}

View File

@ -3,6 +3,7 @@
"author": "NewLife",
"classifications": [ "NewLife", "Worker" ],
"name": "NewLife Worker",
"description": "数据处理、定时任务、MQ生产消费、系统监控等超长独立工作的后台任务",
"identity": "NewLife.Worker",
"shortName": "nworker",
"tags": {

View File

@ -28,15 +28,14 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="NewLife.AntJob" Version="4.0.2024.904" />
<PackageReference Include="NewLife.AntJob.Extensions" Version="3.4.2024.904" />
<PackageReference Include="NewLife.AntJob" Version="4.0.2024.1216" />
<PackageReference Include="NewLife.AntJob.Extensions" Version="3.4.2024.1216" />
<PackageReference Include="NewLife.Core" Version="11.1.2024.1206" />
<PackageReference Include="NewLife.Redis" Version="6.0.2024.1205" />
<PackageReference Include="NewLife.XCode" Version="11.16.2024.1202" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Zero.Core\Zero.Core.csproj" />
<ProjectReference Include="..\Zero.Data\Zero.Data.csproj" />
</ItemGroup>

View File

@ -0,0 +1,39 @@
using NewLife.Remoting.Models;
namespace Zero.Data.Models;
/// <summary>节点登录信息</summary>
public class LoginInfo : LoginRequest
{
#region
/// <summary>产品编码</summary>
public String ProductCode { get; set; }
/// <summary>名称。可用于标识设备的名称</summary>
public String Name { get; set; }
/// <summary>系统名</summary>
public String OSName { get; set; }
/// <summary>系统版本</summary>
public String OSVersion { get; set; }
/// <summary>处理器架构</summary>
public String Architecture { get; set; }
/// <summary>机器名</summary>
public String MachineName { get; set; }
/// <summary>用户名</summary>
public String UserName { get; set; }
/// <summary>核心数</summary>
public Int32 ProcessorCount { get; set; }
/// <summary>内存大小</summary>
public UInt64 Memory { get; set; }
/// <summary>磁盘大小。应用所在盘</summary>
public UInt64 TotalSize { get; set; }
#endregion
}

View File

@ -0,0 +1,42 @@
using NewLife.Remoting.Models;
namespace Zero.Data.Models;
/// <summary>心跳信息</summary>
public class PingInfo : PingRequest
{
#region
///// <summary>内存大小</summary>
//public UInt64 Memory { get; set; }
///// <summary>可用内存大小</summary>
//public UInt64 AvailableMemory { get; set; }
///// <summary>磁盘大小。应用所在盘</summary>
//public UInt64 TotalSize { get; set; }
///// <summary>磁盘可用空间。应用所在盘</summary>
//public UInt64 AvailableFreeSpace { get; set; }
///// <summary>CPU使用率</summary>
//public Double CpuRate { get; set; }
///// <summary>温度</summary>
//public Double Temperature { get; set; }
///// <summary>电量</summary>
//public Double Battery { get; set; }
///// <summary>本地IP</summary>
//public String IP { get; set; }
///// <summary>开机时间单位s</summary>
//public Int32 Uptime { get; set; }
///// <summary>本地UTC时间。ms毫秒</summary>
//public Int64 Time { get; set; }
///// <summary>延迟。ms毫秒</summary>
//public Int32 Delay { get; set; }
#endregion
}

View File

@ -8,7 +8,7 @@ using NewLife.Remoting.Models;
using XCode;
using XCode.Cache;
using XCode.Membership;
using Zero.Models;
using Zero.Data.Models;
namespace Zero.Data.Nodes;

View File

@ -7,7 +7,7 @@ using NewLife.Remoting.Models;
using NewLife.Serialization;
using XCode;
using XCode.Membership;
using Zero.Models;
using Zero.Data.Models;
namespace Zero.Data.Nodes;

View File

@ -0,0 +1,19 @@
using System;
namespace Zero.WeiXin;
/// <summary>文章</summary>
public class Article
{
/// <summary>标题不超过128个字节超过会自动截断</summary>
public String Title { get; set; }
/// <summary>描述不超过512个字节超过会自动截断</summary>
public String Description { get; set; }
/// <summary>点击后跳转的链接。</summary>
public String Url { get; set; }
/// <summary>图文消息的图片链接支持JPG、PNG格式较好的效果为大图 1068*455小图150*150。</summary>
public String PicUrl { get; set; }
}

131
Zero.Data/WeiXin/Robot.cs Normal file
View File

@ -0,0 +1,131 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using NewLife;
using NewLife.Log;
using NewLife.Remoting;
namespace Zero.WeiXin;
/// <summary>企业微信机器人。webhook推送</summary>
public class Robot
{
#region
/// <summary>WebHook机器人地址</summary>
public String Url { get; set; } = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={key}";
/// <summary>性能跟踪</summary>
public ITracer Tracer { get; set; } = DefaultTracer.Instance;
private HttpClient _Client;
#endregion
#region
/// <summary>发消息</summary>
/// <param name="msg"></param>
/// <returns></returns>
protected async Task<Object> PostAsync(Object msg)
{
if (_Client == null)
_Client = Tracer?.CreateHttpClient() ?? new HttpClient();
return await _Client.PostAsync<Object>(Url, msg);
}
/// <summary>发送文本消息</summary>
/// <param name="content">消息内容</param>
/// <param name="mentions">提醒人。userid或者手机号支持@all</param>
public void SendText(String content, params String[] mentions)
{
if (content.IsNullOrEmpty()) return;
// 分解手机号
var mentioned_list = mentions?.Where(e => e.Length != 11 || e.ToLong() == 0).ToArray();
var mentioned_mobile_list = mentions?.Where(e => e.Length == 11 && e.ToLong() > 0).ToArray();
WriteLog(content);
var msg = new
{
msgtype = "text",
text = new
{
content,
mentioned_list,
mentioned_mobile_list,
},
};
PostAsync(msg).Wait();
}
/// <summary>发送markdown</summary>
/// <param name="content"></param>
public void SendMarkDown(String content)
{
if (content.IsNullOrEmpty()) return;
WriteLog(content);
var msg = new
{
msgtype = "markdown",
markdown = new
{
content,
},
};
PostAsync(msg).Wait();
}
/// <summary>发送图片</summary>
/// <param name="image"></param>
public void SendImage(Byte[] image)
{
if (image == null) return;
var base64 = image.ToBase64();
var md5 = image.MD5().ToHex().ToLower();
var msg = new
{
msgtype = "image",
text = new
{
base64,
md5,
},
};
PostAsync(msg).Wait();
}
/// <summary>发送图文,文章列表</summary>
/// <param name="articles"></param>
public void SendNews(params Article[] articles)
{
if (articles == null || articles.Length == 0) return;
var msg = new
{
msgtype = "news",
articles,
};
PostAsync(msg).Wait();
}
#endregion
#region
/// <summary>日志</summary>
public ILog Log { get; set; }
/// <summary>写日志</summary>
/// <param name="format"></param>
/// <param name="args"></param>
public void WriteLog(String format, params Object[] args) => Log?.Info(format, args);
#endregion
}

View File

@ -4,7 +4,7 @@ using NewLife;
using Zero.Data.Projects;
using Zero.WeiXin;
namespace Zero.Data.Common
namespace Zero.Data.WeiXin
{
/// <summary>机器人助手</summary>
public static class RobotHelper

View File

@ -32,8 +32,4 @@
<PackageReference Include="NewLife.XCode" Version="11.16.2024.1202" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Zero.Core\Zero.Core.csproj" />
</ItemGroup>
</Project>

View File

@ -5,8 +5,8 @@ using NewLife.Cube;
using NewLife.Web;
using XCode;
using XCode.Membership;
using Zero.Data.Common;
using Zero.Data.Projects;
using Zero.Data.WeiXin;
namespace Zero.Web.Areas.Projects.Controllers
{

View File

@ -4,8 +4,8 @@ using NewLife.Common;
using NewLife.Cube;
using NewLife.Web;
using XCode.Membership;
using Zero.Data.Common;
using Zero.Data.Projects;
using Zero.Data.WeiXin;
namespace Zero.Web.Areas.Projects.Controllers
{

View File

@ -3,7 +3,7 @@ using NewLife.Remoting.Extensions;
using NewLife.Remoting.Extensions.Models;
using NewLife.Remoting.Extensions.Services;
using NewLife.Remoting.Models;
using Zero.Models;
using Zero.Data.Models;
namespace Zero.Web.Services;

View File

@ -11,9 +11,8 @@ using NewLife.Security;
using NewLife.Serialization;
using NewLife.Web;
using XCode.Membership;
using Zero.Data.Models;
using Zero.Data.Nodes;
using Zero.Models;
using Zero.Web.Models;
namespace Zero.Web.Services;

View File

@ -26,7 +26,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Zero.Core\Zero.Core.csproj" />
<ProjectReference Include="..\Zero.Data\Zero.Data.csproj" />
</ItemGroup>

View File

@ -5,8 +5,8 @@ using NewLife.Cube;
using NewLife.Web;
using XCode;
using XCode.Membership;
using Zero.Data.Common;
using Zero.Data.Projects;
using Zero.Data.WeiXin;
namespace Zero.Web.Areas.Projects.Controllers
{

View File

@ -4,8 +4,8 @@ using NewLife.Common;
using NewLife.Cube;
using NewLife.Web;
using XCode.Membership;
using Zero.Data.Common;
using Zero.Data.Projects;
using Zero.Data.WeiXin;
namespace Zero.Web.Areas.Projects.Controllers
{

View File

@ -3,7 +3,7 @@ using NewLife.Remoting.Extensions;
using NewLife.Remoting.Extensions.Models;
using NewLife.Remoting.Extensions.Services;
using NewLife.Remoting.Models;
using Zero.Models;
using Zero.Data.Models;
namespace Zero.WebApi.Services;

View File

@ -11,8 +11,8 @@ using NewLife.Security;
using NewLife.Serialization;
using NewLife.Web;
using XCode.Membership;
using Zero.Data.Models;
using Zero.Data.Nodes;
using Zero.Models;
namespace Zero.WebApi.Services;

View File

@ -41,7 +41,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Zero.Core\Zero.Core.csproj" />
<ProjectReference Include="..\Zero.Data\Zero.Data.csproj" />
</ItemGroup>

View File

@ -19,7 +19,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NewLife.AntJob.Extensions" Version="3.4.2024.904" />
<PackageReference Include="NewLife.AntJob.Extensions" Version="3.4.2024.1216" />
<PackageReference Include="NewLife.MQTT" Version="2.0.2024.1212" />
<PackageReference Include="NewLife.Redis" Version="6.0.2024.1205" />
<PackageReference Include="NewLife.Redis.Extensions" Version="6.0.2024.1205" />

View File

@ -16,8 +16,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zero.Data", "Zero.Data\Zero
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zero.Web", "Zero.Web\Zero.Web.csproj", "{517ACFC9-2727-4931-B06D-4B073B8CDE55}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zero.Core", "Zero.Core\Zero.Core.csproj", "{A456F9A4-C2C1-4DA0-BB49-302A3A2C78B2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zero.Agent", "Zero.Agent\Zero.Agent.csproj", "{CDDFD803-5973-4AB9-9079-CB7A6CE85A40}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Zero.AntJob", "Zero.AntJob\Zero.AntJob.csproj", "{E59E32C0-DA0C-4983-A6DF-BD42A994EC35}"
@ -74,10 +72,6 @@ Global
{517ACFC9-2727-4931-B06D-4B073B8CDE55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{517ACFC9-2727-4931-B06D-4B073B8CDE55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{517ACFC9-2727-4931-B06D-4B073B8CDE55}.Release|Any CPU.Build.0 = Release|Any CPU
{A456F9A4-C2C1-4DA0-BB49-302A3A2C78B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A456F9A4-C2C1-4DA0-BB49-302A3A2C78B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A456F9A4-C2C1-4DA0-BB49-302A3A2C78B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A456F9A4-C2C1-4DA0-BB49-302A3A2C78B2}.Release|Any CPU.Build.0 = Release|Any CPU
{CDDFD803-5973-4AB9-9079-CB7A6CE85A40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CDDFD803-5973-4AB9-9079-CB7A6CE85A40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CDDFD803-5973-4AB9-9079-CB7A6CE85A40}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -145,7 +139,6 @@ Global
GlobalSection(NestedProjects) = preSolution
{9F174334-B067-4826-9934-80B1ED103810} = {3E1AEC0D-54C7-4ED9-A5D2-445F0C461732}
{517ACFC9-2727-4931-B06D-4B073B8CDE55} = {77385A67-113D-45DF-A38A-E067632E78B6}
{A456F9A4-C2C1-4DA0-BB49-302A3A2C78B2} = {3E1AEC0D-54C7-4ED9-A5D2-445F0C461732}
{CDDFD803-5973-4AB9-9079-CB7A6CE85A40} = {F3C64311-26FD-4720-9C41-A33DBE0181BB}
{E59E32C0-DA0C-4983-A6DF-BD42A994EC35} = {F3C64311-26FD-4720-9C41-A33DBE0181BB}
{11AA0791-B891-40F9-94F4-07AC339C9C95} = {77385A67-113D-45DF-A38A-E067632E78B6}