HDL Home App 第二版本 旧平台金堂用 正在使用
黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Member/MemberListForm.cs
@@ -54,7 +54,10 @@
                            return;
                        }
                        //搜索ID
                        this.SearchMemberInfo(qrCode);
                        HdlThreadLogic.Current.RunThread(() =>
                        {
                            this.SearchMemberInfo(qrCode);
                        });
                    }, 
                    Language.StringByID(R.MyInternationalizationString.uCancel),
                    Language.StringByID(R.MyInternationalizationString.uFlashlamp),
@@ -105,10 +108,10 @@
            //用户图标
            var btnUserIcon = new ImageView();
            btnUserIcon.Height = Application.GetMinRealAverage(207);
            btnUserIcon.Width = Application.GetMinRealAverage(207);
            btnUserIcon.Radius = (uint)Application.GetMinRealAverage(207) / 2;
            btnUserIcon.ImagePath = UserCenterResourse.UserInfo.UserIconFile;
            btnUserIcon.Height = this.GetPictrueRealSize(207);
            btnUserIcon.Width = this.GetPictrueRealSize(207);
            btnUserIcon.Radius = (uint)this.GetPictrueRealSize(207) / 2;
            btnUserIcon.ImagePath = HdlFileNameResourse.UserHeadIconFile;
            btnUserIcon.Y = Application.GetRealHeight(46);
            btnUserIcon.Gravity = Gravity.CenterHorizontal;
            frameBack.AddChidren(btnUserIcon);
@@ -118,7 +121,7 @@
            btnName.TextAlignment = TextAlignment.Center;
            btnName.Y = btnUserIcon.Bottom + Application.GetRealHeight(20);
            btnName.TextSize = 16;
            btnName.Text = UserCenterResourse.UserInfo.UserName; ;
            btnName.Text = HdlUserCenterResourse.UserInfo.NickName; ;
            frameBack.AddChidren(btnName);
            //身份
@@ -126,8 +129,8 @@
            btnAuthority.TextAlignment = TextAlignment.Center;
            btnAuthority.Y = btnName.Bottom + Application.GetRealHeight(10);
            btnAuthority.TextSize = 12;
            btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor;
            btnAuthority.Text = UserCenterResourse.UserInfo.AuthorityText;
            btnAuthority.TextColor = UserCenterColor.Current.TextGrayColor1;
            btnAuthority.Text = HdlUserCenterResourse.ResidenceOption.AuthorityText;
            frameBack.AddChidren(btnAuthority);
        }
@@ -142,7 +145,7 @@
        {
            //标题:成员列表
            var btnMenberTile = new NormalViewControl(800, 60, true);
            btnMenberTile.X = ControlCommonResourse.XXLeft;
            btnMenberTile.X = HdlControlResourse.XXLeft;
            btnMenberTile.Y = Application.GetRealHeight(480);
            btnMenberTile.TextColor = UserCenterColor.Current.TextColor1;
            btnMenberTile.TextID = R.MyInternationalizationString.MenberList;
@@ -165,7 +168,7 @@
            HdlThreadLogic.Current.RunThread(() =>
            {
                //总之先清空共享文件夹准没错
                HdlShardLogic.Current.ClearShardDirectory();
                HdlShardLogic.Current.Dispone();
                //初始化成员列表
                this.InitMemberList();
            });
@@ -174,28 +177,13 @@
        /// <summary>
        /// 初始化成员列表
        /// </summary>
        private async void InitMemberList()
        private void InitMemberList()
        {
            //开启进度条
            this.ShowProgressBar();
            var pra = new MemberListInfoPra();
            string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra);
            if (result == null)
            {
                //关闭进度条
                this.CloseProgressBar(ShowReLoadMode.YES);
                return;
            }
            if (this.Parent == null)
            {
                //关闭进度条
                this.CloseProgressBar();
                return;
            }
            List<MemberInfoRes> listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MemberInfoRes>>(result);
            if (listInfo == null)
            var listShowInfo = HdlMemberLogic.Current.GetMemberListInfo();
            if (listShowInfo == null)
            {
                //关闭进度条
                this.CloseProgressBar(ShowReLoadMode.YES);
@@ -204,53 +192,26 @@
            //关闭进度条
            this.CloseProgressBar();
            //先清空成员列表信息
            UserCenterResourse.ListMemberInfo.Clear();
            List<string> listCheck = new List<string>();
            foreach (MemberInfoRes infoRes in listInfo)
            {
                if (listCheck.Contains(infoRes.DistributedMark) == true
                    || infoRes.Account == UserCenterResourse.UserInfo.Phone
                    || infoRes.Account == UserCenterResourse.UserInfo.Email)
                {
                    //如果是它自己的话,不显示
                    continue;
                }
                if (UserCenterResourse.UserInfo.AuthorityNo != 1 && infoRes.AccountType != 0)
                {
                    //不能够获取权限等级比他高的(主人自己可以无视这个判断)
                    continue;
                }
                listCheck.Add(infoRes.DistributedMark);
                //添加成员信息的缓存
                UserCenterResourse.ListMemberInfo.Add(infoRes);
            }
            listInfo.Clear();
            //保存成员信息的缓存到本地文件
            UserCenterLogic.SaveLocalMemberListInfo();
            if (UserCenterResourse.ListMemberInfo.Count == 0)
            if (listShowInfo.Count == 0)
            {
                return;
            }
            HdlThreadLogic.Current.RunMain(() =>
            {
                //添加成员列表
                this.AddMemberListRowByData();
                this.AddMemberListRowByData(listShowInfo);
            });
        }
        /// <summary>
        /// 添加成员列表
        /// </summary>
        private void AddMemberListRowByData()
        private void AddMemberListRowByData(List<MemberInfoRes> listNewInfo)
        {
            if (this.Parent == null)
            {
                return;
            }
            var listNewInfo = UserCenterResourse.ListMemberInfo;
            int count = listNewInfo.Count - 1;
            for (int i = 0; i < listNewInfo.Count; i++)
@@ -281,13 +242,13 @@
            listView.AddChidren(rowlayout);
            //成员头像图标
            string iconPath = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, info.DistributedMark + ".png");
            string iconPath = System.IO.Path.Combine(HdlFileNameResourse.UserPictrueDirectory, info.ChildAccountId + ".png");
            var btnIcon = new ImageView();
            btnIcon.X = ControlCommonResourse.XXLeft;
            btnIcon.X = HdlControlResourse.XXLeft;
            btnIcon.Gravity = Gravity.CenterVertical;
            btnIcon.Height = Application.GetMinRealAverage(115);
            btnIcon.Width = Application.GetMinRealAverage(115);
            btnIcon.Radius = (uint)Application.GetMinRealAverage(115) / 2;
            btnIcon.Height = this.GetPictrueRealSize(115);
            btnIcon.Width = this.GetPictrueRealSize(115);
            btnIcon.Radius = (uint)this.GetPictrueRealSize(115) / 2;
            if (System.IO.File.Exists(iconPath) == true)
            {
                btnIcon.ImagePath = iconPath;
@@ -295,15 +256,15 @@
            else
            {
                btnIcon.ImagePath = "Center/Admin.png";
                this.dicIconControl[info.DistributedMark] = btnIcon;
                this.dicMemberAccount[info.DistributedMark] = info.Account;
                this.dicIconControl[info.ChildAccountId] = btnIcon;
                this.dicMemberAccount[info.ChildAccountId] = info.Account;
            }
            rowlayout.AddChidren(btnIcon);
            //成员昵称
            string memberName = string.IsNullOrEmpty(info.UserName) == true ? info.Account : info.UserName;
            string memberName = info.ShowName;
            var btnName = rowlayout.AddLeftCaption(memberName, 600, true);
            btnName.X = ControlCommonResourse.XXLeft + btnIcon.Height + Application.GetRealWidth(35);
            btnName.X = HdlControlResourse.XXLeft + btnIcon.Height + Application.GetRealWidth(35);
            btnName.TextSize = 15;
            rowlayout.AddChidren(btnName);
@@ -321,6 +282,23 @@
            };
        }
        /// <summary>
        /// 添加成员行(外部调用)
        /// </summary>
        /// <param name="info"></param>
        public void AddRowLayoutByOtherForm(MemberInfoRes info)
        {
            var myRow = listView.GetChildren(listView.ChildrenCount - 1);
            if (myRow != null)
            {
                //最后一行加底线
                ((FrameRowControl)myRow).AddBottomLine();
            }
            this.AddRowLayout(info, false);
            //调整列表控件的高度
            listView.AdjustRealHeight(Application.GetRealHeight(23));
        }
        #endregion
        #region ■ 获取成员头像_______________________
@@ -334,32 +312,20 @@
            {
                return;
            }
            HdlThreadLogic.Current.RunThread(async () =>
            HdlThreadLogic.Current.RunThread(() =>
            {
                var pra = new AccountInfoPra();
                foreach (var keys in dicMemberAccount.Keys)
                {
                    if (this.Parent == null)
                    {
                        return;
                    }
                    pra.Account = dicMemberAccount[keys];
                    var result = await UserCenterLogic.GetByteResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", false, pra, new List<string>() { "NotSetAgain" });
                    if (result == null)
                    {
                        continue;
                    }
                    var revertObj = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.ResponsePack>(System.Text.Encoding.UTF8.GetString(result));
                    if (revertObj == null || revertObj.ResponseData == null)
                    {
                        continue;
                    }
                    var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountInfoResult>(revertObj.ResponseData.ToString());
                    if (infoResult.HeadImage != null)
                    var imageData = HdlAccountLogic.Current.DownLoadAccountPictrue(dicMemberAccount[keys]);
                    if (imageData != null && imageData.Length > 0)
                    {
                        //写入头像内容
                        string iconPath = System.IO.Path.Combine(UserCenterResourse.Option.UserPictruePath, keys + ".png");
                        Shared.IO.FileUtils.WriteFileByBytes(iconPath, infoResult.HeadImage);
                        string iconPath = System.IO.Path.Combine(HdlFileNameResourse.UserPictrueDirectory, keys + ".png");
                        Shared.IO.FileUtils.WriteFileByBytes(iconPath, imageData);
                        HdlThreadLogic.Current.RunMain(() =>
                        {
                            dicIconControl[keys].ImageBytes = Shared.IO.FileUtils.ReadFile(iconPath);
@@ -374,7 +340,7 @@
        #region ■ 删除指定行_________________________
        /// <summary>
        /// 删除指定行
        /// 删除指定行(外部调用)
        /// </summary>
        /// <param name="accountId"></param>
        public void DeleteRowByAccount(string accountId)
@@ -389,6 +355,9 @@
                if (row.MainKeys == accountId)
                {
                    row.RemoveFromParent();
                    //调整列表控件的高度
                    listView.AdjustRealHeight(Application.GetRealHeight(23));
                    break;
                }
            }
@@ -403,31 +372,34 @@
        /// </summary>
        /// <param name="accountId">成员ID</param>
        /// <param name="txtMsg">信息控件</param>
        private async void SearchMemberInfo(string accountId)
        private void SearchMemberInfo(string accountId)
        {
            var pra = new AccountInfoPra();
            pra.Account = accountId;
            string result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountInfo", false, pra, new List<string>() { "AccountNoExists" });
            //开启进度条
            this.ShowProgressBar();
            var result = HdlMemberLogic.Current.SearchNormalInfoByAccount(accountId);
            //关闭进度条
            this.CloseProgressBar();
            if (result == null)
            {
                //异常
                return;
            }
            if (result == string.Empty)
            if (result.Account == string.Empty)
            {
                //成员不存在
                var form = new MemberNotEsixtForm();
                form.AddForm();
                HdlThreadLogic.Current.RunMain(() =>
                {
                    //成员不存在
                    var form = new MemberNotEsixtForm();
                    form.AddForm(Language.StringByID(R.MyInternationalizationString.uMemberInformation));
                });
                return;
            }
            var infoResult = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountInfoResult>(result);
            infoResult.Account = accountId;
            Application.RunOnMainThread(() =>
            HdlThreadLogic.Current.RunMain(() =>
            {
                var form = new AddMemberInfoForm();
                form.AddForm(infoResult);
                form.AddForm(result);
            });
        }
@@ -441,13 +413,7 @@
        public override int FormActionAgainEvent()
        {
            //清空共享文件夹
            HdlShardLogic.Current.ClearShardDirectory();
            this.listView.RemoveAll();
            listView.Height = bodyFrameLayout.Height - Application.GetRealHeight(567);
            //添加成员列表
            this.AddMemberListRowByData();
            HdlShardLogic.Current.Dispone();
            return 1;
        }