Last Date Activity - Best Ideas to Implement

For a typical user registration and membership system, I follow the ASP.NET website, I would like to update the latest date and time of activity. Which of the following methods would be ideal to follow.

1

Whenever a request is made to a method that accesses data from a table of user accounts, it automatically (O_o) updates the date of last_account_activity using GETDATE()

2

Call UpdateLastActivity() as an external method after calling the method from the membership system.

information:

From a reliability point of view, # 2 is ideal because I cannot rely on # 1 when a user actively uses data from other tables, not user account tables.

What do you think? Do I have another way to do this?

the functions

.NET Framework 2.0

Asp.net 2.0

Implement user membership.

Sql Server 2005 Database

+6
source share
4 answers

Approach 2 is better than 1.

Sentence

You can do this with Async . You simply run the UpdateLastActivity() method and forget about the result. Thus, the performance of your application will not be difficult.

Hope this works for you.

+5
source

Itโ€™s not very clear how your system is built (in fact, this is the root point), but given that you say that solution #2 better (in terms of call paths), I would go for a more reliable solution, naturally, if it isnโ€™t detrimental to performance and does not create frustration for my user.

If you are working on DataBase (this is also not very clear from the question), the general approach here is to use triggers that are bound to the table.

+2
source

My personal opinion is that methods should be kept separate. This is due to the fact that the name of the method should reflect its purpose. Therefore, placing the functionality of the โ€œupdateโ€ in a method that is not named as such is not a big practice.

+1
source

In my opinion, this is more of a template question. I know little about your architecture, so the code may change, but my main idea will define each action as a class that implements the same interface as below:

 public interface IMemberActivity { void Execute(IMemberActivityLogger logger); } 
0
source

Source: https://habr.com/ru/post/907228/


All Articles