1

I have a program that 10-20 people use throughout the day. Because things are rapidly fluctuating I occasionally have to take the database offline, or restart the server for other reasons. I'd like to have a better way to make sure no one is currently in the program than walking to each person and asking them.

I don't want to re-invent the wheel if something like this already exists.

The thoughts I had were:

  • Create a database "history" entry each time users open or close the program to see who is currently using the system.
  • Use WCF to have the clients "tell" the server that they are connected every X seconds.

Are there better or easier solutions to this problem?

Origin
  • 1,943
  • 13
  • 33
  • What kind of "program" is it, ASP.NET, WPF,Winforms,...? – Tim Schmelter Mar 05 '12 at 22:52
  • It is a Winforms program – Origin Mar 05 '12 at 23:01
  • Maybe your database keeps record of currently logged in users that you can just query. One of those system tables... – Dialecticus Mar 05 '12 at 23:06
  • and what kind of database are you using? SQLServer, Access, MySQL or... – Steve Mar 05 '12 at 23:07
  • 2
    It sounds like you have larger issues if you have to take a production database offline in the middle of the business day. Schedule your maintenance after-hours. – Daniel Mann Mar 05 '12 at 23:10
  • Maybe you can use a [WCF Duplex Service](http://msdn.microsoft.com/en-us/library/ms731064.aspx). It enables communication between all endpoints. Use it to send heartbeat request from server to client, you could even send maintenance messages to your clients that way. – nik Mar 05 '12 at 23:54
  • Thanks for comments. As for @DBM , your comment would apply to most industries, but not mine. – Origin Mar 06 '12 at 03:07
  • @Origin In what industry would the rebooting of production servers during the business day be acceptable? I'm *extremely* curious. – Daniel Mann Mar 06 '12 at 03:11
  • @DBM - Semiconductor. The requirements are changing daily, if not hourly, and we must react to changes as quickly as possible. It's not always a reboot, but often times it is a change to the table structure, and some programming logic changes. – Origin Mar 06 '12 at 05:05
  • @Origin Then you have issues with your requirements gathering process and development schedule, but this is neither the place nor the time to be discussing them. – Daniel Mann Mar 06 '12 at 13:10
  • @Origin Duplicate: http://stackoverflow.com/questions/4722198/checking-if-windows-application-is-running – Jeremy Thompson Mar 26 '12 at 00:27
  • Not a duplicate. That question is specifically about on one machine. Mine is clearly about multiple machines. I will be adding this feature to my program soon and will assign an answer based on which method I go with. – Origin Mar 26 '12 at 04:16

2 Answers2

0

One solution would be to create a database table where everytime someone logs on, a record is created for them. Every 15 mins it updates with the last update time. When they close, it deletes the record. If any record is more than 15 mins long, it is an app crash.

Its crude but it works, you then have a simple DB query to run.

LongArm
  • 208
  • 1
  • 6
  • Thanks. This is the option I had been considering - but wasn't sure if it was considered "hackish" by others. – Origin Mar 05 '12 at 22:58
  • Thanks for the response LongArm. It's unfortunate that all the people who were complaining about how bad your answer was didn't post up one of their own. I decided to just use windows functions like `net session`, `net file`, and `netstat | find "{portNumberOfSqlServer}` to figure out who was currently connected to the machine. – Origin Mar 27 '12 at 02:12
0

One solution is to broadcast some data across the network with UdpClient and look for responses to see if any instances of the application are online.

I don't know if this solution is viable in your case, but I figured this solution would come in handy for some people, at least.

Timiz0r
  • 1,304
  • 7
  • 7