Ejemplo n.º 1
0
 /// <summary>
 /// 设置model,如果不为空就设置,如果为空则和之前一样
 /// </summary>
 /// <param name="target"></param>
 /// <param name="source"></param>
 /// <returns></returns>
 public AccessLogs SetAccessLogs(AccessLogs old, AccessLogs data)
 {
     if (!string.IsNullOrEmpty(data.Code))
     {
         old.Code = data.Code;
     }
     if (!string.IsNullOrEmpty(data.AccessClass))
     {
         old.AccessClass = data.AccessClass;
     }
     if (!string.IsNullOrEmpty(data.AccessAction))
     {
         old.AccessAction = data.AccessAction;
     }
     if (!string.IsNullOrEmpty(data.AccessInfo))
     {
         old.AccessInfo = data.AccessInfo;
     }
     if (data.AccessTime != DateTime.MinValue && data.AccessTime != SqlDateTime.MinValue.Value)
     {
         old.AccessTime = data.AccessTime;
     }
     if (!string.IsNullOrEmpty(data.AccessPerson))
     {
         old.AccessPerson = data.AccessPerson;
     }
     return(old);
 }
Ejemplo n.º 2
0
        public AccessLogs UpdateSingle(int id, AccessLogs data)
        {
            AccessLogs model = db.AccessLogs.Find(id);

            SetAccessLogs(model, data);
            db.SaveChanges();
            return(model);
        }
Ejemplo n.º 3
0
        public static void AddLog(Context db, string person, int id, string logClass, string logAction, string info)
        {
            AccessLogs a = new AccessLogs();

            a.KeyId        = id;
            a.AccessClass  = logClass;
            a.AccessAction = logAction;
            a.AccessInfo   = info;
            a.AccessTime   = DateTime.Now;
            a.AccessPerson = person;
            db.AccessLogs.Add(a);
        }
Ejemplo n.º 4
0
        public static void AddLogAndSave(Context db, string person, string code, string logClass, string logAction, string info)
        {
            AccessLogs a = new AccessLogs();

            a.Code         = code;
            a.AccessClass  = logClass;
            a.AccessAction = logAction;
            a.AccessInfo   = info;
            a.AccessTime   = DateTime.Now;
            a.AccessPerson = person;
            db.AccessLogs.Add(a);
            db.SaveChanges();
        }