Commit 9f577ac1 张东亮

添加删除上一个任务判断,重试次数5次

1 个父辈 e36248e1
...@@ -242,7 +242,6 @@ namespace BLL ...@@ -242,7 +242,6 @@ namespace BLL
//防止上一个任务已执行但返回失败时,删除任务 //防止上一个任务已执行但返回失败时,删除任务
//if (isRemovePreMission) //if (isRemovePreMission)
Del_Mission(info); Del_Mission(info);
string ip = Common.appConfig.AppSettings.Settings["FLEET"].Value; string ip = Common.appConfig.AppSettings.Settings["FLEET"].Value;
string url = "http://" + ip + "/api/v2.0.0/mission_scheduler"; string url = "http://" + ip + "/api/v2.0.0/mission_scheduler";
string body = "{\"mission_id\":\"" + mission_id + "\",\"robot_id\":" + info.ID + "}"; string body = "{\"mission_id\":\"" + mission_id + "\",\"robot_id\":" + info.ID + "}";
...@@ -368,15 +367,46 @@ namespace BLL ...@@ -368,15 +367,46 @@ namespace BLL
{ {
try try
{ {
int tryTimes = 5;
while (tryTimes > 0)
{
string url = "http://" + info.IP + "/api/v2.0.0/mission_queue"; string url = "http://" + info.IP + "/api/v2.0.0/mission_queue";
HttpDel(url, info.IP, info.Authorization); System.Net.HttpStatusCode res = HttpDel(url, info.IP, info.Authorization);
if (res.Equals(System.Net.HttpStatusCode.NoContent))
break;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
Common.log.Error("Del_Mission", ex); Common.log.Error("Del_Mission", ex);
} }
} }
/// <summary>
/// 删除Fleet尽快中指定id的任务,已运行的无法删除
/// </summary>
/// <param name="authorization"></param>
/// <param name="id"></param>
//public void Del_Mission_Fleet(Agv_Info agv, string id)
//{
// try
// {
// int tryTimes = 5;
// while (tryTimes > 0)
// {
// string ip = AppConfigHelper.GetValue(SettingString.FLEET);
// string url = "http://" + ip + "/api/v2.0.0/mission_scheduler/" + id;
// System.Net.HttpStatusCode res = HttpDel(url, ip, agv.Authorization);
// if (res.Equals(System.Net.HttpStatusCode.NoContent))
// break;
// }
// }
// catch (Exception ex)
// {
// log.Error(ex);
// }
//}
/// <summary> /// <summary>
/// 获取当前小车状态 /// 获取当前小车状态
/// </summary> /// </summary>
...@@ -687,7 +717,7 @@ namespace BLL ...@@ -687,7 +717,7 @@ namespace BLL
return s; return s;
} }
private void HttpDel(string url, string ip, string authorization) private System.Net.HttpStatusCode HttpDel(string url, string ip, string authorization)
{ {
RestClient client = new RestClient(url) { Timeout = httpTimeout }; RestClient client = new RestClient(url) { Timeout = httpTimeout };
RestRequest request = new RestRequest(Method.DELETE); RestRequest request = new RestRequest(Method.DELETE);
...@@ -698,8 +728,9 @@ namespace BLL ...@@ -698,8 +728,9 @@ namespace BLL
request.AddHeader("Accept-Language", "zh_CN"); request.AddHeader("Accept-Language", "zh_CN");
request.AddParameter("application/json", "", ParameterType.RequestBody); request.AddParameter("application/json", "", ParameterType.RequestBody);
IRestResponse response = client.Execute(request); IRestResponse response = client.Execute(request);
string s = response.Content; System.Net.HttpStatusCode s = response.StatusCode;
Common.log.Debug("HttpDel URL: " + url); Common.log.Debug("HttpDel URL: " + url+"#"+s.ToString());
return s;
} }
} }
......
...@@ -71,4 +71,3 @@ E:\Neotel\Projects\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLi ...@@ -71,4 +71,3 @@ E:\Neotel\Projects\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLi
E:\Neotel\Projects\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.csproj.CopyComplete E:\Neotel\Projects\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.csproj.CopyComplete
E:\Neotel\Projects\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.exe E:\Neotel\Projects\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.exe
E:\Neotel\Projects\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.pdb E:\Neotel\Projects\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.pdb
E:\Neotel\Projects\Gitee\AGVControl-Qisda-ProductionLine\AGVControl-ProductionLine\obj\Debug\AGVControl-ProductionLine.csprojAssemblyReference.cache
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!