New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | | namespace Shared.Phone |
| | | { |
| | | /// <summary> |
| | | /// 成员的逻辑业务 |
| | | /// </summary> |
| | | public class HdlMemberLogic |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 本地安防数据 |
| | | /// </summary> |
| | | private static HdlMemberLogic m_Current = null; |
| | | /// <summary> |
| | | /// 本地安防数据 |
| | | /// </summary> |
| | | public static HdlMemberLogic Current |
| | | { |
| | | get |
| | | { |
| | | if (m_Current == null) |
| | | { |
| | | m_Current = new HdlMemberLogic(); |
| | | } |
| | | return m_Current; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 成员列表___________________________ |
| | | |
| | | /// <summary> |
| | | /// 获取成员列表信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<MemberInfoRes> GetMemberListInfo(ShowNetCodeMode mode = ShowNetCodeMode.No) |
| | | { |
| | | var pra = new { homeId = Common.Config.Instance.Home.Id }; |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/app/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<List<MemberInfoRes>>(result.Data.ToString()); |
| | | |
| | | var listCheck = new List<string>(); |
| | | var listShowInfo = new List<MemberInfoRes>(); |
| | | 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 ■ 成员权限___________________________ |
| | | |
| | | /// <summary> |
| | | /// 设置远程操作权限 |
| | | /// </summary> |
| | | /// <param name="i_childAccountId">子账号的主键</param> |
| | | /// <param name="i_statu">true:可以远程操作 false:不可以远程操作</param> |
| | | /// <param name="mode">失败时是否显示tip消息</param> |
| | | /// <returns></returns> |
| | | 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/app/child/account/update", RestSharp.Method.POST, pra, null, null, CheckMode.A账号权限); |
| | | //检测状态码 |
| | | if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false) |
| | | { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 编辑成员的权限 |
| | | /// </summary> |
| | | /// <param name="i_childAccountId">子账号的主键</param> |
| | | /// <param name="i_authorityNo">1:普通成员 3:管理员</param> |
| | | /// <returns></returns> |
| | | 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/app/child/account/update", RestSharp.Method.POST, pra); |
| | | //检测状态码 |
| | | if (HdlCheckLogic.Current.CheckNetCode(result, ShowNetCodeMode.YES) == false) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 删除成员___________________________ |
| | | |
| | | /// <summary> |
| | | /// 删除成员 |
| | | /// </summary> |
| | | /// <param name="i_childAccountId">子账号的主键</param> |
| | | /// <param name="mode">失败时是否显示tip消息</param> |
| | | /// <returns></returns> |
| | | 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/app/child/account/delete", RestSharp.Method.POST, pra, null, null, CheckMode.A账号权限); |
| | | //检测状态码 |
| | | if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false) |
| | | { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 添加成员___________________________ |
| | | |
| | | /// <summary> |
| | | /// 添加成员 |
| | | /// </summary> |
| | | /// <param name="i_account">子账号的Phone或者Email</param> |
| | | /// <param name="i_nickName">备注子账号的昵称</param> |
| | | /// <param name="mode">失败时是否显示tip消息</param> |
| | | /// <returns></returns> |
| | | 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/app/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<MemberInfoRes>(result.Data.ToString()); |
| | | |
| | | return info; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 搜索账号___________________________ |
| | | |
| | | /// <summary> |
| | | /// 根据账号,检索账号的基本信息 |
| | | /// </summary> |
| | | /// <param name="i_account">邮箱或者手机号</param> |
| | | /// <returns></returns> |
| | | 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<AccountInfoResult>(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 |
| | | } |
| | | } |