static void Main(string[] args) { try { Logger.logFileName = Path.Combine(System.IO.Path.GetTempPath(), "print-file-to-printer.log"); } catch (Exception ex) { } if (!FilePrintHelper.Checklisence()) { return; } if (args != null && args.Length > 0) { FilePrintHelper fileprint = new FilePrintHelper(args[0]); fileprint.Manage(); //Console.ReadKey(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainPage()); } }
protected void WebSocketServer_NewMessageReceived(WebSocketSession session, string e) { try { var data = JsonConvert.DeserializeObject <UniversalFileToPrinter.Models.FilePrintRequest>(e); if (!FilePrintHelper.Checklisence()) { session.Close(); return; } switch (data.action) { case "HandShake": session.Send(JsonConvert.SerializeObject(data)); break; case "Print": if (!string.IsNullOrEmpty(data.dataSTR)) { data.dataBin = Convert.FromBase64String(data.dataSTR); } _printHelper.Print(data.type, data.extension, data.printer, data.fileUrl, data.dataBin, data.info, session); break; case "ListPrinters": session.Send(JsonConvert.SerializeObject(new { list = _printHelper.ListPrinters(), isError = false, action = "ListPrinters" })); break; case "Stop": session.Close(); _printHelper.StopAndClose(); break; } } catch (Exception ex) { Logger.Error("WebSocketServer_NewMessageReceived", ex); } }
public WebSocketHelper(int port, FilePrintHelper printHelper) { this.port = port; this._printHelper = printHelper; }