Ejemplo n.º 1
0
 public static UserAccessLog GetByUserId(string userId)
 {
     UserAccessLog record = null;
     string sql = @"SELECT * FROM UserAccessLog WHERE UserId=@UserId";
     try
     {
         using (SqlConnection conn = new SqlConnection(DataConnection.AppData))
         {
             conn.Open();
             using (SqlCommand cmd = new SqlCommand(sql, conn))
             {
                 cmd.Parameters.AddWithValue("@UserId", userId);
                 SqlDataReader reader = cmd.ExecuteReader();
                 if (reader.Read())
                 {
                     record = new UserAccessLog(reader);
                 }
             }
         }
     }
     catch (Exception e)
     {
         string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         ErrLogger.Log(_className, methodName, e.Message);
         record = null;
     }
     return record;
 }
Ejemplo n.º 2
0
        public void UserAccesLogTest()
        {
            UserAccessLog log = new UserAccessLog();
            log.UserId = "3707cf22-2ab7-4e4e-9dc2-1eb25155e922";
            log.Resource = "Login";
            log = log.Insert();

            Assert.IsTrue(log != null);
            return ;
        }
Ejemplo n.º 3
0
        private bool Add(string userId, string resource)
        {
            bool result = false;

            if (userId != null)
            {
                UserAccessLog record = new UserAccessLog(userId, resource);
                record = record.Insert();
                result = record != null;
            }

            return result;
        }