|
@@ -6,20 +6,20 @@ namespace WingCloudServer.Loader
|
|
|
{
|
|
|
public class ProcessStarter
|
|
|
{
|
|
|
- private ProcessStarter(){}
|
|
|
+ private ProcessStarter() { }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 开始执行工具程序
|
|
|
/// </summary>
|
|
|
/// <param name="processName">工具程序名称</param>
|
|
|
- public static void StartTool(string processName, string paramsValue="")
|
|
|
+ public static void StartTool(string processName, string paramsValue = "")
|
|
|
{
|
|
|
- var toolsRootPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Tools");
|
|
|
+ var toolsRootPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Tools");
|
|
|
var subPath = GetPlatfromTitle();
|
|
|
- var tool = Path.Combine(toolsRootPath,subPath, $"{subPath}_{processName}");
|
|
|
+ var tool = Path.Combine(toolsRootPath, subPath, $"{subPath}_{processName}");
|
|
|
if (Process.GetProcessesByName(Path.GetFileName(tool)).Length == 0)
|
|
|
- {
|
|
|
- using(Process process = new Process())
|
|
|
+ {
|
|
|
+ using (Process process = new Process())
|
|
|
{
|
|
|
process.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
|
|
process.StartInfo.FileName = tool;
|
|
@@ -29,6 +29,18 @@ namespace WingCloudServer.Loader
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 开始执行工具程序
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="processName">工具程序名称</param>
|
|
|
+ public static void StartProcess(string path)
|
|
|
+ {
|
|
|
+ Process process = new Process();
|
|
|
+ process.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory;
|
|
|
+ process.StartInfo.FileName = path;
|
|
|
+ //process.StartInfo.Arguments = paramsValue;
|
|
|
+ process.Start();
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 停止工具程序
|
|
|
/// </summary>
|
|
@@ -36,14 +48,14 @@ namespace WingCloudServer.Loader
|
|
|
public static void StopTool(string processName)
|
|
|
{
|
|
|
var proc = Process.GetProcessesByName($"{GetPlatfromTitle()}_{processName}");
|
|
|
- foreach(var p in proc)
|
|
|
+ foreach (var p in proc)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
Console.WriteLine($"close {p.ProcessName}");
|
|
|
Process.GetProcessById(p.Id).Kill();
|
|
|
}
|
|
|
- catch(Exception pex)
|
|
|
+ catch (Exception pex)
|
|
|
{
|
|
|
Console.WriteLine($"{pex}");
|
|
|
}
|
|
@@ -53,17 +65,17 @@ namespace WingCloudServer.Loader
|
|
|
private static string GetPlatfromTitle()
|
|
|
{
|
|
|
string platfrom;
|
|
|
- switch(Environment.OSVersion.Platform)
|
|
|
+ switch (Environment.OSVersion.Platform)
|
|
|
{
|
|
|
case PlatformID.Win32NT:
|
|
|
platfrom = "win";
|
|
|
- break;
|
|
|
+ break;
|
|
|
case PlatformID.MacOSX:
|
|
|
platfrom = "mac";
|
|
|
- break;
|
|
|
+ break;
|
|
|
default:
|
|
|
platfrom = "lin";
|
|
|
- break;
|
|
|
+ break;
|
|
|
}
|
|
|
return platfrom;
|
|
|
}
|