wxr
2022-05-30 48dc77a381eb33b0057ad496c02577806d2b5b5c
Crabtree/SmartHome/UI/SimpleControl/Phone/Register/AccountView.cs
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using service.hdlcontrol.com_push;
namespace Shared.SimpleControl.Phone
@@ -181,7 +183,7 @@
            Button btnTitle = new Button () {
                X = Application.GetRealWidth (40),
                TextID = R.MyInternationalizationString.ModifyPasswrod,
                Text = "平台迁移",
                TextAlignment = TextAlignment.CenterLeft,
                TextColor = SkinStyle.Current.TextColor1,
            };
@@ -198,47 +200,26 @@
            moveToNewCloudView.AddChidren (btnRight);
            EventHandler<MouseEventArgs> eHandler = (sender, e) => {
                //1.检测一端口固件
                var localFileList = IO.FileUtils.ReadFiles ();
                var gateWayList = localFileList.FindAll ((obj) => {
                    return (obj.StartsWith ("Equipment_")) && (
                     obj.Split ('_') [1].ToString () == DeviceType.OnePortBus.ToString () ||
                        obj.Split ('_') [1].ToString () == DeviceType.RCU.ToString () ||
                        obj.Split ('_') [1].ToString () == DeviceType.OnePortWirelessFR.ToString ());
                });
                List<string> linkList = new List<string> ();
                GatewayBase common = null;
                string gateWayString = "";
                if (gateWayList.Count > 0) {
                    foreach (var gatewayFileName in gateWayList) {
                        var tempStrings = gatewayFileName.Split ('_');
                        if (tempStrings [1].ToString () == DeviceType.OnePortBus.ToString () || tempStrings [1].ToString () == DeviceType.RCU.ToString () ||
                            tempStrings [1].ToString () == DeviceType.OnePortWirelessFR.ToString ()) {
                            gateWayString = CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (gatewayFileName));
                            common = Newtonsoft.Json.JsonConvert.DeserializeObject<GatewayBase> (gateWayString);
                            for (int i = 0; i < 7; i++) {
                                Control.ControlBytesSend (Command.enjoyUpgrade, common.SubnetID, common.DeviceID, new byte [] { });
                            }
                            break;//只升级一个
             System.IO.FileStream fs = null;
                byte [] buffer = new byte [4 * 1024];
                List<byte> bbb = new List<byte> ();
                System.IO.Stream stream = Shared.Application.Activity.Assets.Open ("FW_MCIP-L1_RF.01_V03.01_210712_STM32F107VCT6_U2_india_beta.bin");
                int length = 0;
                try {
                    while ((length = stream.Read (buffer, 0, buffer.Length)) != 0) {
                        for (int i = 0; i < length; i++) {
                            bbb.Add (buffer [i]);
                        }
                    }
                } else {
                    //没有网关
                } catch {
                } finally {
                    stream.Close ();
                }
                string status = "";
                    return;
                }
                Control.ControlBytesSend (Command.enjoyUpgrade2, common.SubnetID, common.DeviceID, new byte [] { });
                //2.进入网关升级模式
                //3.接收升级文件获取请求
                //迁移账号
                #region 弹窗输入密码确认迁移
                #region 弹窗
                Dialog dialog = new Dialog ();
                FrameLayout dialogBodyView = new FrameLayout () {
@@ -351,12 +332,80 @@
                        dicAccount.Add ("appCode", "HDL-HOME-IND-APP");
                        dicAccount.Add ("pwd", etBackupRemark.Text.Trim());
                        dicAccount.Add ("tenantId", "202106");
                        var revertObj = MainPage.RequestHttps ("/home-wisdom/data/move/home/save", requestJson, false,false, $"https://test-gz.hdlcontrol.com");
                        //var revertObj = MainPage.RequestHttps ("/home-wisdom/data/move/home/save", requestJson, false,false, $"https://test-gz.hdlcontrol.com");
                    } else {
                    }
                };
                dialog.Show ();
                if (MainPage.WiFiStatus != "CrabtreeAdd/WiFi.png") {
                    //status = btnSave.Text = "ReCheck";
                    btnTipMsg.Text = "请在局域网内连接网关设备";
                    etBackupRemark.Visible = false;
                    btnSave.MouseUpEventHandler = (sender2, e2) => {
                        dialog.Close ();
                    };
                } else {
                    //1.检测一端口固件
                    var localFileList = IO.FileUtils.ReadFiles ();
                    var gateWayList = localFileList.FindAll ((obj) => {
                        return (obj.StartsWith ("Equipment_")) && (
                         obj.Split ('_') [1].ToString () == DeviceType.OnePortBus.ToString () ||
                            obj.Split ('_') [1].ToString () == DeviceType.RCU.ToString () ||
                            obj.Split ('_') [1].ToString () == DeviceType.OnePortWirelessFR.ToString ());
                    });
                    List<string> linkList = new List<string> ();
                    GatewayBase common = null;
                    string gateWayString = "";
                    if (gateWayList.Count > 0) {
                        foreach (var gatewayFileName in gateWayList) {
                            var tempStrings = gatewayFileName.Split ('_');
                            if (tempStrings [1].ToString () == DeviceType.OnePortBus.ToString () || tempStrings [1].ToString () == DeviceType.RCU.ToString () ||
                                tempStrings [1].ToString () == DeviceType.OnePortWirelessFR.ToString ()) {
                                gateWayString = CommonPage.MyEncodingUTF8.GetString (IO.FileUtils.ReadFile (gatewayFileName));
                                common = Newtonsoft.Json.JsonConvert.DeserializeObject<GatewayBase> (gateWayString);
                                var bytes = Control.ControlBytesSendHasReturn (Command.readGatewayVision, common.SubnetID, common.DeviceID, new byte [] { });
                                var visionString = Encoding.GetEncoding ("gb2312").GetString (bytes);
                                if (visionString == "FW_MCIP-L1_RF.01_V03.01_210712_STM32F107VCT6_U2_india_beta") {
                                    //已经升级过的
                                    btnTipMsg.Text = "网关设备已经满足迁移条件";
                                    btnSave.Text = "下一步";
                                    btnSave.MouseUpEventHandler = (sender3, e3) => {
                                        btnTipMsg.Text = "请输入账号密码,确认迁移";
                                        btnSave.Text = "Confirm";
                                    };
                                } else {
                                    //需要升级一端口
                                    for (int i = 0; i < 7; i++) {
                                        Control.ControlBytesSend (Command.enjoyUpgrade, common.SubnetID, common.DeviceID, new byte [] { });
                                    }
                                }
                                break;//只升级一个
                            }
                        }
                    } else {
                        //没有网关
                        return;
                    }
                    Control.ControlBytesSend (Command.enjoyUpgrade2, common.SubnetID, common.DeviceID, new byte [] { });
                }
                //2.进入网关升级模式
                //3.接收升级文件获取请求
                //迁移账号
                #endregion
@@ -368,12 +417,15 @@
                dic.Add ("userId", MainPage.LoginUser.ID);
                dic.Add ("homeType", "BUSPRO");
                dic.Add ("tenantId", "202106");
                requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (dic);
                revertObj = MainPage.RequestHttps ("/home-wisdom/data/move/home/save", requestJson, false,false, $"https://test-gz.hdlcontrol.com");
                //requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (dic);
                //revertObj = MainPage.RequestHttps ("/home-wisdom/data/move/home/save", requestJson, false,false, $"https://test-gz.hdlcontrol.com");
            };
            moveToNewCloudView.MouseUpEventHandler += eHandler;
            btnTitle.MouseUpEventHandler += eHandler;
            btnRight.MouseUpEventHandler += eHandler;
            Button btnLine = new Button () {
                Height = Application.GetRealHeight (5),