改进主程序线程

pull/1/head v1.0.3
吴顺明 2 years ago
parent a172677af9
commit aae6fa9301

@ -456,7 +456,7 @@ namespace UMC.Host
{
var key = UMC.Data.Utility.Parse36Encode(UMC.Data.Utility.IntParse(new Guid(UMC.Data.Utility.MD5(UMC.Data.Utility.MapPath("~"))))); ;
using (NamedPipeServerStream pipeServer =
new NamedPipeServerStream($"UMC.{key}", PipeDirection.InOut))
new NamedPipeServerStream($"APIUMC", PipeDirection.InOut))
// new NamedPipeServerStream($"APIUMC", PipeDirection.InOut))
{
do
@ -628,6 +628,15 @@ namespace UMC.Host
}
break;
case "check":
if (str.Length > 1)
{
if (String.Equals(key, str[1]) == false)
{
pipeServer.Write(System.Text.Encoding.UTF8.GetBytes($"主程序目录:{UMC.Data.Utility.MapPath("~")}"));
}
}
break;
case "http":
case "start":
if (str.Length > 1)

@ -21,7 +21,7 @@ namespace UMC.Host
{
public static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += UnhandledException;
var variable = System.Environment.GetEnvironmentVariable("UMC");
@ -92,28 +92,33 @@ namespace UMC.Host
public static bool IsRun()
{
var ls = Utility.Reader(UMC.Data.Utility.MapPath(".lock"));
if (String.IsNullOrEmpty(ls) == false)
using (var pipeClient = new NamedPipeClientStream(".", $"APIUMC", PipeDirection.InOut))
{
var hs = JSON.Deserialize<Hashtable>(ls);
if (hs != null)
try
{
var id = hs["Id"] as string;
try
{
var prc = System.Diagnostics.Process.GetProcessById(Convert.ToInt32(id));
if (prc != null)
{
return true;
}
}
catch
var key = UMC.Data.Utility.Parse36Encode(UMC.Data.Utility.IntParse(new Guid(UMC.Data.Utility.MD5(UMC.Data.Utility.MapPath("~"))))); ;
pipeClient.Connect(10);
pipeClient.Write(System.Text.Encoding.UTF8.GetBytes($"check {key}"));
var ls = new byte[0x200];
var l = pipeClient.Read(ls, 0, ls.Length);
if (l > 0)
{
return false;
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine(System.Text.Encoding.UTF8.GetString(ls, 0, l));
Console.WriteLine();
Console.ResetColor();
}
pipeClient.Close();
return true;
}
catch
{
return false;
}
}
return false;
}
static void Write(params string[] args)
@ -121,7 +126,7 @@ namespace UMC.Host
try
{
var key = UMC.Data.Utility.Parse36Encode(UMC.Data.Utility.IntParse(new Guid(UMC.Data.Utility.MD5(UMC.Data.Utility.MapPath("~"))))); ;
using (var pipeClient = new NamedPipeClientStream(".", $"UMC.{key}", PipeDirection.InOut))
using (var pipeClient = new NamedPipeClientStream(".", $"APIUMC", PipeDirection.InOut))
{
@ -387,17 +392,22 @@ namespace UMC.Host
stream.Flush();
stream.Close();
stream.Dispose();
System.IO.Compression.ZipFile.ExtractToDirectory(downloadFile, UMC.Data.Utility.MapPath("/"), true);
if (native.EndsWith("exe"))
try
{
Utility.Move(UMC.Data.Utility.MapPath("/cavif.exe"), file);
System.IO.Compression.ZipFile.ExtractToDirectory(downloadFile, UMC.Data.Utility.MapPath("/"), true);
if (native.EndsWith("exe"))
{
Utility.Move(UMC.Data.Utility.MapPath("/cavif.exe"), file);
}
else
{
Utility.Move(UMC.Data.Utility.MapPath("/cavif"), file);
}
}
else
catch
{
Utility.Move(UMC.Data.Utility.MapPath("/cavif"), file);
Console.WriteLine($"图片组件下载失败,影响图片功能");
}
File.Delete(downloadFile);
mre.Set();
}

@ -43,6 +43,10 @@
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.3" />
<PackageReference Include="SkiaSharp" Version="2.88.3" />
<PackageReference Include="UMC" Version="1.0.32" />
<PackageReference Include="UMC.Data" Version="1.0.40" />
<PackageReference Include="UMC.Data" Version="1.0.41" />
</ItemGroup>
<ItemGroup>
<!-- <ProjectReference Include="..\UMC\UMC.csproj" />
<ProjectReference Include="..\UMC.Data\UMC.Data.csproj" /> -->
</ItemGroup>
</Project>
Loading…
Cancel
Save