From 2511ba50a85a8b60a8ef4429bb50c11f000d63a1 Mon Sep 17 00:00:00 2001 From: Candy Date: Fri, 25 Sep 2020 15:41:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=B8=B8=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Develop/DBDevelopService/GrpcDBService.cs | 1 + Develop/DBDevelopService/Service.cs | 25 ++- Develop/DBDevelopService/WebAPIDBService.cs | 10 +- Develop/DBStudio/Program.cs | 32 ++- .../Properties/Resources.Designer.cs | 9 + .../Properties/Resources.resx | 3 + .../Properties/Resources.zh-CN.resx | 3 + .../Properties/launchSettings.json | 2 +- .../ViewModel/LoginViewModel.cs | 11 +- .../SpiderDriverDemo/MainWindow.xaml | 3 +- .../SpiderDriverDemo/MainWindow.xaml.cs | 18 ++ .../Compress/Special/LosslessCompressUnit2.cs | 40 ++-- .../His/Compress/Special/NoneCompressUnit2.cs | 192 +++++++++--------- 13 files changed, 212 insertions(+), 137 deletions(-) diff --git a/Develop/DBDevelopService/GrpcDBService.cs b/Develop/DBDevelopService/GrpcDBService.cs index 4087882..df972cb 100644 --- a/Develop/DBDevelopService/GrpcDBService.cs +++ b/Develop/DBDevelopService/GrpcDBService.cs @@ -56,6 +56,7 @@ namespace DBDevelopService { try { + LoggerService.Service.Info("GrpcDBService", "Ready to start to GrpcDBService......"); StartAsync("0.0.0.0", port); } catch(Exception ex) diff --git a/Develop/DBDevelopService/Service.cs b/Develop/DBDevelopService/Service.cs index f512849..5b28489 100644 --- a/Develop/DBDevelopService/Service.cs +++ b/Develop/DBDevelopService/Service.cs @@ -32,8 +32,9 @@ namespace DBDevelopService DBDevelopService.SecurityManager.Manager.Init(); //驱动初始化 Cdy.Tag.DriverManager.Manager.Init(); - //注册日志 - ServiceLocator.Locator.Registor(new ConsoleLogger()); + + ////注册日志 + //ServiceLocator.Locator.Registor(new ConsoleLogger()); } #endregion ...Constructor... @@ -49,12 +50,20 @@ namespace DBDevelopService /// public void Start(int grpcPort = 5001, int webSocketPort = 8000, bool isEnableGrpc = true, bool isEnableWebApi = true) { - DbManager.Instance.Load(); - if (isEnableGrpc) - grpcDBService.Start(grpcPort); - - if (isEnableWebApi) - webDBService.Start(webSocketPort); + try + { + LoggerService.Service.Info("Service", "Ready to start...."); + DbManager.Instance.Load(); + if (isEnableGrpc) + grpcDBService.Start(grpcPort); + + if (isEnableWebApi) + webDBService.Start(webSocketPort); + } + catch(Exception ex) + { + LoggerService.Service.Erro("Service","start "+ ex.Message); + } } /// diff --git a/Develop/DBDevelopService/WebAPIDBService.cs b/Develop/DBDevelopService/WebAPIDBService.cs index b78e32e..fc2409e 100644 --- a/Develop/DBDevelopService/WebAPIDBService.cs +++ b/Develop/DBDevelopService/WebAPIDBService.cs @@ -43,7 +43,15 @@ namespace DBDevelopService /// public void Start(int port) { - StartAsync("0.0.0.0", port); + try + { + LoggerService.Service.Info("WebAPIDBService", "Ready to start to WebAPI DBService....."); + StartAsync("0.0.0.0", port); + } + catch(Exception ex) + { + LoggerService.Service.Erro("WebAPIDBService", ex.Message); + } } /// diff --git a/Develop/DBStudio/Program.cs b/Develop/DBStudio/Program.cs index 4e46b08..25602cd 100644 --- a/Develop/DBStudio/Program.cs +++ b/Develop/DBStudio/Program.cs @@ -63,7 +63,7 @@ namespace DBStudio /// /// /// - public bool IsGrpcEnable { get; set; } + public bool IsGrpcEnable { get; set; } = true; /// /// @@ -79,14 +79,24 @@ namespace DBStudio /// public void Load() { - string spath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.GetType().Assembly.FullName), "DbInStudioServer.cfg"); - if(System.IO.File.Exists(spath)) + try + { + string spath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.GetType().Assembly.Location), "DbInStudioServer.cfg"); + + LoggerService.Service.Info("Config", "Start to load config"); + + if (System.IO.File.Exists(spath)) + { + var xxx = XElement.Load(spath); + this.IsWebApiEnable = bool.Parse(xxx.Attribute("IsWebApiEnable")?.Value); + this.IsGrpcEnable = bool.Parse(xxx.Attribute("IsGrpcEnable")?.Value); + this.WebApiPort = int.Parse(xxx.Attribute("WebApiPort")?.Value); + this.GrpcPort = int.Parse(xxx.Attribute("GrpcPort")?.Value); + } + } + catch(Exception ex) { - var xxx = XElement.Load(spath); - this.IsWebApiEnable = bool.Parse(xxx.Attribute("IsWebApiEnable")?.Value); - this.IsGrpcEnable = bool.Parse(xxx.Attribute("IsGrpcEnable")?.Value); - this.WebApiPort = int.Parse(xxx.Attribute("WebApiPort")?.Value); - this.GrpcPort = int.Parse(xxx.Attribute("GrpcPort")?.Value); + LoggerService.Service.Erro("Config", ex.Message); } } @@ -100,6 +110,10 @@ namespace DBStudio static void Main(string[] args) { + LogoHelper.Print(); + + //注册日志 + ServiceLocator.Locator.Registor(new ConsoleLogger()); Program pg = new Program(); Config.Instance.Load(); @@ -123,7 +137,7 @@ namespace DBStudio AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; - LogoHelper.Print(); + DBDevelopService.Service.Instanse.Start(port, webPort,Config.Instance.IsGrpcEnable,Config.Instance.IsWebApiEnable); Thread.Sleep(100); diff --git a/Develop/DbManager.Desktop/Properties/Resources.Designer.cs b/Develop/DbManager.Desktop/Properties/Resources.Designer.cs index da41206..5050325 100644 --- a/Develop/DbManager.Desktop/Properties/Resources.Designer.cs +++ b/Develop/DbManager.Desktop/Properties/Resources.Designer.cs @@ -384,6 +384,15 @@ namespace DBInStudio.Desktop.Properties { } } + /// + /// 查找类似 Manual 的本地化字符串。 + /// + internal static string Manual { + get { + return ResourceManager.GetString("Manual", resourceCulture); + } + } + /// /// 查找类似 Welcome to Mars realtime iot database 的本地化字符串。 /// diff --git a/Develop/DbManager.Desktop/Properties/Resources.resx b/Develop/DbManager.Desktop/Properties/Resources.resx index 0a42803..1a0450b 100644 --- a/Develop/DbManager.Desktop/Properties/Resources.resx +++ b/Develop/DbManager.Desktop/Properties/Resources.resx @@ -227,6 +227,9 @@ Mars database developer + + Manual + Welcome to Mars realtime iot database diff --git a/Develop/DbManager.Desktop/Properties/Resources.zh-CN.resx b/Develop/DbManager.Desktop/Properties/Resources.zh-CN.resx index 1e048a5..feba998 100644 --- a/Develop/DbManager.Desktop/Properties/Resources.zh-CN.resx +++ b/Develop/DbManager.Desktop/Properties/Resources.zh-CN.resx @@ -227,6 +227,9 @@ Mars数据库开发平台 + + 手动 + 欢迎来到Mars实时物联数据库 diff --git a/Develop/DbManager.Desktop/Properties/launchSettings.json b/Develop/DbManager.Desktop/Properties/launchSettings.json index 4cfb86d..e480c59 100644 --- a/Develop/DbManager.Desktop/Properties/launchSettings.json +++ b/Develop/DbManager.Desktop/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "DBInStudio.Desktop": { "commandName": "Executable", - "executablePath": "C:\\Users\\cdy81\\source\\repos\\mars\\Output\\DBInStudio.exe" + "executablePath": "C:\\Users\\chongdaoyang\\source\\repos\\mars\\Output\\DBInStudio.exe" } } } \ No newline at end of file diff --git a/Develop/DbManager.Desktop/ViewModel/LoginViewModel.cs b/Develop/DbManager.Desktop/ViewModel/LoginViewModel.cs index 0a603de..122bba4 100644 --- a/Develop/DbManager.Desktop/ViewModel/LoginViewModel.cs +++ b/Develop/DbManager.Desktop/ViewModel/LoginViewModel.cs @@ -176,9 +176,18 @@ namespace DBInStudio.Desktop.ViewModel if(mServer=="127.0.0.1"||mServer=="localhost") { var pps = Process.GetProcessesByName("DBInStudioServer"); + if(pps==null||pps.Length==0) { - Process.Start("DBInStudioServer.exe").WaitForExit(5000); + try + { + var vfile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(this.GetType().Assembly.Location), "DBInStudioServer.exe"); + Process.Start(vfile).WaitForExit(5000); + } + catch + { + + } } } } diff --git a/Example/Producter/SpiderDriverDemo/MainWindow.xaml b/Example/Producter/SpiderDriverDemo/MainWindow.xaml index b5f03b2..b8f2655 100644 --- a/Example/Producter/SpiderDriverDemo/MainWindow.xaml +++ b/Example/Producter/SpiderDriverDemo/MainWindow.xaml @@ -5,7 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:SpiderDriverDemo" mc:Ignorable="d" - Title="SpiderSim" Height="290" Width="634"> + Title="SpiderSim" Height="353" Width="634">