称重优化日志
This commit is contained in:
@@ -120,7 +120,8 @@ namespace Tnb.ProductionMgr
|
|||||||
Log.Information($"称重完成参数:{JsonConvert.SerializeObject(dicCommand2)}");
|
Log.Information($"称重完成参数:{JsonConvert.SerializeObject(dicCommand2)}");
|
||||||
for (int i = 0; i < 1; i++)
|
for (int i = 0; i < 1; i++)
|
||||||
{
|
{
|
||||||
await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2);
|
string responseresult = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2,false);
|
||||||
|
Log.Information($"称重完成返回结果:{responseresult}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,9 +99,12 @@ namespace Tnb.Common.Utils
|
|||||||
return respJson;
|
return respJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<string> GetRequestAsync(string url, Dictionary<string, string> pars = null)
|
public static async Task<string> GetRequestAsync(string url, Dictionary<string, string> pars = null,bool isLog = true)
|
||||||
{
|
{
|
||||||
Log.Information($"开始请求 {url} 请求参数: {JsonConvert.SerializeObject(pars)}");
|
if (isLog)
|
||||||
|
{
|
||||||
|
Log.Information($"开始请求 {url} 请求参数: {JsonConvert.SerializeObject(pars)}");
|
||||||
|
}
|
||||||
HttpClient Client = new HttpClient();
|
HttpClient Client = new HttpClient();
|
||||||
var reqUri = url;
|
var reqUri = url;
|
||||||
if (pars?.Count > 0)
|
if (pars?.Count > 0)
|
||||||
@@ -112,7 +115,10 @@ namespace Tnb.Common.Utils
|
|||||||
Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
var respBody = await Client.GetAsync(reqUri);
|
var respBody = await Client.GetAsync(reqUri);
|
||||||
var result = await respBody.Content.ReadAsStringAsync();
|
var result = await respBody.Content.ReadAsStringAsync();
|
||||||
Log.Information($"请求 {url} 结果: {result}");
|
if (isLog)
|
||||||
|
{
|
||||||
|
Log.Information($"请求 {url} 结果: {result}");
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user