コード例 #1
0
        public List <SystemModule> ListByCompany(long companyId, string domain, long userId)
        {
            Expression <Func <SystemModule, bool> > condition = null;
            List <SystemModule> list = new DALBase <SystemModule, DataContext>().List(condition, m => m.OrderBy);

            if (!string.IsNullOrEmpty(domain))
            {
                Company companyInfo = new DALBase <Company, DataContext>().Info(m => m.Domain == domain);
                if (companyInfo == null)
                {
                    return(null);
                }
                companyId = companyInfo.CompanyId;
            }
            Expression <Func <CompanyModule, bool> > companyCondition = m => m.CompanyId == companyId;
            List <CompanyModule> companyList = new DALBase <CompanyModule, DataContext>().List(companyCondition, m => m.id);

            //new Camel.ApiUserBLL.UserPowerExBLL().
            Camel.ApiModel.CompanyManageUser userModule = Camel.ApiUserBLL.UserPowerExBLL.CompanyManageGet(companyId, userId);
            if (userModule == null)
            {
                return(null);
            }
            foreach (SystemModule item in list)
            {
                if (userModule.RoleTypeId == 1)//超级用户
                {
                    if (item.IsDefault ||
                        companyId == 1)
                    {
                        item.State = 0;
                        continue;
                    }
                    if (companyList.Where(m => m.ModuleId == item.id).ToArray().Length > 0)
                    {
                        CompanyModule existModel = companyList.Where(m => m.ModuleId == item.id).ToArray()[0];

                        if (existModel.ValidityDateEnd >= DateTime.Now && existModel.ValidityDateStart <= DateTime.Now)
                        {
                            item.State = 0;
                        }
                        else//过期
                        {
                            item.State = 1;
                        }
                    }
                    else//未开通
                    {
                        item.State = 2;
                    }
                }
                else//普通用户
                {
                    if (
                        (companyList.Where(m => m.ModuleId == item.id).ToArray().Length > 0 || item.IsDefault) &&//企业有模块使用权
                        userModule._UserPowerExLst.Where(m => m.ModuleId == item.id).ToArray().Length > 0   //用户仍有操作权限
                        )
                    {
                        if (item.IsDefault ||
                            companyId == 1)
                        {
                            item.State = 0;
                            continue;
                        }

                        CompanyModule existModel = companyList.Where(m => m.ModuleId == item.id).ToArray()[0];
                        if (existModel.ValidityDateEnd >= DateTime.Now && existModel.ValidityDateStart <= DateTime.Now)

                        {
                            item.State = 0;
                        }
                        else//过期
                        {
                            item.State = 3;
                        }
                    }
                    else
                    {
                        item.State = 3;
                    }
                }
            }
            return(list);
        }
コード例 #2
0
        public int VerifyCheck(long companyId, long userId, int moduleId, int fnId)
        {
            //return 0;
            DALBase <CompanyModule, DataContext> bll = new DALBase <CompanyModule, DataContext>();
            CompanyModule info = bll.Info(m => m.ModuleId == moduleId && m.CompanyId == companyId);
            DALBase <SystemModule, DataContext>     baseModuleBll = new DALBase <SystemModule, DataContext>();
            Expression <Func <SystemModule, bool> > baseCondition = m => m.IsDefault == true;
            List <SystemModule> baseList = baseModuleBll.List(baseCondition, m => m.id);

            Camel.ApiModel.CompanyManageUser userModule = Camel.ApiUserBLL.UserPowerExBLL.CompanyManageGet(companyId, userId);
            if (baseList.Where(m => m.id == moduleId).ToArray().Length > 0)//模块为基本模块
            {
                if (userId == 0)
                {
                    return(0);
                }
                Camel.ApiModel.UserActionType result = Camel.ApiUserBLL.UserPowerExBLL.UserPowerExGet(companyId, userId, moduleId);
                if (userModule.RoleTypeId == 1)//当前为总管理用户
                {
                    return(0);
                }
                if (result == Camel.ApiModel.UserActionType.View)//仅能查看
                {
                    return(1);
                }
                else if (result == Camel.ApiModel.UserActionType.All)//可编辑
                {
                    return(0);
                }
                else
                {
                    return(-3);
                }
            }
            if (info == null)//无购买模块
            {
                return(-1);
            }
            if (info.ValidityDateEnd.CompareTo(DateTime.Now) > -1 && info.ValidityDateStart.CompareTo(DateTime.Now) < 1)
            {
                if (userId == 0)
                {
                    return(0);
                }
                if (userModule.RoleTypeId == 1)//当前为总管理用户
                {
                    return(0);
                }
                Camel.ApiModel.UserActionType result = Camel.ApiUserBLL.UserPowerExBLL.UserPowerExGet(companyId, userId, moduleId);
                if (result == Camel.ApiModel.UserActionType.View)//仅能查看
                {
                    return(1);
                }
                else if (result == Camel.ApiModel.UserActionType.All)//可编辑
                {
                    return(0);
                }
                else
                {
                    return(-3);
                }
            }
            else//模块过期
            {
                return(-2);
            }
        }