using System; using System.Collections.Generic; using System.Text; namespace Shared.Phone { /// /// 成员的逻辑业务 /// public class HdlMemberLogic { #region ■ 变量声明___________________________ /// /// 本地安防数据 /// private static HdlMemberLogic m_Current = null; /// /// 本地安防数据 /// public static HdlMemberLogic Current { get { if (m_Current == null) { m_Current = new HdlMemberLogic(); } return m_Current; } } #endregion #region ■ 成员列表___________________________ /// /// 获取成员列表信息 /// /// public List GetMemberListInfo(ShowNetCodeMode mode = ShowNetCodeMode.No) { var pra = new { homeId = Common.Config.Instance.Home.Id }; var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/child/account/findAll", RestSharp.Method.POST, pra, null, null, CheckMode.A账号权限); //检测状态码 if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false) { return null; } var listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject>(result.Data.ToString()); var listCheck = new List(); var listShowInfo = new List(); foreach (MemberInfoRes infoRes in listInfo) { if (listCheck.Contains(infoRes.ChildAccountId) == true || infoRes.Account == HdlUserCenterResourse.UserInfo.UserPhone || infoRes.Account == HdlUserCenterResourse.UserInfo.UserEmail) { //如果是它自己的话,不显示 continue; } if (infoRes.ChildAccountType == "ADMIN") { infoRes.AccountType = 1; } if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1 && infoRes.AccountType != 0) { //不能够获取权限等级比他高的(主人自己可以无视这个判断) continue; } listCheck.Add(infoRes.ChildAccountId); //添加成员信息的缓存 listShowInfo.Add(infoRes); } return listShowInfo; } #endregion #region ■ 成员权限___________________________ /// /// 设置远程操作权限 /// /// 子账号的主键 /// true:可以远程操作 false:不可以远程操作 /// 失败时是否显示tip消息 /// public bool SetRemoteOperationPermissions(string i_childAccountId, bool i_statu, ShowNetCodeMode mode = ShowNetCodeMode.YES) { var pra = new { childAccountId = i_childAccountId, homeId = Common.Config.Instance.Home.Id, isRemoteControl = i_statu }; var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/child/account/update", RestSharp.Method.POST, pra, null, null, CheckMode.A账号权限); //检测状态码 if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false) { return false; } return true; } /// /// 编辑成员的权限 /// /// 子账号的主键 /// 1:普通成员 3:管理员 /// public bool EditorMemberAuthority(string i_childAccountId, int i_authorityNo) { string authorityDiv = i_authorityNo == 3 ? "ADMIN" : "ORDINARY"; var pra = new { homeId = Common.Config.Instance.Home.Id, childAccountId = i_childAccountId, childAccountType = authorityDiv }; var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/child/account/update", RestSharp.Method.POST, pra); //检测状态码 if (HdlCheckLogic.Current.CheckNetCode(result, ShowNetCodeMode.YES) == false) { return false; } return true; } #endregion #region ■ 删除成员___________________________ /// /// 删除成员 /// /// 子账号的主键 /// 失败时是否显示tip消息 /// public bool DeleteMember(string i_childAccountId, ShowNetCodeMode mode = ShowNetCodeMode.YES) { var pra = new { childAccountId = i_childAccountId, homeId = Common.Config.Instance.Home.Id }; var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/child/account/delete", RestSharp.Method.POST, pra, null, null, CheckMode.A账号权限); //检测状态码 if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false) { return false; } return true; } #endregion #region ■ 添加成员___________________________ /// /// 添加成员 /// /// 子账号的Phone或者Email /// 备注子账号的昵称 /// 失败时是否显示tip消息 /// public MemberInfoRes AddMember(string i_account, string i_nickName, ShowNetCodeMode mode = ShowNetCodeMode.YES) { var pra = new { account = i_account, childAccountType = "ORDINARY", homeId = Common.Config.Instance.Home.Id, isRemoteControl = true, nickName = i_nickName }; var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/child/account/add", RestSharp.Method.POST, pra, null, null, CheckMode.A账号权限, false, 3, true); //检测状态码 if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false) { return null; } var info = Newtonsoft.Json.JsonConvert.DeserializeObject(result.Data.ToString()); return info; } #endregion #region ■ 搜索账号___________________________ /// /// 根据账号,检索账号的基本信息 /// /// 邮箱或者手机号 /// public AccountInfoResult SearchNormalInfoByAccount(string i_account) { var pra = new { account = i_account }; var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/member/memberInfo/getMemberInfoByAccount", RestSharp.Method.POST, pra, null, null, CheckMode.A不检测, false, 3, true); if (result == null) { //网关连接失败,请确认网络 HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uGatewayIsNotLinkAndCheckNetwork)); return null; } if (result.Code == HttpMessageEnum.A10010) { //账号不存在 return new AccountInfoResult(); } var info = Newtonsoft.Json.JsonConvert.DeserializeObject(result.Data.ToString()); info.Account = i_account; if (info.MemberName == string.Empty) { info.MemberName = info.Account; } //下载头像 info.HeadImage = HdlAccountLogic.Current.DownLoadAccountPictrue(i_account); return info; } #endregion } }