Initial commit
This commit is contained in:
196
Handler/Sub/StdLabelPrint/CAmkorSTDBarcode.cs
Normal file
196
Handler/Sub/StdLabelPrint/CAmkorSTDBarcode.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StdLabelPrint
|
||||
{
|
||||
public class CAmkorSTDBarcode
|
||||
{
|
||||
public string Message { get; private set; }
|
||||
public Boolean isValid = false;
|
||||
public string SID { get; set; }
|
||||
public string VLOT { get; set; }
|
||||
public string RID { get; set; }
|
||||
public string MFGDate { get; set; }
|
||||
//public string MFGDateRaw { get; set; }
|
||||
public string VENDERNAME { get; set; }
|
||||
public string PARTNO { get; set; }
|
||||
public int QTY { get; set; }
|
||||
public string RAW { get; set; }
|
||||
public Boolean DateError { get; private set; }
|
||||
public Boolean DisposalCode { get; set; }
|
||||
|
||||
public Boolean NewLen15Barcode { get; set; }
|
||||
|
||||
public void CopyTo(CAmkorSTDBarcode obj)
|
||||
{
|
||||
if (obj == null) obj = new CAmkorSTDBarcode();
|
||||
else obj.Clear();
|
||||
obj.Message = this.Message;
|
||||
obj.isValid = this.isValid;
|
||||
obj.SID = this.SID;
|
||||
obj.VLOT = this.VLOT;
|
||||
obj.RID = this.RID;
|
||||
obj.MFGDate = this.MFGDate;
|
||||
obj.VENDERNAME = this.VENDERNAME;
|
||||
obj.PARTNO = this.PARTNO;
|
||||
obj.QTY = this.QTY;
|
||||
obj.RAW = this.RAW;
|
||||
obj.DateError = this.DateError;
|
||||
obj.DisposalCode = this.DisposalCode;
|
||||
obj.NewLen15Barcode = this.NewLen15Barcode;
|
||||
}
|
||||
public CAmkorSTDBarcode()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
public void Clear()
|
||||
{
|
||||
this.DisposalCode = false;
|
||||
this.NewLen15Barcode = false;
|
||||
this.Message = string.Empty;
|
||||
this.isValid = false;
|
||||
this.SID = string.Empty;
|
||||
this.VLOT = string.Empty;
|
||||
this.RID = string.Empty;
|
||||
//this.MFGDateRaw = string.Empty;
|
||||
this.MFGDate = string.Empty;// new DateTime(1982, 11, 23);
|
||||
this.VENDERNAME = string.Empty;
|
||||
this.PARTNO = string.Empty;
|
||||
this.QTY = 0;
|
||||
this.RAW = string.Empty;
|
||||
DateError = false;
|
||||
}
|
||||
public CAmkorSTDBarcode(string raw)
|
||||
{
|
||||
SetBarcode(raw);
|
||||
}
|
||||
public void SetBarcodeDemo()
|
||||
{
|
||||
//SetBarcode("101410653;AG64B3W;SAMSUNG;20000;AG64B3W0031;19000101;");
|
||||
SetBarcode("101410653;AG64B3W;SAMSUNG;20000;AG64B3W0031;19000101;");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 현재 속성의 값을 가지고 바코드값을 반환합니다.
|
||||
/// 원본 바코드 값을 확인하려면 RAW 속성을 확인하세요
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetBarcode()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(PARTNO))
|
||||
return string.Format("{0};{1};{2};{3};{4};{5}",
|
||||
SID, VLOT, VENDERNAME, QTY, RID, MFGDate);
|
||||
else
|
||||
return string.Format("{0};{1};{2};{3};{4};{5};{6}",
|
||||
SID, VLOT, VENDERNAME, QTY, RID, MFGDate, PARTNO);
|
||||
}
|
||||
public void SetBarcode(string raw)
|
||||
{
|
||||
//101416868;01A3KX;KYOCERA;20000;RC00014A225001I;20220511;N/A
|
||||
|
||||
|
||||
isValid = false;
|
||||
|
||||
this.RAW = raw;
|
||||
var buf = raw.Split(';');
|
||||
if (buf.Length < 5)
|
||||
{
|
||||
isValid = false;
|
||||
Message = "buffer len error : " + raw;
|
||||
return;
|
||||
}
|
||||
decimal vSID = 0;
|
||||
double vQty = 0;
|
||||
if (decimal.TryParse(buf[0], out vSID) == false) return;
|
||||
|
||||
this.SID = buf[0];
|
||||
this.VLOT = buf[1];
|
||||
|
||||
|
||||
//101인경우에는 3번 항목이 벤더네임이다.
|
||||
//103은 partno 값이 들어간다
|
||||
if (this.SID.StartsWith("103"))
|
||||
{
|
||||
if (buf.Length == 7) //구형바코드
|
||||
{
|
||||
this.VENDERNAME = buf[2];
|
||||
this.PARTNO = string.Empty;
|
||||
Message = "폐기된 103코드 입니다";
|
||||
DisposalCode = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//05월 신형은 파트번호가 들어있다
|
||||
this.PARTNO = buf[2];
|
||||
this.VENDERNAME = string.Empty;
|
||||
DisposalCode = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.VENDERNAME = buf[2];
|
||||
this.PARTNO = string.Empty;
|
||||
DisposalCode = false;
|
||||
}
|
||||
|
||||
//일부 데이터를 변조한다 210709
|
||||
if (this.VENDERNAME == "K118165") this.VENDERNAME = "DELTA";
|
||||
else if (this.VENDERNAME == "K113986") this.VENDERNAME = "DREAM CHIP";
|
||||
|
||||
|
||||
if (double.TryParse(buf[3], out vQty) == false) return;
|
||||
this.QTY = (int)vQty;
|
||||
|
||||
this.RID = buf[4];
|
||||
//DateTime vMFGDate;
|
||||
DateError = false;
|
||||
this.MFGDate = buf[5].Trim();
|
||||
|
||||
//신형바코드는 angle 에서 제외하려고 판정한다
|
||||
if (this.RID.Length == 15 && this.RID.StartsWith("RC")) //210703
|
||||
this.NewLen15Barcode = true;
|
||||
else
|
||||
this.NewLen15Barcode = false;
|
||||
|
||||
|
||||
//if (buf[5].Length == 4 && this.SUPPLY == "SAMSUNG")
|
||||
//{
|
||||
// //삼성은 주차로 한다
|
||||
// DateError = true;
|
||||
// Message = "Date Error(samsung)";
|
||||
// MFGDate = new DateTime(2000+ int.Parse( buf[5].Substring(0,2) ), 1, 1);
|
||||
|
||||
// //DateTime.Now.
|
||||
//}
|
||||
//else if (buf[5].Length != 8)
|
||||
//{
|
||||
// Message = "Date value Length Error : " + buf[5];
|
||||
// MFGDate = new DateTime(1900, 1, 1);
|
||||
// return;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// buf[5] = buf[5].Substring(0, 4) + "-" + buf[5].Substring(4, 2) + "-" + buf[5].Substring(6, 2);
|
||||
// if (DateTime.TryParse(buf[5], out vMFGDate) == false) return;
|
||||
// MFGDate = vMFGDate;
|
||||
//}
|
||||
|
||||
//마지막 요소가 PartNo 이다. (아직 이코드는 본적 없음)
|
||||
if (this.SID.StartsWith("103") && buf.Length == 7) //구형번호이다
|
||||
{
|
||||
this.PARTNO = buf[6];
|
||||
}
|
||||
|
||||
if (buf.Length == 7 && string.IsNullOrEmpty(this.PARTNO))
|
||||
{
|
||||
this.PARTNO = buf[6];
|
||||
}
|
||||
//else this.PARTNO = string.Empty;
|
||||
|
||||
isValid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
118
Handler/Sub/StdLabelPrint/Def.cs
Normal file
118
Handler/Sub/StdLabelPrint/Def.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StdLabelPrint
|
||||
{
|
||||
public partial class LabelPrint
|
||||
{
|
||||
private const int ERROR_INSUFFICIENT_BUFFER = 122;
|
||||
|
||||
[FlagsAttribute]
|
||||
public enum PrinterEnumFlags
|
||||
{
|
||||
PRINTER_ENUM_DEFAULT = 0x00000001,
|
||||
PRINTER_ENUM_LOCAL = 0x00000002,
|
||||
PRINTER_ENUM_CONNECTIONS = 0x00000004,
|
||||
PRINTER_ENUM_FAVORITE = 0x00000004,
|
||||
PRINTER_ENUM_NAME = 0x00000008,
|
||||
PRINTER_ENUM_REMOTE = 0x00000010,
|
||||
PRINTER_ENUM_SHARED = 0x00000020,
|
||||
PRINTER_ENUM_NETWORK = 0x00000040,
|
||||
PRINTER_ENUM_EXPAND = 0x00004000,
|
||||
PRINTER_ENUM_CONTAINER = 0x00008000,
|
||||
PRINTER_ENUM_ICONMASK = 0x00ff0000,
|
||||
PRINTER_ENUM_ICON1 = 0x00010000,
|
||||
PRINTER_ENUM_ICON2 = 0x00020000,
|
||||
PRINTER_ENUM_ICON3 = 0x00040000,
|
||||
PRINTER_ENUM_ICON4 = 0x00080000,
|
||||
PRINTER_ENUM_ICON5 = 0x00100000,
|
||||
PRINTER_ENUM_ICON6 = 0x00200000,
|
||||
PRINTER_ENUM_ICON7 = 0x00400000,
|
||||
PRINTER_ENUM_ICON8 = 0x00800000,
|
||||
PRINTER_ENUM_HIDE = 0x01000000,
|
||||
PRINTER_ENUM_CATEGORY_ALL = 0x02000000,
|
||||
PRINTER_ENUM_CATEGORY_3D = 0x04000000
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
public struct PRINTER_INFO_2
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pServerName;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pPrinterName;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pShareName;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pPortName;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pDriverName;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pComment;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pLocation;
|
||||
public IntPtr pDevMode;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pSepFile;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pPrintProcessor;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pDatatype;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
public string pParameters;
|
||||
public IntPtr pSecurityDescriptor;
|
||||
public uint Attributes; // See note below!
|
||||
public uint Priority;
|
||||
public uint DefaultPriority;
|
||||
public uint StartTime;
|
||||
public uint UntilTime;
|
||||
public uint Status;
|
||||
public uint cJobs;
|
||||
public uint AveragePPM;
|
||||
}
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct DOCINFO
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPWStr)] public string pDocName;
|
||||
[MarshalAs(UnmanagedType.LPWStr)] public string pOutputFile;
|
||||
[MarshalAs(UnmanagedType.LPWStr)] public string pDataType;
|
||||
}
|
||||
public class PrintDirect
|
||||
{
|
||||
[DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = false,
|
||||
CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern long OpenPrinter(string pPrinterName, ref IntPtr phPrinter, int pDefault);
|
||||
[DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = false,
|
||||
CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern long StartDocPrinter(IntPtr hPrinter, int Level, ref DOCINFO
|
||||
pDocInfo);
|
||||
[DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true,
|
||||
CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern long StartPagePrinter(IntPtr hPrinter);
|
||||
[DllImport("winspool.drv", CharSet = CharSet.Ansi, ExactSpelling = true,
|
||||
CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern long WritePrinter(IntPtr hPrinter, string data, int buf, ref int pcWritten);
|
||||
[DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true,
|
||||
CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern long EndPagePrinter(IntPtr hPrinter);
|
||||
[DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true,
|
||||
CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern long EndDocPrinter(IntPtr hPrinter);
|
||||
[DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true,
|
||||
CallingConvention = CallingConvention.StdCall)]
|
||||
public static extern long ClosePrinter(IntPtr hPrinter);
|
||||
|
||||
[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern bool EnumPrinters(PrinterEnumFlags Flags, string Name, uint Level, IntPtr pPrinterEnum, uint cbBuf, ref uint pcbNeeded, ref uint pcReturned);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
308
Handler/Sub/StdLabelPrint/LabelPrint.cs
Normal file
308
Handler/Sub/StdLabelPrint/LabelPrint.cs
Normal file
@@ -0,0 +1,308 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StdLabelPrint
|
||||
{
|
||||
public partial class LabelPrint
|
||||
{
|
||||
public string printerName { get; set; } = string.Empty;
|
||||
public List<string> connectedPrinter = new List<string>();
|
||||
public string LastPrintZPL = string.Empty;
|
||||
public string qrData = string.Empty;
|
||||
public string baseZPL { get; set; }
|
||||
|
||||
public LabelPrint(string _prtName)
|
||||
{
|
||||
//GetPrinterList();
|
||||
|
||||
//if (connectedPrinter.Contains(_prtName) == false)
|
||||
// throw new Exception("연결된 프린터가 아닙니다.");
|
||||
|
||||
printerName = _prtName;
|
||||
baseZPL = Properties.Settings.Default.zpl;
|
||||
|
||||
}
|
||||
|
||||
public List<string> GetPrinterList()
|
||||
{
|
||||
connectedPrinter = new List<string>();
|
||||
var list_local = FindPrinters(PrinterEnumFlags.PRINTER_ENUM_LOCAL);
|
||||
var list_connected = FindPrinters(PrinterEnumFlags.PRINTER_ENUM_CONNECTIONS);
|
||||
try
|
||||
{
|
||||
connectedPrinter.AddRange(list_local);
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
connectedPrinter.AddRange(list_connected);
|
||||
}
|
||||
catch { }
|
||||
return connectedPrinter;
|
||||
}
|
||||
public string makeZPL_210101(Reel reel, Boolean D1RID, Boolean drawbox, out string qrData)
|
||||
{
|
||||
string prtData = string.Empty;
|
||||
qrData = string.Format("{0};{1};{2};{3};{4};{5};{6}", reel.sid, reel.lot, reel.manu, reel.qty, reel.id, reel.mfg, reel.partnum);
|
||||
prtData = "^XA\r\n";
|
||||
prtData += "^MMT\r\n";
|
||||
prtData += "^PW519\r\n";
|
||||
prtData += "^LL0200\r\n";
|
||||
prtData += "^LS0\r\n";
|
||||
prtData += "^FO128,96^GFA,01536,01536,00048,:Z64:\r\n";
|
||||
prtData += "eJxjYBgFo2AUkADs/xMN/g1G9aNgFMABAIF9rE0=:1194\r\n";
|
||||
|
||||
if (drawbox)
|
||||
prtData += "^FO1,7^GB505,185,4^FS\r\n";
|
||||
|
||||
prtData += "^BY2,3,41^FT280,82^BCN,,N,N,N,A\r\n";
|
||||
prtData += "^FD" + reel.sid + "^FS\r\n";
|
||||
prtData += "^FT12,160^BQN,2,4\r\n";
|
||||
prtData += string.Format("^FH\\^FDLA,{0}^FS\r\n", qrData);
|
||||
prtData += "^BY2,3,32^FT86,185^BCN,,N,N,N,A\r\n";
|
||||
prtData += string.Format("^FD{0};{1}^FS\r\n", reel.sid, reel.lot);
|
||||
prtData += "^FO278,7^GB0,26,4^FS\r\n";
|
||||
prtData += "^FT160,29^A0N,20,19^FH\\^FDSID^FS\r\n";
|
||||
prtData += "^FT159,111^A0N,20,19^FH\\^FDPN^FS\r\n";
|
||||
prtData += "^FT159,137^A0N,20,19^FH\\^FDRID^FS\r\n";
|
||||
prtData += "^FT194,29^A0N,20,19^FH\\^FD" + reel.sid + "^FS\r\n";
|
||||
prtData += "^FT324,29^A0N,20,19^FH\\^FD" + reel.lot + "^FS\r\n";
|
||||
prtData += "^FT195,111^A0N,20,19^FH\\^FD" + reel.partnum + "^FS\r\n";
|
||||
|
||||
prtData += "^FT195,137^A0N,20,19^FH\\^FD" + (D1RID ? reel.id : string.Empty) + "^FS\r\n"; //210302
|
||||
|
||||
prtData += "^FT441,137^A0N,20,19^FH\\^FD" + reel.qty.ToString() + "^FS\r\n";
|
||||
prtData += "^FT285,29^A0N,20,19^FH\\^FDLOT^FS\r\n";
|
||||
prtData += "^FT396,137^A0N,20,19^FH\\^FDQTY^FS\r\n";
|
||||
prtData += "^FO154,7^GB352,28,4^FS\r\n";
|
||||
prtData += "^FO154,89^GB352,54,4^FS\r\n";
|
||||
prtData += "^FO190,90^GB0,51,4^FS\r\n";
|
||||
prtData += "^FO188,9^GB0,24,4^FS\r\n";
|
||||
prtData += "^FO388,117^GB0,26,4^FS\r\n";
|
||||
prtData += "^FO430,116^GB0,26,4^FS\r\n";
|
||||
prtData += "^FO316,7^GB0,26,4^FS\r\n";
|
||||
prtData += "^PQ1,0,1,Y^XZ\r\n";
|
||||
return prtData;
|
||||
}
|
||||
public string makeZPL_210510(Reel reel, Boolean drawbox, out string qrData)
|
||||
{
|
||||
string m_strSend = string.Empty;
|
||||
qrData = string.Format("{0};{1};{2};{3};{4};{5}", reel.sid, reel.lot, reel.partnum, reel.qty, reel.id, reel.mfg);
|
||||
|
||||
m_strSend = this.baseZPL;
|
||||
m_strSend = m_strSend.Replace("{qrData}", qrData);
|
||||
m_strSend = m_strSend.Replace("{sid}", reel.sid);
|
||||
m_strSend = m_strSend.Replace("{lot}", reel.lot);
|
||||
m_strSend = m_strSend.Replace("{partnum}", reel.partnum);
|
||||
m_strSend = m_strSend.Replace("{rid}", reel.id);
|
||||
m_strSend = m_strSend.Replace("{qty}", reel.qty.ToString());
|
||||
m_strSend = m_strSend.Replace("{mfg}", reel.mfg);
|
||||
m_strSend = m_strSend.Replace("{supply}", reel.manu);
|
||||
|
||||
//줄바꿈제거
|
||||
m_strSend = m_strSend.Replace("\r", "").Replace("\n", "");
|
||||
return m_strSend;
|
||||
}
|
||||
public string makeZPL_210908(Reel reel, Boolean drawbox, out string qrData)
|
||||
{
|
||||
string m_strSend = string.Empty;
|
||||
qrData = string.Format("{0};{1};{2};{3};{4};{5};{6}", reel.sid, reel.lot, reel.manu, reel.qty, reel.id, reel.mfg, reel.partnum);
|
||||
|
||||
m_strSend = this.baseZPL;
|
||||
m_strSend = m_strSend.Replace("{qrData}", qrData);
|
||||
m_strSend = m_strSend.Replace("{sid}", reel.sid);
|
||||
m_strSend = m_strSend.Replace("{lot}", reel.lot);
|
||||
m_strSend = m_strSend.Replace("{partnum}", reel.partnum);
|
||||
m_strSend = m_strSend.Replace("{rid}", reel.id);
|
||||
m_strSend = m_strSend.Replace("{qty}", reel.qty.ToString());
|
||||
m_strSend = m_strSend.Replace("{mfg}", reel.mfg);
|
||||
m_strSend = m_strSend.Replace("{supply}", reel.manu);
|
||||
|
||||
//줄바꿈제거
|
||||
m_strSend = m_strSend.Replace("\r", "").Replace("\n", "");
|
||||
return m_strSend;
|
||||
}
|
||||
public Boolean TestPrint(Boolean drawbox, string manu = "", string mfgdate = "", Boolean Array7 = false)
|
||||
{
|
||||
var dtstr = DateTime.Now.ToShortDateString();
|
||||
var printcode = "103077807;Z577603504;105-35282-1105;15000;RC00004A219001W;20210612";
|
||||
var reel = new StdLabelPrint.Reel(printcode);
|
||||
//reel.id = "RLID" + DateTime.Now.ToString("MMHHmmssfff");
|
||||
reel.sid = "103000000";
|
||||
reel.partnum = "PARTNO".PadRight(20, '0'); //20자리
|
||||
|
||||
if (mfgdate == "") reel.mfg = dtstr;
|
||||
else reel.mfg = mfgdate;
|
||||
|
||||
reel.lot = "LOT000000000";
|
||||
if (manu == "") reel.manu = "ATK4EET1";
|
||||
else reel.manu = manu;
|
||||
|
||||
reel.qty = 15000;
|
||||
var rlt = Print(reel, true, drawbox, Array7);
|
||||
var fi = new System.IO.FileInfo(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "temp_zpl.txt"));
|
||||
System.IO.File.WriteAllText(fi.FullName, LastPrintZPL, System.Text.Encoding.Default);
|
||||
return rlt;
|
||||
}
|
||||
|
||||
|
||||
public Boolean Print(Reel reel, Boolean display1drid, Boolean drawOUtBox, Boolean Array7 = false)
|
||||
{
|
||||
string prtData;
|
||||
if (Array7)
|
||||
prtData = makeZPL_210908(reel, drawOUtBox, out qrData);
|
||||
else
|
||||
prtData = makeZPL_210510(reel, drawOUtBox, out qrData);
|
||||
|
||||
return Print(prtData);
|
||||
}
|
||||
|
||||
public bool Print(string _zpl)
|
||||
{
|
||||
this.LastPrintZPL = _zpl;
|
||||
|
||||
bool retval = false;
|
||||
System.IntPtr lhPrinter = new System.IntPtr();
|
||||
DOCINFO di = new DOCINFO();
|
||||
int pcWritten = 0;
|
||||
//string st1;
|
||||
// text to print with a form feed character
|
||||
//st1 = "This is std label by using zpl\f";
|
||||
di.pDocName = "Component Std Label";
|
||||
di.pDataType = "RAW";
|
||||
// the \x1b means an ascii escape character
|
||||
|
||||
//lhPrinter contains the handle for the printer opened
|
||||
//If lhPrinter is 0 then an error has occured
|
||||
|
||||
//GetPrinterList();
|
||||
|
||||
//if (connectedPrinter.Contains(printerName) == false)
|
||||
// throw new Exception("연결된 프린터가 아닙니다.");
|
||||
|
||||
|
||||
PrintDirect.OpenPrinter(printerName, ref lhPrinter, 0);
|
||||
PrintDirect.StartDocPrinter(lhPrinter, 1, ref di);
|
||||
PrintDirect.StartPagePrinter(lhPrinter);
|
||||
try
|
||||
{
|
||||
PrintDirect.WritePrinter(lhPrinter, _zpl, _zpl.Length, ref pcWritten);
|
||||
retval = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
PrintDirect.EndPagePrinter(lhPrinter);
|
||||
PrintDirect.EndDocPrinter(lhPrinter);
|
||||
PrintDirect.ClosePrinter(lhPrinter);
|
||||
return retval;
|
||||
}
|
||||
private List<string> FindPrinters(PrinterEnumFlags Flags)
|
||||
{
|
||||
List<string> prtList = new List<string>();
|
||||
uint cbNeeded = 0;
|
||||
uint cReturned = 0;
|
||||
if (PrintDirect.EnumPrinters(Flags, null, 2, IntPtr.Zero, 0, ref cbNeeded, ref cReturned))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int lastWin32Error = Marshal.GetLastWin32Error();
|
||||
if (lastWin32Error == ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
IntPtr pAddr = Marshal.AllocHGlobal((int)cbNeeded);
|
||||
if (PrintDirect.EnumPrinters(Flags, null, 2, pAddr, cbNeeded, ref cbNeeded, ref cReturned))
|
||||
{
|
||||
PRINTER_INFO_2[] printerInfo2 = new PRINTER_INFO_2[cReturned];
|
||||
int offset = pAddr.ToInt32();
|
||||
Type type = typeof(PRINTER_INFO_2);
|
||||
int increment = Marshal.SizeOf(type);
|
||||
for (int i = 0; i < cReturned; i++)
|
||||
{
|
||||
printerInfo2[i] = (PRINTER_INFO_2)Marshal.PtrToStructure(new IntPtr(offset), type);
|
||||
prtList.Add(printerInfo2[i].pPrinterName);
|
||||
offset += increment;
|
||||
}
|
||||
Marshal.FreeHGlobal(pAddr);
|
||||
return prtList;
|
||||
}
|
||||
lastWin32Error = Marshal.GetLastWin32Error();
|
||||
}
|
||||
throw new Win32Exception(lastWin32Error);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
public class Reel
|
||||
{
|
||||
public string sid { get; set; }
|
||||
public string lot { get; set; }
|
||||
public string mfg { get; set; }
|
||||
public int qty { get; set; }
|
||||
public string id { get; set; }
|
||||
//public string date { get; set; }
|
||||
public string partnum { get; set; }
|
||||
public string manu { get; set; }
|
||||
|
||||
public Reel()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
public void Clear()
|
||||
{
|
||||
sid = string.Empty;
|
||||
lot = string.Empty;
|
||||
mfg = string.Empty;
|
||||
lot = string.Empty;
|
||||
id = string.Empty;
|
||||
//date = string.Empty;
|
||||
partnum = string.Empty;
|
||||
manu = string.Empty;
|
||||
qty = 0;
|
||||
}
|
||||
public Reel(string _sid, string _lot, string _manu, int _qty, string _id, string _mfgdate, string _partnum)
|
||||
{
|
||||
int sidNum = 0;
|
||||
if (int.TryParse(_sid, out sidNum) && sidNum.ToString().Length == 9)
|
||||
sid = sidNum.ToString();
|
||||
else
|
||||
throw new Exception("SID가 숫자가 아니거나 9자리 숫자가 아닙니다.");
|
||||
|
||||
lot = _lot;
|
||||
mfg = _mfgdate;
|
||||
qty = _qty;
|
||||
id = _id;
|
||||
partnum = _partnum;
|
||||
manu = _manu;
|
||||
}
|
||||
public Reel(string qrbarcodestr)
|
||||
{
|
||||
var spData = qrbarcodestr.Split(';');
|
||||
if (spData.Length < 6)
|
||||
throw new Exception("Barcode Length가 적습니다.");
|
||||
|
||||
sid = spData[0];
|
||||
lot = spData[1];
|
||||
manu = spData[2];
|
||||
|
||||
int _qty = 0;
|
||||
|
||||
if (int.TryParse(spData[3], out _qty))
|
||||
qty = _qty;
|
||||
else
|
||||
throw new Exception("수량란에 숫자 정보가 아닙니다.");
|
||||
|
||||
id = spData[4];
|
||||
mfg = spData[5];
|
||||
if (spData.Length > 6) partnum = spData[6];
|
||||
else partnum = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Handler/Sub/StdLabelPrint/Properties/AssemblyInfo.cs
Normal file
36
Handler/Sub/StdLabelPrint/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해
|
||||
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
|
||||
// 이러한 특성 값을 변경하세요.
|
||||
[assembly: AssemblyTitle("StdLabelPrint")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("StdLabelPrint")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에
|
||||
// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
|
||||
// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
|
||||
[assembly: Guid("b18d3b96-2fdf-4ed9-9a49-d9b8cee4ed6d")]
|
||||
|
||||
// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
|
||||
//
|
||||
// 주 버전
|
||||
// 부 버전
|
||||
// 빌드 번호
|
||||
// 수정 버전
|
||||
//
|
||||
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
|
||||
// 기본값으로 할 수 있습니다.
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
80
Handler/Sub/StdLabelPrint/Properties/Settings.Designer.cs
generated
Normal file
80
Handler/Sub/StdLabelPrint/Properties/Settings.Designer.cs
generated
Normal file
@@ -0,0 +1,80 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 이 코드는 도구를 사용하여 생성되었습니다.
|
||||
// 런타임 버전:4.0.30319.42000
|
||||
//
|
||||
// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
|
||||
// 이러한 변경 내용이 손실됩니다.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace StdLabelPrint.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute(@"^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR6,6~SD15^JUS^LRN^CI0^XZ
|
||||
^XA
|
||||
^MMT
|
||||
^PW519
|
||||
^LL0200
|
||||
^LS25
|
||||
^FO205,5^GB305,186,4^FS
|
||||
^FT25,170^BQN,2,4
|
||||
^FDLA,
|
||||
{qrData}
|
||||
^FS
|
||||
^FO205,9^GB0,183,4^FS
|
||||
^FO250,9^GB0,183,4^FS
|
||||
^FO209,34^GB299,0,4^FS
|
||||
^FO209,65^GB299,0,4^FS
|
||||
^FO207,95^GB300,0,4^FS
|
||||
^FO207,126^GB303,0,4^FS
|
||||
^FT211,30^A0N,23,24^FDSID^FS
|
||||
^FT210,59^A0N,23,24^FDLOT^FS
|
||||
^FT215,91^A0N,23,24^FDPN^FS
|
||||
^FT212,153^A0N,23,24^FDRID^FS
|
||||
^FT210,120^A0N,23,24^FDQ'ty^FS
|
||||
^FT260,31^A0N,23,24^FD
|
||||
{sid}
|
||||
^FS
|
||||
^FT260,60^A0N,23,24^FD
|
||||
{lot}
|
||||
^FS
|
||||
^FT258,93^A0N,27,16^FD
|
||||
{partnum}
|
||||
^FS
|
||||
^FT256,150^A0N,21,19^FD
|
||||
{rid}
|
||||
^FS
|
||||
^FT259,121^A0N,23,24^FD
|
||||
{qty}
|
||||
^FS
|
||||
^FO207,157^GB303,0,4^FS
|
||||
^FT212,182^A0N,20,19^FDDate^FS
|
||||
^FT260,183^A0N,23,24^FD
|
||||
{mfg}
|
||||
^FS
|
||||
^PQ1,0,1,Y^XZ")]
|
||||
public string zpl {
|
||||
get {
|
||||
return ((string)(this["zpl"]));
|
||||
}
|
||||
set {
|
||||
this["zpl"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
Handler/Sub/StdLabelPrint/Properties/Settings.settings
Normal file
51
Handler/Sub/StdLabelPrint/Properties/Settings.settings
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="StdLabelPrint.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="zpl" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR6,6~SD15^JUS^LRN^CI0^XZ
|
||||
^XA
|
||||
^MMT
|
||||
^PW519
|
||||
^LL0200
|
||||
^LS25
|
||||
^FO205,5^GB305,186,4^FS
|
||||
^FT25,170^BQN,2,4
|
||||
^FDLA,
|
||||
{qrData}
|
||||
^FS
|
||||
^FO205,9^GB0,183,4^FS
|
||||
^FO250,9^GB0,183,4^FS
|
||||
^FO209,34^GB299,0,4^FS
|
||||
^FO209,65^GB299,0,4^FS
|
||||
^FO207,95^GB300,0,4^FS
|
||||
^FO207,126^GB303,0,4^FS
|
||||
^FT211,30^A0N,23,24^FDSID^FS
|
||||
^FT210,59^A0N,23,24^FDLOT^FS
|
||||
^FT215,91^A0N,23,24^FDPN^FS
|
||||
^FT212,153^A0N,23,24^FDRID^FS
|
||||
^FT210,120^A0N,23,24^FDQ'ty^FS
|
||||
^FT260,31^A0N,23,24^FD
|
||||
{sid}
|
||||
^FS
|
||||
^FT260,60^A0N,23,24^FD
|
||||
{lot}
|
||||
^FS
|
||||
^FT258,93^A0N,27,16^FD
|
||||
{partnum}
|
||||
^FS
|
||||
^FT256,150^A0N,21,19^FD
|
||||
{rid}
|
||||
^FS
|
||||
^FT259,121^A0N,23,24^FD
|
||||
{qty}
|
||||
^FS
|
||||
^FO207,157^GB303,0,4^FS
|
||||
^FT212,182^A0N,20,19^FDDate^FS
|
||||
^FT260,183^A0N,23,24^FD
|
||||
{mfg}
|
||||
^FS
|
||||
^PQ1,0,1,Y^XZ</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
63
Handler/Sub/StdLabelPrint/StdLabelPrint.csproj
Normal file
63
Handler/Sub/StdLabelPrint/StdLabelPrint.csproj
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{B18D3B96-2FDF-4ED9-9A49-D9B8CEE4ED6D}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>StdLabelPrint</RootNamespace>
|
||||
<AssemblyName>StdLabelPrint</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CAmkorSTDBarcode.cs" />
|
||||
<Compile Include="Def.cs" />
|
||||
<Compile Include="LabelPrint.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
57
Handler/Sub/StdLabelPrint/app.config
Normal file
57
Handler/Sub/StdLabelPrint/app.config
Normal file
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||
<section name="StdLabelPrint.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<userSettings>
|
||||
<StdLabelPrint.Properties.Settings>
|
||||
<setting name="zpl" serializeAs="String">
|
||||
<value>^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR6,6~SD15^JUS^LRN^CI0^XZ
|
||||
^XA
|
||||
^MMT
|
||||
^PW519
|
||||
^LL0200
|
||||
^LS25
|
||||
^FO205,5^GB305,186,4^FS
|
||||
^FT25,170^BQN,2,4
|
||||
^FDLA,
|
||||
{qrData}
|
||||
^FS
|
||||
^FO205,9^GB0,183,4^FS
|
||||
^FO250,9^GB0,183,4^FS
|
||||
^FO209,34^GB299,0,4^FS
|
||||
^FO209,65^GB299,0,4^FS
|
||||
^FO207,95^GB300,0,4^FS
|
||||
^FO207,126^GB303,0,4^FS
|
||||
^FT211,30^A0N,23,24^FDSID^FS
|
||||
^FT210,59^A0N,23,24^FDLOT^FS
|
||||
^FT215,91^A0N,23,24^FDPN^FS
|
||||
^FT212,153^A0N,23,24^FDRID^FS
|
||||
^FT210,120^A0N,23,24^FDQ'ty^FS
|
||||
^FT260,31^A0N,23,24^FD
|
||||
{sid}
|
||||
^FS
|
||||
^FT260,60^A0N,23,24^FD
|
||||
{lot}
|
||||
^FS
|
||||
^FT258,93^A0N,27,16^FD
|
||||
{partnum}
|
||||
^FS
|
||||
^FT256,150^A0N,21,19^FD
|
||||
{rid}
|
||||
^FS
|
||||
^FT259,121^A0N,23,24^FD
|
||||
{qty}
|
||||
^FS
|
||||
^FO207,157^GB303,0,4^FS
|
||||
^FT212,182^A0N,20,19^FDDate^FS
|
||||
^FT260,183^A0N,23,24^FD
|
||||
{mfg}
|
||||
^FS
|
||||
^PQ1,0,1,Y^XZ</value>
|
||||
</setting>
|
||||
</StdLabelPrint.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user