Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I'm working on a web application that will be a hosted, multi-user solution when it is finished. I'm trying to figure out the best way to handle the database design for my app. Specifically, I need to figure out how to handle multiple, separate accounts.

Actually I have a web application(ASP.NET using C#) in which one of the webpages contains a "Compute" button.

1) Compute button click :On its click a C#.net exe is called. In the /bin/debug/ folder which contaions exe too; 2 more folders named Input, Output exist.

2) EXE Exxecution Process : Whenever exe is called, it takes a file from Input folder, performs some calculations and generates some files as a resultset. Those generated files(.txt or .xls or .csv) are stored in output folder. Exe execution ends.

3) Further procees of Compute button click : compute button finishes its exe calling part and exe execution ends genrating results in output folder. Further, the data is read from result files present in ..bin/Debug/Output folder and stored into the Database tables.

Now, since this is a multi-user web application, this process can be followed by multiple user at the same time. So, please help me to understnad and implement this multiple-user feature ?

My-view on the problem discussed above : whenever a user registers to the website through registration form, a folder with his unique username will be created under path ../bin/Debug/

Under this folder Input and Output Folders will be created i.e. now path for accessing Input Folder will be ..bin/Debug/username/Input instead of ..bin/Debug/Input. ll'ly for Output Folder.

I] But then my problem is; when user say 'A' logs in, clicks on compute button; how in C#.net exe, can i get the current session username so that I can access that username folder and take the Input file from that (currently logged in) user's Input Folder and store resultant files in Output Folder ?? And what if other user say 'B' logs in at the same time or in the middle of the process of user 'A' , then how is it pssible to recognize that current username session holds 'A'; because now it will hold 'B' now and then exe will read input from path ..bin/Debug/B/Input instead of ..bin/Debug/A/Input. So. how to handle this ?

II] when user say 'A' logs in, clicks on compute button, C#.net exe gets executed by reading file from correct path ..bin/Debug/A/Input and stores result files in ..bin/Debug/A/Output. Also, user 'B' logs in and follows the same procedure. After this data is to be read from output files and stored into the Database tables. Now both users are active, they have accessed the web application, so how to handle multiple access to database tables at the same time. Is it possible thr' Database Locks, if yes how it should be applied ?

Please do let me know if any other solution is available.

NOTE : I am using MYSQL in the backend.



Thanks in Advance,
Posted
Updated 3-May-11 0:23am
v2

You need not to worry about the session.

Session variable in asp.net store each user session in its process, and as it is a web application you need to create a session variable for every user logs-in.

Each session will process its own request, so to manipulate database retrieve value from session variable and process the operation like insert,update,delete whichever you need.

To Create Session variable

Session.Add("VariableName", "Value");

and to retrieve

string value = Session["VariableName"].ToString();

please read session in asp.net by searching google, it will be more clear than..

And as locking is concerned you have to use threading for your resource you have kept in .exe format.


Hope this help...Cheers
 
Share this answer
 
Just to check I've got this straight - when user clicks Compute, you:
(a) Generate file with input data;
(b) Use EXE to process input data tp generate a file of output results;
(c) Take output results and do some further manipulation.

User has registered and logged in to the site - so you need a table in your database to contain a list of users - and it would probably help if you had some unique ID in it to identify each user.

You can then use ASP.NET session to keep track of which user is active in each session / whether logged in etc. - you can have lots of simultaneous users each with their own session data - ASP.NET handles that fine (it's what session is for!).

Remembering that within a single session a user can have multiple pages open, so even a single user could presumably initiate several sets of computations in parallel - so whenever a user clicks Compute, you need to generate some sort of identifier for that set of computations and link it to that user - maybe a second table in your database to record that (including fields for user ID and computation ID and linked to your user table on User ID)?

I'd then store all your files in 2 folders - 1 for input / 1 for output - with file names starting with the computation ID. I'd also keep them out of the Bin folder - maybe even store them outside the web root unless web clients need direct access to download them (which itself sounds dubious as one user might then be able to get at another user's inputs / results unless you have some protective code somewhere).

All your computations at (b) then need to know is the computation ID - it can then retrieve the right input file / generate the right output file.

You have lots of options for that. Using an EXE, a command line parameter is easy. But why use a separate EXE? If you have control of the coding, why not have one or more worker threads in the ASP.NET code and lists of computation sets awaiting processing / in progress - easier to keep control over the number of simultaneous sets of computations in progress and hence manage server load / no overheads of starting up and ending separate processes / easier to keep track of when a set of computations is complete and initiate step (c) rather than having to check whether a process has ended or monitor output files / easier to implement any relevant exception handling and reporting of errors / terminate computations if a set takes 'too long' to complete . . . You may also need some sort of sweeper thread to make sure you don't gradually accumulate unwanted historic input / output files and database computation records.

The database will handle multiple concurrent accesses fine (databases are very good at that) - just watch out for separate threads or processes accessing the same records in the same table at the same time (different records in the same table simultaneously shouldn't be an issue), especially when data is being altered as you can then get collisions / conflicts - the database will handle these (it shouldn't crash or deadlock), but may result in one or more database requests failing, so your code needs to be aware of possibilities and check / handle them.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900