public static UserInfoModel GetAssociatedUsersByLoginName(string loginName) { var args = new AssociatedUsersGetByLoginNameArgs { LoginName = loginName }; var options = AssociatedUsersGetByLoginNameOptions.Default; var result = AccountService.Instance.GetAssociatedUsersByLoginName(args, options); if (result.Ok) { var user = result.State[0]; return(new UserInfoModel() { TenantId = user.TenantId, UserId = user.UserId }); } return(null); }
/// <summary> /// 根据userName获取员工Id /// </summary> /// <param name="userName"></param> /// <returns></returns> public Dictionary <int, int> GetByUserName(string userName) { var users = new Dictionary <int, int>(); var args = new AssociatedUsersGetByLoginNameArgs { LoginName = userName }; try { var provider = AccountService.Instance; //var provider = PlatformServiceFactory<IAccountProvider>.Instance(); if (provider == null) { AppConnectLogHelper.Error(new ESBServiceNotFoundException("UserFramework ESB Service Is null")); return(null); } var result = provider.GetAssociatedUsersByLoginName(args); if (!result.Ok) { throw new UserOperateException(string.Format("Message:{0}", result.Error.Message)); } if (result.State != null && result.State.Count() > 0) { result.State.ToList().ForEach(item => users.Add(item.UserId, item.TenantId)); } return(users); } catch (System.Exception ex) { AppConnectLogHelper.Error(ex.Message, new UserOperateException(string.Format("根据UserName获取用户信息失败,接口:AccountService.Instance.GetAssociatedUsersByLoginName,参数:userName{0}" , userName), ex)); return(null); } }