Ejemplo n.º 1
0
        public static RightEntity SaveRight(string badge, string dataJson, out bool state, out string msg)
        {
            RightEntity right = Serializer.ToObject <RightEntity>(dataJson);

            right.Operator    = badge;
            right.OperateTime = DateTime.Now;

            if (RightEntity.DefaultDB.IsNew(right))
            {
                if (RightEntity.GetListByProperty(a => a.RightUser, right.RightUser).Count > 0)
                {
                    state = false;
                    msg   = "员工" + right.RightUserExp + "权限已存在!";
                }
                else
                {
                    state = right.Save(out msg);
                    LogService.WriteLog(LogTypeEnum.操作日志, "权限管理", "新增权限:" + badge + "为" + right.RightUser + "分配了 " + right.RightName + " 权限");
                }
            }
            else
            {
                RightEntity oldRight = RightEntity.GetSingle(right.Id);

                right.RightUser = oldRight.RightUser;
                state           = right.Save(out msg);
                LogService.WriteLog(LogTypeEnum.操作日志, "权限管理", "修改权限:" + badge + "修改了" + right.RightUser + "的权限,从 " + oldRight.RightName + " 修改到 " + right.RightName);
            }

            return(right);
        }
Ejemplo n.º 2
0
        public static bool IsHaveRight(string badge, string rightName)
        {
            RightEntity right = RightEntity.GetListByProperty(a => a.RightUser, badge).FirstOrDefault();

            return(right != null && right.RightName.Contains(rightName));
        }