打印服务
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.

55 lines
1.7 KiB

using System;
using System.Collections.Generic;
using System.Text;
namespace POSCorePrint
{
/// <summary>
/// 打印机
/// </summary>
internal class Content
{
/// <summary>
/// ID
/// </summary>
public string ID { get; set; }
/// <summary>
/// 打印的内容
/// </summary>
public string ContentVal { get; set; }
/// <summary>
/// 通过Socket方式判断打印机是否正常连接
/// </summary>
/// <param name="ip"></param>
/// <param name="port"></param>
/// <returns></returns>
//internal static bool IsConnect(string ip, int port)
//{
// //Task.Delay(10);
// var isConnect = false;
// IPAddress iPAddress = IPAddress.Parse(ip);
// IPEndPoint iPEndPoint = new IPEndPoint(iPAddress, port);
// Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
// try
// {
// IAsyncResult asyncResult = socket.BeginConnect(iPEndPoint, null, null);
// asyncResult.AsyncWaitHandle.WaitOne(2000, true);
// if (asyncResult.IsCompleted)
// isConnect = true;
// LogHelper.Log().Warn($"打印机 {ip}" + (isConnect ? "正常" : "离线!"));
// }
// catch (Exception ex)
// {
// ILog log = LogHelper.Log();
// Console.WriteLine($" {ip} 判断打印机是否正常连接失败:【{ex.Message}】",ex);
// }
// finally
// {
// socket.Close();
// }
// return isConnect;
//}
}
}