コード例 #1
0
ファイル: ModuleService.cs プロジェクト: azureidea/NiceFrame
 public void SubmitForm(ModuleBaseEntity moduleBaseEntity, string keyValue)
 {
     if (!string.IsNullOrEmpty(keyValue))
     {
         moduleBaseEntity.Modify(keyValue);
         service.Update(moduleBaseEntity);
     }
     else
     {
         moduleBaseEntity.Create();
         service.Insert(moduleBaseEntity);
     }
 }
コード例 #2
0
        public bool ActionValidate(string roleId, string moduleId, string action)
        {
            var authorizeurldata = new List <AuthorizeActionModel>();
            var cachedata        = CacheFactory.Cache().GetCache <List <AuthorizeActionModel> >("authorizeurldata_" + roleId);

            if (cachedata == null)
            {
                var moduledata    = _moduleService.GetList();
                var buttondata    = _moduleButtonService.GetList();
                var authorizedata = service.Queryable(t => t.F_ObjectId == roleId).ToList();
                foreach (var item in authorizedata)
                {
                    if (item.F_ItemType == 1)
                    {
                        ModuleBaseEntity moduleBaseEntity = moduledata.Find(t => t.F_Id == item.F_ItemId);
                        authorizeurldata.Add(new AuthorizeActionModel {
                            F_Id = moduleBaseEntity.F_Id, F_UrlAddress = moduleBaseEntity.F_UrlAddress
                        });
                    }
                    else if (item.F_ItemType == 2)
                    {
                        ModuleButtonBaseEntity moduleButtonBaseEntity = buttondata.Find(t => t.F_Id == item.F_ItemId);
                        authorizeurldata.Add(new AuthorizeActionModel {
                            F_Id = moduleButtonBaseEntity.F_ModuleId, F_UrlAddress = moduleButtonBaseEntity.F_UrlAddress
                        });
                    }
                }
                CacheFactory.Cache().WriteCache(authorizeurldata, "authorizeurldata_" + roleId, DateTime.Now.AddMinutes(5));
            }
            else
            {
                authorizeurldata = cachedata;
            }
            authorizeurldata = authorizeurldata.FindAll(t => t.F_Id.Equals(moduleId));
            foreach (var item in authorizeurldata)
            {
                if (!string.IsNullOrEmpty(item.F_UrlAddress))
                {
                    string[] url = item.F_UrlAddress.Split('?');
                    if (item.F_Id == moduleId && url[0] == action)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #3
0
        public List <ModuleBaseEntity> GetMenuList(string roleId)
        {
            var data = new List <ModuleBaseEntity>();

            if (OperatorProvider.Provider.GetCurrent().IsSystem)
            {
                data = _moduleService.GetList();
            }
            else
            {
                var moduledata    = _moduleService.GetList();
                var authorizedata = service.Queryable(t => t.F_ObjectId == roleId && t.F_ItemType == 1).ToList();
                foreach (var item in authorizedata)
                {
                    ModuleBaseEntity moduleBaseEntity = moduledata.Find(t => t.F_Id == item.F_ItemId);
                    if (moduleBaseEntity != null)
                    {
                        data.Add(moduleBaseEntity);
                    }
                }
            }
            return(data.OrderBy(t => t.F_SortCode).ToList());
        }
コード例 #4
0
 public ActionResult SubmitForm(ModuleBaseEntity moduleBaseEntity, string keyValue)
 {
     _moduleService.SubmitForm(moduleBaseEntity, keyValue);
     return(Success("操作成功。"));
 }