diff --git a/projects/IoT/IoT.Shared/Application/Services/NodeService.cs b/projects/IoT/IoT.Shared/Application/Services/NodeService.cs index cda4f10a..14ab648a 100644 --- a/projects/IoT/IoT.Shared/Application/Services/NodeService.cs +++ b/projects/IoT/IoT.Shared/Application/Services/NodeService.cs @@ -27,6 +27,7 @@ namespace Application.Services private readonly IConfiguration _cfg; private CancellationTokenSource _tokenSource; public HubConnection Connection; + private string _notifyHost; public NodeService(IServiceProvider applicationServices, IConfiguration configuration) { @@ -533,7 +534,7 @@ namespace Application.Services while (!_tokenSource.IsCancellationRequested) { this.Connect(); - await Task.Delay(60 * 1000); + await Task.Delay(this._cfg.GetValue("timer.seconds", 60) * 1000); } }); } @@ -552,12 +553,19 @@ namespace Application.Services if (Connection.State == HubConnectionState.Disconnected) { Console.WriteLine("start connect"); - Connection.StartAsync(); + Connection.StartAsync().Wait(); this.Notify(); } else { - Console.WriteLine($"connection is connected"); + if (this._notifyHost != this._cfg["notify:host"]) + { + this.ReConnect(null); + } + else + { + Console.WriteLine($"connection is connected"); + } } } catch (Exception ex) @@ -589,12 +597,13 @@ namespace Application.Services private void InitConnection() { + this._notifyHost = this._cfg["notify:host"]; var url = ""; using (var scope = applicationServices.CreateScope()) { var repo = scope.ServiceProvider.GetService>(); var nodeNumber = repo.ReadOnlyTable().FirstOrDefault().Number; - url = $"http://{this._cfg["notify:host"]}/hub?group={nodeNumber}"; + url = $"http://{this._notifyHost}/hub?group={nodeNumber}"; } this.Connection = new HubConnectionBuilder().WithUrl(url).Build(); this.Connection.Closed += ReConnect; diff --git a/projects/IoT/IoTNode/Program.cs b/projects/IoT/IoTNode/Program.cs index abd5fbc2..640f114e 100644 --- a/projects/IoT/IoTNode/Program.cs +++ b/projects/IoT/IoTNode/Program.cs @@ -24,6 +24,7 @@ namespace IoTNode new EFConfigurationValue { Id = "email:password", Value= "aA123456"}, new EFConfigurationValue { Id = "notify:enabled", Value= "true"}, new EFConfigurationValue { Id = "notify:host", Value= "127.0.0.1:8001"}, + new EFConfigurationValue { Id = "timer.seconds", Value="10"}, new EFConfigurationValue { Id = "influxdb:url", Value= "http://localhost:8086"}, new EFConfigurationValue { Id = "influxdb:usr", Value= "admin"}, new EFConfigurationValue { Id = "influxdb:pwd", Value= "admin"}, diff --git a/projects/IoT/IoTNode/appsettings.json b/projects/IoT/IoTNode/appsettings.json index 6d6ea20e..1688bb00 100644 --- a/projects/IoT/IoTNode/appsettings.json +++ b/projects/IoT/IoTNode/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.100", + "version": "1.0.0-beta.101", "Logging": { "LogLevel": { "Default": "Warning" diff --git a/projects/IoT/IoTServices/APService/Controllers/HomeController.cs b/projects/IoT/IoTServices/APService/Controllers/HomeController.cs index 9bb30879..ca40aaaa 100644 --- a/projects/IoT/IoTServices/APService/Controllers/HomeController.cs +++ b/projects/IoT/IoTServices/APService/Controllers/HomeController.cs @@ -21,6 +21,11 @@ namespace APService.Controllers } public IActionResult Index(string command) + { + return View(); + } + + public IActionResult Test(string command) { var result = string.IsNullOrEmpty(command) ? "" : this._apService.RunCommand(command); ViewBag.Result = result; diff --git a/projects/IoT/IoTServices/APService/Infrastructure/ApService.cs b/projects/IoT/IoTServices/APService/Infrastructure/ApService.cs index 77b855c5..e46c1af8 100644 --- a/projects/IoT/IoTServices/APService/Infrastructure/ApService.cs +++ b/projects/IoT/IoTServices/APService/Infrastructure/ApService.cs @@ -23,10 +23,6 @@ namespace APService private readonly IConfiguration _configuration; private readonly IHttpClientFactory _httpClientFactory; private CancellationTokenSource _tokenSource; - private readonly string _ip; - private readonly int _port; - private readonly string _usr; - private readonly string _pwd; private static readonly object thisLock = new object(); public ApService(IHostingEnvironment env, IConfiguration configuration, IHttpClientFactory httpClientFactory) @@ -34,10 +30,6 @@ namespace APService this._env = env; this._configuration = configuration; this._httpClientFactory = httpClientFactory; - this._ip = this._configuration["ap.ip"]; - this._port = this._configuration.GetValue("ap.port"); - this._usr = this._configuration["ap.usr"]; - this._pwd = this._configuration["ap.pwd"]; } public void Start() @@ -183,7 +175,11 @@ namespace APService { lock (thisLock) { - using (var client = new SshClient(this._ip, this._port, this._usr, this._pwd)) + var ip = this._configuration["ap.ip"]; + var port = this._configuration.GetValue("ap.port"); + var usr = this._configuration["ap.usr"]; + var pwd = this._configuration["ap.pwd"]; + using (var client = new SshClient(ip, port, usr, pwd)) { client.Connect(); using (var stream = client.CreateShellStream("AP", 80, 24, 800, 600, 1024)) @@ -197,12 +193,12 @@ namespace APService reader.ReadToEnd(); //usr - writer.WriteLine(this._usr); + writer.WriteLine(usr); this.Sleep(); reader.ReadToEnd(); //pwd - writer.WriteLine(this._pwd); + writer.WriteLine(pwd); this.Sleep(); reader.ReadToEnd(); diff --git a/projects/IoT/IoTServices/APService/Program.cs b/projects/IoT/IoTServices/APService/Program.cs index 5aa27627..a3aaf9b2 100644 --- a/projects/IoT/IoTServices/APService/Program.cs +++ b/projects/IoT/IoTServices/APService/Program.cs @@ -24,7 +24,7 @@ namespace APService new EFConfigurationValue { Id = "email:user", Value= "admin@nbaxp.com"}, new EFConfigurationValue { Id = "email:password", Value= "aA123456"}, new EFConfigurationValue { Id = "node.url", Value= "127.0.0.1:8002"}, - new EFConfigurationValue { Id = "ap.ip", Value= "192.254.1.1"}, + new EFConfigurationValue { Id = "ap.ip", Value= "192.168.3.1"}, new EFConfigurationValue { Id = "ap.port", Value= "22"}, new EFConfigurationValue { Id = "ap.usr", Value= "super"}, new EFConfigurationValue { Id = "ap.pwd", Value= "sp-admin"}, diff --git a/projects/IoT/IoTServices/APService/Views/Home/Index.cshtml b/projects/IoT/IoTServices/APService/Views/Home/Index.cshtml index e04b7078..e69de29b 100644 --- a/projects/IoT/IoTServices/APService/Views/Home/Index.cshtml +++ b/projects/IoT/IoTServices/APService/Views/Home/Index.cshtml @@ -1,22 +0,0 @@ -@model Infrastructure.Models.NotifyModel - - - - - - - - - - - - - -
设备名称:@Model.Name
设备编号:@Model.Number
设备数据: - - @foreach (var item in Model.Data) - { - - } -
@item.Name@item.Value@item.Unit@item.Description
-
\ No newline at end of file diff --git a/projects/IoT/IoTServices/APService/Views/Home/Test.cshtml b/projects/IoT/IoTServices/APService/Views/Home/Test.cshtml new file mode 100644 index 00000000..e04b7078 --- /dev/null +++ b/projects/IoT/IoTServices/APService/Views/Home/Test.cshtml @@ -0,0 +1,22 @@ +@model Infrastructure.Models.NotifyModel + + + + + + + + + + + + + +
设备名称:@Model.Name
设备编号:@Model.Number
设备数据: + + @foreach (var item in Model.Data) + { + + } +
@item.Name@item.Value@item.Unit@item.Description
+
\ No newline at end of file diff --git a/projects/IoT/IoTServices/APService/Views/Shared/_Menu.cshtml b/projects/IoT/IoTServices/APService/Views/Shared/_Menu.cshtml index 29286277..547d75fc 100644 --- a/projects/IoT/IoTServices/APService/Views/Shared/_Menu.cshtml +++ b/projects/IoT/IoTServices/APService/Views/Shared/_Menu.cshtml @@ -4,6 +4,11 @@ 首页 +
  • + + 测试 + +
  • Open API diff --git a/projects/IoT/IoTServices/APService/appsettings.json b/projects/IoT/IoTServices/APService/appsettings.json index bb4a50c0..640c2946 100644 --- a/projects/IoT/IoTServices/APService/appsettings.json +++ b/projects/IoT/IoTServices/APService/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.100", + "version": "1.0.0-beta.101", "Logging": { "LogLevel": { "Default": "Warning" diff --git a/projects/IoT/IoTServices/LiChuangService/appsettings.json b/projects/IoT/IoTServices/LiChuangService/appsettings.json index d7dce16e..6b15dfeb 100644 --- a/projects/IoT/IoTServices/LiChuangService/appsettings.json +++ b/projects/IoT/IoTServices/LiChuangService/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.100", + "version": "1.0.0-beta.101", "Logging": { "LogLevel": { "Default": "Information" diff --git a/projects/IoT/IoTServices/NJWLService/src/main/resources/application.properties b/projects/IoT/IoTServices/NJWLService/src/main/resources/application.properties index bc6d7077..194806cf 100644 --- a/projects/IoT/IoTServices/NJWLService/src/main/resources/application.properties +++ b/projects/IoT/IoTServices/NJWLService/src/main/resources/application.properties @@ -1,4 +1,4 @@ -version=1.0.0-beta.100 +version=1.0.0-beta.101 server.host=127.0.0.1 server.port=8003 spring.thymeleaf.cache=false diff --git a/projects/IoT/IoTServices/ONVIFService/appsettings.json b/projects/IoT/IoTServices/ONVIFService/appsettings.json index 4da849fa..c65751f8 100644 --- a/projects/IoT/IoTServices/ONVIFService/appsettings.json +++ b/projects/IoT/IoTServices/ONVIFService/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.100", + "version": "1.0.0-beta.101", "Logging": { "LogLevel": { "Default": "Information" diff --git a/projects/IoT/IoTServices/SerialPortService/appsettings.json b/projects/IoT/IoTServices/SerialPortService/appsettings.json index 4da849fa..c65751f8 100644 --- a/projects/IoT/IoTServices/SerialPortService/appsettings.json +++ b/projects/IoT/IoTServices/SerialPortService/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.100", + "version": "1.0.0-beta.101", "Logging": { "LogLevel": { "Default": "Information" diff --git a/projects/IoT/IoTServices/WinService/appsettings.json b/projects/IoT/IoTServices/WinService/appsettings.json index bb4a50c0..640c2946 100644 --- a/projects/IoT/IoTServices/WinService/appsettings.json +++ b/projects/IoT/IoTServices/WinService/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.100", + "version": "1.0.0-beta.101", "Logging": { "LogLevel": { "Default": "Warning" diff --git a/projects/IoTCenter/appsettings.json b/projects/IoTCenter/appsettings.json index 2e69ecf4..d19ef3bc 100644 --- a/projects/IoTCenter/appsettings.json +++ b/projects/IoTCenter/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.100", + "version": "1.0.0-beta.101", "Logging": { "LogLevel": { "Default": "Warning" diff --git a/projects/StudyCenter/appsettings.json b/projects/StudyCenter/appsettings.json index 872b852e..1b2bde0a 100644 --- a/projects/StudyCenter/appsettings.json +++ b/projects/StudyCenter/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.100", + "version": "1.0.0-beta.101", "Logging": { "LogLevel": { "Default": "Warning" diff --git a/projects/UserCenter/appsettings.json b/projects/UserCenter/appsettings.json index abe8420b..cbad46dd 100644 --- a/projects/UserCenter/appsettings.json +++ b/projects/UserCenter/appsettings.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-beta.100", + "version": "1.0.0-beta.101", "Logging": { "LogLevel": { "Default": "Warning" @@ -16,7 +16,7 @@ }, //Ocelot config "GlobalConfiguration": { - "BaseUrl": "http://192.168.3.124:8000/" + "BaseUrl": "http://192.168.3.83:8000/" }, "ReRoutes": [ { @@ -24,7 +24,7 @@ "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { - "Host": "192.168.3.124", + "Host": "192.168.3.83", "Port": 8001 } ],