Commit cfa214df 王海洋

增加check功能

1 个父辈 73b660e4
......@@ -69,6 +69,7 @@
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework" />
<Reference Include="RestSharp, Version=106.11.7.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.11.7\lib\net452\RestSharp.dll</HintPath>
</Reference>
......
......@@ -109,6 +109,14 @@ namespace BLL
get => config.Read<bool>(PRINT_COMPLETED_CLEAR);
set => config.Write(PRINT_COMPLETED_CLEAR, value);
}
/// <summary>
/// check功能
/// </summary>
public bool CheckFunction
{
get => config.Read<bool>(Check_Function);
set => config.Write(Check_Function, value);
}
/// <summary>
/// 打开软件后开启工作模式
......@@ -362,6 +370,7 @@ namespace BLL
private const string SELECT_HTTP_PN = "SelectHttpPN";
private const string LABEL_EMPTY_CHECK = "LabelEmptyCheck";
private const string PRINT_COMPLETED_CLEAR = "PrintCompletedClear";
private const string Check_Function = "CheckFunction";
private const string OPEN_START_WORK = "OpenStartWork";
private const string OPEN_MAXIMIZE = "OpenMaximize";
private const string DEFAULT_PRINT_LABEL = "DefaultPrintLabel";
......
......@@ -9,6 +9,8 @@ using Model;
using System.Windows.Forms;
using DocumentFormat.OpenXml.Drawing;
using DocumentFormat.OpenXml.Spreadsheet;
using TcpKPIO;
using DocumentFormat.OpenXml.Wordprocessing;
namespace BLL
{
......@@ -90,12 +92,14 @@ namespace BLL
};
currentExtension = dicExtension[config.ExtensionName];
}
}
public void Dispose()
{
currentExtension.Dispose();
}
public string labelText = "等待中";
public void LoadPanel(FacePanel pnl,List<string> keywords)
{
......@@ -208,6 +212,9 @@ namespace BLL
}
}
};
if (!string.IsNullOrEmpty(config.HttpReelID))
listrow.Add(new object[] { A });
#region 显示替换数据按钮
......@@ -261,6 +268,39 @@ namespace BLL
}
#endregion
listrow.Add(new object[] { B });
if (BLLCommon.config.CheckFunction)
{
Dictionary<string, object> newLabel = CreateNewLabel(labelText);
Dictionary<string, object> D = new()
{
{ "Type", "Button" },
{
"Attribute",
new Dictionary<string, object>()
{
{ "Name", "BtnSkip"},
{ "Font", "Arial,12,B,"},
//{"BorderWidth", 0},
{"Width", -1},
{"Height", 40},
{"Text", "跳过"},//"Print Label"
}
},
{
"Event",
new Dictionary<string, object>()
{
{ "Click", "BtnSkip_Click"},
}
}
};
listrow.Add(new object[] {newLabel, D });
}
rows = listrow.ToArray();
}
else
......@@ -279,7 +319,56 @@ namespace BLL
currentExtension.Load(ctlGroup);
}
// 封装一个方法来创建带有指定文本的 newLabel
private Dictionary<string, object> CreateNewLabel(string text)
{
if (text=="OK")
{
return new Dictionary<string, object>
{
{ "Type", "Label" },
{ "LinkName", "ischeckresult"},
{
"Attribute",
new Dictionary<string, object>()
{
{ "Name", "labresult" },
{ "Font", "Arial,18,B,"},
{ "BorderWidth", 0 }, // 边框宽度
{ "Width", 100 }, // 宽度
{ "Height", 40 },
{ "Text", text }, // 显示的文本
{ "TextAlign", "MiddleCenter" }, // 文本对齐方式
{ "Foreground", "Green" } // 添加字体颜色为绿色
}
}
};
}
else
{
return new Dictionary<string, object>
{
{ "Type", "Label" },
{ "LinkName", "ischeckresult"},
{
"Attribute",
new Dictionary<string, object>()
{
{ "Name", "labresult" },
{ "Font", "Arial,18,B,"},
{ "BorderWidth", 0 }, // 边框宽度
{ "Width", 100 },
{ "Height", 40 }, // 高度
{ "Text", text }, // 显示的文本
{ "TextAlign", "MiddleCenter" }, // 文本对齐方式
{ "Foreground", "Red" } // 添加字体颜色为绿色
}
}
};
}
}
public void Clear()
{
currentExtension.Clear();
......
......@@ -21,6 +21,7 @@ using System.Drawing;
using DocumentFormat.OpenXml.Spreadsheet;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml.Presentation;
namespace BLL
{
......@@ -91,14 +92,21 @@ namespace BLL
}
static bool mesResult = false;
bool islast=false;
Dictionary<string, string> lastkey = null;
// 用于存储上一次的 key
private Dictionary<string, string> lastKeys;
//读码后第一步
public bool SetKey(string[] originalCode, Dictionary<string, string> key, bool hasMatch, out string errmsg)
{
errmsg = "";
mesResult = false;
var now = DateTime.Now;
// 比较当前 key 和上次的 key
bool isSame = false;
if (extensions != null && !extensions[0].Control.InvokeRequired)
{
//第一次刷新界面
......@@ -107,6 +115,21 @@ namespace BLL
extensions[i].Control.ForeColor = System.Drawing.Color.White;
if (key.ContainsKey(extensions[i].Key))
extensions[i].Control.Text = key[extensions[i].Key].Replace("<OCR>", "");
if (extensions[i].LinkName== "ischeckresult" && lastKeys != null)
{
//if (BLLCommon.extension.labelText=="NG")
//{
// extensions[i].Control.Text = BLLCommon.extension.labelText;
// extensions[i].Control.ForeColor = System.Drawing.Color.Red;
//}
//else
//{
// extensions[i].Control.Text = BLLCommon.extension.labelText;
// extensions[i].Control.ForeColor = System.Drawing.Color.Green;
//}
}
}
}
Application.DoEvents();
......@@ -171,6 +194,43 @@ namespace BLL
}
}
}
if (lastKeys != null)
{
isSame = key.Count == lastKeys.Count && !key.Except(lastKeys).Any();
}
lastkey = key;
islast = false;
if (isSame)
{
BLLCommon.extension.labelText = "OK";
lastKeys = null;
islast=true;
// 两次的 key 相同,可添加相应逻辑
}
else if (lastKeys != null && !isSame)
{ // 两次的 key 不同,可添加相应逻辑
BLLCommon.extension.labelText = "NG";
}else
{
if (BLLCommon.config.Language.Equals("English"))
{
BLLCommon.extension.labelText = "Waiting";
}
else
{
BLLCommon.extension.labelText = "等待中";
}
}
if (lastKeys == null &&!islast)
{
lastKeys = new Dictionary<string, string>(key); // 更新 lastKey
}
else
{
islast=false;
}
//第二次刷新界面
for (int i = 0; i < extensions.Count; i++)
......@@ -196,10 +256,33 @@ namespace BLL
{
extensions[i].Control.Text = key[extensions[i].Key].Replace("<OCR>", "");
}
if (extensions[i].LinkName == "ischeckresult")
{
extensions[i].Control.Text = BLLCommon.extension.labelText;
}
//if (extensions[i].LinkName == "ischeckresult" && lastKeys != null)
//{
// if (BLLCommon.extension.labelText == "NG")
// {
// extensions[i].Control.Text = BLLCommon.extension.labelText;
// extensions[i].Control.ForeColor = System.Drawing.Color.Red;
// }
// else if (BLLCommon.extension.labelText == "OK")
// {
// extensions[i].Control.Text = BLLCommon.extension.labelText;
// extensions[i].Control.ForeColor = System.Drawing.Color.Green;
// }
//}
}
}
lastkey = key;
if (!updatereelid(key, out errmsg))
return false;
......@@ -232,6 +315,7 @@ namespace BLL
// //PrintLabel(null, EventArgs.Empty);
//}
//SaveRetrospect?.Invoke(key);
return true;
}
bool updatereelid(Dictionary<string, string> key, out string errmsg)
......@@ -362,6 +446,34 @@ namespace BLL
{
updatereelid(lastkey, out _);
}
private void BtnSkip_Click(object sender, EventArgs e)
{
if (BLLCommon.config.Language.Equals("English"))
{
System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show("Whether to skip this operation?", "verify", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question);
if (result == System.Windows.MessageBoxResult.Yes)
{
lastKeys = null;
BLLCommon.extension.labelText = "Waiting";
}
}
else
{
System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show("是否跳过此操作?", "确认", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question);
if (result == System.Windows.MessageBoxResult.Yes)
{
lastKeys = null;
BLLCommon.extension.labelText = "等待中";
}
}
}
private void ComboBoxTextChanged(object sender, EventArgs e)
{
var txt = ((FaceComboBox)sender).Text;
......
......@@ -4,5 +4,6 @@
{
public static FrmMain frmMain;
public static FrmWaitting frmWaitting;
}
}
......@@ -205,15 +205,44 @@ namespace SmartScan
////sb.AppendLine(string.Join(",", content.Values.ToArray()));
//System.IO.File.WriteAllText(filename, sb.ToString(), Encoding.UTF8);
}
public delegate void CheckResultEventHandler(object sender, bool value);
public static event CheckResultEventHandler Checkresult;
public Dictionary<string, string> lastContent;
private bool CompareContent(Dictionary<string, string> content)
{
if (lastContent != null)
{
return content.Count == lastContent.Count && !content.Except(lastContent).Any();
}
return false;
}
private void Extension_Printing(Dictionary<string, string> content)
{
string str = "打印内容:";
//if (lastContent!=null)
//{
// bool isSame = CompareContent(content);
// if (isSame)
// {
// BLLCommon.extension.labelText = "OK";
// lastContent.Clear();
// }
// else
// {
// BLLCommon.extension.labelText = "NG";
// }
//}
try
{
foreach (string key in content.Keys)
{
str += string.Format("({0}:{1})", key, content[key]);
}
LogNet.log.Info(str);
......@@ -238,11 +267,13 @@ namespace SmartScan
UnifiedDataHandler.RecordPrintNg(false, true, out string[] strarrys);
if (BLLCommon.config.PrintCompletedClear)
BLLCommon.extension.Clear();
lastContent = new Dictionary<string, string>(content);
}
catch (Exception ex)
{
LogNet.log.Error($"Extension_Printing", ex);
}
}
private void FrmMain_Load(object sender, EventArgs e)
......@@ -362,6 +393,7 @@ namespace SmartScan
if(BLLCommon.config.Language.Equals("English"))
{
BtnStart.Font = new Font("Arial",14,FontStyle.Bold);
}
else
{
......
......@@ -8,6 +8,7 @@ using System.Text;
using Asa.FaceControl;
using System.Windows.Forms;
using BLL;
using DocumentFormat.OpenXml.Drawing;
namespace SmartScan
{
......@@ -66,6 +67,7 @@ namespace SmartScan
new FaceMessageBox("", text, MessageBoxButtons.OK).ShowDialog();
BLLCommon.extension.Update();
DialogResult = DialogResult.OK;
}
private void BtnCancel_Click(object sender, EventArgs e)
......
......@@ -61,6 +61,8 @@ FrmMain_LblCameraExist 识别设备连接 Camera Arial,9,,
FrmMain_LblIOExist IO模块连接 Machine Arial,9,,
FrmMain_PnlExtension 功能 Print Info. Arial,14,,
FrmMain_BtnPrint 打印标签 Print Label Arial,12,,
FrmMain_BtnSkip 跳过 Skip Arial,12,,
FrmMain_labresult 等待中 Waiting Arial,12,,
FrmMain_DynamicButton 替换数据 Replacedata 微软雅黑,12,,
FrmSet_FrmSet 设置 Setting Arial,20,B,
FrmSet_BtnGenneralSetting 通用设置 General Setting Arial,12,B,
......@@ -96,6 +98,7 @@ UsrWorkMode_RdoNoImage 不保存 Skip Saving Arial,12,,
UsrWorkMode_ChkSelectPN 从服务器上查询PN Query PN From The Server Arial,12,,
UsrWorkMode_ChkLabelEmptyCheck 打印标签空内容提醒 Empty Label Alert Arial,12,,
UsrWorkMode_ChkPrintCompletedClear 打印标签后清除内容 Print&Clear Arial,12,,
UsrWorkMode_ChkCheckFunction Check功能 CheckFunction Arial,12,,
UsrWorkMode_ChkOpenEnterWork 打开软件自动进入工作模式 Auto Start Mode Arial,12,,
UsrWorkMode_ChkOpenMaximize 打开软件最大化窗口 Always Open Maximized Arial,12,,
UsrWorkMode_ChkTriggerOpenLight 触发信号后在打开光源 Turn On Light After Triggering Device Arial,12,,
......
......@@ -61,6 +61,8 @@ FrmMain_LblIOExist IO模块连接 IO模块连接 微软雅黑,9,,
FrmMain_PnlExtension 功能 功能 微软雅黑,14,,
FrmMain_BtnPrint 打印标签 打印标签 微软雅黑,12,,
FrmMain_DynamicButton 替换数据 替换数据 微软雅黑,12,,
FrmMain_BtnSkip 跳过 跳过 Arial,12,,
FrmMain_labresult 等待中 等待中 Arial,12,,
FrmSet_FrmSet 设置 设置 微软雅黑,20,B,
FrmSet_BtnGenneralSetting 通用设置 通用设置 微软雅黑,12,B,
FrmSet_BtnIdentify 识别条码 识别条码 微软雅黑,12,B,
......@@ -88,6 +90,7 @@ UsrWorkMode_LblDefaultLabel 默认打印标签 默认打印标签 微软雅黑,1
UsrWorkMode_RdoLandscape 横向打印 横向打印 微软雅黑,12,,
UsrWorkMode_RdoVertical 纵向打印 纵向打印 微软雅黑,12,,
UsrWorkMode_LblHistoryImage 追溯图像保存 追溯图像保存 微软雅黑,12,B,
UsrWorkMode_ChkCheckFunction Check功能 Check功能 微软雅黑,12,,
UsrWorkMode_RdoOriginal 原图 原图 微软雅黑,12,,
UsrWorkMode_RdoCondense 压缩图像 压缩图像 微软雅黑,12,,
UsrWorkMode_RdoNoImage 不保存 不保存 微软雅黑,12,,
......
......@@ -22,7 +22,7 @@ namespace SmartScan
//this.Height = 738;
this.Top = 15;
this.Left = 0;
WebService.Open(BLLCommon.config.WebService);//启动条码匹配服务
LogNet.log = log4net.LogManager.GetLogger("SmartScan");
}
......
......@@ -120,7 +120,7 @@ namespace SmartScan
Application.Run(new FrmLoading(back)); //预加载,完成后自动退出
Common.frmMain = new FrmMain();
Common.frmWaitting = new FrmWaitting();
WebService.Open();//启动条码匹配服务
WebService.Open(BLLCommon.config.WebService);//启动条码匹配服务
if (back)
{
var fsp = new FrmSetPlus();
......
......@@ -38,6 +38,7 @@ namespace SmartScan
ChkPromptAfterPrinting.Checked = BLLCommon.config.PromptAfterPrinting;
ChkAutoPrint.Checked = BLLCommon.config.AutoPrint;
ChkAllowModifyPrint.Checked = Config.AllowModifyPrintInfo;
ChkCheckFunction.Checked = BLLCommon.config.CheckFunction; ;
//默认标签
LstLabel.Items.AddRange(BLLCommon.labelEdit.Name);
LstLabel.Text = BLLCommon.config.DefaultPrintLabel;
......@@ -107,6 +108,7 @@ namespace SmartScan
BLLCommon.config.TriggerOpenLight = ChkTriggerOpenLight.Checked;
BLLCommon.config.PromptAfterPrinting = ChkPromptAfterPrinting.Checked;
BLLCommon.config.AutoPrint = ChkAutoPrint.Checked;
BLLCommon.config.CheckFunction = ChkCheckFunction.Checked;
BLLCommon.config.Save();
}
......
......@@ -29,6 +29,7 @@ namespace SmartScan
ChkLabelEmptyCheck.Checked = BLLCommon.config.LabelEmptyCheck;
ChkOpenEnterWork.Checked = BLLCommon.config.OpenStartWork;
ChkPrintCompletedClear.Checked = BLLCommon.config.PrintCompletedClear;
ChkPrintCompletedClear.Checked = BLLCommon.config.PrintCompletedClear;
ChkOpenMaximize.Checked = BLLCommon.config.OpenMaximize;
ChkTriggerOpenLight.Checked = BLLCommon.config.TriggerOpenLight;
ChkPromptAfterPrinting.Checked = BLLCommon.config.PromptAfterPrinting;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!