public RespondMenuRightCheckViewModel CheckMenuRightByMenuID(RequestMenuRightCheckViewModel request)
        {
            var user = CPSSAuthenticate.GetCurrentUser();

            return(MemcacheHelper.Get(() =>
            {
                var parameter = new MenuRightCheckParameter
                {
                    MenuID = request.MenuID,
                    UserID = user.UserID
                };
                var dataModel = this.mMenuRightCheckDataAccess.CheckMenuRightByMenuID(parameter);
                var result = new RespondMenuRightCheckViewModel
                {
                    HaveRight = dataModel != null && dataModel.HaveRight
                };
                return result;
            }, string.Format(preCacheKey, "CheckMenuRightByMenuID"),
                                      false,
                                      request.MenuID
                                      , user.UserID));
        }
示例#2
0
        public MongoDbBaseDataAccess()
        {
            var user     = CPSSAuthenticate.GetCurrentUser();
            var filePath = "~/config/mongodbconfig.config";

            if (user != null)
            {
                filePath = string.Format("~/config/{0}/mongodbconfig.config", user.CompanySerialNum);
                if (!ExistsFileHelper.ExistsFile(filePath))
                {
                    var config = new MongoDbConfig
                    {
                        Server   = WebConfigHelper.GetMongoDbServer(),
                        Database = string.Format("MongoDbLog_{0}", user.CompanySerialNum)
                    };
                    ConfigHelper.Save(config, filePath);
                }
            }
            //if (!ExistsFileHelper.ExistsFile(filePath)) throw new Exception("MongoDb库连接配置文件不存在。");
            var mongoDbConfig = ConfigHelper.GetConfig <MongoDbConfig>(filePath);

            this.InitMongoDataBase(mongoDbConfig.Server, mongoDbConfig.Database);
        }
示例#3
0
        /// <summary>
        ///     验证成功返回true,否则返回false并执行 HandleUnauthorizedRequest函数
        /// </summary>
        /// <param name="httpContext"></param>
        /// <returns></returns>
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            #region 如果是管理员或系统账号则不需要验证权限,本身就拥有所有权限

            var currentUser = CPSSAuthenticate.GetCurrentUser();
            if (currentUser.IsManager || currentUser.IsSystem)
            {
                return(true);
            }

            #endregion

            var _autofacScope = AutofacServiceContainer.CurrentServiceContainer.BeginLifetimeScope(new object());
            var _service      = _autofacScope.Resolve <Owned <IMenuRightCheckViewService> >();
            var request       = new RequestMenuRightCheckViewModel
            {
                MenuID = this.MenuID
            };
            var model = _service.Value.CheckMenuRightByMenuID(request);

            //验证权限 有相应权限 返回true,否则返回false
            return(model.HaveRight);
        }
示例#4
0
 public BaseViewService(IMongoDbDataAccess mongoDbDataAccess)
 {
     this.mMongoDbDataAccess = mongoDbDataAccess;
     this.mSigninUser        = CPSSAuthenticate.GetCurrentUser();
 }