Commit 7c33e71c LN

nexim对接修改。

1 个父辈 a8383be3
...@@ -375,6 +375,7 @@ namespace BLL ...@@ -375,6 +375,7 @@ namespace BLL
public static MyConfig<string> Nexim_UserName = ""; public static MyConfig<string> Nexim_UserName = "";
public static MyConfig<string> Nexim_Password = ""; public static MyConfig<string> Nexim_Password = "";
public static MyConfig<string> Nexim_RegisterDidInfoUrl = ""; public static MyConfig<string> Nexim_RegisterDidInfoUrl = "";
public static MyConfig<string> Nexim_PartMastersUrl = "";
/// <summary> /// <summary>
/// Nexim参数,key=需要的参数,value=对应的关键字 /// Nexim参数,key=需要的参数,value=对应的关键字
/// </summary> /// </summary>
......
...@@ -479,10 +479,10 @@ namespace BLL ...@@ -479,10 +479,10 @@ namespace BLL
LogNet.log.Info("ex" + ex.ToString()); LogNet.log.Info("ex" + ex.ToString());
} }
if(!DidRegisterValidate(key, out errmsg)) //if(!DidRegisterValidate(key, out errmsg))
{ //{
return false; // return false;
} //}
//SaveRetrospect?.Invoke(key); //SaveRetrospect?.Invoke(key);
return true; return true;
...@@ -490,30 +490,30 @@ namespace BLL ...@@ -490,30 +490,30 @@ namespace BLL
} }
private bool DidRegisterValidate(Dictionary<string, string> content, out string errmsg) //private bool DidRegisterValidate(Dictionary<string, string> content, out string errmsg)
{ //{
errmsg = ""; // errmsg = "";
try // try
{ // {
if (BLLCommon.neximApiUtils.registerNewDid(content, out string msg)) // if (BLLCommon.neximApiUtils.registerNewDid(content, out string msg))
{ // {
return true; // return true;
} // }
else // else
{ // {
errmsg = msg; // errmsg = msg;
//Register Failure Notice // //Register Failure Notice
MessageboxNeo.Show("Register Failure Notice", errmsg, "NEO SCAN", true); // MessageboxNeo.Show("Register Failure Notice", errmsg, "NEO SCAN", true);
return false; // return false;
} // }
} // }
catch (Exception ex) // catch (Exception ex)
{ // {
LogNet.log.Info("DidRegisterValidate" + ex.ToString()); // LogNet.log.Info("DidRegisterValidate" + ex.ToString());
} // }
return false; // return false;
} //}
public void Update() public void Update()
{ {
......
...@@ -145,6 +145,42 @@ namespace Model ...@@ -145,6 +145,42 @@ namespace Model
LogNet.log.Info("[Post]URL:" + url + "Return:" + s); LogNet.log.Info("[Post]URL:" + url + "Return:" + s);
return FormatContent(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 public class CustSerialize : RestSharp.Serialization.IRestSerializer
{ {
......
...@@ -168,6 +168,18 @@ namespace SmartScan ...@@ -168,6 +168,18 @@ namespace SmartScan
isMatched = Request_API_C2(matchedTexts); isMatched = Request_API_C2(matchedTexts);
} }
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) if (isMatched)
{ {
Check2s?.Invoke("2"); Check2s?.Invoke("2");
...@@ -223,6 +235,67 @@ namespace SmartScan ...@@ -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) private bool Request_API_C2(List<string> matchedTexts)
{ {
string url = config.HttpLabelReport.Trim(); string url = config.HttpLabelReport.Trim();
......
...@@ -119,6 +119,8 @@ namespace SmartScan.SetControl.WPF ...@@ -119,6 +119,8 @@ namespace SmartScan.SetControl.WPF
{ {
codeItems.Add(item); codeItems.Add(item);
} }
data3.ItemsSource = null;
data3.ItemsSource = codeItems;
if (data3.Items.Count > 0) if (data3.Items.Count > 0)
data3.SelectedIndex = -1; data3.SelectedIndex = -1;
bmp = (Bitmap)ImgShow.Image; bmp = (Bitmap)ImgShow.Image;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!