Преглед на файлове

检查有没有AS启动

刘彬 преди 2 седмици
родител
ревизия
07ca107a2e
променени са 1 файла, в които са добавени 11 реда и са изтрити 8 реда
  1. 11 8
      LocalhostMES/App.xaml.cs

+ 11 - 8
LocalhostMES/App.xaml.cs

@@ -52,21 +52,24 @@ namespace LocalhostMES
             try
             {
                 var systemSettingsViewModel = Container.Resolve<SystemSettingsViewModel>();
-                systemSettingsViewModel.SaveSettings();
                 systemSettingsViewModel.StartService();
-
+                systemSettingsViewModel.SaveSettings();
                 Container.Resolve<SystemSettingsViewModel>().StartService();
-                Process.Start(@"D:\HANS LASER\TeamAAS-VP.exe");
+                bool isRunning = Process.GetProcessesByName("TeamAAS-VM").Length > 0;
+                if ( !isRunning )
+                {
+                    Process.Start(@"D:\HANS LASER\TeamAAS-VP.exe");
+                }
             }
-            catch (Exception ex)
+            catch ( Exception ex )
             {
-                MessageBox.Show( $"启动自动初始化系统设置失败: {ex.Message}");
+                MessageBox.Show($"启动自动初始化系统设置失败: {ex.Message}");
             }
         }
         private static System.Threading.Mutex mutex;
         protected override void OnStartup(StartupEventArgs e)
         {
-           
+
 
             mutex = new System.Threading.Mutex(true, "LocalhostMes_CRNS");
             if ( mutex.WaitOne(0, false) )
@@ -79,9 +82,9 @@ namespace LocalhostMES
                 this.Shutdown();
             }
         }
- 
 
-       
+
+
     }
 }