Exemple #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);
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// 删除实体
 /// </summary>
 /// <param name="predicate">Lamda表达式</param>
 public bool DeleteEntity(Expression <Func <TSysLog, bool> > predicate)
 {
     using (UCDbContext db = new UCDbContext())
     {
         TSysLog entity = db.TSysLogs.Where(predicate).First();
         int     rows   = db.TSysLogs.Delete(entity);
         if (rows > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// 修改信息  2014-11-05 20:23:33 By 唐有炜
        /// </summary>
        /// <param name="id">id</param>
        /// <param name="TSysLog">TSysLog</param>
        /// <returns>添加状态</returns>
        public bool EditSysLog(TSysLog SysLog)
        {
            var status = false;

            try
            {
                status = TSysLogDao.UpdateEntity(SysLog);
            }
            catch (Exception ex)
            {
                LogHelper.Error("获取SysLog失败。", ex);
                status = false;
            }

            return(status);
        }
Exemple #4
0
        /// <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);
        }
Exemple #5
0
        public static void InsertLog(int id, string name, string type, string msg, bool fruit)
        {
            APIDataDataContext db = DBFactory.DB;
            TSysLog s = new TSysLog();
            s.CreateTime = DateTime.Now;
            s.LogMsg = msg;
            s.Fruit = fruit;
            if (type == "用户")
            {
                s.TrealsId = id;

            }
            else if (type == "会员")
            {
                s.TagentId = id;
            }
            else if (type == "员工")
            {
                s.StaffId = id;
            }
            else
            {
                s.Name = name;
            }
            db.TSysLog.InsertOnSubmit(s);
            db.SubmitChanges();
        }
Exemple #6
0
        /// <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
            {
                //账户验证
                rmsg = ValidateAccount(type, accountType, userName, userPassword);
                if (!rmsg.Status)
                {
                    return(rmsg);
                }
                //判断用户是否被禁用


                //获取用户信息
                var sysUser = GetSysUserByAccountTypeAndUserLname(accountType, userName);
                if (sysUser.UserEnable != 1)
                {
                    rmsg.Status = false;
                    rmsg.Msg    = "对不起,该用户已经被禁用!";
                    return(rmsg);
                }

                var sysRole = TSysRoleDao.GetEntity(r => r.Id == sysUser.RoleId);
                //书写SessionCookie
                WriteSessionCookie(httpContext, sysUser, sysRole, remember);
                //写日志
                var loginUser = sysUser.UserTname;
                if (String.IsNullOrEmpty(loginUser))
                {
                    if (String.IsNullOrEmpty(clientPlace))
                    {
                        clientPlace = "未知地区";
                    }
                    loginUser = clientPlace + "网友";
                }
                TSysLog sysLog = new TSysLog()
                {
                    UserId    = sysUser.Id,
                    UserLname = sysUser.UserLname,
                    LogAction = UCEnums.LogActionEnum.Login.ToString(),
                    LogRemark = String.Concat(new[] { "【", loginUser, "】,登录了系统。" }),
                    LogIp     = clientIp,
                    LogPlace  = clientPlace,
                    LogTime   = DateTime.Parse(clientTime)
                };
                TSysLogDao.InsertEntity(sysLog);

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

            return(rmsg);
        }