A
A
Alexander Zaitsev2015-05-30 22:10:40
ASP.NET
Alexander Zaitsev, 2015-05-30 22:10:40

Is there a prettier solution to implement such a system?

There is a Windows server and knowledge of C#. It is necessary to implement a system where through the site (ASP.NET MVC) it will be possible to launch some processes (for example, automatically sending messages to users), which will last a certain time. It should be possible to track the progress of these processes through the website. How can this be done?
My vision:
- implement processes as console applications
- launch applications via Process.Start() through the site.
- for progress, create a table for progress in the database
- display progress on the site from the database; Through ajax in an infinite loop, take progress data.
Can it be done in another way? Are there more beautiful ones, or just other solutions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2015-05-31
@Nipheris

If you plan to use dotnet (both for "processes" and for the site), then it makes sense to take advantage of the platform. I would do the following:
- implement site logic + business logic in ASP.NET; here - placing "orders" in the controller's queue;
- a separate process of the operating system - the controller (host) for running "processes"; each such controller (there may be several of them) loads an assembly/assemblies with a "process" code into a separate application domain, configuring its access rights to the surrounding system (sandbox); thus, when a task is queued to a specific controller (you can choose randomly or according to workload), the latter, when ready, creates an application domain, loads the necessary plugin assembly into it, and starts the code for execution with the necessary parameters.
- the code of "processes" should be formatted in the form of dotnet assemblies; design the interface that will be implemented by each assembly;
- progress can of course be written to the database, but you can not write it either: a properly working controller can itself report the most relevant information on the state of execution; in the same interface through which the controller is given to the task queue, you can add the ability to request the execution status; on the client to take on ajax, only of course not in a cycle, but on a timer.
- it is possible and necessary to write to the database the start/completion time of the task, the result (success/error), etc.;
such an architecture will allow you to allocate separate machines for the site, separate machines for execution, increase the number of "process" controllers and the number of machines serving the site itself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question