黄学彪
2020-11-20 99253403b560f761d5f9af8b4f5140496996433a
ZigbeeApp/Shared/Phone/Common/Logic/HdlGatewayBackupLogic.cs
old mode 100755 new mode 100644
File was renamed from ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayBackupLogic.cs
@@ -3,7 +3,7 @@
using System.Text;
using ZigBee.Device;
namespace Shared.Phone.UserCenter
namespace Shared.Phone
{
    /// <summary>
    /// 网关备份业务的逻辑
@@ -48,8 +48,10 @@
            ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uCreatBackupFile));
            System.Threading.Thread.Sleep(1000);
            //☆マーク☆
            //创建一个备份名字
            string backupClassId = HdlBackupLogic.Current.CreatNewBackupNameToDB(backupName, 2, realGateway.GwId);
            //string backupClassId = HdlBackupLogic.Current.CreatNewBackupNameToDB(backupName, 2, realGateway.GwId);
            string backupClassId = null;
            if (backupClassId == null)
            {
                //关闭进度条
@@ -140,7 +142,7 @@
                string msg = Language.StringByID(R.MyInternationalizationString.uSaveGatewayNVFileFail);
                if (result == -1)
                {
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时");
                    msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, null, "回复超时");
                }
                this.ShowErrorMsg(msg);
                return false;
@@ -193,7 +195,7 @@
                string msg = Language.StringByID(R.MyInternationalizationString.uOpenZbMsComSendFail);
                if (result == -1)
                {
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时");
                    msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, null, "回复超时");
                }
                this.ShowErrorMsg(msg);
                return false;
@@ -272,28 +274,29 @@
            };
            realGateway.Actions += action;
            //获取接口的连接模式
            string fullUrl = string.Empty;
            var connectMode = UserCenterLogic.GetHttpConnectMode(true);
            if (connectMode == HttpConnectMode.Normal)
            {
                //普通访问
                fullUrl = $"{Common.CommonPage.RequestHttpsHost}/{"App/UploadHomeAppGatewaySubFiles"}";
            }
            else if (connectMode == HttpConnectMode.Admin)
            {
                //以管理员的身份访问,自身是成员
                fullUrl = $"{Common.Config.Instance.AdminRequestBaseUrl}/{"App/UploadHomeAppGatewaySubFiles"}";
            }
            //☆マーク☆
            ////获取接口的连接模式
            //string fullUrl = string.Empty;
            //var connectMode = HdlUserCenterLogic.GetHttpConnectMode(true);
            //if (connectMode == HttpConnectMode.Normal)
            //{
            //    //普通访问
            //    fullUrl = $"{Common.CommonPage.RequestHttpsHost}/{"App/UploadHomeAppGatewaySubFiles"}";
            //}
            //else if (connectMode == HttpConnectMode.Admin)
            //{
            //    //以管理员的身份访问,自身是成员
            //    fullUrl = $"{Common.Config.Instance.AdminRequestBaseUrl}/{"App/UploadHomeAppGatewaySubFiles"}";
            //}
            var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 6200 } };
            var data = new Newtonsoft.Json.Linq.JObject {
                { "url", fullUrl }, { "RequestVersion", Common.CommonPage.RequestVersion },
                { "LoginAccessToken", UserCenterLogic.GetConnectMainToken() }, { "BackupClassId", backupClassId },
                { "ManualBackupType", 2 },{ "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0}
            };
            jObject.Add("Data", data);
            realGateway.Send("BackupGwDataFile", jObject.ToString());
            //var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 6200 } };
            //var data = new Newtonsoft.Json.Linq.JObject {
            //    { "url", fullUrl }, { "RequestVersion", Common.CommonPage.RequestVersion },
            //    { "LoginAccessToken", HdlUserCenterLogic.GetConnectMainToken() }, { "BackupClassId", backupClassId },
            //    { "ManualBackupType", 2 },{ "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0}
            //};
            //jObject.Add("Data", data);
            //realGateway.Send("BackupGwDataFile", jObject.ToString());
            while (threadAction == true && TimeOut < waitime)
            {
@@ -405,29 +408,30 @@
            };
            realGateway.Actions += action;
            //获取接口的连接模式
            string fullUrl = string.Empty;
            var connectMode = UserCenterLogic.GetHttpConnectMode(true);
            if (connectMode == HttpConnectMode.Normal)
            {
                //普通访问
                fullUrl = $"{Common.CommonPage.RequestHttpsHost}/{"App/GetHomeDataBackupUploadListPagger"}";
            }
            else if (connectMode == HttpConnectMode.Admin)
            {
                //以管理员的身份访问,自身是成员
                fullUrl = $"{Common.Config.Instance.AdminRequestBaseUrl}/{"App/GetHomeDataBackupUploadListPagger"}";
            }
            //☆マーク☆
            ////获取接口的连接模式
            //string fullUrl = string.Empty;
            //var connectMode = HdlUserCenterLogic.GetHttpConnectMode(true);
            //if (connectMode == HttpConnectMode.Normal)
            //{
            //    //普通访问
            //    fullUrl = $"{Common.CommonPage.RequestHttpsHost}/{"App/GetHomeDataBackupUploadListPagger"}";
            //}
            //else if (connectMode == HttpConnectMode.Admin)
            //{
            //    //以管理员的身份访问,自身是成员
            //    fullUrl = $"{Common.Config.Instance.AdminRequestBaseUrl}/{"App/GetHomeDataBackupUploadListPagger"}";
            //}
            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", isAutoBack },
                { "BackupClassId", backupClassId },{ "GatewayUniqueId",realGateway.GwId},
                { "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0}
            };
            jObject.Add("Data", data);
            realGateway.Send("GetDataFileList", jObject.ToString());
            //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", HdlUserCenterLogic.GetConnectMainToken() }, { "IsGatewayAutoBackup", isAutoBack },
            //    { "BackupClassId", backupClassId },{ "GatewayUniqueId",realGateway.GwId},
            //    { "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0}
            //};
            //jObject.Add("Data", data);
            //realGateway.Send("GetDataFileList", jObject.ToString());
            int timeOut = 0;
            while (result == -1 && timeOut < 30)
@@ -503,29 +507,30 @@
            };
            realGateway.Actions += action;
            //获取接口的连接模式
            string fullUrl = string.Empty;
            var connectMode = UserCenterLogic.GetHttpConnectMode(true);
            if (connectMode == HttpConnectMode.Normal)
            {
                //普通访问
                fullUrl = $"{Common.CommonPage.RequestHttpsHost}/{"App/DownloadSomeDataBackup"}";
            }
            else if (connectMode == HttpConnectMode.Admin)
            {
                //以管理员的身份访问,自身是成员
                fullUrl = $"{Common.Config.Instance.AdminRequestBaseUrl}/{"App/DownloadSomeDataBackup"}";
            }
            //☆マーク☆
            ////获取接口的连接模式
            //string fullUrl = string.Empty;
            //var connectMode = HdlUserCenterLogic.GetHttpConnectMode(true);
            //if (connectMode == HttpConnectMode.Normal)
            //{
            //    //普通访问
            //    fullUrl = $"{Common.CommonPage.RequestHttpsHost}/{"App/DownloadSomeDataBackup"}";
            //}
            //else if (connectMode == HttpConnectMode.Admin)
            //{
            //    //以管理员的身份访问,自身是成员
            //    fullUrl = $"{Common.Config.Instance.AdminRequestBaseUrl}/{"App/DownloadSomeDataBackup"}";
            //}
            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", isAutoBack },
                { "BackupClassId", backupClassId },{ "GatewayUniqueId",realGateway.GwId},
                { "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0}
            };
            jObject.Add("Data", data);
            realGateway.Send("GetDataFileList", jObject.ToString());
            //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", HdlUserCenterLogic.GetConnectMainToken() }, { "IsGatewayAutoBackup", isAutoBack },
            //    { "BackupClassId", backupClassId },{ "GatewayUniqueId",realGateway.GwId},
            //    { "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0}
            //};
            //jObject.Add("Data", data);
            //realGateway.Send("GetDataFileList", jObject.ToString());
            while (threadAction == true && timeOut < 30)
            {
@@ -644,7 +649,7 @@
                string msg = Language.StringByID(R.MyInternationalizationString.uGatewayRerootFail);
                if (result == -1)
                {
                    msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时");
                    msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, null, "回复超时");
                }
                this.ShowErrorMsg(msg);
                return false;