HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-12-31 fe3b2466c68b5db70d38e78039703add3b8b1dfe
ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListMainForm.cs
@@ -18,7 +18,7 @@
        /// <summary>
        /// 住宅数据(有网时使用)
        /// </summary>
        private Dictionary<string, ResidenceInformation> dicResidenceData = null;
        private Dictionary<string, Common.ResponseEntity.ResidenceObj> dicResidenceData = null;
        /// <summary>
        /// 住宅数据(无网时使用)
        /// </summary>
@@ -123,11 +123,16 @@
        private bool SetResidenceInfoByOnline()
        {
            //获取住宅信息
            var listHouse = HdlResidenceLogic.Current.GetHomeListsFromDb(ShowNetCodeMode.No);
            if (listHouse == null)
            var Pra = new GetResidenceInfoPra();
            string resultData = UserCenterLogic.GetResponseDataByRequestHttps("App/GetHomePager", false, Pra, new List<string> { "NotCheck" }, false);
            if (string.IsNullOrEmpty(resultData) == true)
            {
                return false;
            }
            var pageData = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.ResidenceRes>(resultData);
            //排序住宅
            var listHouse = HdlResidenceLogic.Current.SortHouse(pageData.PageData);
            HdlThreadLogic.Current.RunMain(() =>
            {
                if (this.Parent == null)
@@ -136,7 +141,7 @@
                }
                listView.Height = bodyFrameLayout.Height;
                this.dicResidenceData = new Dictionary<string, ResidenceInformation>();
                this.dicResidenceData = new Dictionary<string, Common.ResponseEntity.ResidenceObj>();
                for (int i = 0; i < listHouse.Count; i++)
                {
                    var info = listHouse[i];
@@ -156,7 +161,7 @@
        /// 添加住宅的行(有网情况)
        /// </summary>
        /// <param name="info"></param>
        private void AddRowLayoutByOnline(ResidenceInformation info, bool addLine)
        private void AddRowLayoutByOnline(Common.ResponseEntity.ResidenceObj info, bool addLine)
        {
            var rowLayout = new RowLayoutControl(listView.rowSpace / 2);
            this.listView.AddChidren(rowLayout);
@@ -169,7 +174,7 @@
            if (info.Id == Config.Instance.Home.Id)
            {
                //住宅名称
                btnHome = rowLayout.frameTable.AddLeftCaption(info.HomeName, 800, 60, true);
                btnHome = rowLayout.frameTable.AddLeftCaption(info.Name, 800, 60, true);
                btnHome.TextSize = 15;
                btnHome.Y = Application.GetRealHeight(12) + rowLayout.chidrenYaxis;
                rowLayout.frameTable.AddChidren(btnHome, ChidrenBindMode.BindEvent);
@@ -184,7 +189,7 @@
            else
            {
                //住宅名称
                btnHome = rowLayout.frameTable.AddLeftCaption(info.HomeName, 800, true);
                btnHome = rowLayout.frameTable.AddLeftCaption(info.Name, 800, true);
                btnHome.TextSize = 15;
            }
            //右箭头
@@ -203,7 +208,7 @@
                    string msg = Language.StringByID(R.MyInternationalizationString.uSwitchResidenceMsg);
                    if (msg.Contains("{0}") == true)
                    {
                        msg = string.Format(msg, info.HomeName);
                        msg = string.Format(msg, info.Name);
                    }
                    this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                    {
@@ -240,7 +245,7 @@
                }
            };
            if (info.IsOtherShare == true)
            if (info.IsOthreShare == true)
            {
                //分享的,不能更改
                return;
@@ -411,9 +416,9 @@
        /// </summary>
        /// <param name="info">有网时使用</param>
        /// <param name="i_house">无网时适用</param>
        private void ShowEditorNameForm(ResidenceInformation info, House i_house, NormalViewControl btnHome)
        private void ShowEditorNameForm(Common.ResponseEntity.ResidenceObj info, House i_house, NormalViewControl btnHome)
        {
            string oldName = info != null ? info.HomeName : i_house.Name;
            string oldName = info != null ? info.Name : i_house.Name;
            //生成一个弹窗画面
            var dialogForm = new DialogInputControl();
            //编辑住宅
@@ -452,7 +457,7 @@
                            return;
                        }
                        //刷新内存的住宅名
                        HdlResidenceLogic.Current.EditorHouseByHouseId(i_house.Id, textValue, null, null);
                        HdlResidenceLogic.Current.EditorHouseByHouseId(i_house.Id, textValue);
                        //更改显示的名字
                        btnHome.Text = textValue;
                    }
@@ -466,7 +471,7 @@
        /// <param name="ResidenceName"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        private void EditorResidenceName(string ResidenceName, ResidenceInformation info, NormalViewControl btnHome)
        private void EditorResidenceName(string ResidenceName, Common.ResponseEntity.ResidenceObj info, NormalViewControl btnHome)
        {
            //检测能否保存住宅
            if (this.CheckIsCanSaveResidence(info.Id, ResidenceName, true) == false)
@@ -476,7 +481,7 @@
            //开启进度条
            this.ShowProgressBar();
            var result = HdlResidenceLogic.Current.EditorResidenceName(info.Id, ResidenceName, null, null);
            var result = HdlResidenceLogic.Current.EditorResidenceName(info.Id, ResidenceName);
            //关闭进度条
            this.CloseProgressBar();
@@ -486,10 +491,10 @@
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //刷新内存的住宅名
                    HdlResidenceLogic.Current.EditorHouseByHouseId(info.Id, ResidenceName, null, null);
                    HdlResidenceLogic.Current.EditorHouseByHouseId(info.Id, ResidenceName);
                    //更改显示的名字
                    btnHome.Text = ResidenceName;
                    info.HomeName = ResidenceName;
                    info.Name = ResidenceName;
                });
            }
        }
@@ -545,19 +550,28 @@
            //开启进度条
            this.ShowProgressBar();
            //创建住宅
            var newId = HdlResidenceLogic.Current.CreatNewResidence(ResidenceName, null, null);
            this.CloseProgressBar();
            if (newId != null)
            var Pra = new AddResidencePra();
            Pra.Name = ResidenceName;
            //添加住宅
            string resultData = UserCenterLogic.GetResponseDataByRequestHttps("App/AddHome", false, Pra);
            if (string.IsNullOrEmpty(resultData) == true)
            {
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //重新刷新列表
                    this.listView.RemoveAll();
                    this.SetResidenceInfo(2);
                });
                //关闭进度条
                this.CloseProgressBar();
                return;
            }
            var newInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<NewResidenceInfo>>(resultData);
            HdlResidenceLogic.Current.AddHouseToMemmory(newInfo[0].Id, ResidenceName);
            HdlThreadLogic.Current.RunMain(() =>
            {
                //重新刷新列表
                this.listView.RemoveAll();
                this.SetResidenceInfo(2);
            });
        }
        #endregion
@@ -576,13 +590,13 @@
                var result2 = HdlGatewayLogic.Current.ResetComandToBindBackupGateway();
                if (result2 == false)
                {
                    //绑定网关失败,请重新操作
                    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uBindGatewayFailPleaseDoAgain));
                    //临时这么写,新云端就会写到R文件了
                    this.ShowMassage(ShowMsgType.Tip, "绑定网关失败,请重新操作");
                    this.CloseProgressBar();
                    return;
                }
                //检测它有没有备份
                var listBack = HdlBackupLogic.Current.GetBackupListNameFromDB(BackUpMode.A手动备份);
                var listBack = HdlBackupLogic.Current.GetBackupListNameFromDB();
                this.CloseProgressBar();
                if (listBack == null)
@@ -612,7 +626,7 @@
                             HdlThreadLogic.Current.RunThread(() =>
                             {
                                 //创建一个备份名字
                                 string backupClassId = HdlBackupLogic.Current.CreatNewBackupNameToDB(textValue, BackUpMode.A手动备份);
                                 string backupClassId = HdlBackupLogic.Current.CreatNewBackupNameToDB(textValue);
                                 if (backupClassId == null)
                                 {
                                     //创建备份名字失败
@@ -656,7 +670,7 @@
        /// 检测本地有没有这个住宅
        /// </summary>
        /// <param name="info"></param>
        private void CheckIsExsitResidence(ResidenceInformation info)
        private void CheckIsExsitResidence(Common.ResponseEntity.ResidenceObj info)
        {
            var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, info.Id);
            bool isExsit = System.IO.Directory.Exists(path);
@@ -666,9 +680,10 @@
            //创建新的住宅
            var house = new House();
            house.Id = info.Id;
            house.Name = info.HomeName;
            house.IsOtherShare = info.IsOtherShare;
            house.AccountType = info.AccountType == "ADMIN" ? 1 : 0;
            house.Name = info.Name;
            house.IsOthreShare = info.IsOthreShare;
            house.AccountType = info.AccountType;
            house.MainUserDistributedMark = info.MainUserDistributedMark;
            house.Longitude = info.Longitude;
            house.Latitude = info.Latitude;
            house.Save(false);
@@ -686,14 +701,14 @@
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        private bool CheckIsCanDeleteResidence(ResidenceInformation info)
        private bool CheckIsCanDeleteResidence(Common.ResponseEntity.ResidenceObj info)
        {
            if (info.IsOtherShare == false)
            if (info.IsOthreShare == false)
            {
                int myCount = 0;
                foreach (var data in this.dicResidenceData.Values)
                {
                    if (data.IsOtherShare == false)
                    if (data.IsOthreShare == false)
                    {
                        myCount++;
                    }
@@ -751,12 +766,12 @@
                //住宅名字重复检测
                foreach (string strId in this.dicResidenceData.Keys)
                {
                    if (this.dicResidenceData[strId].IsOtherShare == true)
                    if (this.dicResidenceData[strId].IsOthreShare == true)
                    {
                        //分享的住宅不考虑
                        continue;
                    }
                    if (residenceId != strId && residenceName == this.dicResidenceData[strId].HomeName)
                    if (residenceId != strId && residenceName == this.dicResidenceData[strId].Name)
                    {
                        //住宅名字已经存在
                        int msgId = isEditor == true ? R.MyInternationalizationString.EditZigbeeHome_Exist : R.MyInternationalizationString.AddZigbeeHome_Exist;
@@ -770,7 +785,7 @@
            {
                foreach (var myHouse in this.listLocalHouse)
                {
                    if (myHouse.IsOtherShare == true)
                    if (myHouse.IsOthreShare == true)
                    {
                        //分享的住宅不考虑
                        continue;