chore: initial commit

This commit is contained in:
XingCheng3
2026-05-29 09:34:04 +08:00
commit 78ae9dcd2e
683 changed files with 68110 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MesDataFunction
{
public class PP
{
public static string ConnectionString_MES { get; set; }
public static string PrintURL { get; set; }
public static int IsDemoMesServer { get; set; }
}
}

View File

@@ -0,0 +1,65 @@
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
{
/// <summary>
///
/// </summary>
/// <param name="str"></param>
public static bool Print(bool isSinglePrint,string url,string[] strArray)
{
if (PP.IsDemoMesServer == 1)
{
var list = new List<string>();
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;
}
}
}

View File

@@ -0,0 +1,80 @@
using MesDataFunction;
using MesWork;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MesDataFunction
{
public class Print_Sql
{
public static bool Select_Print_Template(out DataTable dt_Print_Template)
{
/*
SELECT [IDG],[TemplateName],[TemplateContent],[DefSelect],[UpdateTime] FROM [OL_Repair_Print_Template]
*/
bool success = false;
var sql =
@"
SELECT [IDG],[TemplateName],[DefSelect],[UpdateTime] FROM [OL_Repair_Print_Template]
ORDER BY [UpdateTime]
";
success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString_MES, out DataTable dt, out string err2);
dt_Print_Template = dt;
return success;
}
public static bool Select_Print_TemplateStr(string IDG, out string templateStr)
{
/*
SELECT [IDG],[TemplateName],[TemplateContent],[DefSelect],[UpdateTime] FROM [OL_Repair_Print_Template]
*/
templateStr = "";
bool success = false;
var sql =
$" DECLARE @IDG nvarchar(50) = '{IDG}'" +
@"
SELECT [TemplateContent] FROM [OL_Repair_Print_Template]
WHERE [IDG] = @IDG
";
success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString_MES, out DataTable dt, out string err2);
if (dt.Rows.Count > 0)
{
templateStr = dt.Rows[0]["TemplateContent"].ToString();
}
return success;
}
public static bool Select_Print_Template_Def(out string templateStr)
{
/*
SELECT [IDG],[TemplateName],[TemplateContent],[DefSelect],[UpdateTime] FROM [OL_Repair_Print_Template]
*/
templateStr = "";
bool success = false;
var sql =
@"
SELECT top 1 [TemplateContent] FROM [OL_Repair_Print_Template]
WHERE [DefSelect]= 'True'
";
success = DataLinkMesWork.SQLCommon.ExecuteDataTable(sql, PP.ConnectionString_MES, out DataTable dt, out string err2);
if (dt.Rows.Count > 0)
{
templateStr = dt.Rows[0]["TemplateContent"].ToString();
}
return success;
}
}
}

View File

@@ -0,0 +1,33 @@
using MesWork;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MesDataFunction
{
public class PrinterCommandCenter
{
public static bool PrintToPrinter(string code)
{
bool success = false;
Print_Sql.Select_Print_Template_Def(out string templateStr);
var printContent = Template_Make_Zpl(templateStr, code);
PrintTo.Print(true, PP.PrintURL, new string[] { printContent });
return success;
}
public static string Template_Make_Zpl(string templateStr,string TowCode)
{
return templateStr.Replace("@TowCode", TowCode);
}
}
}