Click here to Skip to main content
15,905,915 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
QuestionPassing UserId To DAL Pin
Kevin Marois8-Jan-18 18:30
professionalKevin Marois8-Jan-18 18:30 
AnswerRe: Passing UserId To DAL Pin
Nathan Minier22-Jan-18 1:37
professionalNathan Minier22-Jan-18 1:37 
AnswerRe: Passing UserId To DAL Pin
Eddy Vluggen25-Jan-18 8:00
professionalEddy Vluggen25-Jan-18 8:00 
GeneralRe: Passing UserId To DAL Pin
Kevin Marois25-Jan-18 8:24
professionalKevin Marois25-Jan-18 8:24 
GeneralRe: Passing UserId To DAL Pin
Eddy Vluggen25-Jan-18 8:33
professionalEddy Vluggen25-Jan-18 8:33 
GeneralRe: Passing UserId To DAL Pin
Kevin Marois25-Jan-18 8:37
professionalKevin Marois25-Jan-18 8:37 
GeneralRe: Passing UserId To DAL Pin
Eddy Vluggen25-Jan-18 8:42
professionalEddy Vluggen25-Jan-18 8:42 
AnswerRe: Passing UserId To DAL Pin
jschell27-Jan-18 6:36
jschell27-Jan-18 6:36 
Your question is phrased in such a way that it is confusing.

Summary of the actual problem.
1. You have a number of tables which you want to update with information specific to the user that initiated the action.
2. You want to know how to get the user information, automatically, to the point to where it is used.

First problems with this architecture.
1. You said "all". Generally a bad idea. Often tables represent structure that has nothing to do with users and keeping data specific to the user every where is pointless.
2. It is better to track what a user did in the business sense and not in the data sense. This leads to several requirements that you often want to know what general action initiated the action, you want to keep the entire history (more than one user) and you need to deal with what happens when a user is deleted from the system.
3. Automated processes can be required to update a system. They have not user.
4. Some systems allow for one user to act on the behalf of another user. Single data collection points do not allow for that action to be captured.

Solution to your specific problem is as follows.
1. A user action is either initiated as a request (thread level) or a message (not thread level.)
2. As a request you can use the class ThreadLocal to store the user and then many layers later you retrieve the user from the ThreadLocal for use in your DAL.
3. A message has no way to transport that information except via a specific attribute. But the message should have originated as a request (real people must always start with real UI actions) so one uses 2 at the point where the message is created to add the user to the message. Then end that processes the message (again in a thread) extracts the user and puts it into the ThreadLocal that is processing now.

I suggest that you insure at and request origination point that you should, for all exit points, including exceptions, clear the user.

I suggest that you test the usage of the user at all usage points to insure that it does in fact exist, before attempting to use it. That insures no null pointers.

I suggest creating a user proxy object, do NOT use the original DAL user object, to contain the information about the user. That proxy object must be exposed to ALL layers whereas the DAL user object should not be.
GeneralRe: Passing UserId To DAL Pin
Gerry Schmitz27-Jan-18 11:54
mveGerry Schmitz27-Jan-18 11:54 
Questionhave u solved the code? Pin
chitaranjan pradhan8-Jan-18 8:54
chitaranjan pradhan8-Jan-18 8:54 
AnswerRe: have u solved the code? Pin
Pete O'Hanlon8-Jan-18 9:11
mvePete O'Hanlon8-Jan-18 9:11 
GeneralRe: have u solved the code? Pin
jschell20-Jan-18 5:56
jschell20-Jan-18 5:56 
QuestionAzure Pin
Mycroft Holmes29-Dec-17 20:18
professionalMycroft Holmes29-Dec-17 20:18 
AnswerRe: Azure Pin
Gerry Schmitz30-Dec-17 6:28
mveGerry Schmitz30-Dec-17 6:28 
GeneralRe: Azure Pin
Mycroft Holmes30-Dec-17 13:47
professionalMycroft Holmes30-Dec-17 13:47 
QuestionCredential stuffing / Passing Auth cookie to current user Pin
SEJohnson9-Dec-17 5:00
SEJohnson9-Dec-17 5:00 
QuestionJSON size Pin
Eytukan28-Nov-17 21:07
Eytukan28-Nov-17 21:07 
AnswerRe: JSON size Pin
Eddy Vluggen29-Nov-17 0:58
professionalEddy Vluggen29-Nov-17 0:58 
GeneralRe: JSON size Pin
Eytukan29-Nov-17 22:14
Eytukan29-Nov-17 22:14 
GeneralRe: JSON size Pin
Eddy Vluggen30-Nov-17 1:12
professionalEddy Vluggen30-Nov-17 1:12 
GeneralRe: JSON size Pin
Eytukan30-Nov-17 20:29
Eytukan30-Nov-17 20:29 
AnswerRe: JSON size Pin
Gerry Schmitz30-Nov-17 5:25
mveGerry Schmitz30-Nov-17 5:25 
GeneralRe: JSON size Pin
Eddy Vluggen30-Nov-17 8:16
professionalEddy Vluggen30-Nov-17 8:16 
GeneralRe: JSON size Pin
Gerry Schmitz30-Nov-17 9:19
mveGerry Schmitz30-Nov-17 9:19 
GeneralRe: JSON size Pin
Eddy Vluggen30-Nov-17 9:32
professionalEddy Vluggen30-Nov-17 9:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.