升级 ,以及修复一些BUG
This commit is contained in:
@@ -48,8 +48,8 @@ namespace RCUHost.Implement
|
||||
//添加升级功能标志,告诉缓存,不能被拦截
|
||||
foreach (var item in hosts)
|
||||
{
|
||||
string Key="Upgrade_UpdateSQL_"+ item.HostNumber;
|
||||
MemoryCacheHelper.Set(Key,item.ID,DateTimeOffset.Now.AddMinutes(3));
|
||||
string Key = "Upgrade_UpdateSQL_" + item.HostNumber;
|
||||
MemoryCacheHelper.Set(Key, item.ID, DateTimeOffset.Now.AddMinutes(3));
|
||||
}
|
||||
|
||||
FileInfo fileInfo = new FileInfo(updateFile);
|
||||
@@ -85,7 +85,7 @@ namespace RCUHost.Implement
|
||||
{
|
||||
int startIndex = StructConverter.SizeOf(context1.SystemHeader);
|
||||
UpdateHostPacketReply? reply1 = DecodeUpdateHostPacketReply(context1.Data, startIndex);
|
||||
var TTT = new Tuple<ReceiverContext, UpdateHostPacketReply?>(context1,reply1);
|
||||
var TTT = new Tuple<ReceiverContext, UpdateHostPacketReply?>(context1, reply1);
|
||||
//logger.Error(string.Format("收到tftp升级回复命令({0}:{1}):{2},解析结果:{3}", context.RemoteEndPoint.Address.ToString(), context.RemoteEndPoint.Port, Tools.ByteToString(context.Data), reply.HasValue));
|
||||
if (reply1.HasValue)
|
||||
{
|
||||
@@ -95,8 +95,20 @@ namespace RCUHost.Implement
|
||||
var context = NNN.Item1;
|
||||
var reply = NNN.Item2;
|
||||
var updateHostWorker = this.updateHostList.FirstOrDefault(r => r.Host.HostNumber == context.SystemHeader.Value.HostNumber.ToString());
|
||||
//logger.Error(string.Format("酒店{0}客房{1}升级({2}),状态{3}", updateHostWorker.Host.SysHotel.Code, updateHostWorker.Host.RoomNumber, updateHostWorker.RemoteFile, reply.Value.Status));
|
||||
SaveSystemLog(30, "升级主机", string.Format("收到主机({0})升级回复命令,状态:{1}", updateHostWorker.Host.RoomNumber, reply.Value.Status), "收到命令", "RCU", context.RemoteEndPoint.Address.ToString(), updateHostWorker.Host.SysHotel.ID);
|
||||
var data= Tools.ByteToString( context1.Data);
|
||||
logger.Error(string.Format("主机{0}升级返回:{1}", context.SystemHeader.Value.HostNumber.ToString(),data));
|
||||
if (updateHostWorker == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
SaveSystemLog(30, "升级主机", string.Format("收到主机({0})升级回复命令,状态:{1}", updateHostWorker.Host.RoomNumber, reply.Value.Status), "收到命令", "RCU", context.RemoteEndPoint.Address.ToString(), updateHostWorker.Host.SysHotel.ID);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
if (updateHostWorker.HostUpdate == null)
|
||||
{
|
||||
BarData bbb = new BarData();
|
||||
@@ -114,6 +126,18 @@ namespace RCUHost.Implement
|
||||
HostRepository.SetUpgradeStatus(updateHostWorker.Host, 1);//升级完成
|
||||
bbb.Upgrade_status = "升级完成";
|
||||
break;
|
||||
case UpdateHostPacketReply.BlockNumError:
|
||||
bbb.Upgrade_status = "块错误";
|
||||
HostRepository.SetUpgradeStatus(updateHostWorker.Host, 2);//升级失败
|
||||
break;
|
||||
case UpdateHostPacketReply.FileTypeError:
|
||||
bbb.Upgrade_status = "文件错误";
|
||||
HostRepository.SetUpgradeStatus(updateHostWorker.Host, 2);//升级失败
|
||||
break;
|
||||
case UpdateHostPacketReply.FileMD5Error:
|
||||
bbb.Upgrade_status = "文件MD5校验错误";
|
||||
HostRepository.SetUpgradeStatus(updateHostWorker.Host, 2);//升级失败
|
||||
break;
|
||||
default:
|
||||
HostRepository.SetUpgradeStatus(updateHostWorker.Host, 2);//升级失败
|
||||
bbb.Upgrade_status = "升级失败";
|
||||
@@ -147,6 +171,21 @@ namespace RCUHost.Implement
|
||||
hostUpdateStatus.Status = 1;//升级完成
|
||||
updateHostList.Remove(updateHostWorker);
|
||||
break;
|
||||
case UpdateHostPacketReply.BlockNumError:
|
||||
bbb.Upgrade_status = "块错误";
|
||||
hostUpdateStatus.Status = 2;//升级失败
|
||||
updateHostList.Remove(updateHostWorker);
|
||||
break;
|
||||
case UpdateHostPacketReply.FileTypeError:
|
||||
bbb.Upgrade_status = "文件错误";
|
||||
hostUpdateStatus.Status = 2;//升级失败
|
||||
updateHostList.Remove(updateHostWorker);
|
||||
break;
|
||||
case UpdateHostPacketReply.FileMD5Error:
|
||||
bbb.Upgrade_status = "文件MD5校验错误";
|
||||
hostUpdateStatus.Status = 2;//升级失败
|
||||
updateHostList.Remove(updateHostWorker);
|
||||
break;
|
||||
default:
|
||||
bbb.Upgrade_status = "升级失败";
|
||||
hostUpdateStatus.Status = 2;//升级失败
|
||||
@@ -158,7 +197,7 @@ namespace RCUHost.Implement
|
||||
hostUpdateStatus.UpdatedTime = DateTime.Now;
|
||||
HostUpdateStatusRepository.SaveOrUpdate(hostUpdateStatus);
|
||||
}
|
||||
},TTT);
|
||||
}, TTT);
|
||||
}
|
||||
}
|
||||
public override CommandType CommandType
|
||||
@@ -175,6 +214,7 @@ namespace RCUHost.Implement
|
||||
/// <param name="updateFileMd5">升级文件MD5值</param>
|
||||
private void SendUpdateRequest(Host host, string updateFileMd5, ushort blockNum, byte fileType, string fileName)
|
||||
{
|
||||
logger.Error("主机升级:"+host.SysHotel.Code+":"+host.RoomNumber);
|
||||
byte[] data = CreateUpdateRequestPacket(updateFileMd5, blockNum, fileType, fileName);
|
||||
Send(data, host.HostNumber, host.MAC);// host.IP, host.Port);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user