JLChen
2020-02-28 9137222ece9b978eb97b5598f2eee6e070bcf9d6
Crabtree/SmartHome/UI/SimpleControl/Phone/Guide/GuideAddGateway.cs
@@ -322,7 +322,7 @@
                                        UserHomePage.FrameLayoutMain.AddChidren (UserMiddle.guidePageView);
                                        var guide = new GuideAddResidence ();
                                        UserMiddle.guidePageView.AddChidren (guide);
                                        guide.ShowHomeList ();
                                        guide.ShowHomeView ();
                                        UserMiddle.guidePageView.PageIndex = 0;
                                        //重置为加密模式
                                        UserConfig.Instance.IsLocalEncrypt = true;
@@ -345,14 +345,16 @@
        static bool inThisView = false;
        Alert checkInternetAlert = new Alert ("", "Your phone in not connected to WIFI network, please connet", "Close", "Search again");
        Alert confirmAlert = new Alert ("", "Please make sure gateway is powered up and comect to WiFi router.", "Close", "Search again");
        Alert confirmAlert1 = new Alert ("", "If not all the gateways are in the list,you can search again.", "Close", "Search again");
        Alert wrongPasswordAlert = new Alert ("", ErrorCode.GatewayPasswordError, "Close", "Search again");
        //Alert checkInternetAlert = new Alert ("", "Your phone in not connected to WIFI network, please connet", "Close", "Search again");
        //Alert confirmAlert = new Alert ("", "Please make sure gateway is powered up and comect to WiFi router.", "Close", "Search again");
        //Alert confirmAlert1 = new Alert ("", "If not all the gateways are in the list,you can search again.", "Close", "Search again");
        //Alert wrongPasswordAlert = new Alert ("", ErrorCode.GatewayPasswordError, "Close", "Search again");
        void SearchGatewayList ()
        {
            if (UserConfig.Instance.internetStatus == 0 || UserConfig.Instance.internetStatus == 1) {
                Alert checkInternetAlert = new Alert ("", "Your phone in not connected to WIFI network, please connet", "Close", "Search again");
                checkInternetAlert.Show ();
                checkInternetAlert.ResultEventHandler += (dsss, eee) => {
@@ -443,6 +445,8 @@
                        } else {
                            if (this != null && this.Parent != null) {
                                if (inThisView) {// this.Parent.GetChildren (this.Parent.ChildrenCount - 1) == this) {
                                    Alert confirmAlert1 = new Alert ("", "If not all the gateways are in the list,you can search again.", "Close", "Search again");
                                    confirmAlert1.Show ();
                                    confirmAlert1.ResultEventHandler += (ddf, ddd) => {
                                        MainPage.Loading.Hide ();
@@ -468,19 +472,18 @@
            if (UserConfig.Instance.IsLocalEncrypt) {
                //密码检验正确
                if (UserConfig.Instance.EncryptedPasswordCorrect) {
                    inView.confirmAlert.Show ();
                    inView.confirmAlert.ResultEventHandler += (ddf, ddd) => {
                    Alert confirmAlert = new Alert ("", "Please make sure gateway is powered up and comect to WiFi router.", "Close", "Search again");
                    confirmAlert.Show ();
                    confirmAlert.ResultEventHandler += (ddf, ddd) => {
                        MainPage.Loading.Hide ();
                        if (ddd) {
                            inView.SearchGatewayList ();
                        }
                    };
                } else {
                    inView.wrongPasswordAlert.Show ();
                    inView.wrongPasswordAlert.ResultEventHandler += (ddf, ddd) => {
                    Alert wrongPasswordAlert = new Alert ("", ErrorCode.GatewayPasswordError, "Close", "Search again");
                    wrongPasswordAlert.Show ();
                    wrongPasswordAlert.ResultEventHandler += (ddf, ddd) => {
                        MainPage.Loading.Hide ();
                        if (ddd) {
                            inView.SearchGatewayList ();
@@ -489,8 +492,9 @@
                }
            } else {
                inView.confirmAlert.Show ();
                inView.confirmAlert.ResultEventHandler += (ddf, ddd) => {
                Alert confirmAlert = new Alert ("", "Please make sure gateway is powered up and comect to WiFi router.", "Close", "Search again");
                confirmAlert.Show ();
                confirmAlert.ResultEventHandler += (ddf, ddd) => {
                    MainPage.Loading.Hide ();
                    if (ddd) {
                        inView.SearchGatewayList ();
@@ -527,11 +531,11 @@
        /// </summary>
        /// <param name="backBytes"></param>
        /// <returns></returns>
        static bool CheckIsSuccessfulWithBytes (byte [] backBytes)
        static bool CheckIsSuccessfulWithBytes (byte [] backBytes, string errorStr = "Modify gateway configuration failed,please try again!")
        {
            if (backBytes == null) {
                Application.RunOnMainThread (() => {
                    new Alert ("", Language.StringByID (R.MyInternationalizationString.TipEquipmentNotOnline),
                    new Alert ("", ErrorCode.GatewayNoResponse,
                               Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                });
                return false;
@@ -539,7 +543,7 @@
                return true;
            } else {
                Application.RunOnMainThread (() => {
                    new Alert ("", Language.StringByID (R.MyInternationalizationString.OperationFailed),
                    new Alert ("", errorStr,
                               Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                });
                return false;
@@ -611,12 +615,17 @@
                        //如果没加密,走修改加密方法
                        var result = SetGateWayLocalEncryption (common);
                        if (!result) {
                            MainPage.LoadingHide ();
                            Application.RunOnMainThread (() => {
                                MainPage.Loading.Hide ();
                                new Alert ("", "Encryption gateway failed, please try again.", Language.StringByID (R.MyInternationalizationString.Close)).Show ();
                            });
                            return result;//修改失败 返回goNext false
                        }
                        //修改成功,设置本地为加密方式
                        UserConfig.Instance.IsLocalEncrypt = true;
                        System.Console.WriteLine ($"============>LocalEncryptKey 加密成功Key为:{UserConfig.Instance.LocalEncryptKey}");
                        //System.Console.WriteLine ($"============>LocalEncryptKey 加密成功Key为:{UserConfig.Instance.LocalEncryptKey}");
                    }
                    goNext = true;