| | |
| | |
|
| | | //获取需要下载的固件数据
|
| | | var listVersion = GetNeedToDownLoadVersionData(listTempDevice, listTempGateway);
|
| | | if (listVersion.Count == 0)
|
| | | //获取需要下载的空调模块
|
| | | var listAcOta = new List<OTADevice>();
|
| | | var listAcUpdate = GetNeedDownLoadAirConditionerModule(listTempDevice, ref listAcOta);
|
| | |
|
| | | if (listVersion.Count == 0 && listAcUpdate.Count == 0)
|
| | | {
|
| | | return 0;
|
| | | }
|
| | |
| | | //固件存储路径
|
| | | string firmwareDir = DirNameResourse.FirmwareUpdateDirectory;
|
| | | int nowCount = 0;
|
| | | int macCount = listVersion.Count + listAcUpdate.Count;
|
| | |
|
| | | foreach (var versionData in listVersion)
|
| | | {
|
| | | nowCount++;
|
| | |
| | | if (result == -1)
|
| | | {
|
| | | ProgressFormBar.Current.Close();
|
| | | //保存列表名字
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.FirmwareUpdateList, dicFirmwareName);
|
| | | return -1;
|
| | | }
|
| | | //获取当前这个版本的固件信息
|
| | |
| | | if (versionFirmware == null)
|
| | | {
|
| | | //云端没有这个版本 进度值
|
| | | ProgressFormBar.Current.SetValue(nowCount, listVersion.Count);
|
| | | ProgressFormBar.Current.SetValue(nowCount, macCount);
|
| | | continue;
|
| | | }
|
| | | //去下载这个固件
|
| | | var pra = new { RequestVersion = Common.CommonPage.RequestVersion, DistributedMark = versionFirmware.DistributedMark };
|
| | | var byteData = UserCenterLogic.GetByteResponseDataByRequestHttps("FirmwareMana/DownloadPlatformUploadFirmware", false, pra, null, true);
|
| | | var byteData = UserCenterLogic.GetByteResponseDataByRequestHttps("FirmwareMana/DownloadPlatformUploadFirmware", false, pra, new List<string> { "NotCheck" }, true);
|
| | | if (byteData == null)
|
| | | {
|
| | | ProgressFormBar.Current.Close();
|
| | | //保存列表名字
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.FirmwareUpdateList, dicFirmwareName);
|
| | | return -1;
|
| | | }
|
| | | //保存固件
|
| | |
| | | dicFirmwareName[saveFile] = versionFirmware.Name;
|
| | |
|
| | | //进度值
|
| | | ProgressFormBar.Current.SetValue(nowCount, listVersion.Count);
|
| | | ProgressFormBar.Current.SetValue(nowCount, macCount);
|
| | | }
|
| | | for (int i = 0; i < listAcUpdate.Count; i++)
|
| | | {
|
| | | //下载空调模块
|
| | | var pra = new { RequestVersion = Common.CommonPage.RequestVersion, DistributedMark = listAcUpdate[i].DistributedMark };
|
| | | var deviceFirmwareByte = UserCenterLogic.GetByteResponseDataByRequestHttps("FirmwareMana/DownloadPlatformUploadFirmware", false, pra, new List<string> { "NotCheck" }, true);
|
| | | if (deviceFirmwareByte == null)
|
| | | {
|
| | | ProgressFormBar.Current.Close();
|
| | | //保存列表名字
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.FirmwareUpdateList, dicFirmwareName);
|
| | | return -1;
|
| | | }
|
| | | //保存固件
|
| | | string fileName = "AC_" + listAcOta[i].HwVersion + "_" + listAcOta[i].ImgTypeId + "_" + listAcUpdate[i].Name;
|
| | | var saveFile = System.IO.Path.Combine(firmwareDir, fileName);
|
| | | HdlFileLogic.Current.SaveByteToFile(saveFile, deviceFirmwareByte);
|
| | |
|
| | | //进度值
|
| | | ProgressFormBar.Current.SetValue(nowCount, macCount);
|
| | | }
|
| | |
|
| | | //保存列表名字
|
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.FirmwareUpdateList, dicFirmwareName);
|
| | | ProgressFormBar.Current.Close();
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取需要下载的空调模块
|
| | | /// </summary>
|
| | | /// <param name="listDevice">设备列表</param>
|
| | | /// <param name="listTaget">与返回值对应的东西</param>
|
| | | private static List<FirmwareVersionInfo> GetNeedDownLoadAirConditionerModule(List<OTADevice> listDevice, ref List<OTADevice> listTaget)
|
| | | {
|
| | | var listUpdate = new List<FirmwareVersionInfo>();
|
| | | //固件存储路径
|
| | | string firmwareDir = DirNameResourse.FirmwareUpdateDirectory;
|
| | |
|
| | | foreach (var otaDevice in listDevice)
|
| | | {
|
| | | var myType = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice> { otaDevice });
|
| | | if (myType.ConcreteType != Common.DeviceConcreteType.AirConditioner_ZbGateway)
|
| | | {
|
| | | //只处理中央空调
|
| | | continue;
|
| | | }
|
| | | var list = GetFirmwareVersionListInfo(FirmwareLevelType.A设备, otaDevice.HwVersion.ToString(), otaDevice.ImgTypeId.ToString());
|
| | | foreach (var data in list)
|
| | | {
|
| | | if (data.Name.EndsWith(".bin") == true && System.IO.File.Exists(firmwareDir) == false)
|
| | | {
|
| | | //只要.bin文件
|
| | | listUpdate.Add(data);
|
| | | listTaget.Add(otaDevice);
|
| | | }
|
| | | }
|
| | | }
|
| | | return listUpdate;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 模板设备的版本信息
|
| | | /// </summary>
|
| | | private class TemplateDeviceVersion
|