예제 #1
0
        private void CheckCurrent()
        {
            if (!HttpContext.Current.Request.IsAuthenticated)
            {
                throw new NotSupportedException(
                          "本系统的 SessionSettings 不支持非登录用户采样,请确保你书写的代码段不存在非登录用户访问的漏洞!");
            }

            if (_user == null)
            {
                var u  = APDBDef.ResUser;
                var r  = APDBDef.ResRole;
                var ur = APDBDef.ResUserRole;
                var ra = APDBDef.ResRoleApprove;

                using (APDBDef db = new APDBDef())
                {
                    _user = db.ResUserDal.ConditionQuery(u.UserName == HttpContext.Current.User.Identity.Name, null, null, null).FirstOrDefault();
                    if (_user != null)
                    {
                        _role = APQuery.select(r.Asterisk)
                                .from(r, ur.JoinInner(r.RoleId == ur.RoleId))
                                .where (ur.UserId == _user.UserId)
                                .query(db, r.Map).FirstOrDefault();

                        if (_role != null)
                        {
                            _approves = APQuery.select(ra.ApproveId).from(ra).where (ra.RoleId == _role.RoleId)
                                        .query(db, reader => { return(ra.ApproveId.GetValue(reader)); }).ToArray();
                        }
                    }
                }
            }
        }
예제 #2
0
파일: Entity.cs 프로젝트: MaddysTeam/Thesis
 public static string FitPhotoPathWithUser(ResUser user)
 {
     if (user.PhotoPath == "")
     {
         return("/assets/img/gender_" + user.GenderPKID + ".jpg");
     }
     return(user.PhotoPath);
 }
예제 #3
0
 public void ResetCurrent()
 {
     if (_user != null)
     {
         _user     = null;
         _role     = null;
         _approves = null;
     }
 }