예제 #1
0
        public void AddNewLog(string ip, DateTime time, string cachedWord)
        {
            int         cachedWordID = cachedWordsService.GetCachedWordID(cachedWord).Value;
            UserLogFull userLog      = new UserLogFull(ip, time, cachedWordID);

            Repository.AddUserLog(userLog);
        }
예제 #2
0
        public void AddNewLogView(string ip, DateTime time, string cachedWord)
        {
            int?cachedWordID = cachedWordsService.GetCachedWordID(cachedWord);

            if (cachedWordID != null)
            {
                UserLogFull userLog = new UserLogFull(ip, time, cachedWordID.Value, "View");
                Repository.AddUserLog(userLog);
            }
        }
예제 #3
0
        public void AddNewLogAdded(string ip, DateTime time, string cachedWord)
        {
            int?cachedWordID = cachedWordsService.GetCachedWordID(cachedWord);

            if (cachedWordID == null)
            {
                cachedWordsService.FindAnagrams(cachedWord);
                cachedWordID = cachedWordsService.GetCachedWordID(cachedWord);
            }
            UserLogFull userLog = new UserLogFull(ip, time, cachedWordID.Value, "Add");

            Repository.AddUserLog(userLog);
        }
예제 #4
0
 public void AddUserLog(UserLogFull userLog)
 {
     using (var context = new AnagramsEntities())
     {
         var newUserLog = new UserLog()
         {
             IP_address   = userLog.IP_address,
             CachedWordID = userLog.CachedWordID,
             SearchTime   = userLog.Time
         };
         context.UserLogs.Add(newUserLog);
         context.SaveChanges();
     }
 }
예제 #5
0
 public void AddUserLog(UserLogFull userLog)
 {
     using (SqlConnection connection = new SqlConnection(_connectionString))
     {
         connection.Open();
         if (userLog != null)
         {
             string sql = "INSERT INTO UserLogs (IP_address, CachedWordID, SearchTime) " +
                          "VALUES(@IP_address,@CachedWordID, @SearchTime)";
             SqlCommand cmd = new SqlCommand(sql, connection);
             cmd = new SqlCommand(sql, connection);
             cmd.Parameters.Add(new SqlParameter("@IP_address", userLog.IP_address));
             cmd.Parameters.Add(new SqlParameter("@CachedWordID", userLog.CachedWordID));
             cmd.Parameters.Add(new SqlParameter("@SearchTime", userLog.Time));
             cmd.CommandType = CommandType.Text;
             cmd.ExecuteNonQuery();
         }
     }
 }