From f382eaff90d5126387b5616b602b4168b37ad21c Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期二, 12 一月 2021 16:54:12 +0800
Subject: [PATCH] Merge branch 'master' into wjc
---
Crabtree/SmartHome/HDL/Operation/ResponseEntity/API.cs | 96 +-
Crabtree/ON.Ios/AppDelegate.cs | 2
Crabtree/SmartHome/HDL/Common/CommonUtlis.cs | 367 ++++++++++++
Crabtree/SmartHome/UI/SimpleControl/Phone/Register/Databackup.cs | 942 +++++---------------------------
Crabtree/SmartHome/HDL/Common/HttpUtil/HttpServerRequest.cs | 132 +++
Crabtree/SmartHome/HDL/Common/HttpUtil/NewAPI.cs | 68 +-
Crabtree/ON/Application.cs | 2
Crabtree/SmartHome/HDL/Common/HttpUtil/HttpUtil.cs | 3
Crabtree/SmartHome/UI/SimpleControl/MainPage.cs | 84 +-
9 files changed, 761 insertions(+), 935 deletions(-)
diff --git a/Crabtree/ON.Ios/AppDelegate.cs b/Crabtree/ON.Ios/AppDelegate.cs
index 884f733..2f356a3 100644
--- a/Crabtree/ON.Ios/AppDelegate.cs
+++ b/Crabtree/ON.Ios/AppDelegate.cs
@@ -278,7 +278,7 @@
{
if (closeTime == DateTime.MinValue) {
closeTime = DateTime.Now;
- } else if (closeTime.AddSeconds (10) < DateTime.Now) {
+ } else if (closeTime.AddSeconds (20) < DateTime.Now) {
if (CommonPage.IsRemote) {
MqttCommon.DisConnectRemote ("closeTime", false);
}
diff --git a/Crabtree/ON/Application.cs b/Crabtree/ON/Application.cs
index e6b529d..b4239a4 100644
--- a/Crabtree/ON/Application.cs
+++ b/Crabtree/ON/Application.cs
@@ -332,7 +332,7 @@
closeTime = DateTime.Now;
} else if (closeTime.AddSeconds (20) < DateTime.Now) {
if (CommonPage.IsRemote) {
- SmartHome.MqttCommon.DisConnectRemoteMqttClient ("closeTime");
+ MqttCommon.DisConnectRemote ("closeTime", false);
}
}
diff --git a/Crabtree/SmartHome/HDL/Common/CommonUtlis.cs b/Crabtree/SmartHome/HDL/Common/CommonUtlis.cs
index 1d6fc81..933002e 100644
--- a/Crabtree/SmartHome/HDL/Common/CommonUtlis.cs
+++ b/Crabtree/SmartHome/HDL/Common/CommonUtlis.cs
@@ -1,6 +1,8 @@
锘縰sing System;
+using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
+using Shared.SimpleControl;
namespace Shared
{
@@ -185,6 +187,371 @@
alert.Show ();
}
+ #region 鈻� 閫氱敤Dialog_______________________
+ /// <summary>
+ /// 閫氱敤缂栬緫Dialog
+ /// </summary>
+ /// <param name="nameStr"></param>
+ /// <param name="titleStr"></param>
+ public void ShowEditTextDialog (string nameStr, Action<string> saveAction, string titleStr = "")
+ {
+ Dialog dialog = new Dialog ();
+
+ FrameLayout dialogBodyView = new FrameLayout () {
+ Gravity = Gravity.Center,
+ Width = Application.GetRealWidth (500),
+ Height = Application.GetRealHeight (330),
+ Radius = 5,
+ BorderColor = SkinStyle.Current.Transparent,
+ BorderWidth = 0,
+ BackgroundColor = SkinStyle.Current.DialogColor,
+ };
+ dialog.AddChidren (dialogBodyView);
+
+ Button btnTitle = new Button () {
+ Height = Application.GetRealHeight (80),
+ TextAlignment = TextAlignment.Center,
+ Text = titleStr,
+ TextColor = SkinStyle.Current.DialogTextColor,
+ BackgroundColor = SkinStyle.Current.DialogTitle,
+ };
+ dialogBodyView.AddChidren (btnTitle);
+
+ EditText etZoneName = new EditText () {
+ X = Application.GetRealWidth (50),
+ Y = Application.GetRealHeight (120),
+ Width = Application.GetRealWidth (400),
+ Height = Application.GetRealHeight (80),
+ TextColor = SkinStyle.Current.TextColor,
+ TextAlignment = TextAlignment.Center,
+ Radius = 5,
+ BorderColor = SkinStyle.Current.BorderColor,
+ BorderWidth = 2,
+ Text = nameStr,
+ };
+ dialogBodyView.AddChidren (etZoneName);
+
+ FrameLayout BottomView = new FrameLayout () {
+ Y = dialogBodyView.Height - Application.GetRealHeight (88),
+ Height = Application.GetRealHeight (90),
+ BackgroundColor = SkinStyle.Current.Black50Transparent,
+ };
+ dialogBodyView.AddChidren (BottomView);
+
+ Button btnClose = new Button () {
+ Width = Application.GetRealWidth (250),
+ TextID = SimpleControl.R.MyInternationalizationString.Close,
+ TextColor = SkinStyle.Current.DialogTextColor,
+ BackgroundColor = SkinStyle.Current.DialogTitle,
+ };
+ BottomView.AddChidren (btnClose);
+ btnClose.MouseUpEventHandler += (sdf, fds) => {
+ dialog.Close ();
+ };
+
+ Button btnOption = new Button () {
+ X = btnClose.Right + Application.GetRealWidth (2),
+ Width = Application.GetRealWidth (250),
+ TextID = SimpleControl.R.MyInternationalizationString.SAVE,
+ TextColor = SkinStyle.Current.DialogTextColor,
+ BackgroundColor = SkinStyle.Current.DialogTitle,
+ };
+ BottomView.AddChidren (btnOption);
+
+ btnOption.MouseUpEventHandler += (sdf, fds) => {
+ //淇敼鍚嶇О
+ var newStr = etZoneName.Text.Trim ();
+ if (nameStr != newStr) {
+ saveAction?.Invoke (newStr);
+ }
+ dialog.Close ();
+ };
+ dialog.Show ();
+ }
+ #endregion
+
+
+ #region 鈻� 鍏辩敤涓婁紶澶囦唤鎿嶄綔_______________________
+ /// <summary>
+ /// 灏嗗綋鍓嶆湰鍦版暟鎹笂浼犲埌鑷姩澶囦唤
+ /// </summary>
+ /// <param name="finishAction">涓婁紶缁撴潫浜嬩欢</param>
+ public void ShowUploadToAutomaticBackupDialog (Action finishAction)
+ {
+ Dialog dialog = new Dialog ();
+
+ FrameLayout dialogBodyView = new FrameLayout () {
+ Gravity = Gravity.Center,
+ Width = Application.GetRealWidth (500),
+ Height = Application.GetRealHeight (500),
+ BackgroundColor = SkinStyle.Current.DialogColor,
+ Radius = 5,
+ BorderColor = SkinStyle.Current.Transparent,
+ BorderWidth = 0,
+ };
+ dialog.AddChidren (dialogBodyView);
+
+ Button btnTitle = new Button () {
+ Height = Application.GetRealHeight (80),
+ BackgroundColor = SkinStyle.Current.DialogTitle,
+ TextAlignment = TextAlignment.Center,
+ TextID = SimpleControl.R.MyInternationalizationString.Backup,
+ TextColor = SkinStyle.Current.DialogTextColor
+ };
+ dialogBodyView.AddChidren (btnTitle);
+ //Button btnGoDownTip = new Button () {
+ // Gravity = Gravity.CenterHorizontal,
+ // Y = Application.GetRealHeight (90 - 26),
+ // Width = Application.GetRealWidth (53),
+ // Height = Application.GetRealHeight (26),
+ // UnSelectedImagePath = "Room/godown.png",
+ //};
+ //dialogBodyView.AddChidren (btnGoDownTip);
+
+ Button btnackupRemark = new Button () {
+ Gravity = Gravity.CenterHorizontal,
+ Y = Application.GetRealHeight (100),
+ Width = Application.GetRealWidth (400),
+ Height = Application.GetRealHeight (80),
+ TextID = SimpleControl.R.MyInternationalizationString.Remark,
+ TextAlignment = TextAlignment.CenterLeft,
+ TextColor = SkinStyle.Current.TextColor,
+ };
+ dialogBodyView.AddChidren (btnackupRemark);
+
+ EditText etBackupRemark = new EditText () {
+ Gravity = Gravity.CenterHorizontal,
+ Y = btnackupRemark.Bottom,
+ Width = Application.GetRealWidth (400),
+ Height = Application.GetRealHeight (80),
+ TextAlignment = TextAlignment.Center,
+ Radius = 5,
+ BorderColor = SkinStyle.Current.BorderColor,
+ BorderWidth = 1,
+ TextColor = SkinStyle.Current.TextColor,
+ };
+ dialogBodyView.AddChidren (etBackupRemark);
+ etBackupRemark.EditorEnterAction += (obj) => {
+ Application.HideSoftInput ();
+ };
+ FrameLayout bottomView = new FrameLayout () {
+ Y = Application.GetRealHeight (420),
+ Height = Application.GetRealHeight (85),
+ BackgroundColor = SkinStyle.Current.DialogTitle
+ };
+ dialogBodyView.AddChidren (bottomView);
+
+ Button btnClose = new Button () {
+ Width = Application.GetRealWidth (249),
+ TextID = SimpleControl.R.MyInternationalizationString.Close,
+ TextAlignment = TextAlignment.Center
+ };
+ bottomView.AddChidren (btnClose);
+ btnClose.MouseUpEventHandler += (send2er, e2) => {
+ dialog.Close ();
+ };
+
+ Button btnBottomLine = new Button () {
+ X = btnClose.Right,
+ Width = 1,
+ BackgroundColor = SkinStyle.Current.Black50Transparent,
+ };
+ bottomView.AddChidren (btnBottomLine);
+
+ Button btnSave = new Button () {
+ X = btnBottomLine.Right,
+ Width = Application.GetRealWidth (249),
+ TextID = SimpleControl.R.MyInternationalizationString.SAVE,
+ TextAlignment = TextAlignment.Center
+ };
+ bottomView.AddChidren (btnSave);
+
+ btnSave.MouseUpEventHandler += (sender2, e2) => {
+ if (etBackupRemark.Text.Trim () == "") {
+ new Alert (Language.StringByID (SimpleControl.R.MyInternationalizationString.Tip), Language.StringByID (SimpleControl.R.MyInternationalizationString.InputNewBakeUpFilesName),
+ Language.StringByID (SimpleControl.R.MyInternationalizationString.Close)).Show ();
+ return;
+ }
+ if (MainPage.LoginUser == null) {
+ new Alert (Language.StringByID (SimpleControl.R.MyInternationalizationString.Tip), Language.StringByID (SimpleControl.R.MyInternationalizationString.PleaseLoginSystem),
+ Language.StringByID (SimpleControl.R.MyInternationalizationString.Close)).Show ();
+ return;
+ }
+ userBakeupFile (etBackupRemark.Text.Trim (), finishAction);
+ dialog.Close ();
+ };
+ dialog.Show ();
+
+ }
+
+
+ ///// <summary>
+ ///// 浜や簰澶囦唤
+ ///// </summary>
+ //int InteractiveBackup = 0;
+ ///// <summary>
+ ///// 鑷畾涔夊伐绋嬪浠�
+ ///// </summary>
+ //int CustomProjectBackup = 1;
+ ///// <summary>
+ ///// 鐢ㄦ埛鑷姩澶囦唤
+ ///// </summary>
+ //int UserAutoBackup = 2;
+ ///// <summary>
+ ///// 鐢ㄦ埛鑷畾涔夊浠�
+ ///// </summary>
+ //int UserCustomizedBackup = 3;
+ /// <summary>
+ /// 鐢ㄦ埛澶囦唤鏂囦欢
+ /// </summary>
+ void userBakeupFile (string folderName, Action finishAction)
+ {
+ MainPage.Loading.Start ("Upload...");
+ System.Threading.Tasks.Task.Run (() => {
+ try {
+ var revertObj = HttpServerRequest.Current.CreateBackupFolder(folderName);
+ if (revertObj.Code == StateCode.SUCCESS) {
+ var mBackupFolderCreateRes = Newtonsoft.Json.JsonConvert.DeserializeObject<BackupFolderCreateRes> (revertObj.Data.ToString ());
+ //UpLoadBackupFileNEW (mBackupFolderCreateRes.id);
+ UpLoadBackupFileOne (mBackupFolderCreateRes.id);
+ } else {
+ IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code);
+ }
+ } catch (Exception ex) {
+ Shared.Application.RunOnMainThread (() => {
+ new Alert (Language.StringByID (SimpleControl.R.MyInternationalizationString.Tip), Language.StringByID (SimpleControl.R.MyInternationalizationString.CheckInternet),
+ Language.StringByID (SimpleControl.R.MyInternationalizationString.Close)).Show ();
+ Shared.Utlis.WriteLine (ex.Message);
+ });
+ } finally {
+ Shared.Application.RunOnMainThread (() => {
+ MainPage.Loading.Hide ();
+ //缁撴潫浜嬩欢
+ finishAction?.Invoke ();
+ });
+ }
+ });
+ }
+
+
+
+
+ //2020-01-11
+ /// <summary>
+ /// 鍒犻櫎鏌愪釜澶囦唤
+ /// </summary>
+ /// <param name="folderID"></param>
+ void DeleteFolderDataAfterUploadFailed (string folderID)
+ {
+ try {
+ var revertObj = HttpServerRequest.Current.DeleteBackupFolder (folderID);
+ if (revertObj.Code == StateCode.SUCCESS) {
+ //GetHomeDataBackupList ();
+ } else {
+ //IMessageCommon.Current.ShowErrorInfoAlter (API.API_DELETE_Folder_Delete, revertObj.StateCode);
+ }
+ } catch { } finally {
+ Application.RunOnMainThread (() => {
+ MainPage.Loading.Hide ();
+ });
+ }
+ }
+
+ /// <summary>
+ /// 涓婁紶澶囦唤鏂囦欢
+ /// 澶氭涓婁紶澶氫釜鏂囦欢
+ /// </summary>
+ /// <param name="mBackupClassId"></param>
+ public void UpLoadBackupFileOne (string folderId)
+ {
+ var backuplist = IO.FileUtils.ReadFiles ();
+ var mFileList = backuplist.FindAll ((obj) => obj != "null" && obj != UserConfig.configFile && obj != UserInfo.GlobalRegisterFile && obj != "AccountListDB" && obj != CommonConfig.ConfigFile && (!obj.Contains (".json")));
+
+ if (mFileList.Count <= 0) return;
+
+ int resultCount = mFileList.Count;
+ int index = 0;
+ foreach (var fileName in mFileList) {
+ byte [] fileBytes = IO.FileUtils.ReadFile (fileName);
+ var result = UploadDataBackupByOne (folderId, fileName, fileBytes);
+ if (result) {
+ index++;
+ Application.RunOnMainThread (() => {
+ int pro = (int)(index * 1.0 / resultCount * 100);
+ MainPage.Loading.Text = pro.ToString () + "%";
+ });
+ } else {
+ Console.WriteLine ("涓婁紶澶辫触锛�" + fileName);
+ }
+ }
+
+
+ Utlis.WriteLine ($"涓婁紶瀹屾垚");
+
+ if (index != resultCount) {
+ //2020-01-11 澶囦唤澶辫触
+ DeleteFolderDataAfterUploadFailed (folderId);
+ Shared.Application.RunOnMainThread (() => {
+ new Alert ("", Language.StringByID (SimpleControl.R.MyInternationalizationString.FailedToBackupFile), Language.StringByID (SimpleControl.R.MyInternationalizationString.Close)).Show ();
+ MainPage.Loading.Hide ();
+ });
+ return;
+ }
+
+ Application.RunOnMainThread (() => {
+ //MainPage.Loading.Text = "100%";
+ new Alert ("", Language.StringByID (SimpleControl.R.MyInternationalizationString.BackupFileIsSuccessful), Language.StringByID (SimpleControl.R.MyInternationalizationString.Close)).Show ();
+ });
+
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="folderId"></param>
+ /// <param name="fileName"></param>
+ /// <param name="fileBytes"></param>
+ /// <returns></returns>
+ bool UploadDataBackupByOne (string folderId, string fileName, byte [] fileBytes)
+ {
+ try {
+ var queryDic = new Dictionary<string, object> ();
+ queryDic.Add ("folderId", folderId);
+ queryDic.Add ("fileName", fileName);
+ queryDic.Add ("homeId", UserConfig.Instance.CurrentRegion.Id);
+
+ var revertObj = HttpUtil.RequestHttpsUpload (RestSharp.Method.POST, NewAPI.API_POST_File_Create, fileBytes, queryDic, null, UserConfig.Instance.CurrentRegion.regionUrl);
+ if (revertObj.Code == StateCode.SUCCESS) {
+ return true;
+ } else {
+ //鎻愮ず閿欒
+ return false;
+ }
+ } catch {
+ return false;
+ }
+ }
+
+
+ #endregion
+
+ //#region 鈻� 鏂囦欢鎿嶄綔_______________________
+ ///// <summary>
+ ///// 鍒犻櫎鏈湴鏂囦欢
+ ///// </summary>
+ //public void ReadFilesAndDelete ()
+ //{
+ // var fileNames = IO.FileUtils.ReadFiles ();
+ // foreach (var fileName in fileNames) {
+ // if (fileName == UserInfo.GlobalRegisterFile || fileName == UserConfig.configFile || fileName == MqttInfoConfig.ConfigFile || fileName == APIInfoConfig.ConfigFile) {
+ // continue;
+ // }
+ // IO.FileUtils.DeleteFile (fileName);
+ // }
+
+ //}
+ //#endregion
+
}
}
diff --git a/Crabtree/SmartHome/HDL/Common/HttpUtil/HttpServerRequest.cs b/Crabtree/SmartHome/HDL/Common/HttpUtil/HttpServerRequest.cs
index 297cb8f..4559761 100644
--- a/Crabtree/SmartHome/HDL/Common/HttpUtil/HttpServerRequest.cs
+++ b/Crabtree/SmartHome/HDL/Common/HttpUtil/HttpServerRequest.cs
@@ -31,7 +31,6 @@
}
#endregion
-
#region 鈻� 閫氱敤璇锋眰鎺ュ彛_______________________
/// <summary>
/// 鏍规鐢ㄦ埛璐﹀彿鑾峰彇娉ㄥ唽鍖哄煙 鍏嶇櫥褰� // 妫�娴嬭处鍙锋槸鍚︽敞鍐屼篃鐢ㄨ繖涓帴鍙�
@@ -67,7 +66,7 @@
}
#endregion
- #region 娉ㄥ唽銆佺櫥褰曢儴鍒�
+ #region * 娉ㄥ唽銆佺櫥褰曢儴鍒哶__________________________
/// <summary>
/// 閫氱敤 鍙戦�侀獙璇佺爜鏂规硶
/// </summary>
@@ -222,7 +221,7 @@
#endregion
- #region 涓汉淇℃伅閮ㄥ垎
+ #region * 涓汉淇℃伅閮ㄥ垎___________________________
///// <summary>
///// 鑾峰彇鐢ㄦ埛淇℃伅
///// </summary>
@@ -237,7 +236,7 @@
// MainPage.LoginUser.userEmailInfo = info.memberEmail;
// MainPage.LoginUser.userMobileInfo = info.memberPhone;
// MainPage.LoginUser.userName = info.memberName;
-
+
// if (!string.IsNullOrEmpty(info.memberPhonePrefix))
// {
// MainPage.LoginUser.areaCode = info.memberPhonePrefix;
@@ -358,7 +357,7 @@
#endregion
- #region 浣忓畢閮ㄥ垎
+ #region * 浣忓畢閮ㄥ垎___________________________
///// <summary>
///// 鑾峰彇浣忓畢鍒楄〃
///// </summary>
@@ -483,6 +482,7 @@
return HttpUtil.RequestHttpsPostFroHome (NewAPI.API_POST_Home_Delete, requestJson);
}
+ #region 缃戝叧鐩稿叧
/// <summary>
/// 缁戝畾缃戝叧
/// </summary>
@@ -535,6 +535,7 @@
return "";
}
}
+
/// <summary>
/// 鑾峰彇缃戝叧淇℃伅
/// </summary>
@@ -558,9 +559,9 @@
}
return revertObj.Code;
}
+ #endregion
-
-
+ #region 瀛愯处鍙风浉鍏�
/// <summary>
/// 鑾峰彇浣忓畢涓嬬殑鎴愬憳璐﹀彿
/// </summary>
@@ -569,6 +570,21 @@
{
var requestJson = HttpUtil.GetSignRequestJson(new HomeIdObj() { homeId = UserConfig.Instance.CurrentRegion.Id });
return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_FindAll, requestJson);
+ }
+
+ /// <summary>
+ /// 缁戝畾瀛愯处鍙峰埌浣忓畢涓�
+ /// </summary>
+ /// <param name="subAccount"></param>
+ /// <param name="nickName"></param>
+ /// <returns></returns>
+ public ResponsePackNew BindResidenceMemberAccount (string subAccount, string nickName)
+ {
+ //娣诲姞瀛愯处鍙�
+ var requestObj = new ChildAddObj () { homeId = UserConfig.Instance.CurrentRegion.Id, account = subAccount, nickName = nickName };
+ var requestJson = HttpUtil.GetSignRequestJson (requestObj);
+ return HttpUtil.RequestHttpsPostFroHome (NewAPI.API_POST_Child_Add, requestJson);
+
}
/// <summary>
@@ -603,6 +619,7 @@
return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_Update, requestJson);
}
+
/// <summary>
/// 淇敼瀛愯处鍙峰垱寤哄満鏅潈闄�
/// </summary>
@@ -619,6 +636,7 @@
});
return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_Update, requestJson);
}
+ #endregion
#region 鏂版暟鎹垎浜�
/// <summary>
@@ -662,23 +680,92 @@
}
#endregion
- /// <summary>
- /// 缁戝畾瀛愯处鍙峰埌浣忓畢涓�
- /// </summary>
- /// <param name="subAccount"></param>
- /// <param name="nickName"></param>
- /// <returns></returns>
- public ResponsePackNew BindResidenceMemberAccount(string subAccount, string nickName)
- {
- //娣诲姞瀛愯处鍙�
- var requestObj = new ChildAddObj() { homeId = UserConfig.Instance.CurrentRegion.Id, account = subAccount, nickName = nickName };
- var requestJson = HttpUtil.GetSignRequestJson(requestObj);
- return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_Add, requestJson);
+ #endregion
+ #region * 澶囦唤鐩稿叧閮ㄥ垎___________________________
+ /// <summary>
+ /// 鍒涘缓澶囦唤鏂囦欢澶�
+ /// </summary>
+ /// <param name="folderName"></param>
+ /// <returns></returns>
+ public ResponsePackNew GetHomeDataBackupList ()
+ {
+ var requestObj = new HomeIdObj () {
+ homeId = UserConfig.Instance.CurrentRegion.Id,
+ };
+ var requestJson = HttpUtil.GetSignRequestJson (requestObj);
+ return HttpUtil.RequestHttpsPostFroHome (NewAPI.API_POST_Folder_FindAll, requestJson);
+ }
+
+
+ /// <summary>
+ /// 鍒涘缓澶囦唤鏂囦欢澶�
+ /// </summary>
+ /// <param name="folderName"></param>
+ /// <returns></returns>
+ public ResponsePackNew CreateBackupFolder (string folderName)
+ {
+ var requestObj = new BackupFolderCreateObj () {
+ backupClassify = BackupClassify.USER_DEFINED_BACKUP.ToString (),
+ backupDataType = BackupDataType.HDL_ON.ToString (),
+ homeId = UserConfig.Instance.CurrentRegion.Id,
+ folderName = folderName,
+ };
+ var requestJson = HttpUtil.GetSignRequestJson (requestObj);
+ return HttpUtil.RequestHttpsPostFroHome (NewAPI.API_POST_Folder_Create, requestJson);
}
+ /// <summary>
+ /// 淇敼澶囦唤鏂囦欢澶瑰悕瀛�
+ /// </summary>
+ /// <param name="newName"></param>
+ /// <param name="mBackupFile"></param>
+ /// <returns></returns>
+ public ResponsePackNew UpdateBackupFolderName (string newName, BackupListNameInfoRes mBackupFile)
+ {
+ var requestObj = new UpdateBackupObj () {
+ folderId = mBackupFile.id,
+ homeId = mBackupFile.homeId,
+ folderName = newName,
+ };
+ var requestJson = HttpUtil.GetSignRequestJson (requestObj);
+ return HttpUtil.RequestHttpsPostFroHome (NewAPI.API_POST_Folder_Update, requestJson);
+ }
+
+
+ /// <summary>
+ /// 鍒犻櫎澶囦唤鏂囦欢澶�
+ /// </summary>
+ /// <param name="folderId"></param>
+ /// <returns></returns>
+ public ResponsePackNew DeleteBackupFolder (string folderId)
+ {
+ var requestObj = new BackupFolderIdObj () {
+ homeId = UserConfig.Instance.CurrentRegion.Id,
+ folderId = folderId,
+ };
+ var requestJson = HttpUtil.GetSignRequestJson (requestObj);
+ return HttpUtil.RequestHttpsPostFroHome (NewAPI.API_POST_Folder_Delete, requestJson);
+ }
+
+ /// <summary>
+ /// 鑾峰彇澶囦唤鏂囦欢澶规墍鏈夋枃浠跺垪琛�
+ /// </summary>
+ /// <param name="folderId"></param>
+ /// <returns></returns>
+ public ResponsePackNew GetBackupFolderAllFileList (string folderId)
+ {
+ var requestObj = new BackupFolderIdObj () {
+ homeId = UserConfig.Instance.CurrentRegion.Id,
+ folderId = folderId,
+ };
+ var requestJson = HttpUtil.GetSignRequestJson (requestObj);
+ return HttpUtil.RequestHttpsPostFroHome (NewAPI.API_POST_File_FindAll, requestJson);
+ }
#endregion
+
+ #region * Mqtt___________________________
/// <summary>
/// 鑾峰彇MQTT杩滅▼杩炴帴淇℃伅鎺ュ彛
/// </summary>
@@ -698,7 +785,7 @@
}
else
{
- Utlis.WriteLine("GetMqttRemoteInfo error");
+ Utlis.WriteLine("GetMqttRemoteInfo error Code锛�" + revertObj.Code);
return null;
}
}
@@ -707,9 +794,9 @@
return null;
}
}
+ #endregion
-
- #region 鑾峰彇澶╂皵閮ㄥ垎
+ #region * 鑾峰彇澶╂皵閮ㄥ垎___________________________
/// <summary>
/// 鑾峰彇鎸囧畾缁忕含搴︾殑鍩庡競淇℃伅
/// </summary>
@@ -765,7 +852,6 @@
}
#endregion
-
//#region Kaede --璁惧鍔熻兘鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺��
///// <summary>
diff --git a/Crabtree/SmartHome/HDL/Common/HttpUtil/HttpUtil.cs b/Crabtree/SmartHome/HDL/Common/HttpUtil/HttpUtil.cs
index 18094c9..d391493 100644
--- a/Crabtree/SmartHome/HDL/Common/HttpUtil/HttpUtil.cs
+++ b/Crabtree/SmartHome/HDL/Common/HttpUtil/HttpUtil.cs
@@ -391,7 +391,7 @@
/// <param name="replaceToken"></param>
/// <param name="mTimeout"></param>
/// <returns></returns>
- public static ResponsePackNew RequestHttpsUpload(Method method, string apiPath, object bodyParameterObject = null, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = 10)
+ public static ResponsePackNew RequestHttpsUpload(Method method, string apiPath, object bodyParameterObject = null, Dictionary<string, object> queryDictionary = null, Dictionary<string, object> urlSegmentDictionary = null, string urlHead = "", string replaceToken = "", int mTimeout = 20)
{
#region HttpWebRequest
try
@@ -408,7 +408,6 @@
////**************娴嬭瘯**************
RestClient client = new RestClient(requestFullUrl);
- //client.Timeout = mTimeout * 1000;
RestRequest request = new RestRequest(method);
request.Timeout = mTimeout * 1000;
//request.AddHeader ("content-type", "application/json");
diff --git a/Crabtree/SmartHome/HDL/Common/HttpUtil/NewAPI.cs b/Crabtree/SmartHome/HDL/Common/HttpUtil/NewAPI.cs
index bab5115..7912ccb 100644
--- a/Crabtree/SmartHome/HDL/Common/HttpUtil/NewAPI.cs
+++ b/Crabtree/SmartHome/HDL/Common/HttpUtil/NewAPI.cs
@@ -197,45 +197,45 @@
#endregion
#region 鈻� HomebackupCluster -- 浣忓畢澶囦唤寰湇鍔__________________________
- ///// <summary>
- ///// 鍒涘缓鏂囦欢澶�
- ///// </summary>
- //public const string API_POST_Folder_Create = "/home-wisdom/app/backup/folder/create";
+ /// <summary>
+ /// 鍒涘缓鏂囦欢澶�
+ /// </summary>
+ public const string API_POST_Folder_Create = "/home-wisdom/app/backup/folder/create";
+
+ /// <summary>
+ /// 鍒犻櫎鏂囦欢澶�
+ /// </summary>
+ public const string API_POST_Folder_Delete = "/home-wisdom/app/backup/folder/delete";
+
+ /// <summary>
+ /// 鏌ユ壘鎵�鏈夋枃浠跺す
+ /// </summary>
+ public const string API_POST_Folder_FindAll = "/home-wisdom/app/backup/folder/findAll";
+
+ /// <summary>
+ /// 鏇存柊鏂囦欢澶�
+ /// </summary>
+ public const string API_POST_Folder_Update = "/home-wisdom/app/backup/folder/update";
+
+ /// <summary>
+ /// 涓婁紶鏂囦欢
+ /// </summary>
+ public const string API_POST_File_Create = "/home-wisdom/app/backup/file/create";
///// <summary>
- ///// 鍒犻櫎鏂囦欢澶�
+ ///// 鍒犻櫎鏂囦欢
///// </summary>
- //public const string API_POST_Folder_Delete = "/home-wisdom/app/backup/folder/delete";
+ //public const string API_DELETE_File_Delete = "/HomebackupCluster/V1/file/delete";
- ///// <summary>
- ///// 鏌ユ壘鎵�鏈夋枃浠跺す
- ///// </summary>
- //public const string API_POST_Folder_FindAll = "/home-wisdom/app/backup/folder/findAll";
+ /// <summary>
+ /// 涓嬭浇澶囦唤鏂囦欢
+ /// </summary>
+ public const string API_POST_File_Down = "/home-wisdom/app/backup/file/downOne";
- ///// <summary>
- ///// 鏇存柊鏂囦欢澶�
- ///// </summary>
- //public const string API_POST_Folder_Update = "/home-wisdom/app/backup/folder/update";
-
- ///// <summary>
- ///// 涓婁紶鏂囦欢
- ///// </summary>
- //public const string API_POST_File_Create = "/home-wisdom/app/backup/file/create";
-
- /////// <summary>
- /////// 鍒犻櫎鏂囦欢
- /////// </summary>
- ////public const string API_DELETE_File_Delete = "/HomebackupCluster/V1/file/delete";
-
- ///// <summary>
- ///// 涓嬭浇澶囦唤鏂囦欢
- ///// </summary>
- //public const string API_POST_File_Down = "/home-wisdom/app/backup/file/downOne";
-
- ///// <summary>
- ///// 鏌ヨ涓�涓枃浠跺す鎵�鏈夋枃浠跺悕
- ///// </summary>
- //public const string API_POST_File_FindAll = "/home-wisdom/app/backup/file/findAll";
+ /// <summary>
+ /// 鏌ヨ涓�涓枃浠跺す鎵�鏈夋枃浠跺悕
+ /// </summary>
+ public const string API_POST_File_FindAll = "/home-wisdom/app/backup/file/findAll";
#endregion
diff --git a/Crabtree/SmartHome/HDL/Operation/ResponseEntity/API.cs b/Crabtree/SmartHome/HDL/Operation/ResponseEntity/API.cs
index bb6be2d..0cda94d 100644
--- a/Crabtree/SmartHome/HDL/Operation/ResponseEntity/API.cs
+++ b/Crabtree/SmartHome/HDL/Operation/ResponseEntity/API.cs
@@ -46,18 +46,18 @@
///// 蹇樿瀵嗙爜
///// </summary>
//public static string YdForgetPassword = API_ZigbeeUsers + "YdForgetPassword";
- /// <summary>
- /// 缁戝畾瀛愯处鍙峰埌椤圭洰 need Authorization
- /// </summary>
- public static string BindSubAccount = API_ZigbeeUsers + "BindSubAccount";
- /// <summary>
- /// 瑙i櫎瀛愯处鍙峰拰浣忓畢鐨勭粦瀹� need Authorization
- /// </summary>
- public static string DeletedSubAccount = API_ZigbeeUsers + "DeletedSubAccount";
- /// <summary>
- /// 鑾峰彇椤圭洰(浣忓畢)涓嬮潰鐨勫瓙璐﹀彿 need Authorization
- /// </summary>
- public static string GetSubAccountByDistributedMark = API_ZigbeeUsers + "GetSubAccountByDistributedMark";
+ ///// <summary>
+ ///// 缁戝畾瀛愯处鍙峰埌椤圭洰 need Authorization
+ ///// </summary>
+ //public static string BindSubAccount = API_ZigbeeUsers + "BindSubAccount";
+ ///// <summary>
+ ///// 瑙i櫎瀛愯处鍙峰拰浣忓畢鐨勭粦瀹� need Authorization
+ ///// </summary>
+ //public static string DeletedSubAccount = API_ZigbeeUsers + "DeletedSubAccount";
+ ///// <summary>
+ ///// 鑾峰彇椤圭洰(浣忓畢)涓嬮潰鐨勫瓙璐﹀彿 need Authorization
+ ///// </summary>
+ //public static string GetSubAccountByDistributedMark = API_ZigbeeUsers + "GetSubAccountByDistributedMark";
///// <summary>
@@ -70,36 +70,36 @@
//***************************APP 閮ㄥ垎********************************
public static string API_APP = "/App/";
- /// <summary>
- /// 1.21 娣诲姞椤圭洰(浣忓畢)[App(缃戝叧)鎵嬪姩澶囦唤]澶囨敞鏂囦欢澶�
- /// </summary>
- public static string AddHomeAppGatewayName = API_APP + "AddHomeAppGatewayName";
- /// <summary>
- /// 1.22 涓婁紶[椤圭洰(浣忓畢(App(缃戝叧)鎵嬪姩澶囦唤]瀛愭枃浠�
- /// </summary>
- public static string UploadHomeAppGatewaySubFiles = API_APP + "UploadHomeAppGatewaySubFiles";
- public static string UploadHomeAppGatewaySingleSubFile = API_APP + "UploadHomeAppGatewaySingleSubFile";
-
///// <summary>
- ///// 1.23 鍒犻櫎App澶囦唤[鎵嬪姩澶囦唤浣忓畢銆佹墜鍔ㄥ浠界綉鍏炽�佽嚜鍔ㄥ浠戒綇瀹呫�佸叕鍏卞浠絔鐨勬煇浜涙枃浠�
+ ///// 1.21 娣诲姞椤圭洰(浣忓畢)[App(缃戝叧)鎵嬪姩澶囦唤]澶囨敞鏂囦欢澶�
///// </summary>
- //public static string DeleteAppBackupFile = API_APP + "DeleteAppBackupFile";
- /// <summary>
- /// 1.24 鑾峰彇浣忓畢澶囦唤鏁版嵁_鍒嗛〉
- /// </summary>
- public static string GetHomeDataBackupPagger = API_APP + "GetHomeDataBackupPagger";
- /// <summary>
- /// 1.25 鑾峰彇澶囦唤鏂囦欢涓嶅甫鏁版嵁_鍒嗛〉
- /// </summary>
- public static string GetHomeDataBackupUploadListPagger = API_APP + "GetHomeDataBackupUploadListPagger";
- /// <summary>
- /// 1.26 涓嬭浇鏌愪竴涓浠芥暟鎹枃浠�
- /// </summary>
- public static string DownloadSomeDataBackup = API_APP + "DownloadSomeDataBackup";
- /// <summary>
- /// 1.27 鍒犻櫎椤圭洰(浣忓畢)鍚勭澶囦唤鏂囦欢澶�(鏂囦欢澶逛笅鎵�鏈夋枃浠朵篃浼氬垹闄�)
- /// </summary>
- public static string DelHomeAppGatewayName = API_APP + "DelHomeAppGatewayName";
+ //public static string AddHomeAppGatewayName = API_APP + "AddHomeAppGatewayName";
+ ///// <summary>
+ ///// 1.22 涓婁紶[椤圭洰(浣忓畢(App(缃戝叧)鎵嬪姩澶囦唤]瀛愭枃浠�
+ ///// </summary>
+ //public static string UploadHomeAppGatewaySubFiles = API_APP + "UploadHomeAppGatewaySubFiles";
+ //public static string UploadHomeAppGatewaySingleSubFile = API_APP + "UploadHomeAppGatewaySingleSubFile";
+
+ /////// <summary>
+ /////// 1.23 鍒犻櫎App澶囦唤[鎵嬪姩澶囦唤浣忓畢銆佹墜鍔ㄥ浠界綉鍏炽�佽嚜鍔ㄥ浠戒綇瀹呫�佸叕鍏卞浠絔鐨勬煇浜涙枃浠�
+ /////// </summary>
+ ////public static string DeleteAppBackupFile = API_APP + "DeleteAppBackupFile";
+ ///// <summary>
+ ///// 1.24 鑾峰彇浣忓畢澶囦唤鏁版嵁_鍒嗛〉
+ ///// </summary>
+ //public static string GetHomeDataBackupPagger = API_APP + "GetHomeDataBackupPagger";
+ ///// <summary>
+ ///// 1.25 鑾峰彇澶囦唤鏂囦欢涓嶅甫鏁版嵁_鍒嗛〉
+ ///// </summary>
+ //public static string GetHomeDataBackupUploadListPagger = API_APP + "GetHomeDataBackupUploadListPagger";
+ ///// <summary>
+ ///// 1.26 涓嬭浇鏌愪竴涓浠芥暟鎹枃浠�
+ ///// </summary>
+ //public static string DownloadSomeDataBackup = API_APP + "DownloadSomeDataBackup";
+ ///// <summary>
+ ///// 1.27 鍒犻櫎椤圭洰(浣忓畢)鍚勭澶囦唤鏂囦欢澶�(鏂囦欢澶逛笅鎵�鏈夋枃浠朵篃浼氬垹闄�)
+ ///// </summary>
+ //public static string DelHomeAppGatewayName = API_APP + "DelHomeAppGatewayName";
///// <summary>
///// 1.28 鏇存柊椤圭洰(浣忓畢)[App(缃戝叧)鎵嬪姩澶囦唤]澶囨敞鍚�
///// </summary>
@@ -126,20 +126,20 @@
///// 1.63 鑾峰緱鏌愪釜甯愬彿鎵�鏈夊凡缁戝畾鐨勭綉鍏冲垎椤�
///// </summary>
//public static string GetAllBindGatewarysPagger = API_APP + "GetAllBindGatewarysPagger";
- /// <summary>
- /// 1.64 鑾峰彇鏌愪釜浣忓畢鐨勭綉鍏冲垎椤�
- /// </summary>
- public static string GetSingleHomeGatewayPagger = API_APP + "GetSingleHomeGatewayPagger";
+ ///// <summary>
+ ///// 1.64 鑾峰彇鏌愪釜浣忓畢鐨勭綉鍏冲垎椤�
+ ///// </summary>
+ //public static string GetSingleHomeGatewayPagger = API_APP + "GetSingleHomeGatewayPagger";
///// <summary>
///// 1.65 UpdateMac 鏇存柊Mac(鍗板害)
///// </summary>
//public static string UpdateMac = API_APP + "UpdateMac";
- /// <summary>
- /// 1.66 BindMac 鏇存柊缁戝畾Mac(鍗板害)
- /// </summary>
- public static string BindMac = API_APP + "BindMac";
+ ///// <summary>
+ ///// 1.66 BindMac 鏇存柊缁戝畾Mac(鍗板害)
+ ///// </summary>
+ //public static string BindMac = API_APP + "BindMac";
diff --git a/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs b/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs
index 46332c8..ee06e8d 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs
@@ -254,52 +254,52 @@
//}
- /// <summary>
- /// 璇锋眰鏈嶅姟鍣ㄦ柟娉�
- /// </summary>
- /// <returns>The https.</returns>
- /// <param name="methodType">璇锋眰鏂规硶.</param>
- /// <param name="dataStringJson">璇锋眰鐨勫弬鏁�.</param>
- /// <param name="needHeaders">鏄惁闇�瑕佸寘澶�.</param>
- public static byte [] RequestHttpsReturnByte (string methodType, string dataStringJson, bool needHeaders = false, string urlHead = "")
- {
- ResponsePack revertObj = null;
- try {
+ ///// <summary>
+ ///// 璇锋眰鏈嶅姟鍣ㄦ柟娉�
+ ///// </summary>
+ ///// <returns>The https.</returns>
+ ///// <param name="methodType">璇锋眰鏂规硶.</param>
+ ///// <param name="dataStringJson">璇锋眰鐨勫弬鏁�.</param>
+ ///// <param name="needHeaders">鏄惁闇�瑕佸寘澶�.</param>
+ //public static byte [] RequestHttpsReturnByte (string methodType, string dataStringJson, bool needHeaders = false, string urlHead = "")
+ //{
+ // ResponsePack revertObj = null;
+ // try {
- ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, error) => {
- return true;
- };
+ // ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, error) => {
+ // return true;
+ // };
- #region
- var webClient = new WebClient ();
- if (urlHead == "") {
- urlHead = RequestHttpsHost;
- }
- //else {
- // webClient.Headers.Add ("CONTENT-TYPE", "application/json");
- //}
- webClient.Headers.Add ("CONTENT-TYPE", "application/json");
- string url = urlHead + methodType;
- if (needHeaders && LoginUser != null) {/* 濡傛灉涓嶉渶瑕侀獙璇乀oken鍙互涓嶇敤浼犲叆 */
- webClient.Headers.Add ("Authorization", LoginUser.LoginTokenString);
- }
- byte [] bytes = null;
- try {
- bytes = webClient.UploadData (url, Encoding.UTF8.GetBytes (dataStringJson));
- } catch (System.Net.WebException webEx) {
- return bytes;
- }
+ // #region
+ // var webClient = new WebClient ();
+ // if (urlHead == "") {
+ // urlHead = RequestHttpsHost;
+ // }
+ // //else {
+ // // webClient.Headers.Add ("CONTENT-TYPE", "application/json");
+ // //}
+ // webClient.Headers.Add ("CONTENT-TYPE", "application/json");
+ // string url = urlHead + methodType;
+ // if (needHeaders && LoginUser != null) {/* 濡傛灉涓嶉渶瑕侀獙璇乀oken鍙互涓嶇敤浼犲叆 */
+ // webClient.Headers.Add ("Authorization", LoginUser.LoginTokenString);
+ // }
+ // byte [] bytes = null;
+ // try {
+ // bytes = webClient.UploadData (url, Encoding.UTF8.GetBytes (dataStringJson));
+ // } catch (System.Net.WebException webEx) {
+ // return bytes;
+ // }
- return bytes;
- #endregion
- } catch (Exception ex) {
- Utlis.WriteLine (ex.Message);
- return null;
- } finally {
- //requesTime = requesTime.AddDays(1);
- }
- }
+ // return bytes;
+ // #endregion
+ // } catch (Exception ex) {
+ // Utlis.WriteLine (ex.Message);
+ // return null;
+ // } finally {
+ // //requesTime = requesTime.AddDays(1);
+ // }
+ //}
/// <summary>
diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/Databackup.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/Databackup.cs
index 29af1dc..c5f942f 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/Databackup.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Register/Databackup.cs
@@ -17,6 +17,9 @@
BackgroundColor = SkinStyle.Current.MainColor;
}
+ /// <summary>
+ /// 鍔犺浇澶囦唤鏂囦欢鍒楄〃椤甸潰
+ /// </summary>
public void DatabackupShow ()
{
this.RemoveAll ();
@@ -171,102 +174,11 @@
topView.AddChidren (ItemButton);
ItemButton.MouseUpEventHandler += (sender, e) => {
- Dialog dialog = new Dialog ();
-
- FrameLayout dialogBodyView = new FrameLayout () {
- Gravity = Gravity.Center,
- Width = Application.GetRealWidth (500),
- Height = Application.GetRealHeight (500),
- BackgroundColor = SkinStyle.Current.DialogColor,
- Radius = 5,
- BorderColor = SkinStyle.Current.Transparent,
- BorderWidth = 0,
+ Action finishAction = () => {
+ GetHomeDataBackupList ();
};
- dialog.AddChidren (dialogBodyView);
-
- Button btnTitle = new Button () {
- Height = Application.GetRealHeight (80),
- BackgroundColor = SkinStyle.Current.DialogTitle,
- TextAlignment = TextAlignment.Center,
- TextID = R.MyInternationalizationString.Backup,
- TextColor = SkinStyle.Current.DialogTextColor
- };
- dialogBodyView.AddChidren (btnTitle);
-
- Button btnackupRemark = new Button () {
- Gravity = Gravity.CenterHorizontal,
- Y = Application.GetRealHeight (100),
- Width = Application.GetRealWidth (400),
- Height = Application.GetRealHeight (80),
- TextID = R.MyInternationalizationString.Remark,
- TextAlignment = TextAlignment.CenterLeft,
- TextColor = SkinStyle.Current.TextColor,
- };
- dialogBodyView.AddChidren (btnackupRemark);
-
- EditText etBackupRemark = new EditText () {
- Gravity = Gravity.CenterHorizontal,
- Y = btnackupRemark.Bottom,
- Width = Application.GetRealWidth (400),
- Height = Application.GetRealHeight (80),
- TextAlignment = TextAlignment.Center,
- Radius = 5,
- BorderColor = SkinStyle.Current.BorderColor,
- BorderWidth = 1,
- TextColor = SkinStyle.Current.TextColor,
- };
- dialogBodyView.AddChidren (etBackupRemark);
- etBackupRemark.EditorEnterAction += (obj) => {
- Application.HideSoftInput ();
- };
-
- FrameLayout bottomView = new FrameLayout () {
- Y = Application.GetRealHeight (420),
- Height = Application.GetRealHeight (85),
- BackgroundColor = SkinStyle.Current.DialogTitle
- };
- dialogBodyView.AddChidren (bottomView);
-
- Button btnClose = new Button () {
- Width = Application.GetRealWidth (249),
- TextID = R.MyInternationalizationString.Close,
- TextAlignment = TextAlignment.Center
- };
- bottomView.AddChidren (btnClose);
- btnClose.MouseUpEventHandler += (send2er, e2) => {
- dialog.Close ();
- };
-
- Button btnBottomLine = new Button () {
- X = btnClose.Right,
- Width = 1,
- BackgroundColor = SkinStyle.Current.Black50Transparent,
- };
- bottomView.AddChidren (btnBottomLine);
-
- Button btnSave = new Button () {
- X = btnBottomLine.Right,
- Width = Application.GetRealWidth (249),
- TextID = R.MyInternationalizationString.SAVE,
- TextAlignment = TextAlignment.Center
- };
- bottomView.AddChidren (btnSave);
-
- btnSave.MouseUpEventHandler += (sender2, e2) => {
- if (etBackupRemark.Text.Trim () == "") {
- new Alert ("", Language.StringByID (R.MyInternationalizationString.InputNewBakeUpFilesName),
- Language.StringByID (R.MyInternationalizationString.Close)).Show ();
- return;
- }
- if (MainPage.LoginUser == null) {
- new Alert ("", Language.StringByID (R.MyInternationalizationString.PleaseLoginSystem),
- Language.StringByID (R.MyInternationalizationString.Close)).Show ();
- return;
- }
- userBakeupFile (etBackupRemark.Text.Trim ());
- dialog.Close ();
- };
- dialog.Show ();
+ //寮圭獥鎻愮ず涓婁紶澶囦唤Dialog
+ CommonUtlis.Current.ShowUploadToAutomaticBackupDialog (finishAction);
};
var back = new Button () {
@@ -293,66 +205,38 @@
VerticalScrolViewMiddle.RemoveAll ();
FrameLayoutView.AddChidren (VerticalScrolViewMiddle);
+ GetHomeDataBackupList ();
+ }
+
+ /// <summary>
+ /// 鑾峰彇浣忓畢澶囦唤鏁版嵁鍒楄〃
+ /// </summary>
+ void GetHomeDataBackupList ()
+ {
System.Threading.Tasks.Task.Run (() => {
try {
+
Application.RunOnMainThread (() => {
- MainPage.Loading.Start ("Please wait...");
+ VerticalScrolViewMiddle.RemoveAll ();
+ MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load));
});
- var requestObj = new GetHomeDataBackupPaggerObj () {
- 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, urlHead);
- if (revertObj.StateCode.ToUpper () == StateCode.SUCCESS) {
- var data = Newtonsoft.Json.JsonConvert.DeserializeObject<GetBackupListResult> (revertObj.ResponseData.ToString ());
- //var list = new List<BackupListNameInfo> ();
- //foreach (var data2 in data.PageData) {
- // if (ZigbeeUniqueId != null && data2.GatewayUniqueId != ZigbeeUniqueId) {
- // continue;
- // }
- // if (getLogBackup == false && data2.BackupName == LogBackupName) {
- // //涓嶈幏鍙朙og澶囦唤
- // continue;
- // }
- // list.Add (data2);
- //}
-
-
- //var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<FolderRes>> (revertObj.ResponseData.ToString ());
+ var revertObj = HttpServerRequest.Current.GetHomeDataBackupList ();
+ if (revertObj.Code == StateCode.SUCCESS) {
+ var data = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BackupListNameInfoRes>> (revertObj.Data.ToString ());
if (data == null) return;
-
Application.RunOnMainThread (() => {
- foreach (var folder in data.PageData) {
- addRow (folder.BackupName, folder.Id);
+ foreach (var folder in data) {
+ AddRowView (folder);
}
});
} else {
- //2020-01-11 鍒锋柊涓�娆asterToken
- if (requestObj.IsOtherAccountCtrl) {
- //if (revertObj.StateCode == "ParameterOrEmpty" || revertObj.StateCode == "NoLogin" || revertObj.StateCode == "HomeIdAndTokenNoConsistent") {
- if (revertObj.StateCode != ErrorCode.NetworkError) {
- UserConfig.Instance.CheckIfNeedGetMasterAccountToken ();
- }
- }
- MainPage.ShowAlertOnMainThread ("Failed to get backup data list!");
+ //鎻愮ず閿欒
+ IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code);
}
- //var groupNames = service_backup.GetUserGroup (MainPage.LoginUser.MasterID, 0);
- //Application.RunOnMainThread (() => {
- // foreach (UserBackup groupName in groupNames) {
- // addRow (groupName.UserGroup);
- // }
- //});
+
} catch {
Application.RunOnMainThread (() => {
- new Alert ("", Language.StringByID (R.MyInternationalizationString.CheckInternet), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
+ new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.CheckInternet), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
});
} finally {
Application.RunOnMainThread (() => {
@@ -362,7 +246,12 @@
});
}
- void addRow (string groupName, string folderID)
+ /// <summary>
+ /// 鍔犺浇view
+ /// </summary>
+ /// <param name="groupName"></param>
+ /// <param name="folderID"></param>
+ void AddRowView (BackupListNameInfoRes mBackupFile)
{
var rowView = new RowLayout () {
Height = Application.GetRealHeight (110),
@@ -381,27 +270,23 @@
BackgroundColor = SkinStyle.Current.DelColor
};
btnDelFile.MouseUpEventHandler += (sender, e) => {
- Alert alert = new Alert ("", Language.StringByID (R.MyInternationalizationString.AreYouSureToDeleteFile), Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
+ Alert alert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.AreYouSureToDeleteFile), Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
alert.ResultEventHandler += (sender2, e2) => {
if (e2) {
- DeleteFolderData (folderID);
+ DeleteFolderData (mBackupFile.id);
}
};
alert.Show ();
};
- //if (MainPage.LoginUser.AccountType != 1) {
- // rowView.AddRightView (btnDelFile);
- //}
-
- //2020-07-01 褰撳墠浣忓畢灞炰簬鑷繁鐨� 鍏佽鍒犻櫎澶囦唤
- if (!MainPage.IsAdministrator) {
+ //鍒嗕韩浣忓畢闅愯棌鍒犻櫎澶囦唤鎸夐挳
+ if (UserConfig.Instance.CurrentRegion.IsOthreShare == false) {
rowView.AddRightView (btnDelFile);
}
var btnPoint = new Button () {
Width = Application.GetRealWidth (10),
- Height = Application.GetRealWidth (10),
+ Height = Application.GetRealHeight (10),
X = Application.GetRealWidth (25),
Gravity = Gravity.CenterVertical,
UnSelectedImagePath = "Item/Point.png",
@@ -412,24 +297,21 @@
var btnName = new Button () {
Width = Application.GetRealWidth (342),
Height = LayoutParams.MatchParent,
- Text = groupName.Trim (),
+ Text = mBackupFile.folderName.Trim (),
TextAlignment = TextAlignment.CenterLeft,
X = Application.GetRealWidth (50),
TextColor = SkinStyle.Current.TextColor1,
};
rowView.AddChidren (btnName);
- btnName.MouseLongEventHandler += (sender, e) => {
- Alert alert = new Alert ("", Language.StringByID (R.MyInternationalizationString.AreYouSureToDeleteFile), Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
- alert.ResultEventHandler += (sender2, e2) => {
- if (e2) {
- DeleteFolderData (folderID);
- }
- };
- alert.Show ();
+ //淇濆瓨浜嬩欢
+ Action<string> renameAction = (newName) => {
+ RenameFileName (newName, mBackupFile, btnName);
};
-
+ btnName.MouseUpEventHandler += (sender, e) => {
+ CommonUtlis.Current.ShowEditTextDialog (mBackupFile.folderName, renameAction, Language.StringByID (R.MyInternationalizationString.rename));
+ };
var backupIcon = new Button () {
Width = Application.GetRealWidth (72),
@@ -443,7 +325,7 @@
Height = Application.GetMinRealAverage (57),
X = backupIcon.Right + Application.GetRealWidth (20),
UnSelectedImagePath = "Register/Backup_ restores.png",
- SelectedImagePath = "Register/Backup_ restores_on.png",
+ SelectedImagePath = "Register/Backup_ restores.png",
Gravity = Gravity.CenterVertical,
};
rowView.AddChidren (Backup_restores);
@@ -452,39 +334,61 @@
};
Backup_restores.MouseUpEventHandler += (sender, e) => {
Backup_restores.IsSelected = false;
- UserBakeupFileDetailedInformation (folderID);
+ UserBakeupFileDetailedInformation (mBackupFile.id);
};
+ }
+
+ /// <summary>
+ /// 璇锋眰淇敼澶囨敞
+ /// </summary>
+ /// <param name="newName"></param>
+ /// <param name="mAlexa"></param>
+ /// <param name="btnName"></param>
+ void RenameFileName (string newName, BackupListNameInfoRes mBackupFile, Button btnName)
+ {
+ MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load));
+ System.Threading.Tasks.Task.Run (() => {
+ try {
+
+ var revertObj = HttpServerRequest.Current.UpdateBackupFolderName (newName, mBackupFile);
+ if (revertObj.Code == StateCode.SUCCESS) {
+ //AmendTheSuccess 淇敼鎴愬姛
+ Application.RunOnMainThread (() => {
+ mBackupFile.folderName = newName;
+ btnName.Text = newName;
+ Utlis.ShowAlertOnMainThread (Language.StringByID (R.MyInternationalizationString.AmendTheSuccess));
+ });
+ } else {
+ //鎻愮ず閿欒
+ IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code);
+ }
+ } catch {
+
+ } finally {
+ Application.RunOnMainThread (() => {
+ MainPage.Loading.Hide ();
+ });
+ }
+ });
+
}
/// <summary>
/// 鍒犻櫎鏌愪釜澶囦唤
/// </summary>
/// <param name="folderID"></param>
- void DeleteFolderData (string folderID)
+ void DeleteFolderData (string folderId)
{
- MainPage.Loading.Start ("Please wait...");
+ MainPage.Loading.Start (Language.StringByID (R.MyInternationalizationString.load));
+
System.Threading.Tasks.Task.Run (() => {
try {
- var requestObj = new DelHomeAppGatewayNameObj () {
- BackupClassId = folderID,
- 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, urlHead);
- if (revertObj.StateCode.ToUpper () == StateCode.SUCCESS) {
- Application.RunOnMainThread (() => {
- DatabackupShow ();
- });
+
+ var revertObj = HttpServerRequest.Current.DeleteBackupFolder (folderId);
+ if (revertObj.Code == StateCode.SUCCESS) {
+ GetHomeDataBackupList ();
} else {
- ShowDelErrorInfo (revertObj.StateCode);
+ IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code);
}
} catch { } finally {
Application.RunOnMainThread (() => {
@@ -495,383 +399,37 @@
}
- //2020-01-11
- /// <summary>
- /// 鍒犻櫎鏌愪釜澶囦唤
- /// </summary>
- /// <param name="folderID"></param>
- void DeleteFolderDataAfterUploadFailed (string folderID)
- {
- Application.RunOnMainThread (() => {
- MainPage.Loading.Start ("Please wait...");
- });
-
-
- try {
- var requestObj = new DelHomeAppGatewayNameObj () {
- BackupClassId = folderID,
- 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, urlHead);
- if (revertObj.StateCode.ToUpper () == StateCode.SUCCESS) {
- //鍒犻櫎鎴愬姛
- } else {
- //鍒犻櫎澶辫触
- }
- } catch { } finally {
- Application.RunOnMainThread (() => {
- MainPage.Loading.Hide ();
- });
- }
-
-
- }
-
- /// <summary>
- /// (2)ParameterOrEmpty,鍒欏搷搴斿瓧娈典腑[ErrorInfo]涓洪敊璇俊鎭�,ResponseData鍒欎负null
- //3)NoLogin,鍒欏搷搴斿瓧娈典腑 [ErrorInfo] 涓洪敊璇俊鎭负 [鏃犳晥鐧诲綍Token!]
- //(5)NoRecord,鍒欏搷搴斿瓧娈典腑 [ErrorInfo] 涓洪敊璇俊鎭负 [纭繚鎮ㄦ墍鎻愪氦 [椤圭洰 (浣忓畢)Id涓嶅瓨鍦�!]
- //(6)BackupClassIdNoIsYou, 鍒欏搷搴斿瓧娈典腑 [ErrorInfo]涓洪敊璇俊鎭负 [鎮ㄦ墍澶囨敞鍚嶄富閿� = XXXX骞朵笉灞炰簬鎮ㄥ綋鍓嶄綇瀹�:XXXX]
- //(7)NoPermission, 鍒欏搷搴斿瓧娈典腑 [ErrorInfo]涓洪敊璇俊鎭负 [鎮ㄥ苟涓嶅叿鏈夋鍒嗕韩鑰呮浣忓畢鐨勬潈闄�!]
- //(8)InsufficientAuthority, 鍒欏搷搴斿瓧娈典腑 [ErrorInfo]涓洪敊璇俊鎭负 [鎮ㄥ苟涓嶅叿鏈夋鍒嗕韩鑰呮浣忓畢鐨勫畬鍏ㄦ帶鍒舵潈闄�!]
- //(9)HomeIdAndTokenNoConsistent, 鍒欏搷搴斿瓧娈典腑 [ErrorInfo]涓洪敊璇俊鎭负 [鎮ㄥ綋鍓峊oken涓庝綘褰撳墠鎺у埗鐨凥omeId涓嶄竴鑷�!]
- //(10)DeliveryBackNoUpdateDel, 鍒欏搷搴斿瓧娈典腑 [ErrorInfo]涓洪敊璇俊鎭负 [姝ゅ墠鎻愪氦鏂囦欢澶笽d鏄睘浜庝氦浠樺浠�, 涓嶈兘杩涜鏇存柊鍒犻櫎!]
- /// </summary>
- /// <param name="stateCodeStr"></param>
- void ShowDelErrorInfo (string stateCodeStr)
- {
- string mes = "";
- if (stateCodeStr == "HomeIdAndTokenNoConsistent") {
- //Token 楠岃瘉澶辫触
- mes = ErrorCode.HomeIdAndTokenNoConsistent;
- } else if (stateCodeStr == "DeliveryBackNoUpdateDel") {
- //浜や粯澶囦唤, 涓嶈兘鍒犻櫎!
- mes = ErrorCode.DeliveryBackNoUpdateDel;
- } else if (stateCodeStr == ErrorCode.NetworkError) {
- mes = ErrorCode.NetworkError;
- } else {
- mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr;
-
- }
- if (!string.IsNullOrEmpty (mes)) {
- Application.RunOnMainThread (() => {
- new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show ();
- });
- }
-
-
- }
-
-
- /// <summary>
- /// 鐢ㄦ埛澶囦唤鏂囦欢
- /// </summary>
- void userBakeupFile (string groupName)
- {
- //纭畾瑕佸浠借鏂囦欢鐨勬暟鎹�
- //Alert alert = new Alert ("", Language.StringByID (R.MyInternationalizationString.SureToBackupYourthisFile), Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
-
- //alert.ResultEventHandler += (object sender2, bool e2) => {
- //if (e2) {
- MainPage.Loading.Start ("Upload...");
-
- System.Threading.Tasks.Task.Run (() => {
- try {
-
- //if (string.IsNullOrEmpty (UserConfig.Instance.GatewayMAC)) return;
- //2020-01-11 娌$粦瀹歁AC涓嶅厑璁镐笂浼犲浠�
- if (!UserConfig.Instance.CheckHomeGatewaysNotEmpty()) {
- MainPage.ShowAlertOnMainThread (ErrorCode.BindGatewayFirst);
- return;
- }
-
- var requestObj = new AddHomeAppGatewayNameObj () {
- HomeId = UserConfig.Instance.CurrentRegion.Id,
- BackupName = groupName,
- 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, urlHead);
- if (revertObj.StateCode.ToUpper () == StateCode.SUCCESS) {
- var DATA = Newtonsoft.Json.JsonConvert.DeserializeObject<AddBackupNameResult> (revertObj.ResponseData.ToString ());
- var addFolderID = DATA.BackupClassId;
- //UpLoadBackupFileToDB (addFolderID);
- UpLoadBackupFileToDBNew (addFolderID);
-
-
- } else {
- ShowAddHomeAppGatewayNameErrorInfo (revertObj.StateCode);
-
- }
-
- } catch (Exception ex) {
- Shared.Application.RunOnMainThread (() => {
- new Alert ("", Language.StringByID (R.MyInternationalizationString.CheckInternet),
- Language.StringByID (R.MyInternationalizationString.Close)).Show ();
- Utlis.WriteLine (ex.Message);
- });
- } finally {
- Shared.Application.RunOnMainThread (() => {
- MainPage.Loading.Hide ();
- DatabackupShow ();
- });
- }
- });
- // }
- //};
- //alert.Show ();
- }
-
- /// <summary>
- ///(1)Success 鍒橻璋冪敤姝ゆ帴鍙f搷浣滄垚鍔焆,ResponseData鍒欎负null
- //(2)ParameterOrEmpty,鍒欏搷搴斿瓧娈典腑 [ErrorInfo] 涓洪敊璇俊鎭�, ResponseData鍒欎负null
- //(3)NoLogin,鍒欏搷搴斿瓧娈典腑 [ErrorInfo] 涓洪敊璇俊鎭负 [鏃犳晥鐧诲綍Token!]
- //(4)NoRecord,鍒欏搷搴斿瓧娈典腑 [ErrorInfo] 涓洪敊璇俊鎭负 [纭繚鎮ㄦ墍鎻愪氦 [椤圭洰 (浣忓畢)Id涓嶅瓨鍦�!]
- //(5)Exist, 鍒欏搷搴斿瓧娈典腑 [ErrorInfo]涓洪敊璇俊鎭负 [鎮ㄥ湪浣忓畢: XXX, 褰撳墠澶囦唤鍚�: XXXX宸插瓨鍦�, 璇锋崲涓浠藉啀鎻愪氦!]
- //(6)NoBind, 鍒欏搷搴斿瓧娈典腑 [ErrorInfo]涓洪敊璇俊鎭负 [缃戝叧鐨勫敮涓�Id = XXX锛屼笌浣忓畢: XXXX骞朵笉瀛樺湪缁戝畾鍏崇郴!]
- //(7)NoPermission, 鍒欏搷搴斿瓧娈典腑 [ErrorInfo]涓洪敊璇俊鎭负 [鎮ㄥ苟涓嶅叿鏈夋鍒嗕韩鑰呮浣忓畢鐨勬潈闄�!]
-
- //(8)InsufficientAuthority, 鍒欏搷搴斿瓧娈典腑 [ErrorInfo]涓洪敊璇俊鎭负 [鎮ㄥ苟涓嶅叿鏈夋鍒嗕韩鑰呮浣忓畢鐨勫畬鍏ㄦ帶鍒舵潈闄�!]
- //(9)HomeIdAndTokenNoConsistent, 鍒欏搷搴斿瓧娈典腑 [ErrorInfo]涓洪敊璇俊鎭负 [鎮ㄥ綋鍓峊oken涓庝綘褰撳墠鎺у埗鐨凥omeId涓嶄竴鑷�!]
- /// </summary>
- /// <param name="stateCodeStr"></param>
- void ShowAddHomeAppGatewayNameErrorInfo (string stateCodeStr)
- {
- string mes = "";
- if (stateCodeStr == "Exist") {
- //澶囦唤鍚嶅凡瀛樺湪
- mes = ErrorCode.NameExist;
- } else if (stateCodeStr == "HomeIdAndTokenNoConsistent") {
- //Token 楠岃瘉澶辫触
- mes = ErrorCode.HomeIdAndTokenNoConsistent;
- } else if (stateCodeStr == ErrorCode.NetworkError) {
- mes = ErrorCode.NetworkError;
- } else {
- mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr;
-
- }
- if (!string.IsNullOrEmpty (mes)) {
- Application.RunOnMainThread (() => {
- new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show ();
- });
- }
-
-
- }
-
- ///// <summary>
- ///// 涓婁紶澶囦唤鏂囦欢
- ///// </summary>
- ///// <param name="mBackupClassId"></param>
- //void UpLoadBackupFileToDB (string mBackupClassId)
- //{
-
- // var backuplist = IO.FileUtils.ReadFiles ();
- // int index = 0;
- // foreach (var fileName in backuplist) {
- // index++;
- // /// <summary>
- // /// 濡傛灉鏄壒娈婄殑娉ㄥ唽鐧婚檰鏂囦欢锛屽垯涓嶉渶瑕佸浠藉埌鏈嶅姟鍣�
- // /// </summary>
- // if (fileName == UserInfo.GlobalRegisterFile) {
- // continue;
- // }
- // //鏁寸悊鏁版嵁
- // var datainfo = new FileInfoData ();
- // datainfo.BackupFileName = fileName;
- // datainfo.BackupFileContent = Shared.IO.FileUtils.ReadFile (fileName);
-
- // var list = new List<FileInfoData> ();
- // list.Add (datainfo);
-
- // var upData = new UploadHomeAppGatewaySubFilesObj ();
- // upData.HomeId = UserConfig.Instance.CurrentRegion.Id;
- // upData.BackupClassId = mBackupClassId;
- // upData.UploadSubFileLists = list;
- // //鑾峰彇鎺у埗涓讳汉璐﹀彿鐨凾oken
- // 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, urlHead);
- // if (revertObj2.StateCode.ToUpper () == StateCode.SUCCESS) {
- // //index++;
- // Application.RunOnMainThread (() => {
- // int pro = (int)(index * 1.0 / backuplist.Count * 100);
- // MainPage.Loading.Text = pro.ToString () + "%";
- // });
- // } else {
- // //鎻愮ず閿欒
- // break;
- // }
- // }
- // if (index != backuplist.Count) {
- // //2020-01-11
- // DeleteFolderDataAfterUploadFailed (mBackupClassId);
- // Shared.Application.RunOnMainThread (() => {
- // new Alert ("", "Upload failed!", Language.StringByID (R.MyInternationalizationString.Close)).Show ();
- // MainPage.Loading.Hide ();
- // });
-
- // }
-
- // //Shared.Application.RunOnMainThread (() => {
- // // if (index == 0) {
- // // new Alert ("", "Upload failed!", Language.StringByID (R.MyInternationalizationString.Close)).Show ();
- // // }
-
- // // MainPage.Loading.Hide ();
- // //});
- //}
-
-
-
-
/// <summary>
/// 鐢ㄦ埛鎭㈠鏂囦欢
/// </summary>
- public void UserBakeupFileDetailedInformation (string BackupClassId)
+ public void UserBakeupFileDetailedInformation (string folderId)
{
//鏄惁纭畾鎭㈠璇ユ枃浠舵暟鎹俊鎭�
- Alert alert = new Alert ("", Language.StringByID (R.MyInternationalizationString.SureToRestoreFileInformation), Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
+ Alert alert = new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.SureToRestoreFileInformation), Language.StringByID (R.MyInternationalizationString.Cancel), Language.StringByID (R.MyInternationalizationString.Confrim));
alert.ResultEventHandler += (sender2, e2) => {
if (e2) {
MainPage.Loading.Start ("Download...");
System.Threading.Tasks.Task.Run (() => {
try {
- var fileNames = IO.FileUtils.ReadFiles ();
- foreach (var fileName in fileNames) {
- if (fileName == UserInfo.GlobalRegisterFile) {
- continue;
- }
- IO.FileUtils.DeleteFile (fileName);
- }
+ ReadFilesAndDelete ();
- var requestObj2 = new GetHomeDataBackupUploadListPaggerObj ();
- requestObj2.HomeId = UserConfig.Instance.CurrentRegion.Id;
- requestObj2.BackupClassId = BackupClassId;
- requestObj2.PageSetting.PageSize = 999999;
- requestObj2.PageSetting.Page = 1;
- //鑾峰彇鎺у埗涓讳汉璐﹀彿鐨凾oken
- requestObj2.LoginAccessToken = MainPage.LoginUser.LoginTokenString;
- string urlHead = MainPage.RequestHttpsHost;
- if (requestObj2.IsOtherAccountCtrl) {
- urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl;
- requestObj2.LoginAccessToken = UserConfig.Instance.MasterAccountToken;
- }
+ var revertObj = HttpServerRequest.Current.GetBackupFolderAllFileList (folderId);
+ if (revertObj.Code == StateCode.SUCCESS) {
- //鑾峰彇鎵�鏈夋枃浠剁粍鍚�
- //var requestObj2 = new UserBackupListObj () { LevelID = folderID };
- var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2);
- var revertObj2 = MainPage.RequestHttps (API.GetHomeDataBackupUploadListPagger, requestJson2, urlHead);
- if (revertObj2.StateCode.ToUpper () == StateCode.SUCCESS) {
- var fileListData = Newtonsoft.Json.JsonConvert.DeserializeObject<LoadBackInfoResult> (revertObj2.ResponseData.ToString ());
- var responseDataObj = fileListData.PageData;
- ////鑾峰彇鏂囦欢鍚嶅瓧
- //List<string> listFileName = new List<string> ();
- //foreach (LoadBackupFileNameInfo file in fileListData.PageData) {
- // listFileName.Add (file.BackupFileName);
- //}
- //var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BackupInfoRes>> (revertObj2.ResponseData.ToString ());
+ var fileListData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BackupFileInfoRes>> (revertObj.Data.ToString ());
- var mDownLoad = new DownloadSomeDataBackupObj ();
- mDownLoad.HomeId = UserConfig.Instance.CurrentRegion.Id;
- mDownLoad.BackupClassId = BackupClassId;
- //鑾峰彇鎺у埗涓讳汉璐﹀彿鐨凾oken
- mDownLoad.LoginAccessToken = MainPage.LoginUser.LoginTokenString;
- string mUrlHead = MainPage.RequestHttpsHost;
- if (mDownLoad.IsOtherAccountCtrl) {
- urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl;
- mDownLoad.LoginAccessToken = UserConfig.Instance.MasterAccountToken;
- }
+ MultiThreadDownload (fileListData, folderId);
- MultiThreadDownload (responseDataObj, mDownLoad, mUrlHead);
-
-
- //int index = 0;
-
- //foreach (var file in responseDataObj) {
- // index++;
- // if (file.BackupFileName == "null" || "UserConfig" == file.BackupFileName) {
- // continue;
- // }
- // 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, false, mUrlHead);
- // if (revertObj3 != null) {
-
- // IO.FileUtils.WriteFileByBytes (file.BackupFileName, revertObj3);
- // Application.RunOnMainThread (() => {
- // int pro = (int)(index * 1.0 / responseDataObj.Count * 100);
- // MainPage.Loading.Text = pro.ToString () + "%";
- // });
- // } else {
- // break;
- // }
-
- //}
-
-
- //if (index != responseDataObj.Count) {
- // //鍒犻櫎宸茬粡涓嬭浇鐨勬枃浠朵釜鏁伴敊璇�
- // var fileNames2 = IO.FileUtils.ReadFiles ();
- // foreach (var fileName in fileNames2) {
- // if (fileName == UserInfo.GlobalRegisterFile) {
- // continue;
- // }
- // IO.FileUtils.DeleteFile (fileName);
- // }
-
- // MainPage.ShowAlertOnMainThread ("Download failed!");
-
- // return;
- //}
-
- //MainPage.LoginUser.SaveUserInfo ();
- //Room.InitAllRoom ();
- //Application.RunOnMainThread (() => {
- // this.RemoveFromParent ();
- // CommonPage.IsRemote = false;
- // UserMiddle.Init ();
- // EquipmentPublicClass.CheckLinkRemote (UserConfig.Instance.internetStatus);
- // new Alert ("", Language.StringByID (R.MyInternationalizationString.RestoreFileIsSuccessfull),
- // Language.StringByID (R.MyInternationalizationString.Close)).Show ();
- //});
- //MainPage.LoginUser = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInfo> (System.Text.Encoding.UTF8.GetString (Shared.IO.FileUtils.ReadFile (UserInfo.GlobalRegisterFile)));
- //if (MainPage.LoginUser != null) {
- // MainPage.LoginUser.LastTime = System.DateTime.Now;
- // MainPage.LoginUser.SaveUserInfo ();
- //}
+ } else {
+ //鎻愮ず閿欒
+ IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code);
}
} catch (Exception ex) {
Shared.Application.RunOnMainThread (() => {
- new Alert ("", Language.StringByID (R.MyInternationalizationString.CheckInternet),
+ new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.CheckInternet),
Language.StringByID (R.MyInternationalizationString.Close)).Show ();
});
- Utlis.WriteLine (ex.ToString ());
+ Shared.Utlis.WriteLine (ex.ToString ());
} finally {
Shared.Application.RunOnMainThread (() => {
MainPage.Loading.Hide ();
@@ -883,29 +441,11 @@
alert.Show ();
}
-
- bool DownloadSomeDataBackup (DownloadSomeDataBackupObj mmDownLoad, string mUrlHead, LoadBackupFileNameInfo file)
- {
- DownloadSomeDataBackupObj mDownLoad = mmDownLoad;
- mDownLoad.BackupFileName = file.BackupFileName;
- //var requestObj3 = new BackupDetailObj () { Id = file.Id };
- var requestJson3 = Newtonsoft.Json.JsonConvert.SerializeObject (mDownLoad);
- var revertObj3 = MainPage.RequestHttpsReturnByteNew (API.DownloadSomeDataBackup, requestJson3, mUrlHead);
- if (revertObj3 != null) {
-
- IO.FileUtils.WriteFileByBytes (file.BackupFileName, revertObj3);
- return true;
- } else {
- return false;
- }
- }
-
/// <summary>
/// 鍒犻櫎鏈湴鏂囦欢
/// </summary>
void ReadFilesAndDelete ()
{
-
var fileNames = IO.FileUtils.ReadFiles ();
foreach (var fileName in fileNames) {
if (fileName == UserInfo.GlobalRegisterFile || fileName == UserConfig.configFile) {
@@ -916,25 +456,29 @@
}
+ /// <summary>
+ ///
+ /// </summary>
private readonly object SendLocker = new object ();
+ /// <summary>
+ ///
+ /// </summary>
private readonly object DownloadLocker = new object ();
/// <summary>
/// 澶氱嚎绋嬩笅杞�
/// </summary>
- void MultiThreadDownload (List<LoadBackupFileNameInfo> dataList, DownloadSomeDataBackupObj mDownLoad, string mUrlHead, int maxThreads = 5)
+ void MultiThreadDownload (List<BackupFileInfoRes> dataList, string folderId, int maxThreads = 5)
{
int index = 0;
int indexCount = 0;
-
- var mFileList = dataList.FindAll ((obj) => obj.BackupFileName != "null" && obj.BackupFileName != UserConfig.configFile && obj.BackupFileName != UserInfo.GlobalRegisterFile && obj.BackupFileName != "AccountListDB" && obj.BackupFileName != CommonConfig.ConfigFile);
+ var mFileList = dataList.FindAll ((obj) => obj.fileName != "null" && obj.fileName != UserConfig.configFile && obj.fileName != UserInfo.GlobalRegisterFile && obj.fileName != "AccountListDB" && obj.fileName != CommonConfig.ConfigFile);
if (maxThreads > mFileList.Count) {
maxThreads = mFileList.Count;
}
if (mFileList.Count <= 0) return;
-
int resultCount = mFileList.Count / maxThreads;
@@ -958,43 +502,25 @@
for (var j = startIndex1; j <= endIndex1; j++) {
try {
- //濡傛灉澶辫触閲嶆柊涓嬭浇锛岄噸澶�3娆�
- int errorCount = 0;
- while (errorCount < 3) {
- var result = DownloadSomeDataBackup (mDownLoad, mUrlHead, mFileList [j]);
- if (result) {
- lock (DownloadLocker) {
- index++;
- }
- Application.RunOnMainThread (() => {
- int pro = (int)(index * 1.0 / mFileList.Count * 100);
- MainPage.Loading.Text = pro.ToString () + "%";
- });
- errorCount = 3;
- } else {
- errorCount++;
- Utlis.WriteLine ($"涓嬭浇澶辫触锛� {mFileList [j].BackupFileName} 娆℃暟:{errorCount}");
+ var result = DownloadSomeDataBackup (folderId, mFileList [j]);
+ if (result) {
+ lock (DownloadLocker) {
+ index++;
}
+
+ //index++;
+
+ Application.RunOnMainThread (() => {
+ int pro = (int)(index * 1.0 / mFileList.Count * 100);
+ MainPage.Loading.Text = pro.ToString () + "%";
+ });
+
}
} catch { } finally {
lock (SendLocker) {
indexCount++;
}
}
-
- //var t1 = DateTime.Now.Second;
- //var result = DownloadSomeDataBackup (mDownLoad, mUrlHead, mFileList [j]);
- //if (result) {
- // index++;
- // Application.RunOnMainThread (() => {
- // int pro = (int)(index * 1.0 / mFileList.Count * 100);
- // MainPage.Loading.Text = pro.ToString () + "%";
- // });
-
- //} else {
- // Utlis.WriteLine ($"涓嬭浇澶辫触锛� {mFileList [j].BackupFileName} 鏃堕棿:{DateTime.Now.Second - t1}S");
- //}
- //indexCount++;
//Utlis.WriteLine ($"涓嬭浇绾跨▼锛歿id} 瀹屾垚index:{j} indexCount: {indexCount}");
}
@@ -1026,200 +552,48 @@
MainPage.LoginUser.SaveUserInfo ();
Room.InitAllRoom ();
Application.RunOnMainThread (() => {
- this.RemoveFromParent ();
- //CommonPage.IsRemote = false;
- UserMiddle.Init ();
- EquipmentPublicClass.CheckLinkRemote (UserConfig.Instance.internetStatus);
- new Alert ("", Language.StringByID (R.MyInternationalizationString.RestoreFileIsSuccessfull),
- Language.StringByID (R.MyInternationalizationString.Close)).Show ();
- });
- MainPage.LoginUser = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInfo> (System.Text.Encoding.UTF8.GetString (Shared.IO.FileUtils.ReadFile (UserInfo.GlobalRegisterFile)));
- if (MainPage.LoginUser != null) {
- MainPage.LoginUser.LastTime = System.DateTime.Now;
- MainPage.LoginUser.SaveUserInfo ();
- }
-
-
-
- }
-
- bool UploadDataBackup (UploadHomeAppGatewaySubFilesObj upData, string mUrlHead, List<string> fileList, int startIndex1, int endIndex1)
- {
- try {
-
- var list = new List<FileInfoData> ();
- for (var j = startIndex1; j <= endIndex1; j++) {
- var datainfo = new FileInfoData ();
- datainfo.BackupFileName = fileList [j];
- datainfo.BackupFileContent = Shared.IO.FileUtils.ReadFile (fileList [j]);
- list.Add (datainfo);
- }
-
- //鏁寸悊鏁版嵁
- UploadHomeAppGatewaySubFilesObj mUpData = upData;
- mUpData.UploadSubFileLists = list;
-
- var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (mUpData);
- var revertObj2 = MainPage.RequestHttps (API.UploadHomeAppGatewaySubFiles, requestJson2, mUrlHead);
- if (revertObj2.StateCode.ToUpper () == StateCode.SUCCESS) {
- return true;
- } else {
- //鎻愮ず閿欒
- return false;
- }
- } catch {
- return false;
- }
- }
-
-
-
-
- /// <summary>
- /// 涓婁紶澶囦唤鏂囦欢
- /// 澶氭涓婁紶澶氫釜鏂囦欢
- /// </summary>
- /// <param name="mBackupClassId"></param>
- void UpLoadBackupFileToDBNew (string mBackupClassId, int maxThreads = 20)
- {
- var backuplist = IO.FileUtils.ReadFiles ();
- var mFileList = backuplist.FindAll ((obj) => obj != "null" && obj != UserConfig.configFile && obj != UserInfo.GlobalRegisterFile && obj != "AccountListDB" && obj != CommonConfig.ConfigFile);
- if (mFileList.Count <= 0) return;
-
- if (maxThreads > mFileList.Count) {
- maxThreads = mFileList.Count;
- }
-
- int index = 0;
- int indexCount = 0;
- int resultCount = mFileList.Count / maxThreads;
-
- var upData = new UploadHomeAppGatewaySubFilesObj ();
- upData.HomeId = UserConfig.Instance.CurrentRegion.Id;
- upData.BackupClassId = mBackupClassId;
- //鑾峰彇鎺у埗涓讳汉璐﹀彿鐨凾oken
- upData.LoginAccessToken = MainPage.LoginUser.LoginTokenString;
- string urlHead = MainPage.RequestHttpsHost;
- if (upData.IsOtherAccountCtrl) {
- urlHead = UserConfig.Instance.MasterAccountRequestBaseUrl;
- upData.LoginAccessToken = UserConfig.Instance.MasterAccountToken;
- }
-
-
- for (int i = 1; i <= resultCount; i++) {
- int startIndex = ((i - 1) * maxThreads + 0);
- int endIndex = maxThreads * i - 1;
- if (i == resultCount) {
- /*鏈�鍚庝竴涓嚎绋�* */
- endIndex = mFileList.Count - 1;
- }
- var id = i;
- var startIndex1 = startIndex;
- var endIndex1 = endIndex;
- //2020-06-10 淇敼澶у浘鐗囧ぇ鏂囦欢澶勭悊
- var result = UploadDataBackupNew (upData, urlHead, mFileList, startIndex1, endIndex1);
- if (result) {
- index++;
- Application.RunOnMainThread (() => {
- int pro = (int)(index * 1.0 / resultCount * 100);
- MainPage.Loading.Text = pro.ToString () + "%";
- });
-
- }
- indexCount++;
-
- }
-
-
- Utlis.WriteLine ($"涓婁紶瀹屾垚");
-
- if (index != resultCount) {
- //2020-01-11 澶囦唤澶辫触
- DeleteFolderDataAfterUploadFailed (mBackupClassId);
- Shared.Application.RunOnMainThread (() => {
- new Alert ("", Language.StringByID (R.MyInternationalizationString.FailedToBackupFile), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
- MainPage.Loading.Hide ();
- });
- return;
- }
-
- Application.RunOnMainThread (() => {
- //MainPage.Loading.Text = "100%";
- new Alert ("", Language.StringByID (R.MyInternationalizationString.BackupFileIsSuccessful), Language.StringByID (R.MyInternationalizationString.Close)).Show ();
- });
-
- }
-
-
- /// <summary>
- /// 2020-06-05 闇�瑕佺瓑寰呬簯绔鍔犳帴鍙�
- /// 澶勭悊澶ф枃浠跺拰鍥剧墖涓婁紶
- ///
- /// </summary>
- /// <param name="upData"></param>
- /// <param name="mUrlHead"></param>
- /// <param name="fileList"></param>
- /// <param name="startIndex1"></param>
- /// <param name="endIndex1"></param>
- /// <returns></returns>
- bool UploadDataBackupNew (UploadHomeAppGatewaySubFilesObj upData, string mUrlHead, List<string> fileList, int startIndex1, int endIndex1)
- {
- try {
-
- var list = new List<FileInfoData> ();
- for (var j = startIndex1; j <= endIndex1; j++) {
- var datainfo = new FileInfoData ();
- datainfo.BackupFileName = fileList [j];
- datainfo.BackupFileContent = Shared.IO.FileUtils.ReadFile (fileList [j]);
-
- if (datainfo.BackupFileContent.Length > 1024 * 10) {
- var upDataBig = new UploadHomeAppGatewaySubFilesBigObj ();
- upDataBig.RequestVersion = upData.RequestVersion;
- upDataBig.HomeId = upData.HomeId;
- upDataBig.BackupClassId = upData.BackupClassId;
- upDataBig.FileName = fileList [j];
- upDataBig.IsOtherAccountCtrl = upData.IsOtherAccountCtrl;
-
- var revertObj5 = MainPage.RequestHttpsNewBig (API.UploadHomeAppGatewaySingleSubFile, datainfo.BackupFileContent, upDataBig, mUrlHead);
-
- } else {
- list.Add (datainfo);
- }
- }
-
- //鏁寸悊鏁版嵁
- UploadHomeAppGatewaySubFilesObj mUpData = upData;
- mUpData.UploadSubFileLists = list;
-
- //var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (mUpData);
- //var revertObj2 = MainPage.RequestHttps (API.UploadHomeAppGatewaySubFiles, requestJson2, mUrlHead);
- //if (revertObj2.StateCode.ToUpper () == StateCode.SUCCESS) {
- // return true;
- //} else {
- // //鎻愮ず閿欒
- // return false;
+ //if (CommonPage.IsRemote) {
+ // SmartHome.MqttCommon.DisConnectRemote("UserBakeupFileDetailedInformation");
//}
+ this.RemoveFromParent ();
+ UserMiddle.Init (true, true);
+ EquipmentPublicClass.CheckLinkRemote (UserConfig.Instance.internetStatus);
+ new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.RestoreFileIsSuccessfull),
+ Language.StringByID (R.MyInternationalizationString.Close)).Show ();
+ });
- //2020-11-16 濡傛灉澶辫触閲嶆柊涓婁紶锛岄噸澶�3娆�
- int errorCount = 0;
- var result = false;
- while (errorCount < 3) {
- var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (mUpData);
- var revertObj2 = MainPage.RequestHttps (API.UploadHomeAppGatewaySubFiles, requestJson2, mUrlHead, MainPage.TIME_OUT_20);
- if (revertObj2.StateCode.ToUpper () == StateCode.SUCCESS) {
- result = true;
- errorCount = 3;
- } else {
- errorCount++;
- //Utlis.WriteLine ($"涓婁紶澶辫触({startIndex1}-{endIndex1})锛屾鏁�:{errorCount}");
- }
- }
- return result;
- } catch {
+
+
+ }
+
+ /// <summary>
+ /// 涓嬭浇鍗曚釜澶囦唤鏂囦欢
+ /// </summary>
+ /// <param name="mmDownLoad"></param>
+ /// <param name="mUrlHead"></param>
+ /// <param name="file"></param>
+ /// <returns></returns>
+ bool DownloadSomeDataBackup (string folderId, BackupFileInfoRes file)
+ {
+ var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (new BackupFileDownObj () {
+ folderId = folderId,
+ fileId = file.id,
+ homeId = UserConfig.Instance.CurrentRegion.Id
+ });
+ var revertObj = HttpUtil.RequestHttpsDownload (NewAPI.API_POST_File_Down, requestJson, null, UserConfig.Instance.CurrentRegion.regionUrl);
+
+ if (revertObj != null) {
+ Utlis.WriteLine ("DownloadSomeDataBackup: " + file.fileName);
+ IO.FileUtils.WriteFileByBytes (file.fileName, revertObj);
+ return true;
+ } else {
return false;
}
}
+ #region 澶囦笂浼犲拰涓嬭浇鐩稿叧鎺ュ彛灏佽
+
+ #endregion
}
}
\ No newline at end of file
--
Gitblit v1.8.0