ソースを参照

修复远程控制无法操作的bug

肖奇伟 4 週間 前
コミット
8292e521a6

+ 0 - 15
SCADA_DAQ/Bat/DBPublish.cmd

@@ -1,15 +0,0 @@
-@rem ¸üÐÂÊý¾Ý¿â
-
-@rem TargetDir
-set SrcPath=%1
-set SrcPath=%SrcPath:"=%
-
-@rem ProjectDir
-set ProjectDir=%2
-set ProjectDir=%ProjectDir:"=%
-
-@rem SolutionDir
-set SolutionDir=%3
-set SolutionDir=%SolutionDir:"=%
-
-"C:\Program Files\WinRAR\WinRAR.exe" a -ep1 -o+ -inul -r -ibck  "%ProjectDir%Data\QwPlatform.zip" "%SrcPath%Data\QwPlatform.db"

+ 0 - 12
SCADA_DAQ/Bat/DevicecfgPublish.cmd

@@ -1,12 +0,0 @@
-@rem ¸üÐÂÊý¾Ý¿â
-
-@rem TargetDir
-set SrcPath=%1
-set SrcPath=%SrcPath:"=%
-
-@rem ProjectDir
-set ProjectDir=%2
-set ProjectDir=%ProjectDir:"=%
-
-
-"C:\Program Files\WinRAR\WinRAR.exe" a -ep1 -o+ -inul -r -ibck  "%ProjectDir%Customer\Doc\DeviceCfg.zip" "%SrcPath%DeviceCfg.json"

+ 0 - 10
SCADA_DAQ/Bat/bulid.bat

@@ -1,10 +0,0 @@
-
-set SolutionDir=%1
-set SolutionDir=%SolutionDir:"=%
-
-set SolutionFileName=%1
-set SolutionFileName=%SolutionFileName:"=%
-
-MSBuild %SolutionFileName% /p:Configuration=Debug
-rem  MSBuild D:\ÏîÄ¿´úÂë¹ÜÀí\SCADA_DAQ2023\\"SCADA_DAQ3.0.sln" /p:Configuration=Debug
-pause

+ 6 - 6
SCADA_DAQ/Bat/publish.cmd

@@ -23,7 +23,7 @@ rem BinDir
 set OutDir=%5
 set OutDir=%OutDir:"=%
 set BatDir=%OutDir:"=%
-for %%a in ("%BatDir:~,-8%") do set PublishDirName=%%~nxa
+for %%a in ("%BatDir%..") do set PublishDirName=%%~nxa
 echo 上级目录名为:%PublishDirName%
 
 set TargetPath="D:\项目代码管理\发布管理\Updates\%PublishDirName%\"
@@ -83,11 +83,11 @@ xcopy  "%ProjectDir%Icon\*.*" "%TargetPath%Publish\Content\Img\" /Y
 if exist "%ProjectDir%Tools"  echo F | xcopy  "%ProjectDir%Tools\*.*" "%TargetPath%Publish\Tools\" /Y
 if exist "%ProjectDir%Customer\Doc\DeviceCfg.zip"  xcopy "%ProjectDir%Customer\Doc\DeviceCfg.zip" "%TargetPath%Publish"
 
-xcopy  "%OutDir%\plugin\SCADA.CommonLib.dll" %OutDir%  /Y
-xcopy  "%OutDir%\plugin\SCADA.CommonCtrl.dll" %OutDir%  /Y
-xcopy  "%OutDir%\plugin\SCADA.dll" %OutDir%  /Y
-xcopy  "%OutDir%\plugin\Opc.Ua.*.dll" %OutDir%  /Y
-xcopy  "%OutDir%\plugin\Magick.*.dll" %OutDir%  /Y
+xcopy  "%OutDir%\plugin\SCADA.CommonLib.dll" "%OutDir%"  /Y
+xcopy  "%OutDir%\plugin\SCADA.CommonCtrl.dll" "%OutDir%"  /Y
+xcopy  "%OutDir%\plugin\SCADA.dll" "%OutDir%"  /Y
+xcopy  "%OutDir%\plugin\Opc.Ua.*.dll" "%OutDir%"  /Y
+xcopy  "%OutDir%\plugin\Magick.*.dll" "%OutDir%" /Y
 
 del /f /q "%OutDir%\plugin\SCADA.CommonLib.dll"
 del /f /q "%OutDir%\plugin\SCADA.CommonCtrl.dll" 

BIN
SCADA_DAQ/Customer/Doc/DeviceCfg.zip


+ 21 - 25
SCADA_DAQ/SystemControl.cs

@@ -26,17 +26,13 @@ namespace SCADA_DAQ
         /// </summary>
         bool isShutDown = false;
         ILog Log { get; set; } = null;
-
         private EventWaitHandle evh;
         public App App { get; private set; }
         private static SystemControl systemControl;
-
         private static readonly object syncObj = new object();
-
         private readonly List<AdvanceTimer> Timers = new List<AdvanceTimer>();
         private readonly Task initTask;
         private readonly Task initServer;
-        private ServiceHost host = null;
         public string UidVersion { get; }
 
         private string SoftWareId { get; set; }
@@ -156,9 +152,6 @@ namespace SCADA_DAQ
                 var st = new Stopwatch();
                 st.Start();
                 EicpCoreManage.AppRuntime = App;
-                host = ServiceHost.Instance;
-                (App as IApp).ServiceHost = host;
-                host.Start(App);
                 try
                 {
                     App.RuntimeInfo.StartTime = DateTime.Now;
@@ -175,11 +168,15 @@ namespace SCADA_DAQ
                         { SCADA.CommonLib.LoggerHelper.LogLevel.None,log4net.Core.Level.Off},
                     };
                     LogManager.GetRepository().Threshold = logLevel[App.SystemConfig.LogLevel];
-                    Log.Info($"App {App.RuntimeInfo.ProductId} ({UidVersion}) is starting ……");
+                    Log.Info($"App {App.RuntimeInfo.ProductId} ({UidVersion}) [{App.SystemConfig.ComputerTag}] is starting ……");
                     Task.WaitAll(initServer);
                     Console.WriteLine($"系统初始化完成 {DateTime.Now:yyyy-MM-dd HH:mm:ss,fff}");
                     Func<bool> action = null;
                     LoadLicense();
+                    App.RuntimeInfo.ComputerId = App.RuntimeInfo.LicenseInfo.Computer.ComputerId;
+                    var host = ServiceHost.Instance;
+                    App.ServiceHost = host;
+                    host.Start(App);
                     App.Dispatcher.Invoke(new Action(() =>
                     {
                         if (App.MainWindow is MainWindow window)
@@ -200,7 +197,7 @@ namespace SCADA_DAQ
                     {
                         App.RuntimeInfo.LicenseInfo = LicenseManage.GetLicenseInfo(App.RuntimeInfo.ProductId);
                     }
-                    App.RuntimeInfo.ComputerId = App.RuntimeInfo.LicenseInfo.Computer.ComputerId;
+
 
                     App.Dispatcher.Invoke(new Action(() =>
                     {
@@ -277,19 +274,20 @@ namespace SCADA_DAQ
 
         private void ReportAppInfo(bool isOnline = true)
         {
-            if (App.RuntimeInfo.LicenseInfo != null && (App.RuntimeInfo.LicenseInfo.LicenseType == LicenseType.TempLicense || App.RuntimeInfo.LicenseInfo.LicenseType == LicenseType.Permanentlicense))
+            var license = App.RuntimeInfo.LicenseInfo;
+            if (license != null && (license.LicenseType == LicenseType.TempLicense || license.LicenseType == LicenseType.Permanentlicense))
             {
                 var reportInfo = new
                 {
                     SessionID = App.RuntimeInfo.SessionId,
-                    AppName = App.RuntimeInfo.LicenseInfo?.AppName,
+                    AppName = license?.AppName,
                     Version = UidVersion,
                     CustomerTag = App.SystemConfig.ComputerTag,
-                    ComputerId = App.RuntimeInfo.LicenseInfo?.Computer.ComputerId,
-                    LicenseId = App.RuntimeInfo.LicenseInfo?.LicenseId,
-                    LicenseType = App.RuntimeInfo.LicenseInfo?.LicenseType.ToString(),
-                    ActiveTime = App.RuntimeInfo.LicenseInfo?.ActiveTime,
-                    ExpireDate = App.RuntimeInfo.LicenseInfo?.ActiveTime.AddDays(App.RuntimeInfo.LicenseInfo.ExpireDays),
+                    ComputerId = license?.Computer.ComputerId,
+                    LicenseId = license?.LicenseId,
+                    LicenseType = license?.LicenseType.ToString(),
+                    ActiveTime = license?.ActiveTime,
+                    ExpireDate = license?.ActiveTime.AddDays(license.ExpireDays),
                     TotalOutputPcs = Env.TotalOutputPcs.Value,
                     TotalOutputQty = Env.TotalOutputQty.Value,
                     IsOnline = isOnline
@@ -305,18 +303,17 @@ namespace SCADA_DAQ
         private void FalatReport(Exception exception)
         {
             if (isShutDown) return;
-            if (App.RuntimeInfo.LicenseInfo != null &&
-                (App.RuntimeInfo.LicenseInfo.LicenseType == LicenseType.TempLicense ||
-                App.RuntimeInfo.LicenseInfo.LicenseType == LicenseType.Permanentlicense))
+            var license = App.RuntimeInfo.LicenseInfo;
+            if (license != null && (license.LicenseType == LicenseType.TempLicense || license.LicenseType == LicenseType.Permanentlicense))
             {
                 try
                 {
                     EicpCoreManage.FalatReport(new
                     {
                         SessionID = App.RuntimeInfo.SessionId,
-                        AppName = App.RuntimeInfo.LicenseInfo?.AppName,
+                        AppName = license?.AppName,
                         Version = UidVersion,
-                        ComputerId = App.RuntimeInfo.LicenseInfo?.Computer?.ComputerId,
+                        ComputerId = license?.Computer?.ComputerId,
                         SoftwareID = SoftWareId,
                         Customer = System.Windows.Forms.Application.CompanyName,
                         Message = exception.Message,
@@ -333,7 +330,7 @@ namespace SCADA_DAQ
         }
         public bool RestartHost()
         {
-            return host.Restart();
+            return App.ServiceHost.Restart();
         }
 
         private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
@@ -344,7 +341,6 @@ namespace SCADA_DAQ
             {
                 FalatReport(e.Exception);
             }
-
         }
 
         private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
@@ -373,7 +369,7 @@ namespace SCADA_DAQ
                 {"HCNETSDKLib.zip",null },
                 {"RunTime.zip",null },
                 {"SyntecLib_v4.zip",null},
-                {"FocasLib.zip",AppDomain.CurrentDomain.BaseDirectory },
+                {"Fwlib.zip",AppDomain.CurrentDomain.BaseDirectory },
                 {"DeviceCfg.zip",null},
                 {"x86_x64.zip",null },
             };
@@ -416,7 +412,7 @@ namespace SCADA_DAQ
         public void ApplicationDispose(int exitCode)
         {
             isShutDown = true;
-            if (host != null) host.Stop();
+            App.ServiceHost?.Stop();
             foreach (var item in Timers)
             {
                 item.Dispose();