Ejemplo n.º 1
0
        public void add <T>(CitySouthContext db, sysUser user, string LogType, T t1, T t2)
        {
            var            dType = typeof(T);
            List <LogItem> items = new List <LogItem>();

            foreach (PropertyInfo dP in dType.GetProperties())
            {
                object value1 = dType.GetProperty(dP.Name).GetValue(t1, null);
                object value2 = dType.GetProperty(dP.Name).GetValue(t2, null);
                if ((value1 != null || value2 != null) && ((value1 == null && value2 != null) || (value1 != null && value2 == null) || !value1.Equals(value2)))
                {
                    items.Add(new LogItem(dP.Name, new object[] { value1, value2 }));
                }
            }
            if (items.Count > 1)
            {
                this.LogType   = LogType;
                this.Remark    = JsonConvert.SerializeObject(items);
                this.UserId    = user.UserId;
                this.LoginName = user.LoginName;
                this.Ip        = System.Web.HttpContext.Current.Request.UserHostAddress;
                this.LogTime   = DateTime.Now;
                db.sysUserLogs.Add(this);
            }
        }
Ejemplo n.º 2
0
 public void add(CitySouthContext db, sysUser user)
 {
     this.UserId    = user.UserId;
     this.LoginName = user.LoginName;
     this.Ip        = System.Web.HttpContext.Current.Request.UserHostAddress;
     this.LogTime   = DateTime.Now;
     db.sysUserLogs.Add(this);
 }
Ejemplo n.º 3
0
 public void Valid(List <string> list, CitySouthContext db, bool IsVerfyPassword = true)
 {
     if (string.IsNullOrEmpty(LoginName))
     {
         list.Add("必须输入账户名称");
     }
     else if (IsVerfyPassword && string.IsNullOrEmpty(Password))
     {
         list.Add("必须输入账户密码");
     }
     else if (IsVerfyPassword && !Regex.IsMatch(Password, @"^[\S]{4,40}$"))
     {
         list.Add("账户密码至少输入4位");
     }
     else if (IsVerfyPassword && db.sysUsers.Count(w => w.LoginName == LoginName) > 0)
     {
         list.Add("账户名称已存在");
     }
 }
Ejemplo n.º 4
0
        public void add <T>(CitySouthContext db, sysUser user, string LogType, T t1)
        {
            var            dType = typeof(T);
            List <LogItem> items = new List <LogItem>();

            foreach (PropertyInfo dP in dType.GetProperties())
            {
                object value = dType.GetProperty(dP.Name).GetValue(t1, null);
                if (value != null && (dP.PropertyType != typeof(DateTime) || Convert.ToDateTime(value) != DateTime.MinValue))
                {
                    items.Add(new LogItem(dP.Name, new object[] { value }));
                }
            }

            this.LogType   = LogType;
            this.Remark    = JsonConvert.SerializeObject(items);
            this.UserId    = user.UserId;
            this.LoginName = user.LoginName;
            this.Ip        = System.Web.HttpContext.Current.Request.UserHostAddress;
            this.LogTime   = DateTime.Now;
            db.sysUserLogs.Add(this);
        }