예제 #1
0
        private void IsExists(ISession session, ModFunc modFunc)
        {
            ICriteria criteria = session.CreateCriteria(typeof(ModFunc));

            ICriterion criterion = null;
            if (modFunc.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(modFunc.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("Cls", modFunc.Cls);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.ModFuncIsExistsException();//模块功能已经存在
            }
        }
예제 #2
0
        public void Init()
        {
            try
            {
                Guid pId;

                Mod mod = new Mod();

                mod = new Mod();
                mod.Name = "SystemManager";
                mod.Text = "系统管理";
                mod.Icon = "glyphicon glyphicon-cog";
                mod.Type = 1; //有子菜单
                mod.Href = "";
                mod.Index = 1;
                modOper.Add(mod);

                pId = mod.Id;

                Type type = typeof(ModController);
                //添加菜单的操作函数
                ModFunc modFunc = new ModFunc();
                modFunc.Cls = type.FullName;
                modFuncOper.Add(modFunc);

                Mod subMod = new Mod();
                subMod.Name = "ModManager";
                subMod.Text = "菜单管理";
                subMod.Icon = "glyphicon glyphicon-user";
                subMod.Type = 0; //没有子菜单
                subMod.Href = "/Admin/ModManager";
                subMod.PId = pId;
                subMod.Index = 0;
                subMod.ModFunc = modFunc;
                modOper.Add(subMod);

                type = typeof(EmployeeController);
                //添加菜单的操作函数
                modFunc = new ModFunc();
                modFunc.Cls = type.FullName;
                modFuncOper.Add(modFunc);

                subMod = new Mod();
                subMod.Name = "PowerManager";
                subMod.Text = "权限管理";
                subMod.Icon = "glyphicon glyphicon-user";
                subMod.Type = 0; //没有子菜单
                subMod.Href = "/Admin/PowerManager";
                subMod.PId = pId;
                subMod.Index = 0;
                subMod.ModFunc = modFunc;
                modOper.Add(subMod);

            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
            }
        }
예제 #3
0
 public ActionResult Update(ModFunc modFunc)
 {
     return Json(modFuncOper.Update(modFunc,
         delegate(object sender, ISession session)
         {
             //判断是否存在模块功能
             IsExists(session, modFunc);
         }
         ));
 }
예제 #4
0
 public ActionResult Del(ModFunc modFunc)
 {
     return Json(modFuncOper.Del(modFunc));
 }