Ejemplo n.º 1
0
        private async Task <List <SystemUserEntity> > GetUserEntityByUserCodeAsync(string userCode)
        {
            List <SystemUserEntity> userQuery = null;

            try
            {
                var userInfo = _ISystemUserRepository.FirstOrDefault(s => s.UserCode.Equals(userCode));
                if (userInfo != null)
                {
                    var areaData = _IAreaAppService.GetAreaListInfoByUserCode(userCode);
                    if (areaData != null && areaData.Count > 0)
                    {
                        var areaCodes = areaData.Select(s => s.Code).ToArray();
                        //userQuery = await _ISystemUserRepository.GetAllListAsync(s =>
                        //    s.Department.Equals(userInfo.Department) ? s.UserCode.Equals(userCode) : areaCodes.Contains(s.Department));

                        userQuery = _ISystemUserRepository.GetAllList(s =>
                                                                      s.Department.Equals(userInfo.Department) ? s.UserCode.Equals(userCode) : areaCodes.Contains(s.Department));
                    }
                }
            }
            catch
            {
                return(null);
            }
            return(userQuery);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 通过UserCode和AreaCode获取权限内所有AreaCode
        /// </summary>
        /// <param name="userCode">登陆人ID</param>
        /// <param name="areaCode">区域编号(即Department)</param>
        private List <string> GetAreaByUserAreaCode(string userCode, string areaCode)
        {
            if (!string.IsNullOrWhiteSpace(userCode) && string.IsNullOrWhiteSpace(areaCode))
            {
                List <Area>   listAreaByUser = _IAreaAppService.GetAreaListInfoByUserCode(userCode);
                List <string> listCodeByUser = new List <string>();
                foreach (Area element in listAreaByUser)
                {
                    listCodeByUser.Add(element.Code);
                }
                return(listCodeByUser);
            }
            else if (string.IsNullOrWhiteSpace(userCode) && !string.IsNullOrWhiteSpace(areaCode))
            {
                List <Area>   listAreaByArea = _IAreaAppService.GetAreaListInfoByAreaCode(areaCode);
                List <string> listCodeByArea = new List <string>();
                foreach (Area element in listAreaByArea)
                {
                    listCodeByArea.Add(element.Code);
                }
                return(listCodeByArea);
            }
            else if (!string.IsNullOrWhiteSpace(userCode) && !string.IsNullOrWhiteSpace(areaCode))
            {
                List <Area>   listAreaByUser = _IAreaAppService.GetAreaListInfoByUserCode(userCode);
                List <string> listCodeByUser = new List <string>();
                foreach (Area element in listAreaByUser)
                {
                    listCodeByUser.Add(element.Code);
                }

                List <Area>   listAreaByArea = _IAreaAppService.GetAreaListInfoByAreaCode(areaCode);
                List <string> listResult     = new List <string>();
                foreach (Area element in listAreaByArea)
                {
                    if (listCodeByUser.Contains(element.Code))
                    {
                        listResult.Add(element.Code);
                    }
                }
                return(listResult);
            }

            return(null);
        }