Commit ed886837 LN

1.外部数据匹配后显示到界面。2.外部数据源读取优化。

1 个父辈 f88539ce
...@@ -302,6 +302,15 @@ namespace BLL ...@@ -302,6 +302,15 @@ namespace BLL
{ {
LogNet.log.Info($"updatereelid false"); LogNet.log.Info($"updatereelid false");
if (findOk)
{
LogNet.log.Info($"OnKeySet3 findOK");
OnKeySet(templateName, originalCode, key, hasMatch);
if (lastKeys == null && !islast && BLLCommon.config.CheckFunction)
{
lastKeys = new Dictionary<string, string>(key); // 更新 lastKey
}
}
return false; return false;
} }
// } // }
......
...@@ -69,7 +69,7 @@ namespace BLL ...@@ -69,7 +69,7 @@ namespace BLL
var dataline = sm.ReadLine(); var dataline = sm.ReadLine();
if (string.IsNullOrWhiteSpace(dataline)) if (string.IsNullOrWhiteSpace(dataline))
break; break;
var datas = dataline.Split(','); var datas = ParseCsvLine(dataline);
if (datas.Length < Titles.Count) if (datas.Length < Titles.Count)
continue; continue;
string keydata = ""; string keydata = "";
...@@ -115,10 +115,56 @@ namespace BLL ...@@ -115,10 +115,56 @@ namespace BLL
using var sm = new StreamReader(filename, Encoding.GetEncoding(Config.DataSource_Encoding.Val)); using var sm = new StreamReader(filename, Encoding.GetEncoding(Config.DataSource_Encoding.Val));
var titleline = sm.ReadLine(); var titleline = sm.ReadLine();
var titles = new List<string>(titleline.Split(',')); var titles = new List<string>(ParseCsvLine(titleline));
return titles; return titles;
} }
private static string[] ParseCsvLine(string line)
{
List<string> result = new List<string>();
try
{
if (string.IsNullOrEmpty(line))
return new string[0];
StringBuilder currentStr = new StringBuilder();
bool inQuotes = false;
for (int i = 0; i < line.Length; i++)
{
char c = line[i];
if (c == '\"')
{
if (inQuotes && i + 1 < line.Length && line[i + 1] == '\"')
{
currentStr.Append('\"');
i++;
}
else
{
inQuotes = !inQuotes;
}
}
else if (c == ',' && !inQuotes)
{
result.Add(currentStr.ToString());
currentStr.Clear();
}
else
{
currentStr.Append(c);
}
}
result.Add(currentStr.ToString());
}
catch (Exception ex)
{
LogNet.log.Error("ParseCsvLine,line=" + line + " 出错:" + ex.ToString());
}
return result.ToArray();
}
public static void LoadXLSALlData() public static void LoadXLSALlData()
{ {
...@@ -374,12 +420,16 @@ namespace BLL ...@@ -374,12 +420,16 @@ namespace BLL
foreach (Dictionary<string, string> data in sourceData) foreach (Dictionary<string, string> data in sourceData)
{ {
if (data.ContainsKey(titleValue) && data[titleValue] == CleanData) if (data.ContainsKey(titleValue) )
{
string vstring = data[titleValue];
if (vstring.Trim().Equals(CleanData.Trim()))
{ {
findData.Add(data); findData.Add(data);
} }
} }
} }
}
if (findData.Count > 0) if (findData.Count > 0)
{ {
var findDataMap = new Dictionary<string, string>(); var findDataMap = new Dictionary<string, string>();
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!