Ejemplo n.º 1
0
        /// <summary>
        /// 添加信息  2014-11-05 20:23:33 By 唐有炜
        /// </summary>
        /// <param name="TSysRole">TSysRole</param>
        /// <returns>添加状态</returns>
        public bool AddSysRole(TSysRole SysRole)
        {
            var status = false;
               try
                {
                     status = TSysRoleDao.InsertEntity(SysRole);
                }
                catch (Exception ex)
                {
                    LogHelper.Error("获取SysRole失败。", ex);
                    status = false;
                }

            return status;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 书写SesionCookie 2014/8/21 9:04:10   By 唐有炜
 /// </summary>
 /// <param name="sessionHttpContext">HttpContext</param>
 /// <param name="sysUser">用户</param>
 /// <param name="sysRole">角色</param>
 /// <param name="remember">是否记住密码(默认记住)</param>
 public void WriteSessionCookie(HttpContext sessionHttpContext, TSysUser sysUser, TSysRole sysRole,
     string remember = "true")
 {
     sessionHttpContext.Session[UCKeys.SESSION_USER_ID] = sysUser.Id;
     sessionHttpContext.Session[UCKeys.SESSION_USER_NAME] = sysUser.UserTname;
     sessionHttpContext.Session[UCKeys.SESSION_ROLE_ID] = sysRole.Id;
     sessionHttpContext.Session[UCKeys.SESSION_ROLE_NAME] = sysRole.RoleName;
     sessionHttpContext.Session.Timeout = UCKeys.SESSION_TIMEOUT; //默认45分钟
     //记住登录状态下次自动登录
     if (remember.ToLower() == "true")
     {
         //默认30天
         Utils.WriteCookie(sessionHttpContext, UCKeys.COOKIE_USER_REMEMBER, remember, UCKeys.COOKIE_TIMEOUT);
         Utils.WriteCookie(sessionHttpContext, UCKeys.COOKIE_USERNAME_REMEMBER, sysUser.UserLname,
             UCKeys.COOKIE_TIMEOUT);
         Utils.WriteCookie(sessionHttpContext, UCKeys.COOKIE_USERPWD_REMEMBER, sysUser.UserPassword,
             UCKeys.COOKIE_TIMEOUT);
     }
     else
     {
         Utils.WriteCookie(sessionHttpContext, UCKeys.COOKIE_USER_REMEMBER, remember);
         Utils.WriteCookie(sessionHttpContext, UCKeys.COOKIE_USERNAME_REMEMBER, "");
         Utils.WriteCookie(sessionHttpContext, UCKeys.COOKIE_USERPWD_REMEMBER, "");
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 修改实体
 /// </summary>
 /// <param name="entity">实体对象</param>
 public bool UpdateEntity(TSysRole entity)
 {
     using (UCDbContext db=new UCDbContext())
     {
        int rows= db.TSysRoles.Update(entity);
        if (rows > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }