| | |
| | | try { |
| | | var backuplist = IO.FileUtils.ReadFiles (); |
| | | int index = 0; |
| | | string oldRegionRootPath = IO.FileUtils.CreateRegionBackup (UserConfig.Instance.CurrentRegion.Name); |
| | | string oldRegionRootPath = IO.FileUtils.CreateRegionBackup (UserConfig.Instance.CurrentRegion.Id); |
| | | IO.FileUtils.DeleteRegionFiles (oldRegionRootPath); |
| | | foreach (var fileName in backuplist) { |
| | | System.IO.FileInfo fileInfo = new System.IO.FileInfo (IO.FileUtils.RootPath + fileName); |
| | |
| | | }); |
| | | } |
| | | IO.FileUtils.DeleteAllFile (); |
| | | string newRegionRootPath = IO.FileUtils.CreateRegionBackup (homeTemp.Name); |
| | | string newRegionRootPath = IO.FileUtils.CreateRegionBackup (homeTemp.Id); |
| | | IO.FileUtils.RestoreRegionFiles (newRegionRootPath); |
| | | UserConfig.Instance.RefreshUserConfig (); |
| | | UserConfig.Instance.CurrentRegion = homeTemp; |
| | |
| | | HomeId = UserConfig.Instance.CurrentRegion.Id, |
| | | LoginAccessToken = MainPage.LoginUser.LoginTokenString |
| | | }; |
| | | string urlHead = MainPage.RequestHttpsHost; |
| | | if (requestObj.IsOtherAccountCtrl) { |
| | | urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl; |
| | | requestObj.LoginAccessToken = UserConfig.Instance.MasterAccountToken; |
| | | } |
| | | |
| | | //GetUserFolderObj requestObj = new GetUserFolderObj () { LevelID = UserConfig.Instance.CurrentRegion.Id }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps (API.GetHomeDataBackupPagger, requestJson); |
| | | var revertObj = MainPage.RequestHttps (API.GetHomeDataBackupPagger, requestJson, urlHead); |
| | | if (revertObj.StateCode.ToUpper() == "SUCCESS") { |
| | | var data = Newtonsoft.Json.JsonConvert.DeserializeObject<GetBackupListResult> (revertObj.ResponseData.ToString ()); |
| | | //var list = new List<BackupListNameInfo> (); |
| | |
| | | HomeId = UserConfig.Instance.CurrentRegion.Id, |
| | | LoginAccessToken = MainPage.LoginUser.LoginTokenString |
| | | }; |
| | | string urlHead = MainPage.RequestHttpsHost; |
| | | if (requestObj.IsOtherAccountCtrl) { |
| | | urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl; |
| | | requestObj.LoginAccessToken = UserConfig.Instance.MasterAccountToken; |
| | | } |
| | | |
| | | //DeleteFolderDataObj requestObj = new DeleteFolderDataObj () { Id = folderID }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps (API.DelHomeAppGatewayName, requestJson); |
| | | var revertObj = MainPage.RequestHttps (API.DelHomeAppGatewayName, requestJson, urlHead); |
| | | if (revertObj.StateCode.ToUpper () == "SUCCESS") { |
| | | Application.RunOnMainThread (() => { |
| | | DatabackupShow (); |
| | |
| | | LoginAccessToken = MainPage.LoginUser.LoginTokenString, |
| | | GatewayUniqueId = UserConfig.Instance.GatewayMAC |
| | | }; |
| | | string urlHead = MainPage.RequestHttpsHost; |
| | | if (requestObj.IsOtherAccountCtrl) { |
| | | urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl; |
| | | requestObj.LoginAccessToken = UserConfig.Instance.MasterAccountToken; |
| | | } |
| | | |
| | | //AddFolderObj requestObj = new AddFolderObj () { LevelID = UserConfig.Instance.CurrentRegion.Id ,Name = groupName }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps (API.AddHomeAppGatewayName, requestJson); |
| | | var revertObj = MainPage.RequestHttps (API.AddHomeAppGatewayName, requestJson, urlHead); |
| | | if (revertObj.StateCode.ToUpper () == "SUCCESS") { |
| | | var DATA = Newtonsoft.Json.JsonConvert.DeserializeObject<AddBackupNameResult> (revertObj.ResponseData.ToString()); |
| | | var addFolderID = DATA.BackupClassId; |
| | |
| | | var backuplist = IO.FileUtils.ReadFiles (); |
| | | int index = 0; |
| | | foreach (var fileName in backuplist) { |
| | | index++; |
| | | //index++; |
| | | /// <summary> |
| | | /// 如果是特殊的注册登陆文件,则不需要备份到服务器 |
| | | /// </summary> |
| | |
| | | upData.UploadSubFileLists = list; |
| | | //获取控制主人账号的Token |
| | | upData.LoginAccessToken = MainPage.LoginUser.LoginTokenString; |
| | | string urlHead = MainPage.RequestHttpsHost; |
| | | if (upData.IsOtherAccountCtrl) { |
| | | urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl; |
| | | upData.LoginAccessToken = UserConfig.Instance.MasterAccountToken; |
| | | } |
| | | |
| | | //AddUserBackupObj requestObj2 = new AddUserBackupObj () { LevelID = Convert.ToInt32 (revertObj.ResponseData), Name = fileName, DetailByte = IO.FileUtils.ReadFile (fileName) }; |
| | | var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (upData); |
| | | var revertObj2 = MainPage.RequestHttps (API.UploadHomeAppGatewaySubFiles, requestJson2); |
| | | var revertObj2 = MainPage.RequestHttps (API.UploadHomeAppGatewaySubFiles, requestJson2, urlHead); |
| | | if (revertObj2.StateCode.ToUpper () == "SUCCESS") { |
| | | index++; |
| | | Application.RunOnMainThread (() => { |
| | | int pro = (int)(index * 1.0 / backuplist.Count * 100); |
| | | MainPage.Loading.Text = pro.ToString () + "%"; |
| | |
| | | //提示错误 |
| | | } |
| | | } |
| | | |
| | | |
| | | Shared.Application.RunOnMainThread (() => { |
| | | if (index == 0) { |
| | | new Alert ("", "Upload failed!", Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | } |
| | | |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | } |
| | | |
| | | |
| | |
| | | requestObj2.PageSetting.Page = 1; |
| | | //获取控制主人账号的Token |
| | | requestObj2.LoginAccessToken = MainPage.LoginUser.LoginTokenString; |
| | | |
| | | string urlHead = MainPage.RequestHttpsHost; |
| | | if (requestObj2.IsOtherAccountCtrl) { |
| | | urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl; |
| | | requestObj2.LoginAccessToken = UserConfig.Instance.MasterAccountToken; |
| | | } |
| | | |
| | | //获取所有文件组名 |
| | | //var requestObj2 = new UserBackupListObj () { LevelID = folderID }; |
| | | var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2); |
| | | var revertObj2 = MainPage.RequestHttps (API.GetHomeDataBackupUploadListPagger, requestJson2); |
| | | var revertObj2 = MainPage.RequestHttps (API.GetHomeDataBackupUploadListPagger, requestJson2, urlHead); |
| | | if (revertObj2.StateCode.ToUpper() == "SUCCESS") { |
| | | var fileListData = Newtonsoft.Json.JsonConvert.DeserializeObject<LoadBackInfoResult> (revertObj2.ResponseData.ToString ()); |
| | | var responseDataObj = fileListData.PageData; |
| | |
| | | mDownLoad.BackupClassId = BackupClassId; |
| | | //获取控制主人账号的Token |
| | | mDownLoad.LoginAccessToken = MainPage.LoginUser.LoginTokenString; |
| | | string mUrlHead = MainPage.RequestHttpsHost; |
| | | if (mDownLoad.IsOtherAccountCtrl) { |
| | | urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl; |
| | | mDownLoad.LoginAccessToken = UserConfig.Instance.MasterAccountToken; |
| | | } |
| | | |
| | | int index = 0; |
| | | foreach (var file in responseDataObj) { |
| | |
| | | mDownLoad.BackupFileName = file.BackupFileName; |
| | | //var requestObj3 = new BackupDetailObj () { Id = file.Id }; |
| | | var requestJson3 = Newtonsoft.Json.JsonConvert.SerializeObject (mDownLoad); |
| | | var revertObj3 = MainPage.RequestHttpsReturnByte (API.DownloadSomeDataBackup, requestJson3); |
| | | var revertObj3 = MainPage.RequestHttpsReturnByte (API.DownloadSomeDataBackup, requestJson3, false, mUrlHead); |
| | | if (revertObj3 != null) { |
| | | index++; |
| | | IO.FileUtils.WriteFileByBytes (file.BackupFileName, revertObj3); |