多用户Web应用程序查询 [英] Multi-User Web Application Queries

查看:70
本文介绍了多用户Web应用程序查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在开发一个Web应用程序,该应用程序将在完成时成为托管的多用户解决方案.我正在尝试找出处理我的应用程序数据库设计的最佳方法.具体来说,我需要弄清楚如何处理多个单独的帐户.

实际上,我有一个Web应用程序(使用C#的ASP.NET),其中一个网页包含一个计算"按钮.

1)单击计算按钮:单击该按钮将调用C#.net exe.在/bin/debug/文件夹中,也有exe文件存在污染;还有2个名为Input,Output的文件夹.

2)EXE执行过程:每当调用exe时,它都会从Input文件夹中获取一个文件,执行一些计算并生成一些文件作为结果集.这些生成的文件(.txt或.xls或.csv)存储在输出文件夹中. exe执行结束.

3)单击计算按钮的进一步过程:计算按钮完成其exe调用部分,并且exe执行结束,并在输出文件夹中生成结果.此外,将从..bin/Debug/Output文件夹中的结果文件中读取数据,并将其存储到数据库表中.

现在,由于这是一个多用户Web应用程序,因此多个用户可以同时执行此过程.因此,请帮助我理解并实现此多用户功能?

我对上面讨论的问题的看法:每当用户通过注册表单注册到网站时,都会在路径../bin/Debug/
下创建一个具有其唯一用户名的文件夹.
在此文件夹下,将创建输入和输出文件夹,即现在用于访问输入文件夹的路径将是..bin/Debug/username/Input而不是..bin/Debug/Input. ll''ly for Output Folder.

我]但是我的问题是;当用户说"A"登录时,单击计算按钮;如何在C#.net exe中获取当前会话的用户名,以便可以访问该用户名文件夹并从该(当前已登录)用户的输入文件夹中获取输入文件并将结果文件存储在输出文件夹中?如果其他用户说"B"同时或在用户"A"的过程中登录怎么办,那么如何识别当前用户名会话保持"A"呢?因为现在它将立即保持"B",然后exe将从路径..bin/Debug/B/Input而不是..bin/Debug/A/Input读取输入.所以.如何处理?

II]当用户说"A"登录时,单击计算按钮,通过从正确的路径..bin/Debug/A/Input读取文件来执行C#.net exe,并将结果文件存储在..bin/Debug/A/输出.同样,用户"B"登录并遵循相同的过程.之后,将这些数据从输出文件中读取并存储到数据库表中.现在两个用户都处于活动状态,他们已经访问了Web应用程序,因此如何同时处理对数据库表的多次访问.是否可以通过``数据库锁''(如果是的话)应如何应用?

请让我知道是否还有其他解决方案.

注意:我在后端使用MYSQL.



在此先感谢您,

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,

推荐答案

您无需担心会话.

asp.net中的会话变量存储进程中的每个用户会话,并且由于它是Web应用程序,因此您需要为每个用户登录创建会话变量.

每个会话都会处理自己的请求,因此可以操纵数据库从会话变量中检索值,并根据需要处理插入,更新,删除之类的操作.

创建会话变量

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

并检索

字符串值=会话["VariableName"].ToString();

请通过搜索google在asp.net中阅读会话,它将比..
更加清晰.
而且,就锁定而言,您必须对以.exe格式保存的资源使用线程处理.


希望对您有帮助...干杯
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


只需检查一下我是否已明白-当用户单击Compute时,您:
(a)使用输入数据生成文件;
(b)使用EXE处理输入数据tp生成输出结果文件;
(c)获取输出结果并进行一些进一步的操作.

用户已经注册并登录到站点-因此您需要数据库中的一个表来包含用户列表-如果其中有一些唯一的ID来标识每个用户,这可能会有所帮助.

然后,您可以使用ASP.NET会话来跟踪每个会话中哪个用户处于活动状态/是否已登录等.-您可以同时拥有许多同时具有各自会话数据的用户-ASP.NET可以很好地处理它(它'' s是什么会话!).

记住,一个用户可以在一个会话中打开多个页面,因此即使一个用户也可以并行启动多组计算-因此,每当用户单击计算"时,您都需要为该组计算生成某种标识符,然后链接到该用户-也许是数据库中的第二个表来记录该用户(包括用户ID和计算ID的字段,并链接到用户ID上的用户表)?

然后将所有文件存储在2个文件夹中-1个用于输入/1个用于输出-文件名以计算ID开头.我还要将它们放在Bin文件夹之外-甚至将它们存储在Web根目录之外,除非Web客户端需要直接访问以下载它们(这听起来很可疑,因为一个用户随后可能会与另一个用户取得联系).输入/结果,除非您在某处有一些保护性代码.

然后,在(b)处需要知道的所有计算都是计算ID-然后它可以检索正确的输入文件/生成正确的输出文件.

您有很多选择.使用EXE,命令行参数很容易.但是,为什么要使用单独的EXE?如果您可以控制编码,为什么在ASP.NET代码中不包含一个或多个工作线程,以及正在等待处理/进行中的计算集列表-更容易保持对正在进行的同时计算集数的控制,从而进行管理服务器负载/没有启动和结束单独进程的开销/易于跟踪一组计算何时完成并启动步骤(c),而不必检查进程是否已结束或监视输出文件/易于实现相关异常处理和错误报告/如果集合需要太长时间"完成,则终止计算. . .您可能还需要某种清除程序线程,以确保您不会逐渐积累不需要的历史输入/输出文件和数据库计算记录.

数据库可以很好地处理多个并发访问(数据库非常擅长此操作)-只需注意单独的线程或进程同时访问同一表中的相同记录(不应同时访问同一表中的不同记录)一个问题),尤其是当数据被更改时,您可能会遇到冲突/冲突-数据库将处理这些冲突/冲突(不应崩溃或死锁),但可能会导致一个或多个数据库请求失败,因此您的代码需要意识到可能性并检查/处理.
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.


这篇关于多用户Web应用程序查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆