Exemple #1
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);
        }
Exemple #2
0
        /// <summary>
        /// 通过userCode查询数据结果
        /// </summary>
        /// <param name="userCode">登陆人对应权限编号</param>
        /// <param name="department">部门</param>
        /// <param name="userName">名称</param>
        /// <returns></returns>
        private async Task <List <SystemUserEntity> > GetDataByUserCodeAsync(string userCode, string department, string userName)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(userCode))
                {
                    return(null);
                }

                List <SystemUserEntity> query = null;
                if (userCode.ToUpper() == ConstHelper.CONST_SYSTEMNAME)
                {
                    #region 超级用户
                    //query = await _ISystemUserRepository.GetAllListAsync();
                    query = _ISystemUserRepository.GetAllList();
                    #endregion
                }
                else
                {
                    query = await GetUserEntityByUserCodeAsync(userCode);
                }
                if (query != null && query.Count > 0)
                {
                    if (!string.IsNullOrWhiteSpace(department))
                    {
                        if (department != ConstHelper.CONST_SYSTEMCODE)
                        {
                            var areaData = _IAreaAppService.GetAreaListInfoByAreaCode(department);
                            if (areaData != null && areaData.Count > 0)
                            {
                                var areaCodes = areaData.Select(s => s.Code).ToArray();
                                query = query.Where(s => areaCodes.Contains(s.Department)).ToList();
                            }
                        }
                    }
                    if (!string.IsNullOrWhiteSpace(userName))
                    {
                        query = query.Where(s => s.UserName.Contains(userName)).ToList();
                    }
                }
                return(query);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }