/// <summary>
        /// 获取用户菜单
        /// </summary>
        /// <param name="queryParam"></param>
        /// <returns></returns>
        public List <View_MenuSys> GetUserMenuInfoList(View_MenuSysQueryParam queryParam)
        {
            //取出对应功能项下的菜单
            var result = activeContext.View_MenuSys.Where(p => p.FeatureId.HasValue &&
                                                          queryParam.FeatureIds.Contains(p.FeatureId.Value)).Distinct().ToList();

            return(result);
        }
        /// <summary>
        /// 获取用户菜单
        /// </summary>
        /// <param name="queryParam"></param>
        /// <returns></returns>
        public List <View_MenuSys> GetMenuByIds(View_MenuSysQueryParam queryParam)
        {
            var result = activeContext.View_MenuSys.Where(p => queryParam.Ids.Contains(p.Id)).ToList();

            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// 获取用户菜单
        /// </summary>
        /// <param name="queryParam"></param>
        /// <returns></returns>
        public List <View_MenuSys> GetUserMenuInfoList(View_MenuSysQueryParam queryParam)
        {
            var result = vmsDal.GetUserMenuInfoList(queryParam);

            return(result);
        }
Beispiel #4
0
        /// <summary>
        /// 获取用户菜单
        /// </summary>
        /// <param name="queryParam"></param>
        /// <returns></returns>
        public List <View_MenuSys> GetMenuByIds(View_MenuSysQueryParam queryParam)
        {
            var result = vmsDal.GetMenuByIds(queryParam);

            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// 获取用户全部信息
        /// </summary>
        /// <param name="loginname"></param>
        public UserBackFullInfo GetUserFullInfo(Org_UserQueryParam queryParam)
        {
            UserBackFullInfo result = new UserBackFullInfo();

            //全都为空,查个毛啊,这里是精确查询1条,不是模糊查多条
            if (queryParam.Id == Guid.Empty && string.IsNullOrEmpty(queryParam.LoginName) &&
                string.IsNullOrEmpty(queryParam.Phone) && string.IsNullOrEmpty(queryParam.Email) &&
                string.IsNullOrEmpty(queryParam.IdCard))
            {
                return(null);  //返回空,让调用处报异常去
            }
            result.BaseInfo = this.GetUserBaseInfo(queryParam);

            //获取用户组织机构
            if (result.BaseInfo.IsSuperMgr && result.BaseInfo.LoginName == "sysadmin") //超级管理员
            {
                result.UserOrgInfoList     = (new Org_OrganizationDal()).GetAllUserOrgInfo();
                result.UserFeatureInfoList = vfoDal.GetSystemManagerFeatures().ToList();
                result.UserMenuInfoList    = vmsDal.GetAll().ToList();
                //数据权限暂时不考虑
            }
            else
            {
                if (result.BaseInfo.IsSuperMgr)
                {
                    result.UserOrgInfoList     = this.GetUserOrgInfos(queryParam);
                    result.UserFeatureInfoList = vfoDal.GetSystemManagerFeatures().ToList();
                    //var aa = result.UserFeatureInfoList.Where(p => p.FeatureCode == "DCBI-CRE-Head" || p.FeatureCode == "DCBI-CRE-Send").ToList();
                    result.UserMenuInfoList = vmsDal.GetAll().ToList();
                    //var bb = result.UserMenuInfoList.Where(p => p.MenuCode == "DCBI-CRE-Draft" || p.MenuCode == "DCBI-CRE-Finance").ToList();
                }
                else
                {
                    result.UserOrgInfoList = this.GetUserOrgInfos(queryParam);

                    //用户岗位
                    var PositionIds = result.UserOrgInfoList.Where(k => k.PositionId.HasValue).Select(p => p.PositionId.Value).ToList();

                    #region 获取用户功能权限
                    View_FeaturePositionQueryParam featurepqueryParam = new View_FeaturePositionQueryParam();
                    //取出用户的多个岗位,查询多岗位下的功能项
                    //featurepqueryParam.PositionIds = result.UserOrgInfoList.Where(k => k.PositionId.HasValue).Select(p => p.PositionId.Value).ToList();
                    featurepqueryParam.PositionIds = PositionIds;
                    result.UserFeatureInfoList     = this.GetUserFeatureInfos(featurepqueryParam);
                    #endregion

                    #region 获取用户菜单
                    //获取用户的功能项,查询对应的菜单(IsMenu是菜单的功能项)
                    View_MenuSysQueryParam menusyqueryParam = new View_MenuSysQueryParam();
                    menusyqueryParam.FeatureIds = result.UserFeatureInfoList.Where(k => k.FeatureId.HasValue && k.FeatureIsMenu.HasValue && k.FeatureIsMenu.Value == true).Select(p => p.FeatureId.Value).Distinct().ToList();
                    result.UserMenuInfoList     = this.GetUserMenuInfoList(menusyqueryParam);

                    //加上特别配置的菜单
                    Auth_PositionSpecialMenuConfigQueryParam apsmcqueryParam = new Auth_PositionSpecialMenuConfigQueryParam();
                    apsmcqueryParam.PositionIds = PositionIds;
                    var specialMenuIds = this.GetMenuByPositions(apsmcqueryParam); //根据岗位ids查找岗位特别配置的菜单ids
                    menusyqueryParam.Ids = specialMenuIds;
                    var specialMenuInfos = this.GetMenuByIds(menusyqueryParam);    //根据菜单ids查找菜单信息
                    result.UserMenuInfoList = result.UserMenuInfoList.Concat(specialMenuInfos).DistinctBy(p => p.Id).ToList();
                    #endregion

                    //取得用户数据权限
                    View_DataRolePositionQueryParam udataquery = new View_DataRolePositionQueryParam();
                    //取得用户所有岗位
                    //udataquery.PositionIds = result.UserOrgInfoList.Where(k => k.PositionId.HasValue).Select(p => p.PositionId.Value).Distinct().ToList();
                    udataquery.PositionIds  = PositionIds;
                    result.UserDataInfoList = this.GetUserDataInfos(udataquery);
                }
                #region 获取当前登录用户默认组织机构、公司、区域信息
                var OrgAll = (new Org_OrganizationDal()).GetAllOrg();

                //当前登录组织机构
                var notNullOrg = result.UserOrgInfoList.Where(f => !string.IsNullOrEmpty(f.OrganizationCode)).ToList();
                var firstOrg   = notNullOrg.OrderBy(f => f.OrganizationCode).FirstOrDefault();
                if (firstOrg != null)
                {
                    //result.CurrentOrganizationId = firstOrg.OrganizationId.Value;
                    //result.CurrentOrganizationCode = firstOrg.OrganizationCode;
                    //result.CurrentOrganizationName = firstOrg.OrganizationName;
                }
                List <string> parentCode = new List <string>();
                //获取当前登录用户的所有父级组织机构
                foreach (var get in notNullOrg)
                {
                    var OriCode = get.OrganizationRelationShipCode.Replace("[" + get.OrganizationCode + "]", "");
                    var Ary     = OriCode.Split(']');
                    foreach (var str in Ary)
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            parentCode.Add(str.Replace("[", "").Replace("]", ""));
                        }
                    }
                }

                var getCompany = OrgAll.Where(f => f.OrganizationCategoryCode == "Company" && parentCode.Contains(f.Code)).OrderBy(f => f.Code).FirstOrDefault();
                var getArea    = OrgAll.Where(f => f.OrganizationCategoryCode == "Region" && parentCode.Contains(f.Code)).OrderBy(f => f.Code).FirstOrDefault();
                if (getCompany != null)
                {
                    //result.CurrentCompanyId = getCompany.OrganizationId;
                    //result.CurrentCompanyCode = getCompany.Code;
                    //result.CurrentCompanyName = getCompany.Name;
                }
                if (getArea != null)
                {
                    //result.CurrentAreaId = getArea.OrganizationId;
                    //result.CurrentAreaCode = getArea.Code;
                    //result.CurrentAreaName = getArea.Name;
                }
                else
                {
                    //未找到区域公司时查找是否存在总公司
                    getArea = OrgAll.Where(f => f.OrganizationCategoryCode == "MainCompany" && parentCode.Contains(f.Code)).OrderBy(f => f.Code).FirstOrDefault();
                    if (getArea != null)
                    {
                        //result.CurrentAreaId = getArea.OrganizationId;
                        //result.CurrentAreaCode = getArea.Code;
                        //result.CurrentAreaName = getArea.Name;
                    }
                }

                #endregion
            }
            return(result);
        }