打印服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.7 KiB

3 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace POSCorePrint
  5. {
  6. /// <summary>
  7. /// 打印机
  8. /// </summary>
  9. internal class Content
  10. {
  11. /// <summary>
  12. /// ID
  13. /// </summary>
  14. public string ID { get; set; }
  15. /// <summary>
  16. /// 打印的内容
  17. /// </summary>
  18. public string ContentVal { get; set; }
  19. /// <summary>
  20. /// 通过Socket方式判断打印机是否正常连接
  21. /// </summary>
  22. /// <param name="ip"></param>
  23. /// <param name="port"></param>
  24. /// <returns></returns>
  25. //internal static bool IsConnect(string ip, int port)
  26. //{
  27. // //Task.Delay(10);
  28. // var isConnect = false;
  29. // IPAddress iPAddress = IPAddress.Parse(ip);
  30. // IPEndPoint iPEndPoint = new IPEndPoint(iPAddress, port);
  31. // Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  32. // try
  33. // {
  34. // IAsyncResult asyncResult = socket.BeginConnect(iPEndPoint, null, null);
  35. // asyncResult.AsyncWaitHandle.WaitOne(2000, true);
  36. // if (asyncResult.IsCompleted)
  37. // isConnect = true;
  38. // LogHelper.Log().Warn($"打印机 {ip}" + (isConnect ? "正常" : "离线!"));
  39. // }
  40. // catch (Exception ex)
  41. // {
  42. // ILog log = LogHelper.Log();
  43. // Console.WriteLine($" {ip} 判断打印机是否正常连接失败:【{ex.Message}】",ex);
  44. // }
  45. // finally
  46. // {
  47. // socket.Close();
  48. // }
  49. // return isConnect;
  50. //}
  51. }
  52. }