Former-commit-id: 49660a3e76d0c82a96331829461306851c383eaa
TangShanKaiPing
wanggang 5 years ago
parent 2493c3929b
commit e8044e71c9

@ -95,7 +95,7 @@
@Html.Raw(string.Format(copyright, DateTime.Now.Year.ToString())) @Html.Raw(string.Format(copyright, DateTime.Now.Year.ToString()))
</strong> </strong>
<div class="float-right d-none d-sm-inline-block"> <div class="float-right d-none d-sm-inline-block">
<b>v @Helper.Instance.GetVersion()</b> <b>v @Helper.Instance.GetVersion() build @Helper.Instance.GetAssemblyVersion()</b>
</div> </div>
</footer> </footer>
</div> </div>

@ -17,6 +17,11 @@ namespace Infrastructure.Extensions
return Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion; return Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
} }
public static string GetAssemblyVersion(this Helper helper)
{
return Assembly.GetEntryAssembly().GetName().Version?.ToString();
}
public static string GetMacAddress(this Helper helper) public static string GetMacAddress(this Helper helper)
{ {
return NetworkInterface return NetworkInterface

@ -5,7 +5,8 @@
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest> <GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc> <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<Version>1.0.0.427</Version> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Deterministic>false</Deterministic>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -49,5 +50,7 @@
</ItemGroup> </ItemGroup>
 <ItemGroup>  <ItemGroup>
<EmbeddedResource Include="wwwroot\**\*" /> <EmbeddedResource Include="wwwroot\**\*" />
</ItemGroup><ItemGroup>
<Compile Include="..\Version.cs" Link="Version.cs" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -9,21 +9,38 @@ namespace Infrastructure.Web.SignalR
public class BasePageHub : Hub public class BasePageHub : Hub
{ {
public override Task OnConnectedAsync() 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()}"); Debug.WriteLine($"{Context.ConnectionId} has connected which request url is {Context.GetHttpContext().Request.GetUrl()}");
this.Groups.AddToGroupAsync(Context.ConnectionId, Context.ConnectionId); 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); this.Clients.Group(Context.ConnectionId).SendAsync("Connected", Context.ConnectionId);
return base.OnConnectedAsync();
} }
public override Task OnDisconnectedAsync(Exception exception) 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); return base.OnDisconnectedAsync(exception);
} }
protected void OnDisconnected(Exception exception)
{
Debug.WriteLine($"{Context.ConnectionId} has disconnected which request url is {Context.GetHttpContext().Request.GetUrl()}");
}
} }
} }

@ -14,6 +14,9 @@ namespace Application.Domain.Entities
[Required] [Required]
public string Number { get; set; } public string Number { get; set; }
[Display(Name = "在线")]
public bool IsOnline { get; set; }
[Display(Name = "图片")] [Display(Name = "图片")]
public string Image { get; set; } public string Image { get; set; }

@ -16,6 +16,10 @@ namespace Application.Models
[Required(ErrorMessage = nameof(RequiredAttribute))] [Required(ErrorMessage = nameof(RequiredAttribute))]
public string Number { get; set; } public string Number { get; set; }
[Display(Name = "在线")]
[ReadOnly(true)]
public bool IsOnline { get; set; }
[Display(Name = "图片")] [Display(Name = "图片")]
[DataType(DataType.ImageUrl)] [DataType(DataType.ImageUrl)]
public string Image { get; set; } public string Image { get; set; }

@ -5,7 +5,8 @@
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc> <AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest> <GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
<Version>1.0.0.427</Version> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Deterministic>false</Deterministic>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -21,6 +22,9 @@
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="wwwroot\**\*" /> <EmbeddedResource Include="wwwroot\**\*" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Compile Include="..\Version.cs" Link="Version.cs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" /> <ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
</ItemGroup> </ItemGroup>

@ -70,6 +70,42 @@ namespace IoTCenter.Services
this._httpClientFactory = httpClientFactory; 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) public void ServerToClient(string method, string message, string toClient, string fromClient = null)
{ {
Clients.Group(toClient).SendAsync(Methods.ServerToClient, method, message, toClient, fromClient); Clients.Group(toClient).SendAsync(Methods.ServerToClient, method, message, toClient, fromClient);

@ -132,7 +132,7 @@ namespace IoT.Shared.Services
private void InitConnection() private void InitConnection()
{ {
this._notifyHost = GetSetting("notify:host"); 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}"); this._logger.LogDebug($"init connection for {url}");
if (this.Connection != null) if (this.Connection != null)
{ {

@ -2,8 +2,12 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<Version>1.0.0.427</Version> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Deterministic>false</Deterministic>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Include="..\Version.cs" Link="Version.cs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" /> <ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
<ProjectReference Include="..\IoT.Shared\IoT.Shared.csproj" /> <ProjectReference Include="..\IoT.Shared\IoT.Shared.csproj" />

@ -20,6 +20,7 @@ CREATE TABLE "iot_Node" (
"IsDeleted" TEXT NULL, "IsDeleted" TEXT NULL,
"Name" TEXT NULL, "Name" TEXT NULL,
"Number" TEXT NOT NULL, "Number" TEXT NOT NULL,
"IsOnline" INTEGER NOT NULL,
"Image" TEXT NULL, "Image" TEXT NULL,
"Longitude" TEXT NOT NULL, "Longitude" TEXT NOT NULL,
"Latitude" TEXT NOT NULL, "Latitude" TEXT NOT NULL,

@ -97,6 +97,7 @@ namespace IoTNode
Id = $"nodeid-{sn}".ToGuid(), Id = $"nodeid-{sn}".ToGuid(),
Name = "节点", Name = "节点",
Number = sn, Number = sn,
IsOnline = true,
Image = "/images/classroom.png" Image = "/images/classroom.png"
}); });
db.SaveChanges(); db.SaveChanges();

@ -2,8 +2,12 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<Version>1.0.0.427</Version> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Deterministic>false</Deterministic>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Include="..\Version.cs" Link="Version.cs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Hangfire.Core" Version="1.7.11" /> <PackageReference Include="Hangfire.Core" Version="1.7.11" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.11" /> <PackageReference Include="Hangfire.AspNetCore" Version="1.7.11" />

@ -20,6 +20,7 @@ CREATE TABLE "iot_Node" (
"IsDeleted" TEXT NULL, "IsDeleted" TEXT NULL,
"Name" TEXT NULL, "Name" TEXT NULL,
"Number" TEXT NOT NULL, "Number" TEXT NOT NULL,
"IsOnline" INTEGER NOT NULL,
"Image" TEXT NULL, "Image" TEXT NULL,
"Longitude" TEXT NOT NULL, "Longitude" TEXT NOT NULL,
"Latitude" TEXT NOT NULL, "Latitude" TEXT NOT NULL,

@ -3,9 +3,14 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<Version>1.0.0.427</Version> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Deterministic>false</Deterministic>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Include="..\Version.cs" Link="Version.cs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.11" /> <PackageReference Include="Hangfire.AspNetCore" Version="1.7.11" />
<PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" /> <PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" />

@ -2,8 +2,12 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<Version>1.0.0.427</Version> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Deterministic>false</Deterministic>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Include="..\Version.cs" Link="Version.cs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" /> <None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup> </ItemGroup>

@ -2,8 +2,12 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<Version>1.0.0.427</Version> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Deterministic>false</Deterministic>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Include="..\Version.cs" Link="Version.cs" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AspNet.Security.OAuth.GitHub" Version="3.1.0" /> <PackageReference Include="AspNet.Security.OAuth.GitHub" Version="3.1.0" />
<PackageReference Include="AspNet.Security.OAuth.QQ" Version="3.1.0" /> <PackageReference Include="AspNet.Security.OAuth.QQ" Version="3.1.0" />

@ -0,0 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("1.0.0.*")]
[assembly: AssemblyInformationalVersion("1.0.0.428")]

@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.0.0.427</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

@ -2,7 +2,6 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.0.0.427</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

@ -21,6 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
NuGet.config = NuGet.config NuGet.config = NuGet.config
lib\package.json = lib\package.json lib\package.json = lib\package.json
..\README.md = ..\README.md ..\README.md = ..\README.md
Version.cs = Version.cs
EndProjectSection EndProjectSection
ProjectSection(FolderGlobals) = preProject ProjectSection(FolderGlobals) = preProject
C_5_4Users_4wg_4Desktop_4ZHXY_4projects_4lib_4package_1json__JsonSchema = http://json.schemastore.org/project-1.0.0-beta4 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 EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebSPA", "WebSPA\WebSPA.csproj", "{6F839910-580D-4CD1-A0C0-6FAF542B4480}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebSPA", "WebSPA\WebSPA.csproj", "{6F839910-580D-4CD1-A0C0-6FAF542B4480}"
EndProject 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 EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -175,7 +176,7 @@ Global
{6E2766D8-9ECF-469E-8662-A20F673E52CC} = {E1681DC3-9AC2-4FF6-B3DE-37EF826E6F8A} {6E2766D8-9ECF-469E-8662-A20F673E52CC} = {E1681DC3-9AC2-4FF6-B3DE-37EF826E6F8A}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
BuildVersion_StartDate = 2000/1/1
SolutionGuid = {0B7095FB-5E70-4EF8-805A-CB4A91AE4B0A} SolutionGuid = {0B7095FB-5E70-4EF8-805A-CB4A91AE4B0A}
BuildVersion_StartDate = 2000/1/1
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

Loading…
Cancel
Save