146 lines
4.7 KiB
C#
146 lines
4.7 KiB
C#
using Epost.BLL;
|
|
using Epost.Common;
|
|
using Epost.Model;
|
|
using FastReport;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace PrintBoxFormsApp
|
|
{
|
|
public partial class PrintList : Form
|
|
{
|
|
|
|
|
|
AddressstorageBLL addrBLL = new AddressstorageBLL();
|
|
Print_BoxBLL boxbll = new Print_BoxBLL();
|
|
private Thread timerThreadDown;//创建线程11111111111111111111111111111
|
|
private Thread timerThreadUp;//创建线程
|
|
int SleepTime = 1;
|
|
public PrintList()
|
|
{
|
|
|
|
if (!string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["SleepTime"]))
|
|
{
|
|
int.TryParse(ConfigurationManager.AppSettings["SleepTime"], out SleepTime);
|
|
}
|
|
|
|
InitializeComponent();
|
|
if (System.Diagnostics.Process.GetProcessesByName("ReturnDataForms").ToList().Count > 1)
|
|
{
|
|
try
|
|
{
|
|
//存在
|
|
MessageBox.Show("请关闭已经启动的程序后再进行尝试");
|
|
System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcessesByName("ReturnDataForms");
|
|
foreach (System.Diagnostics.Process p in ps)
|
|
{
|
|
p.Kill();
|
|
}
|
|
MessageBox.Show("已经帮您关闭进程,请您重新启动");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
LogHelper.WriteLogInfo("程序已经启动提示异常:" + ex.Message);
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
LogHelper.WriteLogInfo("程序启动-版本20191228");
|
|
timerThreadDown = new Thread(new ThreadStart(GetWorkList));
|
|
timerThreadDown.Start();
|
|
//timerThreadUp = new Thread(new ThreadStart(GetWorkList_DN));
|
|
//timerThreadUp.Start();
|
|
|
|
}
|
|
}
|
|
|
|
#region 获取订单信息
|
|
private void GetWorkList()
|
|
{
|
|
while (true)
|
|
{
|
|
try
|
|
{
|
|
LogHelper.WriteLogInfo("打印程序运行中");
|
|
Print();
|
|
|
|
Thread.Sleep(1000 * SleepTime);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":程序异常!\r\n" + ex.Message);
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 打印
|
|
public void Print()
|
|
{
|
|
try
|
|
{
|
|
//换箱打印
|
|
print_box();
|
|
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.WriteLogInfo("打印异常:" + ex.Message, LogHelper.Log_Type.ERROR);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 换箱打印
|
|
public void print_box()
|
|
{
|
|
List<AddressstorageModel> Arealist = addrBLL.GetOrderWayList();
|
|
if (Arealist.Any())
|
|
{
|
|
foreach (AddressstorageModel areaitem in Arealist)
|
|
{
|
|
//查询需要打印的列表
|
|
DataTable dt = boxbll.GetPrintList(areaitem.way);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
string filePath = ConfigurationManager.AppSettings["Print_Box" + areaitem.way];
|
|
LogHelper.WriteLogInfo("文件路径" + filePath + "\r\n");
|
|
foreach (DataRow item in dt.Rows)
|
|
{
|
|
string totalcount = string.Empty;
|
|
//if (Convert.ToInt32(item["totalcount"].ToString()) > 0)
|
|
//{
|
|
// totalcount = "共" + item["totalcount"].ToString() + "箱";
|
|
//}
|
|
//string boxno = "第" + item["boxno"].ToString() + "箱";
|
|
FastReportHelper.Report_Box(@filePath, "", item["shopid"].ToString(), item["shopname"].ToString(), item["boxcode"].ToString(), item["matchid"].ToString(), item["city"].ToString(), item["orderway"].ToString(), totalcount, item["printstate"].ToString(), item["senddate"].ToString(), item["loc"].ToString(), out Report rep);
|
|
boxbll.UpPrintList(item["id"].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
}
|