Commit 026477d4 刘韬

1

1 个父辈 0de8eabe
...@@ -66,13 +66,13 @@ namespace BLL ...@@ -66,13 +66,13 @@ namespace BLL
static Dictionary<string, TemplateCollection> MatchTemplateList; static Dictionary<string, TemplateCollection> MatchTemplateList;
public static void ShowResult() public static void ShowResult()
{ {
return; //return;
foreach (var tp in MatchTemplateList) { foreach (var tp in MatchTemplateList) {
LogNet.log.Info($"开始解析模版:{tp.Key}"); LogNet.log.Info($"开始解析模版:{tp.Key}");
foreach (var m in tp.Value.MatchCollections) { foreach (var m in tp.Value.MatchCollections) {
LogNet.log.Info($"开始解析关键字:{m.Key}"); LogNet.log.Info($"开始解析关键字:{m.Key}");
LogNet.log.Info($"匹配到关键字:{m.Key}"); //LogNet.log.Info($"匹配到关键字:{m.Key}");
string matchlist = m.Value.barcodeInfo.Text + "\t"; string matchlist = m.Value.barcodeInfo.Text + "\t";
foreach (var item in m.Value.Matchs) foreach (var item in m.Value.Matchs)
{ {
......
...@@ -414,6 +414,7 @@ namespace BLL ...@@ -414,6 +414,7 @@ namespace BLL
for (int i = 0; i < id.Length; i++) for (int i = 0; i < id.Length; i++)
{ {
MatchAnalysis.SetTemplatename(mateTemp[index].Name); MatchAnalysis.SetTemplatename(mateTemp[index].Name);
LogNet.log.Info($"开始匹配模版: {mateTemp[index].Name}");
List<MaterialCodeMatch> codeMatch = mateTemp[index].Match.FindAll(match => match.CodeID == id[i] && match.Keyword != ""); List<MaterialCodeMatch> codeMatch = mateTemp[index].Match.FindAll(match => match.CodeID == id[i] && match.Keyword != "");
if (codeMatch.Count == 0) continue; if (codeMatch.Count == 0) continue;
matchCount += codeMatch.Count; matchCount += codeMatch.Count;
...@@ -613,7 +614,7 @@ namespace BLL ...@@ -613,7 +614,7 @@ namespace BLL
string code, text; string code, text;
int index, count; int index, count;
Identification = false; Identification = false;
LogNet.log.Info($"开始匹配条码 [{codeinfo.Text}]");
for (int i = 0; i < codeMatch.Count; i++) for (int i = 0; i < codeMatch.Count; i++)
{ {
int matchCount = 0; int matchCount = 0;
...@@ -623,6 +624,8 @@ namespace BLL ...@@ -623,6 +624,8 @@ namespace BLL
MatchAnalysis.SetBarcode(codeinfo); MatchAnalysis.SetBarcode(codeinfo);
code = codeMatch[i].CaseSensitive ? codeText : codeText.ToUpper(); code = codeMatch[i].CaseSensitive ? codeText : codeText.ToUpper();
bool ismatch = true; bool ismatch = true;
LogNet.log.Info($"开始匹配规则 [{codeMatch[i].Keyword}]");
//匹配CodeType //匹配CodeType
if (codeMatch[i].CheckCodeType && !string.IsNullOrEmpty(codeMatch[i].CodeType) && !string.IsNullOrEmpty(codeinfo.CodeType)) if (codeMatch[i].CheckCodeType && !string.IsNullOrEmpty(codeMatch[i].CodeType) && !string.IsNullOrEmpty(codeinfo.CodeType))
{ {
......
...@@ -22,7 +22,7 @@ namespace SmartScan ...@@ -22,7 +22,7 @@ namespace SmartScan
//this.Height = 738; //this.Height = 738;
this.Top = 15; this.Top = 15;
this.Left = 0; this.Left = 0;
WebService.Open();//启动条码匹配服务 WebService.Open(BLLCommon.config.WebService);//启动条码匹配服务
LogNet.log = log4net.LogManager.GetLogger("SmartScan"); LogNet.log = log4net.LogManager.GetLogger("SmartScan");
} }
......
...@@ -229,6 +229,7 @@ namespace SmartScan ...@@ -229,6 +229,7 @@ namespace SmartScan
Dictionary<string, string> workCodeKeyword; Dictionary<string, string> workCodeKeyword;
bool rtn = BLLCommon.mateEdit.MatchingTemplate(workCodeInfo, BLLCommon.config.DefaultMaterialName, false, out string mateName, out workCodeKeyword, out AMatch aMatch); bool rtn = BLLCommon.mateEdit.MatchingTemplate(workCodeInfo, BLLCommon.config.DefaultMaterialName, false, out string mateName, out workCodeKeyword, out AMatch aMatch);
BLL.MatchAnalysis.ShowResult();
var point = new Point(-1, -1); var point = new Point(-1, -1);
int angle = 0; int angle = 0;
LogNet.log.Info("模板匹配结果:" + rtn); LogNet.log.Info("模板匹配结果:" + rtn);
......
using BLL; using BLL;
using Microsoft.Win32;
using System; using System;
using System.ServiceModel;
using System.ServiceModel.Web; using System.ServiceModel.Web;
namespace SmartScan namespace SmartScan
...@@ -9,23 +11,37 @@ namespace SmartScan ...@@ -9,23 +11,37 @@ namespace SmartScan
private static WebServiceHost _serviceHost; private static WebServiceHost _serviceHost;
public static bool IsOpen { private set; get; } public static bool IsOpen { private set; get; }
static int errcount = 0;
public static void Open() public static void Open(string url)
{ {
if (string.IsNullOrWhiteSpace(url))
{
Model.LogNet.log.Info("WebService没有配置,不开启");
return;
}
var u = new Uri(url);
try try
{ {
string url = BLLCommon.config.WebService;
if (string.IsNullOrWhiteSpace(url))
{
Model.LogNet.log.Info("WebService没有配置,不开启");
return;
}
WebCallWork service = new(); WebCallWork service = new();
_serviceHost = new(service, new Uri(url)); _serviceHost = new(service, u);
_serviceHost.Open(); _serviceHost.Open();
Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\NS100\\", "port", u.Port);
Model.LogNet.log.Info("Web服务已开启,URL=" + url); Model.LogNet.log.Info("Web服务已开启,URL=" + url);
IsOpen = true; IsOpen = true;
} }
catch (AddressAlreadyInUseException ex)
{
Model.LogNet.log.Info("端口:" + u.Port + " 被占用");
errcount++;
if (errcount > 20)
{
Environment.Exit(99);
return;
}
Random a = new Random((int)DateTime.Now.Ticks);
var nu = "http://0.0.0.0:" + a.Next(40000, 60000) + "/";
Open(nu);
}
catch (Exception ex) catch (Exception ex)
{ {
Model.LogNet.log.Error("Open", ex); Model.LogNet.log.Error("Open", ex);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!