using System;
using System.Collections.Generic;using System.Data;using System.Linq;using System.Web;using System.Web.Services;namespace BarCodePrintApi.WebService
{ /// <summary> /// SapWebService 中的web方法需要在RouteConfig忽略路由,否则被当做路由,无法调用方法。 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。 // [System.Web.Script.Services.ScriptService] public class SapWebService : System.Web.Services.WebService { /// <summary> /// 打印员工卡(二维码加密) /// </summary> /// <param name="systemName">SAP</param> /// <param name="templateNumber">009</param> /// <param name="barCode">二维码内容</param> /// <param name="barCodeText">二维码文本</param> /// <param name="times"></param> /// <returns></returns> [WebMethod] public string PrintStaffCode(string systemName, string templateNumber, string barCode,string barCodeText, int times) { System.Text.StringBuilder sb_Message = new System.Text.StringBuilder(); try { using (var db = new BarCodeTemplatesContext()) { string strSystemName = systemName == null ? "" : systemName; string strTemplateNumber = templateNumber == null ? "" : templateNumber; int intTimes = times;BarCodeTemplates model = db.BarCodeTemplates.Where(w => w.TemplateNumber == strTemplateNumber).OrderBy(b => b.Id).FirstOrDefault();
// 本地打印 string strPrintName = model.PrintName; //"ZDesigner GT800-300dpi EPL"; string strZplCommand = model.TemplateContent.Replace("FN1", barCode);//string strNumber = strBarCode.Substring(strBarCode.Length - 8, 8);
strZplCommand = strZplCommand.Replace("FN2", barCodeText);for (int i = 0; i < intTimes; i++)
{ string isSuccess = RawPrinterHelper.SendStringToPrinter(strPrintName, strZplCommand.ToString()); sb_Message.Append("success\r\n"); } } } catch (Exception ex) { return ex.Message; } return sb_Message.ToString(); }/// <summary>
/// FQC 条码 /// </summary> /// <param name="systemName">系统名称</param> /// <param name="templateNumber">模板编号</param> /// <param name="barCode">条码内容</param> /// <param name="times">相同条码打印次数</param> /// <returns></returns> [WebMethod] public string PrintBarCode(string systemName,string templateNumber,string barCode, int times) { System.Text.StringBuilder sb_Message = new System.Text.StringBuilder(); try { using (var db = new BarCodeTemplatesContext()) { string strSystemName = systemName == null ? "" : systemName; string strTemplateNumber = templateNumber == null ? "" : templateNumber; string strBarCode = barCode == null ? "" : barCode; int intTimes = times;BarCodeTemplates model = db.BarCodeTemplates.Where(w => w.TemplateNumber == strTemplateNumber).OrderBy(b => b.Id).FirstOrDefault();
// 本地打印 string strPrintName = model.PrintName; //"ZDesigner GT800-300dpi EPL"; string strZplCommand = model.TemplateContent.Replace("FN1", strBarCode);string strNumber = strBarCode.Substring(strBarCode.Length - 8, 8);
strZplCommand = strZplCommand.Replace("FN2", strNumber);for (int i = 0; i < intTimes; i++)
{ string isSuccess = RawPrinterHelper.SendStringToPrinter(strPrintName, strZplCommand.ToString()); sb_Message.Append("success\r\n"); } } } catch (Exception ex) { return ex.Message; } return sb_Message.ToString(); }/// <summary>
/// 浇注条码 /// </summary> /// <param name="systemName">系统名称</param> /// <param name="templateNumber">模板编号</param> /// <param name="barCode">条码内容</param> /// <param name="times">打印次数</param> /// <returns></returns> [WebMethod] public string PrintBarCode_JiaoZhu(string systemName, string templateNumber, string barCode, int times) { System.Text.StringBuilder sb_Message = new System.Text.StringBuilder(); try { using (var db = new BarCodeTemplatesContext()) { string strSystemName = systemName == null ? "" : systemName; string strTemplateNumber = templateNumber == null ? "" : templateNumber; string strBarCode = barCode == null ? "" : barCode; int intTimes = times;BarCodeTemplates model = db.BarCodeTemplates.Where(w => w.TemplateNumber == strTemplateNumber).OrderBy(b => b.Id).FirstOrDefault();
//网络打印 string strZplCommand = model.TemplateContent.Replace("FN1", strBarCode); strZplCommand = strZplCommand.Replace("FN2", strBarCode); string strIp = model.PrinterIP; int intPort = model.Port;for (int i = 0; i < intTimes; i++)
{ string isSuccess = RawPrinterHelper.SendStringToNetPrinter(strIp, intPort, strZplCommand.ToString()); sb_Message.Append("success\r\n"); } } } catch (Exception ex) { return ex.Message; } return sb_Message.ToString(); }/// <summary>
/// 浇注条码(物料号和序列号) /// </summary> /// <param name="systemName">系统名称</param> /// <param name="templateNumber">模板编号</param> /// <param name="barCode">条码内容</param> /// <param name="times">打印次数</param> /// <returns></returns> [WebMethod] public string PrintBarCode_JiaoZhu_XuliehaoAndWuliaohao(string systemName, string templateNumber, string barCode, int times) { System.Text.StringBuilder sb_Message = new System.Text.StringBuilder(); try { using (var db = new BarCodeTemplatesContext()) { string strSystemName = systemName == null ? "" : systemName; string strTemplateNumber = templateNumber == null ? "" : templateNumber; string strBarCode = barCode == null ? "" : barCode; int intTimes = times;BarCodeTemplates model = db.BarCodeTemplates.Where(w => w.TemplateNumber == strTemplateNumber).OrderBy(b => b.Id).FirstOrDefault();
string strZplCommand = model.TemplateContent; string[] arryList = barCode.Split(','); string strXuliehao = arryList[0]; string strWuliaohao = arryList[1];strZplCommand = strZplCommand.Replace("FN1", strXuliehao);//序列号二维码
if (strXuliehao.Length <= 10) { strZplCommand = strZplCommand.Replace("FN2", strXuliehao);//前10位 strZplCommand = strZplCommand.Replace("FN3", "");//后10位 } else { strZplCommand = strZplCommand.Replace("FN2", strXuliehao.Substring(0, 10));//前10位 strZplCommand = strZplCommand.Replace("FN3", strXuliehao.Substring(10, strXuliehao.Length - 10));//后10位 }strZplCommand = strZplCommand.Replace("FN4", strWuliaohao);//物料二维码
if (strWuliaohao.Length <= 10) { strZplCommand = strZplCommand.Replace("FN5", strWuliaohao);//前10位 strZplCommand = strZplCommand.Replace("FN6", "");//后10位 } else { strZplCommand = strZplCommand.Replace("FN5", strWuliaohao.Substring(0, 10));//前10位 strZplCommand = strZplCommand.Replace("FN6", strWuliaohao.Substring(10, strWuliaohao.Length - 10));//后10位 }//网络打印
string strIp = model.PrinterIP; int intPort = model.Port;for (int i = 0; i < intTimes; i++)
{ string isSuccess = RawPrinterHelper.SendStringToNetPrinter(strIp, intPort, strZplCommand.ToString()); sb_Message.Append("success\r\n"); } } } catch (Exception ex) { return ex.Message; } return sb_Message.ToString(); } /// <summary> /// 浇注条码(物料号和序列号)(OR车间) /// </summary> /// <param name="systemName">系统名称</param> /// <param name="templateNumber">模板编号</param> /// <param name="barCode">条码内容</param> /// <param name="times">打印次数</param> /// <returns></returns> [WebMethod] public string PrintBarCode_JiaoZhu_XuliehaoAndWuliaohao_ForOR(string systemName, string templateNumber, string barCode, int times) { System.Text.StringBuilder sb_Message = new System.Text.StringBuilder(); try { using (var db = new BarCodeTemplatesContext()) { string strSystemName = systemName == null ? "" : systemName; string strTemplateNumber = templateNumber == null ? "" : templateNumber; string strBarCode = barCode == null ? "" : barCode; int intTimes = times;BarCodeTemplates model = db.BarCodeTemplates.Where(w => w.TemplateNumber == strTemplateNumber).OrderBy(b => b.Id).FirstOrDefault();
string strZplCommand = model.TemplateContent; string[] arryList = barCode.Split(','); string strXuliehao = arryList[0]; string strWuliaohao = arryList[1];strZplCommand = strZplCommand.Replace("FN1", strXuliehao);//序列号二维码
if (strXuliehao.Length <= 10) { strZplCommand = strZplCommand.Replace("FN2", strXuliehao);//前10位 strZplCommand = strZplCommand.Replace("FN3", "");//后10位 } else { strZplCommand = strZplCommand.Replace("FN2", strXuliehao.Substring(0, 10));//前10位 strZplCommand = strZplCommand.Replace("FN3", strXuliehao.Substring(10, strXuliehao.Length - 10));//后10位 }strZplCommand = strZplCommand.Replace("FN4", strWuliaohao);//物料二维码
if (strWuliaohao.Length <= 10) { strZplCommand = strZplCommand.Replace("FN5", strWuliaohao);//前10位 strZplCommand = strZplCommand.Replace("FN6", "");//后10位 } else { strZplCommand = strZplCommand.Replace("FN5", strWuliaohao.Substring(0, 10));//前10位 strZplCommand = strZplCommand.Replace("FN6", strWuliaohao.Substring(10, strWuliaohao.Length - 10));//后10位 } string strPrintName = model.PrintName; int intPort = model.Port;for (int i = 0; i < intTimes; i++)
{ //string isSuccess = RawPrinterHelper.SendStringToNetPrinter(strIp, intPort, strZplCommand.ToString()); string isSuccess = RawPrinterHelper.SendStringToPrinter(strPrintName, strZplCommand.ToString()); sb_Message.Append(isSuccess + "\r\n"); } } } catch (Exception ex) { return ex.Message; } return sb_Message.ToString(); }/// <summary>
/// 中压IQC /// </summary> /// <param name="systemName">从哪个系统调用</param> /// <param name="templateNumber">模板编号</param> /// <param name="QCPASS">检验合格</param> /// <param name="times">次数</param> /// <param name="WuLiao">物料号</param> /// <param name="Count">打印多少张</param> /// <param name="ShuLiang">每张数量</param> /// <param name="WeiShu">位数是多少</param> /// <param name="PiCi">批次号</param> /// <param name="GongYingShang">供应商</param> /// <param name="JianYanYuan">检验员</param> /// <param name="RiQi">日期</param> /// <param name="CaiGouDingDan">采购订单</param> /// <returns></returns> [WebMethod] public string PrintBarCode_IQC(string systemName,string templateNumber,string QCPASS,int times,string WuLiao,int Count,string ShuLiang,string WeiShu,string PiCi,string GongYingShang,string JianYanYuan,string RiQi,string CaiGouDingDan) { System.Text.StringBuilder sb_Message = new System.Text.StringBuilder(); try { for (int i = 0; i < times; i++) { for (int y = 1; y <= Count; y++) { using (var db = new BarCodeTemplatesContext()) { string strSystemName = systemName; string strTemplateNumber = templateNumber; int intTimes = times; int count = Count; string strWuLiao = WuLiao; string strShuLiang = ShuLiang =="" ? "0" : ShuLiang; string strWeiShu = WeiShu == "" ? "0" : WeiShu; string strPiCi = PiCi; string strGongYingShang = GongYingShang; string strJianYanYuan = JianYanYuan; string strRiQi = RiQi; string strCaiGouDingDan = CaiGouDingDan; BarCodeTemplates model = db.BarCodeTemplates.Where(w => w.TemplateNumber == strTemplateNumber).OrderBy(b => b.Id).FirstOrDefault(); // 本地打印 string strPrintName = model.PrintName; //"ZDesigner GT800-300dpi EPL";string strZplCommand = model.TemplateContent;
strZplCommand = model.TemplateContent.Replace("WuLiao", strWuLiao);
sb_Message.Append("WeiShu:" + strWeiShu);
if (Count == 1)//只有一张的情况 { if (strWeiShu=="ZERO")// { strZplCommand = strZplCommand.Replace("ShuLiang", strShuLiang); } else { strZplCommand = strZplCommand.Replace("ShuLiang", strWeiShu); } } else { //两张以上,含两张 if (y == Count && strWeiShu != "ZERO")//最后一张的情况且有尾数的情况下 { strZplCommand = strZplCommand.Replace("ShuLiang", strWeiShu); } else { strZplCommand = strZplCommand.Replace("ShuLiang", strShuLiang); } } //strZplCommand = strZplCommand.Replace("WeiShu", strWeiShu); strZplCommand = strZplCommand.Replace("PiCi", strPiCi); strZplCommand = strZplCommand.Replace("GongYingShang", strGongYingShang); strZplCommand = strZplCommand.Replace("JianYanYuan", strJianYanYuan); strZplCommand = strZplCommand.Replace("RiQi", strRiQi); strZplCommand = strZplCommand.Replace("CaiGouDingDan", strCaiGouDingDan); strZplCommand = strZplCommand.Replace("QR", strWuLiao + "," + strPiCi); strZplCommand = strZplCommand.Replace("QCPASS", QCPASS);//日志
System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(string.Format("[当前时间={0}]",System.DateTime.Now.ToString())); sb.Append(string.Format(" [系统名称={0}]",systemName)); sb.Append(string.Format(" [模板编号={0}]", strTemplateNumber)); sb.Append(string.Format(" [打印份数={0}]", intTimes.ToString())); sb.Append(string.Format(" [打印张数={0}]", count.ToString())); sb.Append(string.Format(" [物料编号={0}]", strWuLiao)); sb.Append(string.Format(" [数量={0}]", strShuLiang)); sb.Append(string.Format(" [尾数={0}]", strWeiShu)); sb.Append(string.Format(" [批次={0}]", strPiCi)); sb.Append(string.Format(" [供应商={0}]", strGongYingShang)); sb.Append(string.Format(" [检验员={0}]", strJianYanYuan)); sb.Append(string.Format(" [日期={0}]", strRiQi)); sb.Append(string.Format(" [采购订单={0}]",strCaiGouDingDan));//SystemLog.WriterLog(sb.ToString());
for (int j = 0; j < intTimes; j++) { string isSuccess = RawPrinterHelper.SendStringToPrinter(strPrintName, strZplCommand.ToString()); sb_Message.Append("success\r\n"); } } } } } catch (Exception ex) { return sb_Message.ToString(); } return sb_Message.ToString(); }/// <summary>
/// /// </summary> /// <param name="strLeftOrRight">L代表在左边打印,R代表在右边打印</param> /// <param name="strKeHuTuHao">客户图号</param> /// <param name="strKeHuTuHaoBanBen">客户图号版本号</param> /// <param name="strXuLieHao">序列号</param> /// <param name="strGongYingShangDaiMa">供应商代码</param> /// <param name="strDingDanHao">订单号</param> /// <param name="strShengChanRiQi">生产日期</param> /// <param name="strWuLiaohao">物料号</param> /// <param name="strInfo">标签信息,格式为:MX- 序列号-浇注号-炉次-模具号</param> /// <returns></returns> public string PrintBarCode_MEHV_QRCode(string strLeftOrRight, string strKeHuTuHao, string strKeHuTuHaoBanBen, string strXuLieHao, string strGongYingShangDaiMa, string strDingDanHao, string strShengChanRiQi , string strWuLiaohao, string strInfo) { System.Text.StringBuilder sb_Message = new System.Text.StringBuilder();try
{ using (var db = new BarCodeTemplatesContext()) { string strSystemName = "MEHV"; string strTemplateNumber = "011";//string strBarCode = barCode == null ? "" : barCode;
int intTimes = 1; BarCodeTemplates model = db.BarCodeTemplates.Where(w => w.TemplateNumber == strTemplateNumber).OrderBy(b => b.Id).FirstOrDefault(); string strIp = model.PrinterIP; int intPort = model.Port; //网络打印 string strTemplateLeftAndRight = model.TemplateContent; string[] arrTemplate = model.TemplateContent.Split('|'); string strZplCommand = ""; if (strLeftOrRight == "L")//左边模板 { strZplCommand = arrTemplate[0]; } if (strLeftOrRight == "R")//右边模板 { strZplCommand = arrTemplate[1]; } strShengChanRiQi = strShengChanRiQi.Replace("0:00:00", "");//生产日期去除时间strZplCommand = strZplCommand.Replace("KeHuTuHao", strKeHuTuHao);
strZplCommand = strZplCommand.Replace("BanBen", strKeHuTuHaoBanBen); strZplCommand = strZplCommand.Replace("XuLieHao", strXuLieHao); strZplCommand = strZplCommand.Replace("GongYingShangDaiMa", strGongYingShangDaiMa); strZplCommand = strZplCommand.Replace("DingDanHao",strDingDanHao); strZplCommand = strZplCommand.Replace("ShengChanRiQi", strShengChanRiQi); strZplCommand = strZplCommand.Replace("WuLiaoHao",strWuLiaohao); strZplCommand = strZplCommand.Replace("Info",strInfo);// 二维码内容格式:*客户图号*客户图号版本号*供应商代码**序列号*生产日期
strDingDanHao = ""; string strQRCode_Customer = string.Format("*{0}*{1}*{2}*{3}*{4}*{5}*" ,strKeHuTuHao // 客户图号 ,strKeHuTuHaoBanBen // 客户图号版本号 ,strGongYingShangDaiMa // 供应商代码 ,strDingDanHao // 订单号 ,strXuLieHao // 序列号 ,strShengChanRiQi // 生产日期 ); strZplCommand = strZplCommand.Replace("QR_Customer",strQRCode_Customer); string strQRCode_Motic = string.Format("{0}-{1}", strWuLiaohao, strInfo); strZplCommand = strZplCommand.Replace("QR_Motic",strQRCode_Motic); for (int i = 0; i < intTimes; i++) { //网络打印 //string isSuccess = RawPrinterHelper.SendStringToNetPrinter(strIp, intPort, strZplCommand.ToString()); //sb_Message.Append("success\r\n"); //本地打印 string isSuccess = RawPrinterHelper.SendStringToPrinter(model.PrintName, strZplCommand.ToString()); sb_Message.Append("success\r\n"); }}
} catch (Exception ex) { return ex.Message; } return sb_Message.ToString(); }[WebMethod]
public string PrintBarCode_MEHV_QRCodeByDataTable(DataTable dtData) { System.Text.StringBuilder sb_Message = new System.Text.StringBuilder(); #region 打印命令备份 // string strTemplateContent = @"//CT~~CD,~CC^~CT~//^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR2,2~SD25^JUS^LRN^CI0^XZ//^XA//^MMT//^PW639//^LL0080//^LS0//^FT237,75^BQN,2,2//^FT12,83^BQN,2,2//^FDLA,QR_Customer0^FS//^FT85,65^A0N,20,20^FH\^FDInfo0^FS//^FT85,40^A0N,20,20^FH\^FDWuLiaoHao0^FS//^FT556,76^BQN,2,2//^FT335,83^BQN,2,2//^FDLA,QR_Customer1^FS//^FT410,65^A0N,20,20^FH\^FDInfo1^FS//^FT410,40^A0N,20,20^FH\^FDWuLiaoHao1^FS//^PQ1,0,1,Y^XZ // "; #endregion try { using (var db = new BarCodeTemplatesContext()) { string strSystemName = "MEHV"; string strTemplateNumber = "011"; int intTimes = 1; BarCodeTemplates model = db.BarCodeTemplates.Where(w => w.TemplateNumber == strTemplateNumber).OrderBy(b => b.Id).FirstOrDefault(); string strIp = model.PrinterIP; int intPort = model.Port; string strZplCommand = model.TemplateContent; for (int i = 0; i < dtData.Rows.Count; i++) { // 数据部分代码 string strKeHuTuHao // 客户图号 , strKeHuTuHaoBanBen // 客户图号版本号 , strGongYingShangDaiMa // 供应商代码 , strDingDanHao // 订单号 , strXuLieHao // 序列号 , strJzNo // 浇注批号 , strLuCi // 炉次 , strMoJuNum // 模具号 , strShengChanRiQi // 生产日期 , strWuLiaohao // 物料号 , strInfo // 格式为:MX- 序列号-浇注号-炉次-模具号 , strQRCode_Customer // 客户二维码内容 , strQRCode_Motic; // Motic二维码内容 strKeHuTuHao = dtData.Rows[i]["CTNO"].ToString(); strKeHuTuHaoBanBen = dtData.Rows[i]["CTNO_Version"].ToString(); strKeHuTuHao = strKeHuTuHao.Replace("-" + strKeHuTuHaoBanBen, "");//从图号中去除版本号 strGongYingShangDaiMa = dtData.Rows[i]["SupplierNo"].ToString(); strDingDanHao = "";//默认不体现在标签上,所以为空 strXuLieHao = dtData.Rows[i]["SerialNo"].ToString(); strJzNo = dtData.Rows[i]["JzNo"].ToString(); strLuCi = dtData.Rows[i]["LuCi"].ToString(); strMoJuNum = dtData.Rows[i]["mojuNo"].ToString(); strShengChanRiQi = dtData.Rows[i]["ShengChanRiQi"].ToString().Replace("0:00:00", "").Replace("/","-").Trim();//生产日期去除时间 strWuLiaohao = dtData.Rows[i]["ProductName"].ToString(); strDingDanHao = "";strInfo = string.Format("{0}-{1}-{2}-{3}"
, "MX" + strXuLieHao , strJzNo , strLuCi , strMoJuNum);// 客户二维码
//strQRCode_Customer = string.Format("*{0}*{1}*{2}*{3}*{4}*{5}*" // , strKeHuTuHao // 客户图号 // , strKeHuTuHaoBanBen // 客户图号版本号 // , strGongYingShangDaiMa // 供应商代码 // , strDingDanHao // 订单号 // //, strXuLieHao // 序列号 // , strInfo // 序列号,完整的序列号用中间的文本(已经拼接好) // , strShengChanRiQi // 生产日期 // ); strQRCode_Customer = string.Format("*{0}*{1}*{2}**{3}*{4}*{5}*1*" , strKeHuTuHao.Replace(" ","") // 客户图号 , strKeHuTuHaoBanBen.Replace(" ","") // 客户图号版本号 , strGongYingShangDaiMa // 供应商代码 , strDingDanHao // 订单号 , strInfo // 序列号,完整的序列号用中间的文本(已经拼接好) , strShengChanRiQi // 生产日期 );// ME内部二维码(暂时不体现在标签上,已经从打印机命令去除)
strQRCode_Motic = string.Format("{0}", strInfo); // 奇数替换左边末班 if (i % 2 == 0) { strZplCommand = strZplCommand.Replace("WuLiaoHao0", strWuLiaohao); strZplCommand = strZplCommand.Replace("QR_Customer0", strQRCode_Customer); // 二维码内容格式:*客户图号*客户图号版本号*供应商代码**序列号*生产日期 strZplCommand = strZplCommand.Replace("Info0", strInfo); // 格式为:MX- 序列号-浇注号-炉次-模具号 strZplCommand = strZplCommand.Replace("QR_Motic0", strQRCode_Motic); // 格式为:MX- 序列号-浇注号-炉次-模具号 }//偶数替换右边模板,并打印
if (i % 2 == 1) { strZplCommand = strZplCommand.Replace("WuLiaoHao1", strWuLiaohao); strZplCommand = strZplCommand.Replace("QR_Customer1", strQRCode_Customer); // 二维码内容格式:*客户图号*客户图号版本号*供应商代码**序列号*生产日期 strZplCommand = strZplCommand.Replace("Info1", strInfo); // 格式为:MX- 序列号-浇注号-炉次-模具号 strZplCommand = strZplCommand.Replace("QR_Motic1", strQRCode_Motic); // 格式为:MX- 序列号-浇注号-炉次-模具号 for (int j = 0; j < intTimes; j++) { string isSuccess = RawPrinterHelper.SendStringToPrinter(model.PrintName, strZplCommand.ToString());//\\\\it-chengeng\\ZDesigner GK888t sb_Message.Append("success\r\n"); } }//最后一条是奇数的时候打印
if (i == dtData.Rows.Count - 1 && i % 2 == 0) { for (int j = 0; j < intTimes; j++) { string isSuccess = RawPrinterHelper.SendStringToPrinter(model.PrintName, strZplCommand.ToString());//\\\\it-chengeng\\ZDesigner GK888t sb_Message.Append("success\r\n"); } } }}
} catch (Exception ex) { return ex.Message; } return sb_Message.ToString(); } /// <summary> /// OR 毛坯工位 /// </summary> /// <param name="strWuLiaoHao"></param> /// <param name="strXuLieHao"></param> /// <returns></returns> [WebMethod] public string PrintBarCode_OR_MaoPi(string systemName,string templateNumber,int times,string strWuLiaoHao,string strXuLieHao) { System.Text.StringBuilder sb_Message = new System.Text.StringBuilder();try
{ using (var db = new BarCodeTemplatesContext()) {//string strBarCode = barCode == null ? "" : barCode;
BarCodeTemplates model = db.BarCodeTemplates.Where(w => w.TemplateNumber == templateNumber).OrderBy(b => b.Id).FirstOrDefault(); string strIp = model.PrinterIP; int intPort = model.Port; //网络打印 string strTemplateLeftAndRight = model.TemplateContent;string strZplCommand = model.TemplateContent;
strZplCommand = strZplCommand.Replace("WuLiaoHao", strWuLiaoHao);
strZplCommand = strZplCommand.Replace("XuLieHao", strXuLieHao);for (int i = 0; i < times; i++)
{ //网络打印 //string isSuccess = RawPrinterHelper.SendStringToNetPrinter(strIp, intPort, strZplCommand.ToString()); //sb_Message.Append("success\r\n"); //本地打印 string isSuccess = RawPrinterHelper.SendStringToPrinter(model.PrintName, strZplCommand.ToString()); sb_Message.Append("success\r\n"); }}
} catch (Exception ex) { return ex.Message; } return sb_Message.ToString(); } }}