|
@@ -24,10 +24,10 @@ namespace fis.Win.Dev.Managers
|
|
|
{
|
|
|
private IList<string> _allPrinterNames;
|
|
|
|
|
|
- Process FrameworkRunner;
|
|
|
- NamedPipeClientStream FisPipeClient;
|
|
|
- StreamReader StreamReader;
|
|
|
- StreamWriter StreamWriter;
|
|
|
+ Process? FrameworkRunner;
|
|
|
+ NamedPipeClientStream? FisPipeClient;
|
|
|
+ StreamReader? StreamReader;
|
|
|
+ StreamWriter? StreamWriter;
|
|
|
|
|
|
public const string ZipExtension = ".zip";
|
|
|
|
|
@@ -64,9 +64,10 @@ namespace fis.Win.Dev.Managers
|
|
|
public void PrintLabels(List<string> labels)
|
|
|
{
|
|
|
Task.Run(() => {
|
|
|
- if (FrameworkRunner == null)
|
|
|
+ if (FrameworkRunner == null || StreamWriter == null || !FisPipeClient.IsConnected)
|
|
|
{
|
|
|
FisPrintDriveInit();
|
|
|
+ Thread.Sleep(1000);
|
|
|
}
|
|
|
foreach (string label in labels)
|
|
|
{
|
|
@@ -77,7 +78,6 @@ namespace fis.Win.Dev.Managers
|
|
|
StreamReader.ReadLine();
|
|
|
Thread.Sleep(200);
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
|
|
|
}
|
|
@@ -132,13 +132,23 @@ namespace fis.Win.Dev.Managers
|
|
|
|
|
|
private void FisPrintDriveInit()
|
|
|
{
|
|
|
+ StreamReader?.Close();
|
|
|
+ StreamWriter?.Close();
|
|
|
+ StreamReader = null;
|
|
|
+ StreamWriter = null;
|
|
|
+ string processName = "FisPrintDrive";
|
|
|
+ Process[] processes = Process.GetProcessesByName(processName);
|
|
|
+ foreach (Process process in processes)
|
|
|
+ {
|
|
|
+ process.Kill();
|
|
|
+ }
|
|
|
ProcessStartInfo startInfo = new ProcessStartInfo
|
|
|
{
|
|
|
FileName = "./FisPrintDrive.exe",
|
|
|
//Debug时FileName可以指定至对应项目的Debug目录,方便调试
|
|
|
//FileName = "F://NetCode//FisPrintDrive//FisPrintDrive//bin//Debug//FisPrintDrive.exe",
|
|
|
UseShellExecute = false,
|
|
|
- CreateNoWindow = true
|
|
|
+ CreateNoWindow = true
|
|
|
};
|
|
|
#if DEBUG
|
|
|
startInfo.CreateNoWindow = false;
|