diff --git a/BaseModule/EC.Helper/EC.Helper.csproj b/BaseModule/EC.Helper/EC.Helper.csproj new file mode 100644 index 0000000..4b56119 --- /dev/null +++ b/BaseModule/EC.Helper/EC.Helper.csproj @@ -0,0 +1,12 @@ + + + + net5.0 + + + + + + + + diff --git a/BaseModule/EC.Helper/FileExt/JsonHelper.cs b/BaseModule/EC.Helper/FileExt/JsonHelper.cs new file mode 100644 index 0000000..eee8ffe --- /dev/null +++ b/BaseModule/EC.Helper/FileExt/JsonHelper.cs @@ -0,0 +1,16 @@ +using Microsoft.Extensions.Configuration; +using System.IO; + +namespace EC.Helper.FileExt +{ + public class JsonHelper + { + public static IConfiguration ReadConfiguration(string configPath) + { + ConfigurationBuilder builder = new(); + if (!File.Exists(configPath)) { return builder.Build(); } + builder.AddJsonFile(configPath); + return builder.Build(); + } + } +} \ No newline at end of file diff --git a/OnvifServer-CSharp.sln b/OnvifServer-CSharp.sln index dcc0df0..9839701 100644 --- a/OnvifServer-CSharp.sln +++ b/OnvifServer-CSharp.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.32014.148 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnvifWebServer", "OnvifWebServer\OnvifWebServer.csproj", "{6932E7F3-56E3-4AA5-898C-1C814D53C5F6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OnvifWebServer", "OnvifWebServer\OnvifWebServer.csproj", "{6932E7F3-56E3-4AA5-898C-1C814D53C5F6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OnvifSocketServer", "OnvifSocketServer\OnvifSocketServer.csproj", "{2CC43390-1870-475A-B2F1-5F66C17E27B5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OnvifSocketServer", "OnvifSocketServer\OnvifSocketServer.csproj", "{2CC43390-1870-475A-B2F1-5F66C17E27B5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BaseModule", "BaseModule", "{8D6DAF0C-45FB-4650-8F4F-A63283D32F75}" EndProject @@ -13,14 +13,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BusinessModule", "BusinessM EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EC.Onvif", "BaseModule\EC.Onvif\EC.Onvif.csproj", "{94728605-7159-40DD-861C-4D1B9E8DEA00}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EC.App.Entity", "BusinessModule\EC.App.Entity\EC.App.Entity.csproj", "{2B89CB02-BA09-4140-A3BF-5A02109C080C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EC.App.Entity", "BusinessModule\EC.App.Entity\EC.App.Entity.csproj", "{2B89CB02-BA09-4140-A3BF-5A02109C080C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EC.App", "BaseModule\EC.App\EC.App.csproj", "{7AE950D5-1982-4D76-94F5-A38347AE8263}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EC.App", "BaseModule\EC.App\EC.App.csproj", "{7AE950D5-1982-4D76-94F5-A38347AE8263}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EC.App.ThatBLL", "BusinessModule\EC.App.ThatBLL\EC.App.ThatBLL.csproj", "{D1528FA0-E88B-483A-932C-A682BDD4FF98}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EC.App.ThatBLL", "BusinessModule\EC.App.ThatBLL\EC.App.ThatBLL.csproj", "{D1528FA0-E88B-483A-932C-A682BDD4FF98}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EC.App.ThatService", "BusinessModule\EC.App.ThatService\EC.App.ThatService.csproj", "{EE03CCDB-A280-477B-86FF-B6918169FCDA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EC.Helper", "BaseModule\EC.Helper\EC.Helper.csproj", "{C0AADD2D-7E01-41B3-BE81-433E49D4CA4B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -55,6 +57,10 @@ Global {EE03CCDB-A280-477B-86FF-B6918169FCDA}.Debug|Any CPU.Build.0 = Debug|Any CPU {EE03CCDB-A280-477B-86FF-B6918169FCDA}.Release|Any CPU.ActiveCfg = Release|Any CPU {EE03CCDB-A280-477B-86FF-B6918169FCDA}.Release|Any CPU.Build.0 = Release|Any CPU + {C0AADD2D-7E01-41B3-BE81-433E49D4CA4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C0AADD2D-7E01-41B3-BE81-433E49D4CA4B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C0AADD2D-7E01-41B3-BE81-433E49D4CA4B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C0AADD2D-7E01-41B3-BE81-433E49D4CA4B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -65,6 +71,7 @@ Global {7AE950D5-1982-4D76-94F5-A38347AE8263} = {8D6DAF0C-45FB-4650-8F4F-A63283D32F75} {D1528FA0-E88B-483A-932C-A682BDD4FF98} = {BE926C07-70B6-48E6-9A09-8089AC72DB52} {EE03CCDB-A280-477B-86FF-B6918169FCDA} = {BE926C07-70B6-48E6-9A09-8089AC72DB52} + {C0AADD2D-7E01-41B3-BE81-433E49D4CA4B} = {8D6DAF0C-45FB-4650-8F4F-A63283D32F75} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {94E890EB-BBFB-4C67-9A75-EF7217F2E82B} diff --git a/OnvifSocketServer/Manager/AppConfig.cs b/OnvifSocketServer/Manager/AppConfig.cs new file mode 100644 index 0000000..742fbad --- /dev/null +++ b/OnvifSocketServer/Manager/AppConfig.cs @@ -0,0 +1,52 @@ +using EC.Helper.FileExt; +using Microsoft.Extensions.Configuration; +using System.IO; + +namespace OnvifSocketServer +{ + public class AppConfig + { + #region Attr + + private static IConfiguration config; + + private static IConfiguration Config + { + get + { + if (config == null) + { + string configPath = Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"); + config = JsonHelper.ReadConfiguration(configPath); + } + return config; + } + } + + public static T Get(string key) + { + return Config.GetValue(key); + } + + #endregion Attr + + #region Apis + + public static string GetApi(string key) + { + return Get($"Apis:{key}"); + } + + public static string GetOnvifHttpUrl() + { + return GetApi("onvif_http_url"); + } + + public static string GetOnvifHttpsUrl() + { + return GetApi("onvif_https_url"); + } + + #endregion Apis + } +} \ No newline at end of file diff --git a/OnvifSocketServer/OnvifSocketServer.csproj b/OnvifSocketServer/OnvifSocketServer.csproj index 2082704..097a605 100644 --- a/OnvifSocketServer/OnvifSocketServer.csproj +++ b/OnvifSocketServer/OnvifSocketServer.csproj @@ -5,4 +5,18 @@ net5.0 + + + + + + + + + + + PreserveNewest + + + diff --git a/OnvifSocketServer/Program.cs b/OnvifSocketServer/Program.cs index cd939c9..240be2c 100644 --- a/OnvifSocketServer/Program.cs +++ b/OnvifSocketServer/Program.cs @@ -1,12 +1,25 @@ -using System; +using Flurl; +using Flurl.Http; +using Newtonsoft.Json.Linq; +using System; namespace OnvifSocketServer { - internal class Program + public class Program { - static void Main(string[] args) + public static void Main(string[] args) { Console.WriteLine("Hello World!"); + + string onvifHttpUrl = AppConfig.GetOnvifHttpUrl(); + string onvifHttpsUrl = AppConfig.GetOnvifHttpsUrl(); + Console.WriteLine(onvifHttpUrl, onvifHttpsUrl); + var baseUri = new Uri(onvifHttpUrl); + var absoluteUri = new Uri(baseUri, "onvif/Curd/IsExist"); + JObject result = absoluteUri.AbsoluteUri + .SetQueryParams(new { ip = "192.168.1.105" }) + .GetJsonAsync().Result; + Console.WriteLine(result); } } -} +} \ No newline at end of file diff --git a/OnvifSocketServer/appsettings.json b/OnvifSocketServer/appsettings.json new file mode 100644 index 0000000..74768ad --- /dev/null +++ b/OnvifSocketServer/appsettings.json @@ -0,0 +1,6 @@ +{ + "Apis": { + "onvif_http_url": "http://localhost:5000", + "onvif_https_url": "https://localhost:5001" + } +} \ No newline at end of file diff --git a/OnvifWebServer/OnvifWebServer.csproj b/OnvifWebServer/OnvifWebServer.csproj index 03b94dd..2823dbc 100644 --- a/OnvifWebServer/OnvifWebServer.csproj +++ b/OnvifWebServer/OnvifWebServer.csproj @@ -7,10 +7,6 @@ 6.0 - - - -