문제

I have an application written in ASP.NET C# that should run for about 2 days and then stop until it is started again. The application sometimes runs into some trouble that, at the moment, requires manual intervention to make it continue. (So far, SQL server in itself was never the problem)

When working, the application writes a line to a log database table at least every 20 minutes. If these lines are not there, it means the application either finished the task or needs help to continue. In these cases, I would like to get an email or some other notification.

What is the best way to detect and notify me if or when the application has stopped writing these lines to the log database table?

If it makes things easier, I could make the application perform some other regular task, such as writing to a file or sending a TCP/UDP packet somewhere.

도움이 되었습니까?

해결책

Aside of the obvious concerns with the design of this application. Given your current design, you could potentially write a windows service to monitor the log file. If it's older than N minutes, fire off an System.Net.Mail.MailMessage.

다른 팁

If you're able to make the application do something like sending packets, is there any reason you couldn't make the application send its own alerts? The alert needs to be sent when the application has finished, or when it needs "help" (I'm assuming some sort of manual input or confirmation). It's reasonable to assume that the application can tell when either of these things have happened, so... why can't the application send an alert? ASP.NET apps can access SMTP and send emails really easily using the System.Net.Mail.SmtpClient. It seems really odd to me to have a separate program sending emails on behalf of a program that has access to a perfectly good email client class.

You can send emails from the global application error handler (Application_Error in Global.asax). Windows service monitoring the database is another solution, but it may be better to write a short script/command line application and run it with windows scheduler. It has lower footprint and it is easier to write and install.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top