Commit bad93f23 LN

支持匹配多行功能可配置

1 个父辈 d5ce2572
...@@ -345,6 +345,8 @@ namespace BLL ...@@ -345,6 +345,8 @@ namespace BLL
[MyConfigComment("数据源匹配Key_其他项_关键字=标题")] [MyConfigComment("数据源匹配Key_其他项_关键字=标题")]
public static MyConfig<string[]> DataSource_DataKey_Others= new string[] { }; public static MyConfig<string[]> DataSource_DataKey_Others= new string[] { };
[MyConfigComment("数据源匹配_是否支持匹配多行,true=支持多行弹框选择。false=多行认为匹配失败")]
public static MyConfig<bool> DataSource_MultilineMode = false ;
[MyConfigComment("数据源匹配_是否可以修改内容重新匹配")] [MyConfigComment("数据源匹配_是否可以修改内容重新匹配")]
public static MyConfig<bool> DataSource_CanReMatch = false ; public static MyConfig<bool> DataSource_CanReMatch = false ;
......
...@@ -293,10 +293,11 @@ namespace BLL ...@@ -293,10 +293,11 @@ namespace BLL
return aExtraData[0]; return aExtraData[0];
} }
else else if (Config.DataSource_MultilineMode.Val == true)
{ {
if (DataSelectingEvent == null) if (DataSelectingEvent == null)
{ {
LogNet.log.Info("匹配到数据源:" + dataKey + " 共有 " + aExtraData.Count + "条数据,默认使用第一条数据");
return aExtraData[0]; return aExtraData[0];
} }
...@@ -304,6 +305,10 @@ namespace BLL ...@@ -304,6 +305,10 @@ namespace BLL
Dictionary<string, string> selecValue = DataSelectingEvent?.Invoke(dataKey, aExtraData); Dictionary<string, string> selecValue = DataSelectingEvent?.Invoke(dataKey, aExtraData);
return selecValue; return selecValue;
} }
else
{
return null;
}
} }
public static bool hasFileData() public static bool hasFileData()
{ {
...@@ -366,28 +371,25 @@ namespace BLL ...@@ -366,28 +371,25 @@ namespace BLL
if (key.ContainsKey(Config.DataSource_DataKey) && ExtraFileData.AllData.ContainsKey(CleanData)) if (key.ContainsKey(Config.DataSource_DataKey) && ExtraFileData.AllData.ContainsKey(CleanData))
{ {
var extraData = ExtraFileData.GetSelectDataSource(CleanData); var extraData = ExtraFileData.GetSelectDataSource(CleanData);
if (extraData != null)
{
findOk = true; findOk = true;
Dictionary<string, string> otherKeys = GetOtherKeys(); Dictionary<string, string> otherKeys = GetOtherKeys();
//foreach (var d in extraData)
//{
// if (!string.IsNullOrEmpty(d.Value))
// key[d.Key] = d.Value;
//}
key = UpdateData(key, extraData, otherKeys); key = UpdateData(key, extraData, otherKeys);
LogNet.log.Info("匹配到数据源:" + Config.DataSource_DataKey + "=" + CleanData + " 数据: " + JsonConvert.SerializeObject(extraData)); LogNet.log.Info("匹配到数据源:" + Config.DataSource_DataKey + "=" + CleanData + " 数据: " + JsonConvert.SerializeObject(extraData));
return key; return key;
} }
} }
}
if (!findOk && Config.DataSource_DataKey_Others.Val != null && Config.DataSource_DataKey_Others.Val.Length > 0) if (!findOk && Config.DataSource_DataKey_Others.Val != null && Config.DataSource_DataKey_Others.Val.Length > 0)
{ {
Dictionary<string, string> otherKeys = GetOtherKeys(); Dictionary<string, string> otherKeys = GetOtherKeys();
foreach (string oKey in otherKeys.Keys) foreach (string oKey in otherKeys.Keys)
{ {
if (key.ContainsKey(oKey)) if (!key.ContainsKey(oKey))
{ {
continue;
}
string CleanData = key[oKey].Replace("<OCR>", ""); string CleanData = key[oKey].Replace("<OCR>", "");
if (String.IsNullOrEmpty(CleanData)) if (String.IsNullOrEmpty(CleanData))
{ {
...@@ -399,18 +401,14 @@ namespace BLL ...@@ -399,18 +401,14 @@ namespace BLL
if (titleValue == Config.DataSource_DataTitle && ExtraFileData.AllData.ContainsKey(CleanData)) if (titleValue == Config.DataSource_DataTitle && ExtraFileData.AllData.ContainsKey(CleanData))
{ {
var extraData = ExtraFileData.GetSelectDataSource(CleanData); var extraData = ExtraFileData.GetSelectDataSource(CleanData);
if (extraData != null)
{
findOk = true; findOk = true;
//foreach (var d in extraData)
//{
// if (!string.IsNullOrEmpty(d.Value))
// key[d.Key] = d.Value;
//}
key = UpdateData(key, extraData, otherKeys); key = UpdateData(key, extraData, otherKeys);
LogNet.log.Info("匹配到数据源:" + titleValue + "=" + CleanData + " 数据: " + JsonConvert.SerializeObject(extraData)); LogNet.log.Info("匹配到数据源:" + titleValue + "=" + CleanData + " 数据: " + JsonConvert.SerializeObject(extraData));
break; break;
} }
}
else else
{ {
List<Dictionary<string, string>> findData = new List<Dictionary<string, string>>(); List<Dictionary<string, string>> findData = new List<Dictionary<string, string>>();
...@@ -420,7 +418,7 @@ namespace BLL ...@@ -420,7 +418,7 @@ namespace BLL
foreach (Dictionary<string, string> data in sourceData) foreach (Dictionary<string, string> data in sourceData)
{ {
if (data.ContainsKey(titleValue) ) if (data.ContainsKey(titleValue))
{ {
string vstring = data[titleValue]; string vstring = data[titleValue];
if (vstring.Trim().Equals(CleanData.Trim())) if (vstring.Trim().Equals(CleanData.Trim()))
...@@ -433,30 +431,32 @@ namespace BLL ...@@ -433,30 +431,32 @@ namespace BLL
if (findData.Count > 0) if (findData.Count > 0)
{ {
var findDataMap = new Dictionary<string, string>(); var findDataMap = new Dictionary<string, string>();
if (findData.Count == 1 || DataSelectingEvent == null) if (findData.Count == 1)
{ {
findOk = true;
findDataMap = findData[0]; findDataMap = findData[0];
LogNet.log.Info("匹配到数据源:" + titleValue + "=" + CleanData + " 共有 " + 1 + "条数据: " + JsonConvert.SerializeObject(findData[0])); LogNet.log.Info("匹配到数据源:" + titleValue + "=" + CleanData + " 共有 " + 1 + "条数据: " + JsonConvert.SerializeObject(findData[0]));
} }
else if (Config.DataSource_MultilineMode.Val == true)
{
if (DataSelectingEvent == null)
{
LogNet.log.Info("匹配到数据源:" + titleValue + "=" + CleanData + " 共有 " + findData.Count + "条数据,默认使用第一条数据");
findDataMap = findData[0];
}
else else
{ {
LogNet.log.Info("匹配到数据源:" + titleValue + "=" + CleanData + " 共有 " + findData.Count + "条数据,弹框让用户选择"); LogNet.log.Info("匹配到数据源:" + titleValue + "=" + CleanData + " 共有 " + findData.Count + "条数据,弹框让用户选择");
findDataMap = DataSelectingEvent?.Invoke(titleValue + "=" + CleanData, findData); findDataMap = DataSelectingEvent?.Invoke(titleValue + "=" + CleanData, findData);
if (findDataMap != null && findDataMap.Count > 0)
{
findOk = true;
} }
} }
if (findOk) if (findDataMap != null && findDataMap.Count > 0)
{ {
key= UpdateData(key, findDataMap, otherKeys); findOk = true;
} key = UpdateData(key, findDataMap, otherKeys);
break;
} }
} }
} }
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!