Files
FG2608061/反编译CODE/HxBusiness/BusinessManage.cs
T

240 lines
6.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Threading;
using Newtonsoft.Json;
namespace HxBusiness
{
// Token: 0x02000005 RID: 5
public class BusinessManage
{
// Token: 0x17000001 RID: 1
// (get) Token: 0x0600000F RID: 15 RVA: 0x000028B4 File Offset: 0x00000AB4
private ConnectedManager webClient
{
get
{
bool flag = this._webClient != null;
ConnectedManager webClient;
if (flag)
{
webClient = this._webClient;
}
else
{
this._webClient = new ConnectedManager();
webClient = this._webClient;
}
return webClient;
}
}
// Token: 0x17000002 RID: 2
// (get) Token: 0x06000010 RID: 16 RVA: 0x000028F0 File Offset: 0x00000AF0
// (set) Token: 0x06000011 RID: 17 RVA: 0x0000294E File Offset: 0x00000B4E
public ApiModel apiModel
{
get
{
bool flag = this._apiModel != null;
ApiModel apiModel;
if (flag)
{
apiModel = this._apiModel;
}
else
{
this._apiModel = new ApiModel
{
requestUrl = "http://192.168.128.1:8080",
leaveUrl = "http://192.168.128.1:8080",
sendUrl = "http://192.168.128.1:8080"
};
apiModel = this._apiModel;
}
return apiModel;
}
set
{
this._apiModel = value;
}
}
// Token: 0x06000012 RID: 18 RVA: 0x00002958 File Offset: 0x00000B58
public BusinessManage()
{
try
{
string value = new ConfigBiz().ReadDb<ApiModel>();
bool flag = string.IsNullOrEmpty(value);
if (flag)
{
throw new Exception("请配置url");
}
this.apiModel = JsonConvert.DeserializeObject<ApiModel>(value);
WriteTxt.SaveLog1("启动api", "插件日志", "插件日志");
}
catch (Exception ex)
{
WriteTxt.SaveLog1("初始化失败!" + ex.ToString(), "异常日志", "插件日志");
}
}
// Token: 0x06000013 RID: 19 RVA: 0x000029E8 File Offset: 0x00000BE8
public void Request(string agvid, string rfid, AgvState state)
{
bool flag = state == null || !state.agvid.ToString().Equals(agvid);
if (!flag)
{
bool flag2 = state.state == E_State.开始;
if (flag2)
{
int requestCount = 0;
bool result = false;
ThreadPool.QueueUserWorkItem(delegate(object o)
{
while (!result)
{
int requestCount;
bool flag3 = requestCount % 2 == 0;
if (flag3)
{
result = this.RequestLeaved(agvid, rfid);
requestCount = requestCount;
requestCount++;
}
Thread.Sleep(1000);
}
});
}
}
}
// Token: 0x06000014 RID: 20 RVA: 0x00002A7C File Offset: 0x00000C7C
public bool RequestLeaved(string agvid, string rfid)
{
bool result;
try
{
bool flag = this.apiModel == null;
if (flag)
{
WriteTxt.SaveLog1("路口请求时配置为空!", "异常日志", "插件日志");
result = false;
}
else
{
bool flag2 = string.IsNullOrEmpty(agvid) || string.IsNullOrEmpty(rfid);
if (flag2)
{
WriteTxt.SaveLog1("路口请求时请求参数为空!", "异常日志", "插件日志");
result = false;
}
else
{
RequestModel value = new RequestModel
{
equipmentCode = agvid,
requestCode = "AGV" + agvid + "-" + rfid,
arriveTime = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
taskPriority = 100,
taskDeadLine = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
allowedQueueUp = false,
interchangePointCode = rfid
};
string text = JsonConvert.SerializeObject(value);
string text2 = this.webClient.PostForUrl(this.apiModel.requestUrl, text);
WriteTxt.SaveLog1(string.Format("路口请求url:{0},请求数据:{1},获取回复:{2}", this.apiModel.requestUrl, text, text2), "插件日志", "插件日志");
ResponseModel responseModel = JsonConvert.DeserializeObject<ResponseModel>(text2);
bool flag3 = responseModel.code == 0;
if (flag3)
{
result = true;
}
else
{
result = false;
}
}
}
}
catch (Exception ex)
{
WriteTxt.SaveLog1("路口请求离开异常!" + ex.ToString(), "异常日志", "插件日志");
result = false;
}
return result;
}
// Token: 0x06000015 RID: 21 RVA: 0x00002C10 File Offset: 0x00000E10
public bool ByLeaved(string agvid, string rfid, string Cross_Location_Go)
{
bool result;
try
{
bool flag = this.apiModel == null;
if (flag)
{
WriteTxt.SaveLog1("离开时请求时配置为空!", "异常日志", "插件日志");
result = false;
}
else
{
bool flag2 = string.IsNullOrEmpty(agvid);
if (flag2)
{
WriteTxt.SaveLog1("离开时请求时请求参数为空!", "异常日志", "插件日志");
result = false;
}
else
{
RequestLeavedModel value = new RequestLeavedModel
{
adapterCode = "HUAXIAO",
equipmentCode = agvid,
requestCode = "AGV" + agvid + "-" + Cross_Location_Go,
leaveTime = DateTime.Now.ToString("yyyyMMddHHmmssfff")
};
string text = JsonConvert.SerializeObject(value);
string text2 = this.webClient.PostForUrl(this.apiModel.leaveUrl, text);
WriteTxt.SaveLog1(string.Format("离开请求url:{0},请求数据:{1},获取回复:{2}", this.apiModel.requestUrl, text, text2), "插件日志", "插件日志");
ResponseModel responseModel = JsonConvert.DeserializeObject<ResponseModel>(text2);
bool flag3 = responseModel.code == 0;
if (flag3)
{
result = true;
}
else
{
result = false;
}
}
}
}
catch (Exception ex)
{
WriteTxt.SaveLog1("离开时请求离开异常!" + ex.ToString(), "异常日志", "插件日志");
result = false;
}
return result;
}
// Token: 0x06000016 RID: 22 RVA: 0x00002D70 File Offset: 0x00000F70
public bool GetStart()
{
return true;
}
// Token: 0x06000017 RID: 23 RVA: 0x00002D84 File Offset: 0x00000F84
public bool GetStop()
{
return true;
}
// Token: 0x04000006 RID: 6
private ConnectedManager _webClient;
// Token: 0x04000007 RID: 7
private ApiModel _apiModel;
}
}