|
|
@ -8,6 +8,7 @@ using SlnMesnac.LabelPrint.FileOperate;
|
|
|
|
using SlnMesnac.LabelPrint.Log4net;
|
|
|
|
using SlnMesnac.LabelPrint.Log4net;
|
|
|
|
using SlnMesnac.LabelPrint.Model;
|
|
|
|
using SlnMesnac.LabelPrint.Model;
|
|
|
|
using SlnMesnac.LabelPrint.TaskQueue;
|
|
|
|
using SlnMesnac.LabelPrint.TaskQueue;
|
|
|
|
|
|
|
|
using SlnMesnac.LabelPrint.Timer;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
@ -24,6 +25,7 @@ namespace SlnMesnac.LabelPrint.viewModel
|
|
|
|
private readonly TaskHelper taskHelper = TaskHelper.Instance;
|
|
|
|
private readonly TaskHelper taskHelper = TaskHelper.Instance;
|
|
|
|
private readonly JsonChange jsonChange = JsonChange.Instance;
|
|
|
|
private readonly JsonChange jsonChange = JsonChange.Instance;
|
|
|
|
private readonly PrintManager printManager = PrintManager.Instance;
|
|
|
|
private readonly PrintManager printManager = PrintManager.Instance;
|
|
|
|
|
|
|
|
private readonly PrintTimer printTimer = PrintTimer.Instance;
|
|
|
|
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
|
|
|
|
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
|
|
|
|
private ObservableCollection<BaseLabelInfo> labelItems = new ObservableCollection<BaseLabelInfo>();
|
|
|
|
private ObservableCollection<BaseLabelInfo> labelItems = new ObservableCollection<BaseLabelInfo>();
|
|
|
|
#region 参数定义
|
|
|
|
#region 参数定义
|
|
|
@ -56,6 +58,11 @@ namespace SlnMesnac.LabelPrint.viewModel
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public RelayCommand ImportFilesCommand { get; set; }
|
|
|
|
public RelayCommand ImportFilesCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 手动执行
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public RelayCommand ManualExecutionCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 开始打印
|
|
|
|
/// 开始打印
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -73,7 +80,9 @@ namespace SlnMesnac.LabelPrint.viewModel
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
taskHelper.ClearLabelInfoDataGridEvent += ClearLabelInfoDataGrid;
|
|
|
|
taskHelper.ClearLabelInfoDataGridEvent += ClearLabelInfoDataGrid;
|
|
|
|
|
|
|
|
printTimer.LogRefreshEvent += PrintMessageToListBox;
|
|
|
|
ImportFilesCommand = new RelayCommand(ImportFile);
|
|
|
|
ImportFilesCommand = new RelayCommand(ImportFile);
|
|
|
|
|
|
|
|
ManualExecutionCommand = new RelayCommand(ManualExecution);
|
|
|
|
StartPrintCommand = new RelayCommand(StartPrint);
|
|
|
|
StartPrintCommand = new RelayCommand(StartPrint);
|
|
|
|
StopPrintCommand = new RelayCommand(StopPrint);
|
|
|
|
StopPrintCommand = new RelayCommand(StopPrint);
|
|
|
|
}catch(Exception ex)
|
|
|
|
}catch(Exception ex)
|
|
|
@ -119,18 +128,19 @@ namespace SlnMesnac.LabelPrint.viewModel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 开始打印事件实现
|
|
|
|
/// 手动打印
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private void StartPrint()
|
|
|
|
private void ManualExecution()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var info = taskHelper.GetTask();
|
|
|
|
var info = taskHelper.GetTask();
|
|
|
|
if(info == null)
|
|
|
|
if (info == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.PrintMessageToListBox("未获取到需要打印的任务");
|
|
|
|
this.PrintMessageToListBox("未获取到需要打印的任务");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.PrintMessageToListBox($"开始打印标签信息:{jsonChange.ModeToJson(info)}");
|
|
|
|
this.PrintMessageToListBox($"开始打印标签信息:{jsonChange.ModeToJson(info)}");
|
|
|
|
|
|
|
|
Thread.Sleep(500);
|
|
|
|
if (info.column_A == null)
|
|
|
|
if (info.column_A == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.PrintMessageToListBox($"{info.productType}打印任务执行失败,A列数据为空");
|
|
|
|
this.PrintMessageToListBox($"{info.productType}打印任务执行失败,A列数据为空");
|
|
|
@ -148,7 +158,14 @@ namespace SlnMesnac.LabelPrint.viewModel
|
|
|
|
|
|
|
|
|
|
|
|
taskHelper.RemoveTask(info);
|
|
|
|
taskHelper.RemoveTask(info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 开始打印事件实现
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
private void StartPrint()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printTimer.StartPrint();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -156,8 +173,7 @@ namespace SlnMesnac.LabelPrint.viewModel
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
private void StopPrint()
|
|
|
|
private void StopPrint()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.PrintMessageToListBox("停止打印事件实现");
|
|
|
|
printTimer.StopPrint();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -201,15 +217,18 @@ namespace SlnMesnac.LabelPrint.viewModel
|
|
|
|
private void PrintMessageToListBox(string message)
|
|
|
|
private void PrintMessageToListBox(string message)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
lock (string.Empty)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
listItems.Add($"{DateTime.Now.ToString("HH:mm:ss")}==>{message}");
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
listItems.Add($"{DateTime.Now.ToString("HH:mm:ss")}==>{message}");
|
|
|
|
|
|
|
|
|
|
|
|
LogInfoListBox = listItems.OrderByDescending(x => x);
|
|
|
|
LogInfoListBox = listItems.OrderByDescending(x => x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logHelper.Error("日志数据绑定异常", ex);
|
|
|
|
logHelper.Error("日志数据绑定异常", ex);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|