| | |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 备份用的网关ID |
| | | /// </summary> |
| | | private List<string> listBackupGwId = new List<string>(); |
| | | /// <summary> |
| | | /// 网关文件的前缀名字 |
| | | /// </summary> |
| | | private string gwFirstName = "Gateway_"; |
| | |
| | | return; |
| | | } |
| | | |
| | | List<string> listBackupGwId = new List<string>(); |
| | | var listBackupGwId = new List<string>(); |
| | | var fileData = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.BackupGatewayIdFile); |
| | | if (fileData != null) |
| | | { |
| | |
| | | /// <param name="zbGateway"></param> |
| | | public void BackupGatewayIdOnNotNetwork(ZbGateway zbGateway) |
| | | { |
| | | var strId = zbGateway.GwId; |
| | | if (listBackupGwId.Contains(strId) == false) |
| | | var listBackupGwId = new List<string>(); |
| | | var fileData = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.BackupGatewayIdFile); |
| | | if (fileData != null) |
| | | { |
| | | listBackupGwId.Add(strId); |
| | | listBackupGwId = JsonConvert.DeserializeObject<List<string>>(System.Text.Encoding.UTF8.GetString(fileData)); |
| | | } |
| | | |
| | | if (listBackupGwId.Contains(zbGateway.GwId) == false) |
| | | { |
| | | listBackupGwId.Add(zbGateway.GwId); |
| | | |
| | | //备份 |
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.BackupGatewayIdFile, listBackupGwId); |
| | |
| | | { |
| | | return true; |
| | | } |
| | | this.listBackupGwId = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(System.Text.Encoding.UTF8.GetString(fileData)); |
| | | var listBackupGwId = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(System.Text.Encoding.UTF8.GetString(fileData)); |
| | | var listTempId = new List<string>(); |
| | | listTempId.AddRange(this.listBackupGwId); |
| | | listTempId.AddRange(listBackupGwId); |
| | | |
| | | //调用接口,绑定网关 |
| | | var bindGateway = new BindGatewayPra(); |
| | |
| | | |
| | | foreach (var gwId in listTempId) |
| | | { |
| | | bindGateway.BindGateways.Clear(); |
| | | bindGateway.BindGateways.Add(gwId); |
| | | var result = UserCenterLogic.GetResultCodeByRequestHttps("App/BindGatewayToHome", true, bindGateway, new List<string> { "NotCheck" }, false); |
| | | if (result == "Success") |
| | | if (this.IsGatewayExist(gwId) == true) |
| | | { |
| | | this.listBackupGwId.Remove(gwId); |
| | | bindGateway.BindGateways.Clear(); |
| | | bindGateway.BindGateways.Add(gwId); |
| | | var result = UserCenterLogic.GetResultCodeByRequestHttps("App/BindGatewayToHome", true, bindGateway, new List<string> { "NotCheck" }, false); |
| | | if (result == "Success") |
| | | { |
| | | listBackupGwId.Remove(gwId); |
| | | } |
| | | if (result == "Error") |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | if (result == "Error") |
| | | { |
| | | break; |
| | | } |
| | | listBackupGwId.Remove(gwId); |
| | | } |
| | | |
| | | if (this.listBackupGwId.Count == 0) |
| | | if (listBackupGwId.Count == 0) |
| | | { |
| | | //如果没有了内容,则删除文件 |
| | | string file = DirNameResourse.BackupGatewayIdFile; |