Beispiel #1
0
 /// <summary>
 /// 修改实体
 /// </summary>
 /// <param name="entity">实体对象</param>
 public bool UpadateEntity(TSysLog entity)
 {
     using (teaCRMDBContext db = new teaCRMDBContext())
     {
         int rows = db.TSysLogs.Update(entity);
         if (rows > 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
 }
        /// <summary>
        /// 登录验证并写入登录日志 2014-08-21 07:58:50 By 唐有炜
        /// </summary>
        /// <param name="httpContext">HttpContext</param>
        /// <param name="type">注册或登录方式(normal,qrcode,usb,footprint)</param>
        /// <param name="accountType">账号类型(username,email,phone)</param>
        /// <param name="userName">用户名</param>
        /// <param name="userPassword">密码</param>
        /// <param name="remember">记住密码</param>
        /// <param name="clientIp">客户端ip地址</param>
        ///   /// <param name="clientPlace">客户端地址</param>
        /// <param name="clientTime">客户端登录时间</param>
        /// <returns>ResponseMessage</returns>
        public ResponseMessage Login(HttpContext httpContext, string type, string accountType, string userName,
            string userPassword,
            string remember, string clientIp, string clientPlace, string clientTime)
        {
            ResponseMessage rmsg = new ResponseMessage();
            try
            {
                //获取用户信息
                var compUser = GetVCompanyUserByAccountTypeAndUserName(accountType, userName);
                //书写SessionCookie
                WriteSessionCookie(httpContext, compUser, userName, userPassword, remember);
                //写日志
                var loginUser = compUser.UserTname;
                if (String.IsNullOrEmpty(loginUser))
                {
                    loginUser = clientPlace + "网友";
                }
                TSysLog sysLog = new TSysLog()
                {
                    UserId = compUser.UserId,
                    UserLname = compUser.UserLname,
                    LogAction = teaCRMEnums.LogActionEnum.Login.ToString(),
                    LogRemark = loginUser + "登录了系统。",
                    LogIp = clientIp,
                    LogPlace = clientPlace,
                    LogTime = DateTime.Parse(clientTime)
                };
                SysLogDao.InsertEntity(sysLog);

                rmsg.Status = true;
                rmsg.Msg = "登陆成功";
                LogHelper.Info(userName + "登录成功,登录日志已记录。");
            }
            catch (Exception ex)
            {
                rmsg.Status = false;
                rmsg.Msg = "登陆失败";
                LogHelper.Debug("登陆错误", ex);
            }

            return rmsg;
        }