//using Admin.NET.Application;
//using iWareCommon.Utils;
//using iWareSql.WmsDBModel;
//using System;
//using System.Collections.Generic;
//using System.Data;
//using System.Linq;
//using System.Threading;
//namespace iWareCC
//{
// ///
// /// 打印处理的线程
// ///
// public class PrintHandler
// {
// public static void Handler()
// {
// var errMsg = "";
// while (true)
// {
// try
// {
// SystemWarningMsg._lbl_Alert_PrintHandler = "循环开始...";
// if (SystemValue.isAllowRuning_PrintHandler && SystemValue.isStartedModel)
// {
// errMsg = "";//重置
// try
// {
// Do(ref errMsg);
// if (!string.IsNullOrEmpty(errMsg))
// {
// SystemWarningMsg._lbl_Alert_PrintHandler = errMsg;
// }
// }
// catch (Exception ex)
// {
// Log4NetHelper.WriteErrorLog(LogType.PrintHandler, "打印处理的线程=>" + errMsg + ",异常:" + ex.Message, ex);
// SystemWarningMsg._lbl_Alert_PrintHandler = "打印处理的线程=>" + errMsg + ",异常:" + ex.Message;
// }
// }
// }
// catch (Exception ex)
// {
// SystemWarningMsg._lbl_Alert_PrintHandler = "出现异常:" + ex.Message;
// Log4NetHelper.WriteErrorLog(LogType.PrintHandler, "PrintHandler 出现异常:" + ex.Message, ex);
// }
// Thread.Sleep(2 * 1000);//休眠2秒
// }
// }
// ///
// /// 打印
// ///
// ///
// ///
// ///
// ///
// private static void Do(ref string errMsg)
// {
// using (WmsDBModel mycontext = new WmsDBModel())
// {
// var query_PrintStatuEnum = (int)PrintStatuEnum.未打印;
// var list = mycontext.wms_record_print.Where(x => (x.IsDelete == false) && x.PrintStatus == query_PrintStatuEnum)
// .OrderBy(x => x.Id).ToList();
// wms_config_print printConfig = null;
// string _PrinterName = "";
// if (list.Count > 0)
// {
// }
// else
// {
// errMsg = $"没有可打印的内容!";
// return;
// }
// foreach (var item in list)
// {
// PrintClassifyEnum printClassifyEnum = PrintClassifyEnum.包装条码;
// printConfig = mycontext.wms_config_print.Where(x => x.PrintClassify == (int)printClassifyEnum).FirstOrDefault();
// if (printConfig == null)
// {
// errMsg = $"没有找到{printClassifyEnum.ToString()}的打印配置!";
// return;
// }
// //设置打印机,注意:这里只获取第一个,以后可能要改!
// _PrinterName = printConfig.PrinterList.Split(',')[0];
// //根据配置名字查询 打印机名字
// //var printConfigData = mycontext.SysDictData.Where(x => x.Name == _PrinterName).FirstOrDefault();
// //if (printConfigData == null)
// //{
// // errMsg = $"没有找到{_PrinterName.ToString()}的打印机名字!";
// // return;
// //}
// //_PrinterName = printConfigData.Value;
// Dictionary data = new Dictionary();
// if (printClassifyEnum == PrintClassifyEnum.包装条码)
// {
// //data.Add("bar", item.SNCode);
// //data.Add("material", item.MaterialCode ?? "" + "/" + item.MaterialName ?? "");
// //data.Add("supplier", item.SupplierName ?? "");
// //data.Add("unit", item.MaterialUnit ?? "");
// //data.Add("qty", item.Quantity);
// //data.Add("date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
// }
// else
// {
// }
// //调用打印接口
// bool isSuccess = false;
// using (PrintBaseService.PrintWcfServiceClient client = new PrintBaseService.PrintWcfServiceClient())
// {
// //isSuccess = client.Print3(data, 1, @"D:\打印程序\跟踪码打印模板\跟踪码打印模板_一维码.btw", "ZDesigner ZD888-203dpi ZPL", out errMsg);
// //isSuccess = client.Print3(data, 1, @"D:\打印程序\跟踪码打印模板\跟踪码打印模板_二维码.btw", "ZDesigner ZD888-203dpi ZPL", out errMsg);
// isSuccess = client.Print3(data, item.PrintSheetNum, printConfig.PrintTemplateAddr, _PrinterName, out errMsg);
// }
// if (isSuccess)
// {
// item.PrintStatus = 1;//打印状态(0:未打印 1:已打印)
// item.PrintNum = (item.PrintNum) + 1;
// mycontext.SaveChanges();
// }
// else
// {
// errMsg = $"打印错误 打印机名称{_PrinterName},错误信息:(打印服务返回)" + errMsg;
// Log4NetHelper.WriteErrorLog(LogType.PrintHandler, errMsg, null);
// return;
// }
// Thread.Sleep(2000);
// }
// }
// }
// }
//}