diff --git a/projects/CheckSum/.gitignore b/projects/CheckSum/.gitignore new file mode 100644 index 00000000..cd5894bd --- /dev/null +++ b/projects/CheckSum/.gitignore @@ -0,0 +1,18 @@ +*.bak +*.suo +*.db +*.db-shm +*.db-wal +*.user +.vs +obj +Obj +bin +Bin +debug +Debug +release +Release +Logs +logs +node_modules \ No newline at end of file diff --git a/projects/CheckSum/CheckSum.csproj b/projects/CheckSum/CheckSum.csproj new file mode 100644 index 00000000..c73e0d16 --- /dev/null +++ b/projects/CheckSum/CheckSum.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/projects/CheckSum/Program.cs b/projects/CheckSum/Program.cs new file mode 100644 index 00000000..4604df35 --- /dev/null +++ b/projects/CheckSum/Program.cs @@ -0,0 +1,35 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using System.Text; + +namespace CheckSum +{ + internal class Program + { + private static void Main(string[] args) + { + Console.InputEncoding = Encoding.UTF8; + Console.OutputEncoding = Encoding.UTF8; + using var sha = SHA512.Create(); + while (true) + { + Console.WriteLine("input file name:"); + var file = Console.ReadLine(); + if (File.Exists(file)) + { + Console.WriteLine(BitConverter.ToString(sha.ComputeHash(File.ReadAllBytes(file))).Replace("-", "").ToLower()); + } + else + { + Console.WriteLine($"file {file} does not Exist"); + } + var key = Console.ReadKey().Key; + if (key == ConsoleKey.Enter || key == ConsoleKey.Escape) + { + break; + } + } + } + } +} \ No newline at end of file diff --git a/projects/Infrastructure/Data/EfDbContext.cs b/projects/Infrastructure/Data/EfDbContext.cs index 63c49a72..3718ccc1 100644 --- a/projects/Infrastructure/Data/EfDbContext.cs +++ b/projects/Infrastructure/Data/EfDbContext.cs @@ -8,7 +8,6 @@ using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Diagnostics; using System.Linq; namespace Infrastructure.Data @@ -18,6 +17,7 @@ namespace Infrastructure.Data public static readonly ILoggerFactory MyLoggerFactory = LoggerFactory.Create(builder => { builder.AddDebug(); + builder.AddConsole(); }); private readonly ILogger _logger; diff --git a/projects/Infrastructure/Web/BaseStartup.cs b/projects/Infrastructure/Web/BaseStartup.cs index e5e01f91..fa2edcf9 100644 --- a/projects/Infrastructure/Web/BaseStartup.cs +++ b/projects/Infrastructure/Web/BaseStartup.cs @@ -368,17 +368,14 @@ namespace Infrastructure.Web var context = services.GetService(); if (context.Database.EnsureCreated()) { - if (!Env.IsDevelopment()) + var sql = context.GetService().GenerateCreateScript(); + var file = "db.sql"; + if (File.Exists(file)) { - var sql = context.GetService().GenerateCreateScript(); - var file = "db.sql"; - if (File.Exists(file)) - { - File.Delete(file); - } - using var fs = File.CreateText(file); - fs.Write(sql); + File.Delete(file); } + using var fs = File.CreateText(file); + fs.Write(sql); using var scope = services.CreateScope(); scope.ServiceProvider.GetService().Seed(context); } diff --git a/projects/IoTCenter/wwwroot/dameon.temp.xml b/projects/IoTCenter/wwwroot/dameon.temp.xml new file mode 100644 index 00000000..b0bee291 --- /dev/null +++ b/projects/IoTCenter/wwwroot/dameon.temp.xml @@ -0,0 +1,5 @@ + + + 1.0.0.20082401 + + \ No newline at end of file diff --git a/projects/IoTDameon/Controllers/HomeController.cs b/projects/IoTDameon/Controllers/HomeController.cs index 4bbc6a6a..ac05a95b 100644 --- a/projects/IoTDameon/Controllers/HomeController.cs +++ b/projects/IoTDameon/Controllers/HomeController.cs @@ -1,6 +1,5 @@ using CookComputing.XmlRpc; using Microsoft.AspNetCore.Mvc; -using System; using System.Net; using System.Net.Http; using System.Reflection; @@ -16,13 +15,30 @@ namespace IoTDameon.Controllers _httpClientFactory = httpClientFactory; } - //public IActionResult Index() - //{ - // var proxy = XmlRpcProxyGen.Create(); - // proxy.Credentials = new NetworkCredential("usr", "pwd"); - // var result = ""proxy.SystemListMethods(); - // return Content(result); - //} + public IActionResult Index() + { + this.Process(); + return Content(""); + } + + private void Process(bool stop = false) + { + try + { + var proxy = XmlRpcProxyGen.Create(); + proxy.Url = "http://192.168.1.3:9001/RPC2"; + proxy.Credentials = new NetworkCredential("usr", "pwd"); + var result = stop ? proxy.stopProcess("iotnode") : proxy.startProcess("iotnode"); + } + catch (XmlRpcFaultException ex) + { + //start:60 stop:70 + if (ex.FaultCode != 60 && ex.FaultCode != 70) + { + throw ex; + } + } + } public IActionResult GetVersion() { diff --git a/projects/IoTDameon/Controllers/ISupervisorService.cs b/projects/IoTDameon/Controllers/ISupervisorService.cs new file mode 100644 index 00000000..5cfe8edc --- /dev/null +++ b/projects/IoTDameon/Controllers/ISupervisorService.cs @@ -0,0 +1,19 @@ +using CookComputing.XmlRpc; + +namespace IoTDameon.Controllers +{ + public interface ISupervisorService : IXmlRpcProxy + { + [XmlRpcMethod("supervisor.getAllProcessInfo")] + XmlRpcStruct getAllProcessInfo(); + + [XmlRpcMethod("supervisor.getProcessInfo")]//result["statename"]: "RUNNING" or "STOPPED" + XmlRpcStruct getProcessInfo(string name); + + [XmlRpcMethod("supervisor.startProcess")] + bool startProcess(string name); + + [XmlRpcMethod("supervisor.stopProcess")] + bool stopProcess(string name); + } +} \ No newline at end of file diff --git a/projects/IoTDameon/ISupervisor.cs b/projects/IoTDameon/ISupervisor.cs deleted file mode 100644 index 5ef7538c..00000000 --- a/projects/IoTDameon/ISupervisor.cs +++ /dev/null @@ -1,11 +0,0 @@ -using CookComputing.XmlRpc; - -namespace IoTDameon -{ - [XmlRpcUrl("http://192.168.1.3:9001/RPC2")] - public interface ISupervisor - { - [XmlRpcMethod("system.listMethods")] - string SystemListMethods(); - } -} \ No newline at end of file diff --git a/projects/IoTDameon/IoTDameon.csproj b/projects/IoTDameon/IoTDameon.csproj index 930ba18a..1d2240dd 100644 --- a/projects/IoTDameon/IoTDameon.csproj +++ b/projects/IoTDameon/IoTDameon.csproj @@ -9,9 +9,9 @@ + - \ No newline at end of file diff --git a/projects/IoTNode/update.ts.sql b/projects/IoTNode/update.temp.sql similarity index 100% rename from projects/IoTNode/update.ts.sql rename to projects/IoTNode/update.temp.sql diff --git a/projects/Version.cs b/projects/Version.cs index 997fa606..cc72c5b6 100644 --- a/projects/Version.cs +++ b/projects/Version.cs @@ -1,4 +1,4 @@ using System.Reflection; [assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyInformationalVersion("1.0.0.0824d3")] \ No newline at end of file +[assembly: AssemblyInformationalVersion("1.0.0.20082501")] \ No newline at end of file diff --git a/projects/projects.sln b/projects/projects.sln index 3b09b09e..28646a8e 100644 --- a/projects/projects.sln +++ b/projects/projects.sln @@ -42,7 +42,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebSPA", "WebSPA\WebSPA.csp EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JobServer", "JobServer\JobServer.csproj", "{6E2766D8-9ECF-469E-8662-A20F673E52CC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IoTDameon", "IoTDameon\IoTDameon.csproj", "{60596088-3C4E-4EA2-933A-B66CD269845B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTDameon", "IoTDameon\IoTDameon.csproj", "{60596088-3C4E-4EA2-933A-B66CD269845B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CheckSum", "CheckSum\CheckSum.csproj", "{EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -174,6 +176,18 @@ Global {60596088-3C4E-4EA2-933A-B66CD269845B}.Release|iPhone.Build.0 = Release|Any CPU {60596088-3C4E-4EA2-933A-B66CD269845B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {60596088-3C4E-4EA2-933A-B66CD269845B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}.Debug|iPhone.Build.0 = Debug|Any CPU + {EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}.Release|Any CPU.Build.0 = Release|Any CPU + {EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}.Release|iPhone.ActiveCfg = Release|Any CPU + {EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}.Release|iPhone.Build.0 = Release|Any CPU + {EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {EE34BB0E-41F3-4F2A-853E-FBFBCF421A5B}.Release|iPhoneSimulator.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -191,7 +205,7 @@ Global {60596088-3C4E-4EA2-933A-B66CD269845B} = {AE34E06D-C5C7-44BC-B168-85808318516C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - BuildVersion_StartDate = 2000/1/1 SolutionGuid = {0B7095FB-5E70-4EF8-805A-CB4A91AE4B0A} + BuildVersion_StartDate = 2000/1/1 EndGlobalSection EndGlobal diff --git a/publish/build.ps1 b/publish/build.ps1 index 28101e0e..d8cff958 100644 --- a/publish/build.ps1 +++ b/publish/build.ps1 @@ -17,4 +17,7 @@ Copy-Item ../projects/WebSPA/wwwroot/* ./dist/linux-x64/publish/apps/WebSPA/www dotnet publish ../projects/UserCenter/UserCenter.csproj -c Release -r linux-x64 -o ../publish/dist/linux-x64/publish/apps/UserCenter dotnet publish ../projects/JobServer/JobServer.csproj -c Release -r linux-x64 -o ../publish/dist/linux-x64/publish/apps/JobServer dotnet publish ../projects/IoTCenter/IoTCenter.csproj -c Release -r linux-x64 -o ../publish/dist/linux-x64/publish/apps/IoTCenter -dotnet publish ../projects/IoTNode/IoTNode.csproj -c Release -r linux-arm64 -o ../publish/dist/linux-arm64/publish/apps/IoTNode \ No newline at end of file + + +dotnet publish ../projects/IoTNode/IoTNode.csproj -c Release -r linux-arm64 -o ../publish/dist/linux-arm64/publish/apps/IoTNode +dotnet publish ../projects/IoTDameon/IoTDameon.csproj -c Release -r linux-arm64 -o ../publish/dist/linux-arm64/publish/apps/IoTDameon \ No newline at end of file diff --git a/publish/src/linux-arm64/publish/supervisor/iotdameon.conf b/publish/src/linux-arm64/publish/supervisor/iotdameon.conf new file mode 100644 index 00000000..72561fbb --- /dev/null +++ b/publish/src/linux-arm64/publish/supervisor/iotdameon.conf @@ -0,0 +1,6 @@ +[program:iotdameon] +directory=/root/publish/apps/IoTDameon/ +command=/root/publish/apps/IoTDameon/IoTDameon +autostart=true +autorestart=true +user=root \ No newline at end of file