|
|
//using System;
|
|
|
//using System.Collections.Generic;
|
|
|
//using System.Text;
|
|
|
//using System.Data;
|
|
|
//using System.IO;
|
|
|
//using Com.Estsh.MES.App;
|
|
|
|
|
|
//namespace Estsh.Core.Util
|
|
|
//{
|
|
|
// public class Printer
|
|
|
// {
|
|
|
// /// <summary>
|
|
|
// /// Bartender 程序存放的路径
|
|
|
// /// </summary>
|
|
|
// private static string BarTenderPath =
|
|
|
// Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"App_Data\Bartend\bartend.exe");
|
|
|
// /// <summary>
|
|
|
// /// 标签文件存放的路径
|
|
|
// /// </summary>
|
|
|
// private static string LabelPath =
|
|
|
// Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"App_Data\LabelFile");
|
|
|
// /// <summary>
|
|
|
// /// 标签模板的文件全名
|
|
|
// /// </summary>
|
|
|
// private static string LabelTemplatePath = Path.Combine(LabelPath, "LableDemo2.btw");
|
|
|
// /// <summary>
|
|
|
// /// 数据源(TXT)的文件全名
|
|
|
// /// </summary>
|
|
|
// private static string LabelTextPath = Path.Combine(LabelPath, "gcd.txt");
|
|
|
// /// <summary>
|
|
|
// /// 共享锁对象,用于线程并发处理
|
|
|
// /// </summary>
|
|
|
// private static object _lock_print_object = new object();
|
|
|
// /// <summary>
|
|
|
// /// TAB 字符
|
|
|
// /// </summary>
|
|
|
// private const char TAB = '\t';
|
|
|
// /// <summary>
|
|
|
// /// 回车+换行 字符
|
|
|
// /// </summary>
|
|
|
// private const string NEW_LINE = "\r\n";
|
|
|
|
|
|
// /// <summary>
|
|
|
// /// 打印一张过程条码,数据源的域以 TAB 字符分割
|
|
|
// /// </summary>
|
|
|
// /// <param name="snData"></param>
|
|
|
// /// <returns></returns>
|
|
|
// public static bool PrintSerialNumber(DataRow snData)
|
|
|
// {
|
|
|
// if (snData == null)
|
|
|
// {
|
|
|
// return false;
|
|
|
// }
|
|
|
// StringBuilder PrintContent = new StringBuilder();
|
|
|
|
|
|
// PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(snData["serial_number"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(snData["part_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(snData["type"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(snData["model_code"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(snData["part_spec"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(snData["part_location"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(snData["create_ymd"].ToString());
|
|
|
// PrintContent.Append(" ");
|
|
|
// PrintContent.Append(snData["create_hms"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(snData["model_type"].ToString());
|
|
|
// lock (_lock_print_object)
|
|
|
// {
|
|
|
// BarTenderPrinter.WriteFile(LabelTextPath, PrintContent.ToString(), Encoding.UTF8, false);
|
|
|
// BarTenderPrinter.Print(BarTenderPath, LabelTemplatePath);
|
|
|
// BarTenderPrinter.WriteFile(LabelTextPath, null, Encoding.UTF8, false);
|
|
|
// }
|
|
|
// return true;
|
|
|
// }
|
|
|
|
|
|
// /// <summary>
|
|
|
// /// 打印所有的物料条码
|
|
|
// /// </summary>
|
|
|
// /// <param name="snData">条码数据</param>
|
|
|
// /// <returns></returns>
|
|
|
// public static String PrintSerialNumber(DataTable snData)
|
|
|
// {
|
|
|
// if (snData == null)
|
|
|
// {
|
|
|
// return "Fail";
|
|
|
// }
|
|
|
// StringBuilder PrintContent = new StringBuilder();
|
|
|
|
|
|
// foreach (DataRow dr in snData.Rows)
|
|
|
// {
|
|
|
// PrintContent.Append(dr["carton_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["part_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["part_spec"]); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["qty"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["lot_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["vendor_name"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["carton_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["order_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(Environment.NewLine);
|
|
|
|
|
|
// }
|
|
|
// lock (_lock_print_object)
|
|
|
// {
|
|
|
// try
|
|
|
// {
|
|
|
// BarTenderPrinter.WriteFile(LabelTextPath, PrintContent.ToString(), Encoding.UTF8, false);
|
|
|
// BarTenderPrinter.Print(BarTenderPath, LabelTemplatePath);
|
|
|
// BarTenderPrinter.WriteFile(LabelTextPath, null, Encoding.UTF8, false);
|
|
|
// }
|
|
|
// catch (Exception e)
|
|
|
// {
|
|
|
// return e.message;
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
// return "OK";
|
|
|
// }
|
|
|
// /// <summary>
|
|
|
// /// 打印所有的物料条码
|
|
|
// /// </summary>
|
|
|
// /// <param name="snData">条码数据</param>
|
|
|
// /// <returns></returns>
|
|
|
// public static String PrintSerialData(DataTable snData)
|
|
|
// {
|
|
|
// if (snData == null)
|
|
|
// {
|
|
|
// return "Fail";
|
|
|
// }
|
|
|
// StringBuilder PrintContent = new StringBuilder();
|
|
|
|
|
|
// //string OldPN = snData.Rows[0]["part_no"].ToString();
|
|
|
// //// 标签序号,同一个零件号的箱子进行累加
|
|
|
// //int Seq = 1;
|
|
|
// //int MaxSeq = snData.Select("part_no='" + OldPN + "'").Length;
|
|
|
|
|
|
// foreach (DataRow dr in snData.Rows)
|
|
|
// {
|
|
|
// // 如果零件号出现变化,序号重置
|
|
|
// //if (OldPN != dr["part_no"].ToString())
|
|
|
// //{
|
|
|
// // OldPN = dr["part_no"].ToString();
|
|
|
// // Seq = 1;
|
|
|
// // MaxSeq = snData.Select("part_no='" + OldPN + "'").Length;
|
|
|
// //}
|
|
|
|
|
|
// PrintContent.Append(dr["carton_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["part_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["part_spec"]); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["qty"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["lot_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["vendor_name"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["carton_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(dr["order_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// PrintContent.Append(Environment.NewLine);
|
|
|
|
|
|
// //PrintContent.Append(dr["locate_name"].ToString()); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(dr["receive_time"].ToString()); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(string.Format("{0}/{1}", Seq, MaxSeq)); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(dr["print_time"].ToString()); PrintContent.Append(TAB);
|
|
|
|
|
|
// //PrintContent.Append(dr["pack_type"].ToString()); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(TAB); // 备注,暂时留空
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //PrintContent.Append(dr["part_spec"]); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(dr["part_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(dr["order_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(dr["locate_name"].ToString()); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(dr["receive_time"].ToString()); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(string.Format("{0}/{1}",Seq, MaxSeq)); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(dr["print_time"].ToString()); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(dr["qty"].ToString()); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(dr["pack_type"].ToString()); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(TAB); // 备注,暂时留空
|
|
|
// //PrintContent.Append(dr["carton_no"].ToString()); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(dr["vendor_name"].ToString()); PrintContent.Append(TAB);
|
|
|
// //PrintContent.Append(Environment.NewLine);
|
|
|
|
|
|
// // 累加序号
|
|
|
// //Seq++;
|
|
|
// }
|
|
|
|
|
|
// lock (_lock_print_object)
|
|
|
// {
|
|
|
// BarTenderPrinter.WriteFile(LabelTextPath, PrintContent.ToString(), Encoding.UTF8, false);
|
|
|
// BarTenderPrinter.Print(BarTenderPath, LabelTemplatePath);
|
|
|
// BarTenderPrinter.WriteFile(LabelTextPath, null, Encoding.UTF8, false);
|
|
|
// }
|
|
|
|
|
|
// return "OK";
|
|
|
// }
|
|
|
// }
|
|
|
//}
|