Пример #1
0
 /// <summary>
 /// 将执行结果写入日志
 /// </summary>
 /// <param name="attr"></param>
 /// <param name="execResult"></param>
 public static void LogWrite(LoginAttribute attr, object execResult)
 {
     if (attr == null)
     {
         return;
     }
 }
Пример #2
0
        /// <summary>
        /// 验证是否满足特性的限定
        /// </summary>
        /// <param name="method">执行的方法</param>
        /// <returns></returns>
        public static LoginAttribute Verify(MemberInfo method, Letter letter)
        {
            string         msg       = string.Format("当前方法 {0}.{1} 需要", method.DeclaringType.Name, method.Name);
            LoginAttribute loginattr = null;

            loginattr = LoginAttribute.GetAttr <AdminAttribute>(method);
            if (loginattr != null && !loginattr.Ignore && !loginattr.Logged())
            {
                throw new Exception(msg + "管理员登录后操作");
            }

            loginattr = LoginAttribute.GetAttr <SuperAdminAttribute>(method);
            if (loginattr != null && !loginattr.Ignore && !loginattr.Logged())
            {
                throw new Exception(msg + "超级管理员登录后操作");
            }

            loginattr = LoginAttribute.GetAttr <StudentAttribute>(method);
            if (loginattr != null && !loginattr.Ignore && !loginattr.Logged())
            {
                throw new Exception(msg + "学员账户登录后操作");
            }

            loginattr = LoginAttribute.GetAttr <TeacherAttribute>(method);
            if (loginattr != null && !loginattr.Ignore && !loginattr.Logged())
            {
                throw new Exception(msg + "教师账号登录后操作");
            }

            return(loginattr);
        }
Пример #3
0
        /// <summary>
        /// 验证是否满足特性的限定
        /// </summary>
        /// <param name="method">执行的方法</param>
        /// <param name="letter">客户端传来的信息</param>
        /// <returns></returns>
        public static HtmlClearAttribute Clear(MemberInfo method, Letter letter)
        {
            HtmlClearAttribute attr = null;

            attr = LoginAttribute.GetAttr <HtmlClearAttribute>(method);
            if (attr != null)
            {
                letter.Params = letter.Params.ToDictionary(x => x.Key, (x) => {
                    string[] nots = attr.Not.Split(',');
                    bool isexist  = false;
                    foreach (string s in nots)
                    {
                        if (string.IsNullOrWhiteSpace(s))
                        {
                            continue;
                        }
                        if (s.Equals(x.Key, StringComparison.CurrentCultureIgnoreCase))
                        {
                            isexist = true;
                            break;
                        }
                    }
                    if (isexist)
                    {
                        return(x.Value);
                    }
                    return(ClearTag(x.Value));
                });
            }
            else
            {
                letter.Params = letter.Params.ToDictionary(x => x.Key, x => ClearTag(x.Value));
            }
            return(attr);
        }