| | |
| | | /// </summary>
|
| | | /// <param name="realGateway">真实物理网关对象</param>
|
| | | /// <param name="backupName">需要创建的备份的名字</param>
|
| | | public async void DoBackupGateway(ZbGateway realGateway, string backupName)
|
| | | public void DoBackupGateway(ZbGateway realGateway, string backupName)
|
| | | {
|
| | | //展开进度条
|
| | | ProgressFormBar.Current.Start();
|
| | | //创建备份文件
|
| | | ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uCreatBackupFile));
|
| | | await System.Threading.Tasks.Task.Delay(1000);
|
| | | System.Threading.Thread.Sleep(1000);
|
| | |
|
| | | //创建一个备份名字
|
| | | string backupClassId = await HdlBackupLogic.Current.CreatNewBackupNameToDB(backupName, 2, HdlGatewayLogic.Current.GetGatewayId(realGateway));
|
| | | string backupClassId = HdlBackupLogic.Current.CreatNewBackupNameToDB(backupName, 2, realGateway.GwId);
|
| | | if (backupClassId == null)
|
| | | {
|
| | | //关闭进度条
|
| | |
| | | }
|
| | |
|
| | | //保存协调器的nv分区组网信息
|
| | | bool result = this.SaveNVFile(realGateway);
|
| | | if (result == false)
|
| | | {
|
| | | //如果上传失败的话,就把它删除
|
| | | await HdlBackupLogic.Current.DeleteDbBackupData(backupClassId);
|
| | | //关闭进度条
|
| | | ProgressFormBar.Current.Close();
|
| | | return;
|
| | | }
|
| | | //bool result = this.SaveNVFile(realGateway);
|
| | | //if (result == false)
|
| | | //{
|
| | | // //如果上传失败的话,就把它删除
|
| | | // await HdlBackupLogic.Current.DeleteDbBackupData(backupClassId);
|
| | | // //关闭进度条
|
| | | // ProgressFormBar.Current.Close();
|
| | | // return;
|
| | | //}
|
| | |
|
| | | //打开协调器串口发送功能
|
| | | result = this.OpenZbMsComSend(realGateway);
|
| | | if (result == false)
|
| | | {
|
| | | //如果上传失败的话,就把它删除
|
| | | await HdlBackupLogic.Current.DeleteDbBackupData(backupClassId);
|
| | | //关闭进度条
|
| | | ProgressFormBar.Current.Close();
|
| | | return;
|
| | | }
|
| | | //result = this.OpenZbMsComSend(realGateway);
|
| | | //if (result == false)
|
| | | //{
|
| | | // //如果上传失败的话,就把它删除
|
| | | // await HdlBackupLogic.Current.DeleteDbBackupData(backupClassId);
|
| | | // //关闭进度条
|
| | | // ProgressFormBar.Current.Close();
|
| | | // return;
|
| | | //}
|
| | |
|
| | | //开始上传数据
|
| | | result = this.StartUpLoadData(realGateway, backupClassId);
|
| | | bool result = this.StartUpLoadData(realGateway, backupClassId);
|
| | | if (result == false)
|
| | | {
|
| | | //如果上传失败的话,就把它删除
|
| | | await HdlBackupLogic.Current.DeleteDbBackupData(backupClassId);
|
| | | HdlBackupLogic.Current.DeleteDbBackupData(backupClassId);
|
| | | //关闭进度条
|
| | | ProgressFormBar.Current.Close();
|
| | | return;
|
| | |
| | | this.ShowErrorMsg(msg);
|
| | | return false;
|
| | | }
|
| | | System.Threading.Thread.Sleep(1000);
|
| | |
|
| | | return success;
|
| | | }
|
| | |
|
| | |
| | | /// </summary>
|
| | | /// <param name="realGateway">真实物理网关对象</param>
|
| | | /// <param name="backupId">备份主键</param>
|
| | | public bool RecoverGateway(ZbGateway realGateway, string backupId)
|
| | | /// <param name="isAutoBack">0:获取网关手动备份文件列表 1:获取网关自动备份文件列表</param>
|
| | | public bool RecoverGateway(ZbGateway realGateway, string backupId, int isAutoBack)
|
| | | {
|
| | | //展开进度条
|
| | | ProgressFormBar.Current.Start();
|
| | | //从云端获取备份文件列表
|
| | | var result = this.GetGatewayFileList(realGateway, backupId);
|
| | | var result = this.GetGatewayFileList(realGateway, backupId, isAutoBack);
|
| | | if (result == false)
|
| | | {
|
| | | //关闭进度条
|
| | |
| | | }
|
| | |
|
| | | //从云端下载备份文件
|
| | | result = this.DownloadGatewayFile(realGateway, backupId);
|
| | | result = this.DownloadGatewayFile(realGateway, backupId, isAutoBack);
|
| | | if (result == false)
|
| | | {
|
| | | //关闭进度条
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | //恢复协调器nv分区的组网信息
|
| | | result = this.RestoreGatewayNV(realGateway);
|
| | | if (result == false)
|
| | | {
|
| | | //关闭进度条
|
| | | ProgressFormBar.Current.Close();
|
| | | return false;
|
| | | }
|
| | | ////恢复协调器nv分区的组网信息
|
| | | //result = this.RestoreGatewayNV(realGateway);
|
| | | //if (result == false)
|
| | | //{
|
| | | // //关闭进度条
|
| | | // ProgressFormBar.Current.Close();
|
| | | // return false;
|
| | | //}
|
| | |
|
| | | //打开协调器串口发送功能
|
| | | result = this.OpenZbMsComSend(realGateway);
|
| | | if (result == false)
|
| | | {
|
| | | //关闭进度条
|
| | | ProgressFormBar.Current.Close();
|
| | | return false;
|
| | | }
|
| | | //result = this.OpenZbMsComSend(realGateway);
|
| | | //if (result == false)
|
| | | //{
|
| | | // //关闭进度条
|
| | | // ProgressFormBar.Current.Close();
|
| | | // return false;
|
| | | //}
|
| | |
|
| | | //重启网关系统
|
| | | result = this.GatewayReboot(realGateway);
|
| | |
| | | /// <param name="realGateway"></param>
|
| | | /// <param name="backupClassId"></param>
|
| | | /// <returns></returns>
|
| | | private bool GetGatewayFileList(ZbGateway realGateway, string backupClassId)
|
| | | private bool GetGatewayFileList(ZbGateway realGateway, string backupClassId, int isAutoBack)
|
| | | {
|
| | | //正在获取备份文件列表
|
| | | ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uBackupFileListGetting));
|
| | |
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 6202 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject {
|
| | | { "url", fullUrl }, { "RequestVersion", Common.CommonPage.RequestVersion },
|
| | | { "LoginAccessToken", UserCenterLogic.GetConnectMainToken() }, { "IsGatewayAutoBackup", 0 },
|
| | | { "BackupClassId", backupClassId },{ "GatewayUniqueId",HdlGatewayLogic.Current.GetGatewayId(realGateway)},
|
| | | { "LoginAccessToken", UserCenterLogic.GetConnectMainToken() }, { "IsGatewayAutoBackup", isAutoBack },
|
| | | { "BackupClassId", backupClassId },{ "GatewayUniqueId",realGateway.GwId},
|
| | | { "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0}
|
| | | };
|
| | | jObject.Add("Data", data);
|
| | |
| | | /// <param name="realGateway"></param>
|
| | | /// <param name="backupClassId"></param>
|
| | | /// <returns></returns>
|
| | | private bool DownloadGatewayFile(ZbGateway realGateway, string backupClassId)
|
| | | private bool DownloadGatewayFile(ZbGateway realGateway, string backupClassId, int isAutoBack)
|
| | | {
|
| | | //正在下载备份文件
|
| | | ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uBackupFileDownloading));
|
| | |
| | | var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 6203 } };
|
| | | var data = new Newtonsoft.Json.Linq.JObject {
|
| | | { "url", fullUrl }, { "RequestVersion", Common.CommonPage.RequestVersion },
|
| | | { "LoginAccessToken", UserCenterLogic.GetConnectMainToken() }, { "IsGatewayAutoBackup", 0 },
|
| | | { "BackupClassId", backupClassId },{ "GatewayUniqueId",HdlGatewayLogic.Current.GetGatewayId(realGateway)},
|
| | | { "LoginAccessToken", UserCenterLogic.GetConnectMainToken() }, { "IsGatewayAutoBackup", isAutoBack },
|
| | | { "BackupClassId", backupClassId },{ "GatewayUniqueId",realGateway.GwId},
|
| | | { "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0}
|
| | | };
|
| | | jObject.Add("Data", data);
|
| | |
| | | //网关已经接收到重启命令,接下来去判断网关是否重启完成
|
| | | bool gatewatAction = false;
|
| | | bool threadAction = true;
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | timeOut = 0;
|
| | | while (gatewatAction == false)
|
| | |
| | | if (timeOut >= 65 && timeOut % 5 == 0)
|
| | | {
|
| | | //5秒一次,去获取版本
|
| | | var data = await HdlGatewayLogic.Current.GetGatewayNewInfoAsync(realGateway, ShowErrorMode.NO);
|
| | | var data = HdlGatewayLogic.Current.GetGatewayInfo(realGateway, false, ShowErrorMode.NO);
|
| | | if (data != null)
|
| | | {
|
| | | gatewatAction = true;
|
| | |
| | | break;
|
| | | }
|
| | | }
|
| | | await System.Threading.Tasks.Task.Delay(1000);
|
| | | System.Threading.Thread.Sleep(1000);
|
| | | timeOut++;
|
| | | //设置进度值
|
| | | ProgressFormBar.Current.SetValue(timeOut, 180);
|
| | |
| | | }
|
| | | if (gatewatAction == true)
|
| | | {
|
| | | //设置进度值:100%
|
| | | ProgressFormBar.Current.SetValue(1, 1);
|
| | | System.Threading.Thread.Sleep(1000);
|
| | | //网关数据恢复成功!
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uRestoreGatewayDataSuccess);
|
| | | this.ShowTipMsg(msg);
|