From e8044e71c9c053c271e6475082de259f7564780d Mon Sep 17 00:00:00 2001
From: wanggang <76527413@qq.com>
Date: Tue, 28 Apr 2020 11:44:52 +0800
Subject: [PATCH] 1.0.0.428
Former-commit-id: 49660a3e76d0c82a96331829461306851c383eaa
---
.../Areas/Admin/Views/Shared/_Layout.cshtml | 2 +-
.../Extensions/HelperExtensions.cs | 5 +++
projects/Infrastructure/Infrastructure.csproj | 5 ++-
.../Infrastructure/Web/SignalR/BasePageHub.cs | 25 ++++++++++---
.../Application/Domain/Entities/Node.cs | 3 ++
.../Application/Models/EditNodeModel.cs | 4 +++
projects/IoT.Shared/IoT.Shared.csproj | 6 +++-
.../Services/IoTCenter/IoTCenterHub.cs | 36 +++++++++++++++++++
.../Services/IoTNode/IoTNodeClient.cs | 2 +-
projects/IoTCenter/IoTCenter.csproj | 6 +++-
projects/IoTCenter/db.sql | 1 +
projects/IoTNode/DbConfig.cs | 1 +
projects/IoTNode/IoTNode.csproj | 6 +++-
projects/IoTNode/db.sql | 1 +
projects/JobServer/JobServer.csproj | 7 +++-
projects/StudyCenter/StudyCenter.csproj | 6 +++-
projects/UserCenter/UserCenter.csproj | 6 +++-
projects/Version.cs | 4 +++
projects/WebMVC/WebMVC.csproj | 3 +-
projects/WebSPA/WebSPA.csproj | 1 -
projects/projects.sln | 5 +--
21 files changed, 117 insertions(+), 18 deletions(-)
create mode 100644 projects/Version.cs
diff --git a/projects/Infrastructure/Areas/Admin/Views/Shared/_Layout.cshtml b/projects/Infrastructure/Areas/Admin/Views/Shared/_Layout.cshtml
index 3c0e000a..eb9e36a7 100644
--- a/projects/Infrastructure/Areas/Admin/Views/Shared/_Layout.cshtml
+++ b/projects/Infrastructure/Areas/Admin/Views/Shared/_Layout.cshtml
@@ -95,7 +95,7 @@
@Html.Raw(string.Format(copyright, DateTime.Now.Year.ToString()))
- v @Helper.Instance.GetVersion()
+ v @Helper.Instance.GetVersion() build @Helper.Instance.GetAssemblyVersion()
diff --git a/projects/Infrastructure/Extensions/HelperExtensions.cs b/projects/Infrastructure/Extensions/HelperExtensions.cs
index 0863016e..eb14a7b9 100644
--- a/projects/Infrastructure/Extensions/HelperExtensions.cs
+++ b/projects/Infrastructure/Extensions/HelperExtensions.cs
@@ -17,6 +17,11 @@ namespace Infrastructure.Extensions
return Assembly.GetEntryAssembly().GetCustomAttribute().InformationalVersion;
}
+ public static string GetAssemblyVersion(this Helper helper)
+ {
+ return Assembly.GetEntryAssembly().GetName().Version?.ToString();
+ }
+
public static string GetMacAddress(this Helper helper)
{
return NetworkInterface
diff --git a/projects/Infrastructure/Infrastructure.csproj b/projects/Infrastructure/Infrastructure.csproj
index ccfc2b87..5006493f 100644
--- a/projects/Infrastructure/Infrastructure.csproj
+++ b/projects/Infrastructure/Infrastructure.csproj
@@ -5,7 +5,8 @@
true
true
true
- 1.0.0.427
+ false
+ false
@@ -49,5 +50,7 @@
+
+
\ No newline at end of file
diff --git a/projects/Infrastructure/Web/SignalR/BasePageHub.cs b/projects/Infrastructure/Web/SignalR/BasePageHub.cs
index 95ef30dd..b692e4b1 100644
--- a/projects/Infrastructure/Web/SignalR/BasePageHub.cs
+++ b/projects/Infrastructure/Web/SignalR/BasePageHub.cs
@@ -9,21 +9,38 @@ namespace Infrastructure.Web.SignalR
public class BasePageHub : Hub
{
public override Task OnConnectedAsync()
+ {
+ this.OnConnected();
+ return base.OnConnectedAsync();
+ }
+
+ protected void OnConnected()
{
Debug.WriteLine($"{Context.ConnectionId} has connected which request url is {Context.GetHttpContext().Request.GetUrl()}");
this.Groups.AddToGroupAsync(Context.ConnectionId, Context.ConnectionId);
- if (Context.GetHttpContext().Request.Query.Keys.Contains("group"))
+ var group = Context.GetHttpContext().Request.Query["group"].ToString();
+ if (!string.IsNullOrEmpty(group))
+ {
+ this.Groups.AddToGroupAsync(Context.ConnectionId, group);
+ Context.Items["group"] = group;
+ }
+ var type = Context.GetHttpContext().Request.Query["type"].ToString();
+ if (!string.IsNullOrEmpty(type))
{
- this.Groups.AddToGroupAsync(Context.ConnectionId, Context.GetHttpContext().Request.Query["group"]);
+ Context.Items["type"] = type;
}
this.Clients.Group(Context.ConnectionId).SendAsync("Connected", Context.ConnectionId);
- return base.OnConnectedAsync();
}
public override Task OnDisconnectedAsync(Exception exception)
{
- Debug.WriteLine($"{Context.ConnectionId} has disconnected which request url is {Context.GetHttpContext().Request.GetUrl()}");
+ this.OnDisconnected(exception);
return base.OnDisconnectedAsync(exception);
}
+
+ protected void OnDisconnected(Exception exception)
+ {
+ Debug.WriteLine($"{Context.ConnectionId} has disconnected which request url is {Context.GetHttpContext().Request.GetUrl()}");
+ }
}
}
\ No newline at end of file
diff --git a/projects/IoT.Shared/Application/Domain/Entities/Node.cs b/projects/IoT.Shared/Application/Domain/Entities/Node.cs
index 0c8cab7b..e9cce167 100644
--- a/projects/IoT.Shared/Application/Domain/Entities/Node.cs
+++ b/projects/IoT.Shared/Application/Domain/Entities/Node.cs
@@ -14,6 +14,9 @@ namespace Application.Domain.Entities
[Required]
public string Number { get; set; }
+ [Display(Name = "在线")]
+ public bool IsOnline { get; set; }
+
[Display(Name = "图片")]
public string Image { get; set; }
diff --git a/projects/IoT.Shared/Application/Models/EditNodeModel.cs b/projects/IoT.Shared/Application/Models/EditNodeModel.cs
index e4a66f4d..c229dd0a 100644
--- a/projects/IoT.Shared/Application/Models/EditNodeModel.cs
+++ b/projects/IoT.Shared/Application/Models/EditNodeModel.cs
@@ -16,6 +16,10 @@ namespace Application.Models
[Required(ErrorMessage = nameof(RequiredAttribute))]
public string Number { get; set; }
+ [Display(Name = "在线")]
+ [ReadOnly(true)]
+ public bool IsOnline { get; set; }
+
[Display(Name = "图片")]
[DataType(DataType.ImageUrl)]
public string Image { get; set; }
diff --git a/projects/IoT.Shared/IoT.Shared.csproj b/projects/IoT.Shared/IoT.Shared.csproj
index 0888e8f2..950717b6 100644
--- a/projects/IoT.Shared/IoT.Shared.csproj
+++ b/projects/IoT.Shared/IoT.Shared.csproj
@@ -5,7 +5,8 @@
true
true
true
- 1.0.0.427
+ false
+ false
@@ -21,6 +22,9 @@
+
+
+
diff --git a/projects/IoT.Shared/Services/IoTCenter/IoTCenterHub.cs b/projects/IoT.Shared/Services/IoTCenter/IoTCenterHub.cs
index 09875381..5fa7d335 100644
--- a/projects/IoT.Shared/Services/IoTCenter/IoTCenterHub.cs
+++ b/projects/IoT.Shared/Services/IoTCenter/IoTCenterHub.cs
@@ -70,6 +70,42 @@ namespace IoTCenter.Services
this._httpClientFactory = httpClientFactory;
}
+ public override Task OnConnectedAsync()
+ {
+ this.OnConnected();
+ this.UpdateNodeStatus(true);
+ return Task.CompletedTask;
+ }
+
+ public override Task OnDisconnectedAsync(Exception exception)
+ {
+ this.OnDisconnected(exception);
+ this.UpdateNodeStatus(false);
+ return Task.CompletedTask;
+ }
+
+ private void UpdateNodeStatus(bool status)
+ {
+ var type = Context.Items["type"] as string;
+ if (!string.IsNullOrEmpty(type) && type == "node")
+ {
+ var group = Context.Items["group"].ToString();
+ var node = this._nodeRepo.Table().FirstOrDefault(o => o.Number == group);
+ if (node != null)
+ {
+ node.IsOnline = status;
+ try
+ {
+ this._nodeRepo.SaveChanges();
+ }
+ catch (Exception ex)
+ {
+ this._logger.LogError(ex.ToString());
+ }
+ }
+ }
+ }
+
public void ServerToClient(string method, string message, string toClient, string fromClient = null)
{
Clients.Group(toClient).SendAsync(Methods.ServerToClient, method, message, toClient, fromClient);
diff --git a/projects/IoT.Shared/Services/IoTNode/IoTNodeClient.cs b/projects/IoT.Shared/Services/IoTNode/IoTNodeClient.cs
index 9f980e88..b4028080 100644
--- a/projects/IoT.Shared/Services/IoTNode/IoTNodeClient.cs
+++ b/projects/IoT.Shared/Services/IoTNode/IoTNodeClient.cs
@@ -132,7 +132,7 @@ namespace IoT.Shared.Services
private void InitConnection()
{
this._notifyHost = GetSetting("notify:host");
- var url = $"{this._notifyHost}/hub?group={GetSetting("sn")}";
+ var url = $"{this._notifyHost}/hub?type=node&group={GetSetting("sn")}";
this._logger.LogDebug($"init connection for {url}");
if (this.Connection != null)
{
diff --git a/projects/IoTCenter/IoTCenter.csproj b/projects/IoTCenter/IoTCenter.csproj
index a15969a4..6503ca65 100644
--- a/projects/IoTCenter/IoTCenter.csproj
+++ b/projects/IoTCenter/IoTCenter.csproj
@@ -2,8 +2,12 @@
netcoreapp3.1
true
- 1.0.0.427
+ false
+ false
+
+
+
diff --git a/projects/IoTCenter/db.sql b/projects/IoTCenter/db.sql
index 4c2a3848..222fc12e 100644
--- a/projects/IoTCenter/db.sql
+++ b/projects/IoTCenter/db.sql
@@ -20,6 +20,7 @@ CREATE TABLE "iot_Node" (
"IsDeleted" TEXT NULL,
"Name" TEXT NULL,
"Number" TEXT NOT NULL,
+ "IsOnline" INTEGER NOT NULL,
"Image" TEXT NULL,
"Longitude" TEXT NOT NULL,
"Latitude" TEXT NOT NULL,
diff --git a/projects/IoTNode/DbConfig.cs b/projects/IoTNode/DbConfig.cs
index 0a2a33d1..34da5de5 100644
--- a/projects/IoTNode/DbConfig.cs
+++ b/projects/IoTNode/DbConfig.cs
@@ -97,6 +97,7 @@ namespace IoTNode
Id = $"nodeid-{sn}".ToGuid(),
Name = "节点",
Number = sn,
+ IsOnline = true,
Image = "/images/classroom.png"
});
db.SaveChanges();
diff --git a/projects/IoTNode/IoTNode.csproj b/projects/IoTNode/IoTNode.csproj
index 33929e03..eaa83037 100644
--- a/projects/IoTNode/IoTNode.csproj
+++ b/projects/IoTNode/IoTNode.csproj
@@ -2,8 +2,12 @@
netcoreapp3.1
true
- 1.0.0.427
+ false
+ false
+
+
+
diff --git a/projects/IoTNode/db.sql b/projects/IoTNode/db.sql
index 4c2a3848..222fc12e 100644
--- a/projects/IoTNode/db.sql
+++ b/projects/IoTNode/db.sql
@@ -20,6 +20,7 @@ CREATE TABLE "iot_Node" (
"IsDeleted" TEXT NULL,
"Name" TEXT NULL,
"Number" TEXT NOT NULL,
+ "IsOnline" INTEGER NOT NULL,
"Image" TEXT NULL,
"Longitude" TEXT NOT NULL,
"Latitude" TEXT NOT NULL,
diff --git a/projects/JobServer/JobServer.csproj b/projects/JobServer/JobServer.csproj
index 14f1921e..5ee5e9b9 100644
--- a/projects/JobServer/JobServer.csproj
+++ b/projects/JobServer/JobServer.csproj
@@ -3,9 +3,14 @@
netcoreapp3.1
true
- 1.0.0.427
+ false
+ false
+
+
+
+
diff --git a/projects/StudyCenter/StudyCenter.csproj b/projects/StudyCenter/StudyCenter.csproj
index 77e043e1..9017a046 100644
--- a/projects/StudyCenter/StudyCenter.csproj
+++ b/projects/StudyCenter/StudyCenter.csproj
@@ -2,8 +2,12 @@
netcoreapp3.1
true
- 1.0.0.427
+ false
+ false
+
+
+
diff --git a/projects/UserCenter/UserCenter.csproj b/projects/UserCenter/UserCenter.csproj
index 564f9d77..fcd980f1 100644
--- a/projects/UserCenter/UserCenter.csproj
+++ b/projects/UserCenter/UserCenter.csproj
@@ -2,8 +2,12 @@
netcoreapp3.1
true
- 1.0.0.427
+ false
+ false
+
+
+
diff --git a/projects/Version.cs b/projects/Version.cs
new file mode 100644
index 00000000..23a6907c
--- /dev/null
+++ b/projects/Version.cs
@@ -0,0 +1,4 @@
+using System.Reflection;
+
+[assembly: AssemblyVersion("1.0.0.*")]
+[assembly: AssemblyInformationalVersion("1.0.0.428")]
\ No newline at end of file
diff --git a/projects/WebMVC/WebMVC.csproj b/projects/WebMVC/WebMVC.csproj
index 5871e44e..e51b1acf 100644
--- a/projects/WebMVC/WebMVC.csproj
+++ b/projects/WebMVC/WebMVC.csproj
@@ -1,8 +1,7 @@
-
+
netcoreapp3.1
- 1.0.0.427
diff --git a/projects/WebSPA/WebSPA.csproj b/projects/WebSPA/WebSPA.csproj
index 8257692b..e51b1acf 100644
--- a/projects/WebSPA/WebSPA.csproj
+++ b/projects/WebSPA/WebSPA.csproj
@@ -2,7 +2,6 @@
netcoreapp3.1
- 1.0.0.427
diff --git a/projects/projects.sln b/projects/projects.sln
index 3b47f691..28467211 100644
--- a/projects/projects.sln
+++ b/projects/projects.sln
@@ -21,6 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
NuGet.config = NuGet.config
lib\package.json = lib\package.json
..\README.md = ..\README.md
+ Version.cs = Version.cs
EndProjectSection
ProjectSection(FolderGlobals) = preProject
C_5_4Users_4wg_4Desktop_4ZHXY_4projects_4lib_4package_1json__JsonSchema = http://json.schemastore.org/project-1.0.0-beta4
@@ -39,7 +40,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UI", "UI", "{11BCB5F9-0020-
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebSPA", "WebSPA\WebSPA.csproj", "{6F839910-580D-4CD1-A0C0-6FAF542B4480}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JobServer", "JobServer\JobServer.csproj", "{6E2766D8-9ECF-469E-8662-A20F673E52CC}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JobServer", "JobServer\JobServer.csproj", "{6E2766D8-9ECF-469E-8662-A20F673E52CC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -175,7 +176,7 @@ Global
{6E2766D8-9ECF-469E-8662-A20F673E52CC} = {E1681DC3-9AC2-4FF6-B3DE-37EF826E6F8A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
- BuildVersion_StartDate = 2000/1/1
SolutionGuid = {0B7095FB-5E70-4EF8-805A-CB4A91AE4B0A}
+ BuildVersion_StartDate = 2000/1/1
EndGlobalSection
EndGlobal