diff --git a/PrintBarCode/Business/PrintBusiness.cs b/PrintBarCode/Business/PrintBusiness.cs
new file mode 100644
index 0000000..da3434c
--- /dev/null
+++ b/PrintBarCode/Business/PrintBusiness.cs
@@ -0,0 +1,134 @@
+using PrintBarCode.Helper;
+using PrintBarCode.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrintBarCode.Business
+{
+ public class PrintBusiness
+ {
+
+ private DebugConfig debugConfig = DebugConfig.Instance;
+ private static string basePath = AppDomain.CurrentDomain.BaseDirectory;
+
+ PrintHelper PrintH = new PrintHelper();
+
+ private RawPrinterHelper zplp = new RawPrinterHelper();
+ public PrintBusiness()
+ {
+
+ }
+
+
+
+ ///
+ /// 打印原材料条码方法
+ ///
+ public void PrintRawBarCodeInfo(RawBarCodeInfo rawBarCodeInfo)
+ {
+ // 拼接成目标文件的完整路径
+ string path = Path.Combine(basePath, "templates", "rawTemplate.prn");
+
+ //
+ string[] args = new string[]
+ {
+ rawBarCodeInfo.MaterialName,
+ rawBarCodeInfo.MaterialCode,
+ rawBarCodeInfo.MaterialSpec,
+ rawBarCodeInfo.BatchCode,
+ rawBarCodeInfo.PoNo,
+ rawBarCodeInfo.SaleOrderCode,
+ rawBarCodeInfo.Barcode,
+ rawBarCodeInfo.QrCode,
+ };
+
+ // 将属性值用 "~" 连接起来,不带前缀
+ string TempStr = $"{rawBarCodeInfo.MaterialName}~{rawBarCodeInfo.MaterialCode}~{rawBarCodeInfo.MaterialSpec}~{rawBarCodeInfo.BatchCode}~{rawBarCodeInfo.PoNo}~{rawBarCodeInfo.SaleOrderCode}~{rawBarCodeInfo.Barcode}~{rawBarCodeInfo.QrCode}";
+
+
+ string ZplStr = PrintH.GetPrintString(path, TempStr);//替换后字符串
+
+ bool pringFlag = zplp.SendStringToPrinter(debugConfig.PrintName, ZplStr);
+ if (pringFlag == false)
+ {
+ Console.WriteLine("打印错误,检查后请重新操作!");
+ }
+ }
+
+
+
+ ///
+ /// 打印成品条码方法
+ ///
+ public void PrintProductBarCodeInfo(ProductBarCodeInfo productBarCodeInfo)
+ {
+ // 拼接成目标文件的完整路径
+ string path = Path.Combine(basePath, "templates", "productTemplate.prn");
+
+ //
+ string[] args = new string[]
+ {
+ productBarCodeInfo.MaterialName,
+ productBarCodeInfo.MaterialCode,
+ productBarCodeInfo.MaterialSpec,
+ productBarCodeInfo.ProductPlanCode,
+ productBarCodeInfo.SaleOrderCode,
+ productBarCodeInfo.BarCode,
+ productBarCodeInfo.Qty,
+ productBarCodeInfo.QrCode,
+
+ };
+
+ string TempStr = $"{productBarCodeInfo.MaterialName}~{productBarCodeInfo.MaterialCode}~{productBarCodeInfo.MaterialSpec}~{productBarCodeInfo.ProductPlanCode}~{productBarCodeInfo.SaleOrderCode}~{productBarCodeInfo.BarCode}~{productBarCodeInfo.Qty}~{productBarCodeInfo.QrCode}";
+
+ string ZplStr = PrintH.GetPrintString(path, TempStr);//替换后字符串
+
+ bool pringFlag = zplp.SendStringToPrinter(debugConfig.PrintName, ZplStr);
+ if (pringFlag == false)
+ {
+ Console.WriteLine("打印错误,检查后请重新操作!");
+ }
+ }
+
+
+ ///
+ /// 打印配对码方法
+ ///
+ public void PrintBindBarCodeInfo(BindBarCodeInfo bindBarCodeInfo)
+ {
+ // 拼接成目标文件的完整路径
+ string path = Path.Combine(basePath, "templates", "bindTemplate.prn");
+
+ //
+ string[] args = new string[]
+ {
+ bindBarCodeInfo.MaterialName,
+ bindBarCodeInfo.MaterialCode,
+ bindBarCodeInfo.MaterialSpec,
+ bindBarCodeInfo.BatchCode,
+ bindBarCodeInfo.PoNo,
+ bindBarCodeInfo.SaleOrderCode,
+ bindBarCodeInfo.Barcode,
+ bindBarCodeInfo.QrCode,
+ };
+
+ // 将属性值用 "~" 连接起来,不带前缀
+ string TempStr = $"{bindBarCodeInfo.MaterialName}~{bindBarCodeInfo.MaterialCode}~{bindBarCodeInfo.MaterialSpec}~{bindBarCodeInfo.BatchCode}~{bindBarCodeInfo.PoNo}~{bindBarCodeInfo.SaleOrderCode}~{bindBarCodeInfo.Barcode}~{bindBarCodeInfo.QrCode}";
+
+
+ string ZplStr = PrintH.GetPrintString(path, TempStr);//替换后字符串
+
+ bool pringFlag = zplp.SendStringToPrinter(debugConfig.PrintName, ZplStr);
+ if (pringFlag == false)
+ {
+ Console.WriteLine("打印错误,检查后请重新操作!");
+ }
+ }
+
+
+
+ }
+}
diff --git a/PrintBarCode/DLL/.keep b/PrintBarCode/DLL/.keep
new file mode 100644
index 0000000..e69de29
diff --git a/PrintBarCode/DLL/BarcodeStandard.dll b/PrintBarCode/DLL/BarcodeStandard.dll
new file mode 100644
index 0000000..4990151
Binary files /dev/null and b/PrintBarCode/DLL/BarcodeStandard.dll differ
diff --git a/PrintBarCode/DLL/BinaryKits.Zpl.Label.dll b/PrintBarCode/DLL/BinaryKits.Zpl.Label.dll
new file mode 100644
index 0000000..e383c4e
Binary files /dev/null and b/PrintBarCode/DLL/BinaryKits.Zpl.Label.dll differ
diff --git a/PrintBarCode/DLL/BinaryKits.Zpl.Viewer.dll b/PrintBarCode/DLL/BinaryKits.Zpl.Viewer.dll
new file mode 100644
index 0000000..05dcc0c
Binary files /dev/null and b/PrintBarCode/DLL/BinaryKits.Zpl.Viewer.dll differ
diff --git a/PrintBarCode/DLL/Neodynamic.SDK.ZPLPrinter.dll b/PrintBarCode/DLL/Neodynamic.SDK.ZPLPrinter.dll
new file mode 100644
index 0000000..08e0786
Binary files /dev/null and b/PrintBarCode/DLL/Neodynamic.SDK.ZPLPrinter.dll differ
diff --git a/PrintBarCode/DLL/QRCoder.dll b/PrintBarCode/DLL/QRCoder.dll
new file mode 100644
index 0000000..6cfbf07
Binary files /dev/null and b/PrintBarCode/DLL/QRCoder.dll differ
diff --git a/PrintBarCode/DLL/SixLabors.ImageSharp.dll b/PrintBarCode/DLL/SixLabors.ImageSharp.dll
new file mode 100644
index 0000000..92a4406
Binary files /dev/null and b/PrintBarCode/DLL/SixLabors.ImageSharp.dll differ
diff --git a/PrintBarCode/DLL/SkiaSharp.dll b/PrintBarCode/DLL/SkiaSharp.dll
new file mode 100644
index 0000000..a23d166
Binary files /dev/null and b/PrintBarCode/DLL/SkiaSharp.dll differ
diff --git a/PrintBarCode/DLL/ZPLPrintDLL.dll b/PrintBarCode/DLL/ZPLPrintDLL.dll
new file mode 100644
index 0000000..964dfcc
Binary files /dev/null and b/PrintBarCode/DLL/ZPLPrintDLL.dll differ
diff --git a/PrintBarCode/DTO/Output.cs b/PrintBarCode/DTO/Output.cs
new file mode 100644
index 0000000..d9f47e6
--- /dev/null
+++ b/PrintBarCode/DTO/Output.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json.Serialization;
+using System.Threading.Tasks;
+
+namespace PrintBarCode.DTO
+{
+ public class Output
+ {
+
+ [JsonPropertyName("template")]
+ public string Template { get; set; }
+
+ [JsonPropertyName("printContent")]
+ public string PrintContent { get; set; }
+ }
+}
diff --git a/PrintBarCode/Helper/DebugConfig.cs b/PrintBarCode/Helper/DebugConfig.cs
new file mode 100644
index 0000000..4f21434
--- /dev/null
+++ b/PrintBarCode/Helper/DebugConfig.cs
@@ -0,0 +1,53 @@
+
+using System;
+using System.Collections.Generic;
+
+namespace PrintBarCode.Helper
+{
+ ///
+ /// 系统配置
+ ///
+ public sealed class DebugConfig
+ {
+ private static IniHelper iniHelper = new IniHelper(System.Environment.CurrentDirectory + "/config/App.InI");
+
+
+ private static readonly Lazy lazy = new Lazy(() => new DebugConfig());
+ public static DebugConfig Instance
+ {
+ get
+ {
+ return lazy.Value;
+ }
+ }
+
+ public DebugConfig()
+ {
+
+ }
+
+
+ ///
+ //打印机名称
+ ///
+ public string PrintName
+ {
+ get { return iniHelper.IniReadValue("system", "PrintName"); }
+ set { iniHelper.IniWriteValue("system", "PrintName", value); }
+ }
+
+
+ ///
+ //所在电脑IP
+ ///
+ public string IP
+ {
+ get { return iniHelper.IniReadValue("system", "IP"); }
+ set { iniHelper.IniWriteValue("system", "IP", value); }
+ }
+
+
+
+
+ }
+}
diff --git a/PrintBarCode/Helper/IniHelper.cs b/PrintBarCode/Helper/IniHelper.cs
new file mode 100644
index 0000000..eae5bc5
--- /dev/null
+++ b/PrintBarCode/Helper/IniHelper.cs
@@ -0,0 +1,105 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PrintBarCode.Helper
+{
+ public class IniHelper
+ {
+ public string path;
+
+ public IniHelper(string INIPath)
+ {
+ path = INIPath;
+ }
+
+ [DllImport("kernel32")]
+ private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
+
+ [DllImport("kernel32")]
+ private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
+
+
+ [DllImport("kernel32")]
+ private static extern int GetPrivateProfileString(string section, string key, string defVal, Byte[] retVal, int size, string filePath);
+
+ [DllImport("kernel32", EntryPoint = "GetPrivateProfileString")]
+ private static extern uint GetPrivateProfileStringA(string section, string key, string def, Byte[] retVal, int size, string filePath);
+
+ ///
+ /// 写INI文件
+ ///
+ ///
+ ///
+ ///
+ public void IniWriteValue(string Section, string Key, string Value)
+ {
+
+ WritePrivateProfileString(Section, Key, Value, this.path);
+ }
+
+ ///
+ /// 读取INI文件
+ ///
+ ///
+ ///
+ ///
+ public string IniReadValue(string Section, string Key)
+ {
+ StringBuilder temp = new StringBuilder(255);
+ int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
+ //return temp.ToString();
+
+ string str = temp.ToString();
+
+ return str;
+ }
+ public byte[] IniReadValues(string section, string key)
+ {
+ byte[] temp = new byte[255];
+ int i = GetPrivateProfileString(section, key, "", temp, 255, this.path);
+ return temp;
+
+ }
+
+
+ ///
+ /// 删除ini文件下所有段落
+ ///
+ public void ClearAllSection()
+ {
+ IniWriteValue(null, null, null);
+ }
+ ///
+ /// 删除ini文件下personal段落下的所有键
+ ///
+ ///
+ public void ClearSection(string Section)
+ {
+ IniWriteValue(Section, null, null);
+ }
+
+ public List ReadKeys(String SectionName)
+ {
+ return ReadKeys(SectionName, this.path);
+ }
+
+ public List ReadKeys(string SectionName, string iniFilename)
+ {
+ List result = new List();
+ Byte[] buf = new Byte[65536];
+ uint len = GetPrivateProfileStringA(SectionName, null, null, buf, buf.Length, iniFilename);
+ int j = 0;
+ for (int i = 0; i < len; i++)
+ if (buf[i] == 0)
+ {
+ result.Add(Encoding.Default.GetString(buf, j, i - j));
+ j = i + 1;
+ }
+ return result;
+ }
+ }
+}
diff --git a/PrintBarCode/Helper/JsonParser.cs b/PrintBarCode/Helper/JsonParser.cs
new file mode 100644
index 0000000..3de73aa
--- /dev/null
+++ b/PrintBarCode/Helper/JsonParser.cs
@@ -0,0 +1,51 @@
+using PrintBarCode.DTO;
+using PrintBarCode.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+
+namespace PrintBarCode.Helper
+{
+ public class JsonParser
+ {
+ public static List