//--------------------------------------------------------------------// // M e t h o d // // r e s p o n s e C l o s e C o n n e c t i o n // //--------------------------------------------------------------------// // // // Close connection (after having read response block(s)). // // // //--------------------------------------------------------------------// public static void responseCloseConnection() { if ((_targetType == eTarget.NetPrinter) && (_binWriter != null)) { TargetNetPrint.closeResponseConnection(); } }
//--------------------------------------------------------------------// // M e t h o d // // r e s p o n s e R e a d B l o c k // //--------------------------------------------------------------------// // // // Read response block into supplied buffer. // // // //--------------------------------------------------------------------// public static Boolean responseReadBlock(Int32 offset, Int32 bufRem, ref Byte[] replyData, ref Int32 blockLen) { Boolean OK = true; //----------------------------------------------------------------// // // // Read response block from target. // // // //----------------------------------------------------------------// if ((_targetType == eTarget.NetPrinter) && (_binWriter != null)) { OK = TargetNetPrint.readResponseBlock(offset, bufRem, ref replyData, ref blockLen); } return(OK); }
//--------------------------------------------------------------------// // M e t h o d // // r e q u e s t S t r e a m W r i t e // //--------------------------------------------------------------------// // // // Write print job / request stream to target device. // // // //--------------------------------------------------------------------// public static void requestStreamWrite(Boolean keepNetConnect) { if ((_targetType == eTarget.NetPrinter) && (_binWriter != null)) { //------------------------------------------------------------// // // // Output to network printer port. // // // //------------------------------------------------------------// Boolean OK; IPAddress ipAddress = new IPAddress(0x00); OK = TargetNetPrint.checkIPAddress(_netPrinterAddress, ref ipAddress); if (!OK) { MessageBox.Show("invalid address" + _netPrinterAddress, "Printer IP Address", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { //----------------------------------------------------// // // // Ensure that the address is stored in the standard // // notation (dotted-quad for IPv4; colon-hexadecimal // // for IPv6). // // // // Then send the generated print stream to the target // // printer port. // // // //----------------------------------------------------// BinaryReader binReader = new BinaryReader(_binWriter.BaseStream); TargetNetPrint.sendData(binReader, _netPrinterAddress, _netPrinterPort, _netPrinterTimeoutSend, _netPrinterTimeoutReceive, keepNetConnect); binReader.Close(); } } else if ((_targetType == eTarget.WinPrinter) && (_binWriter != null)) { //------------------------------------------------------------// // // // Output to windows printer. // // // //------------------------------------------------------------// BinaryReader binReader = new BinaryReader(_binWriter.BaseStream); TargetWinPrint.sendData(binReader, _winPrinterName); binReader.Close(); } _binWriter.Close(); _opStream.Close(); if (_targetType != eTarget.File) { try { File.Delete(_crntFilename); } catch (IOException e) { MessageBox.Show("IO Exception:\r\n" + e.Message + "\r\n" + "Deleting file '" + _crntFilename, "Target stream", MessageBoxButton.OK, MessageBoxImage.Error); } } }