升级 ,以及修复一些BUG
This commit is contained in:
@@ -384,7 +384,67 @@ namespace WebSite.Controllers
|
||||
}
|
||||
|
||||
|
||||
public ActionResult ShengJI_NEW(IList<int> idList, string fileName, IHostManager HostManager1,int RoomTypeID)
|
||||
public ActionResult 新改造(IList<int> idList, string fileName, int RoomTypeID, IHostManager HostManager1)
|
||||
{
|
||||
try
|
||||
{
|
||||
IList<Host> hosts = new List<Host>();
|
||||
foreach (int id in idList)
|
||||
{
|
||||
Host host = HostManager1.Get(id);
|
||||
if (host != null)
|
||||
{
|
||||
hosts.Add(host);
|
||||
}
|
||||
}
|
||||
FileType fileType = FileType.Config;
|
||||
switch (fileName.Substring(fileName.Length - 3).ToLower())
|
||||
{
|
||||
case "bin":
|
||||
case "hex":
|
||||
fileType = FileType.Firmware;
|
||||
break;
|
||||
case "dat":
|
||||
fileType = FileType.Config;
|
||||
break;
|
||||
default:
|
||||
return Json(new { IsSuccess = false, Message = "升级文件不合法!" });
|
||||
}
|
||||
string fileHref = "Uploads/V2/room_type/" + RoomTypeID + "/" + fileName;//升级文件相对路径
|
||||
string fileMd5 = "";
|
||||
string FileKey = "FileMD5_" + fileHref;
|
||||
string kkka = CSRedisCacheHelper.Get_Partition<string>(FileKey, 3);
|
||||
if (!string.IsNullOrEmpty(kkka))
|
||||
{
|
||||
fileMd5 = kkka;
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Stream stream = System.IO.File.Open(Tools.GetApplicationPath() + fileHref, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{
|
||||
fileMd5 = Tools.ComputeFileHash(stream);
|
||||
CSRedisCacheHelper.Set_PartitionWithTime<string>(FileKey, fileMd5, 60 * 60, 3);
|
||||
stream.Close();
|
||||
}
|
||||
}
|
||||
HostManager1.UpdateHostC(null, fileType, fileHref, fileMd5, hosts);
|
||||
//IList<string> hostNumberList = new List<string>();
|
||||
//foreach (Host h in hosts)
|
||||
//{
|
||||
// hostNumberList.Add(h.RoomNumber);
|
||||
//}
|
||||
return Json(new { IsSuccess = true, Message = "shengji" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex.Message);
|
||||
logger.Error(ex.StackTrace);
|
||||
return Json(new { IsSuccess = false, Message = ex.Message });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ActionResult ShengJI_NEW(IList<int> idList, string fileName, IHostManager HostManager1, int RoomTypeID)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user