using MesWork; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MesDataFunction { public class PrintTo { /// /// /// /// public static bool Print(bool isSinglePrint,string url,string[] strArray) { if (PP.IsDemoMesServer == 1) { var list = new List(); foreach (string str in strArray) { var printStr = str; if (isSinglePrint) { printStr = str.Replace("^XB", ""); } list.Add(printStr); } File.WriteAllText($"PrintContent_{DateTime .Now.ToString ("yyyy_MM_dd_HH_mm_ss")}.print", string.Join (" ", list)); return true; } var sucess = false; try { var client = new System.Net.Sockets.TcpClient(); client.Connect(url.Split(':')[0], Convert.ToInt32(url.Split(':')[1])); foreach (string str in strArray) { var printStr = str; if (isSinglePrint) { printStr = str.Replace("^XB", ""); } client.Client.Send(System.Text.Encoding.ASCII.GetBytes(printStr)); } client.Close(); sucess = true; } catch (Exception err) { } return sucess; } } }