Commit 7c33e71c LN

nexim对接修改。

1 个父辈 a8383be3
......@@ -375,6 +375,7 @@ namespace BLL
public static MyConfig<string> Nexim_UserName = "";
public static MyConfig<string> Nexim_Password = "";
public static MyConfig<string> Nexim_RegisterDidInfoUrl = "";
public static MyConfig<string> Nexim_PartMastersUrl = "";
/// <summary>
/// Nexim参数,key=需要的参数,value=对应的关键字
/// </summary>
......
......@@ -479,10 +479,10 @@ namespace BLL
LogNet.log.Info("ex" + ex.ToString());
}
if(!DidRegisterValidate(key, out errmsg))
{
return false;
}
//if(!DidRegisterValidate(key, out errmsg))
//{
// return false;
//}
//SaveRetrospect?.Invoke(key);
return true;
......@@ -490,30 +490,30 @@ namespace BLL
}
private bool DidRegisterValidate(Dictionary<string, string> content, out string errmsg)
{
errmsg = "";
try
{
if (BLLCommon.neximApiUtils.registerNewDid(content, out string msg))
{
return true;
}
else
{
errmsg = msg;
//Register Failure Notice
MessageboxNeo.Show("Register Failure Notice", errmsg, "NEO SCAN", true);
return false;
}
//private bool DidRegisterValidate(Dictionary<string, string> content, out string errmsg)
//{
// errmsg = "";
// try
// {
// if (BLLCommon.neximApiUtils.registerNewDid(content, out string msg))
// {
// return true;
// }
// else
// {
// errmsg = msg;
// //Register Failure Notice
// MessageboxNeo.Show("Register Failure Notice", errmsg, "NEO SCAN", true);
// return false;
// }
}
catch (Exception ex)
{
LogNet.log.Info("DidRegisterValidate" + ex.ToString());
}
return false;
}
// }
// catch (Exception ex)
// {
// LogNet.log.Info("DidRegisterValidate" + ex.ToString());
// }
// return false;
//}
public void Update()
{
......
......@@ -145,6 +145,42 @@ namespace Model
LogNet.log.Info("[Post]URL:" + url + "Return:" + s);
return FormatContent(s);
}
public static string GetWithHeader(string url, Dictionary<string, string> headerMap, Dictionary<string, object> queryParams = null)
{
if (queryParams != null && queryParams.Count > 0)
{
var queryString = HttpUtility.ParseQueryString(string.Empty);
foreach (var param in queryParams)
{
queryString.Add(param.Key, param.Value?.ToString());
}
if (url.Contains("?"))
url += "&" + queryString.ToString();
else
url += "?" + queryString.ToString();
}
LogNet.log.Info("[Get]URL:" + url);
RestClient client = new(url) { Timeout = 10000 };
RestRequest request = new(Method.GET);
if (headerMap != null && headerMap.Count > 0)
{
foreach (var head in headerMap)
{
request.AddHeader(head.Key, head.Value);
}
}
IRestResponse response = client.Execute(request);
if (response.ErrorException != null)
{
LogNet.log.Error("[Get]URL:" + url + " Error: " + response.ErrorException.ToString());
throw response.ErrorException;
}
string s = response.Content;
LogNet.log.Info("[Get]URL:" + url + "Return:" + s);
return FormatContent(s);
}
}
public class CustSerialize : RestSharp.Serialization.IRestSerializer
{
......
......@@ -168,7 +168,19 @@ namespace SmartScan
isMatched = Request_API_C2(matchedTexts);
}
if (isMatched)
Dictionary<string, string> lastKey = BLLCommon.extension.GetUIKeywords();
if (lastKey == null)
lastKey = new Dictionary<string, string>(workCodeKeyword);
else
lastKey = new Dictionary<string, string>(lastKey, StringComparer.OrdinalIgnoreCase);
//nexim对接
if (isMatched && (!DidRegisterValidate(lastKey, out string errmsg)))
{
isMatched = false;
LogNet.log.Info("DidRegisterValidate error ,isMatched = false");
}
if (isMatched)
{
Check2s?.Invoke("2");
// Common.frmMain.wpfControl.SetResultOK();
......@@ -223,6 +235,67 @@ namespace SmartScan
}
}
private bool DidRegisterValidate(Dictionary<string, string> content, out string errmsg)
{
errmsg = "";
if (!BLLCommon.neximApiUtils.IsEnalbe())
{
return true;
}
try
{
string pn = BLLCommon.neximApiUtils.getReelInfo(content, "PN");
string msg;
bool result;
Dictionary<string, object> pmData = BLLCommon.neximApiUtils.getPartMasters(pn, out msg);
if (!string.IsNullOrEmpty(msg))
{
LogNet.log.Error($"getPartMasters failed, pn={pn}, msg={msg},开始注册PN");
result = BLLCommon.neximApiUtils.postPartMasters(content, out msg);
if (result)
{
LogNet.log.Info($"postPartMasters OK, pn={pn}");
}
else
{
LogNet.log.Error($"getPartMasters failed, pn={pn}, msg={msg}");
errmsg = msg;
MessageboxNeo.Show("Register PartMasters Failure Notice", errmsg, "NEO SCAN", false );
return false;
}
}
else
{
string reelId = BLLCommon.neximApiUtils.getReelInfo(content, "RI");
//获取did信息,获取成功直接返回
Dictionary<string, object> didData = BLLCommon.neximApiUtils.getDid(reelId, out msg);
LogNet.log.Error($"getPartMasters OK, getDid OK,直接返回 true");
if (string.IsNullOrEmpty(msg))
{
return true;
}
}
if (BLLCommon.neximApiUtils.registerNewDid(content, pmData, out msg))
{
return true;
}
else
{
errmsg = msg;
//Register Failure Notice
MessageboxNeo.Show("Register Failure Notice", errmsg, "NEO SCAN", false );
return false;
}
}
catch (Exception ex)
{
LogNet.log.Info("DidRegisterValidate" + ex.ToString());
}
return false;
}
private bool Request_API_C2(List<string> matchedTexts)
{
string url = config.HttpLabelReport.Trim();
......
......@@ -119,10 +119,12 @@ namespace SmartScan.SetControl.WPF
{
codeItems.Add(item);
}
data3.ItemsSource = null;
data3.ItemsSource = codeItems;
if (data3.Items.Count > 0)
data3.SelectedIndex = -1;
bmp = (Bitmap)ImgShow.Image;
//给条码加上识别数字
//kmon
//2025-6-25
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!