//場景: spi向printer查詢狀態 (連線時用) //發送IIPrtStatusRequest.txt private bool InquirePrinterStatus() { Log4.PrinterLogger.Info("@InquirePrinterStatus()"); //刪除先前狀態 string inquiredName = _RPCPara.WorkingPath + GetLane() + "IIPrtStatusRequest.txt"; Log4.PrinterLogger.InfoFormat("inquiredName={0}", inquiredName); if (System.IO.File.Exists(inquiredName) == true) { FileProcess.ClearFileReadOnly(inquiredName); Log4.PrinterLogger.InfoFormat("{0} Exists!", inquiredName); try { System.IO.File.Delete(inquiredName); } catch (Exception e) { Log4.PrinterLogger.InfoFormat("Exception:{0}", e.Message); } } //發出更新狀態要求 Log4.PrinterLogger.Info("Request an update..."); System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(); info.WorkingDirectory = _RPCPara.WorkingPath; info.FileName = "PClientExe.exe"; info.Arguments = string.Format("{0} {1}", "IIPrtStatusRequest", GetLane()); Log4.PrinterLogger.InfoFormat("info.WorkingDirectory={0}", info.WorkingDirectory); Log4.PrinterLogger.InfoFormat("info.FileName ={0}", info.FileName); Log4.PrinterLogger.InfoFormat("info.Arguments ={0}", info.Arguments); System.Diagnostics.Process proc = System.Diagnostics.Process.Start(info); proc.WaitForExit(); info = null; //查詢狀態 bool isInquired = false; int msTimer = 500; int msSleep = 5; while (msTimer > 0) { if (System.IO.File.Exists(inquiredName) == true) { isInquired = true; break; } msTimer -= msSleep; System.Threading.Thread.Sleep(msSleep); } Log4.PrinterLogger.InfoFormat("return={0}", isInquired.ToString()); return(isInquired); }