0

I found this thread and this thread, but haven't found a solution I can understand. I'm building a winforms desktop application that I hope to install on a few machines that query a database on a network drive. My goal was to make a table with usernames and a boolean that changes to 'true' when the user signs into the app. My intent was to prevent the same user from signing in on two machines at once. However, it occurred to me that an app crash or loss of power would prevent any code I could write from updating the datatable table column to 'false'. I'm a novice-intermediate programmer, not a professional, and I haven't found a solution so please forgive me. All suggestions would be appreciated. Some suggestions I have found are creating a table with sign-in and sign-out timestamps and to compare the time between them at startup, using session IDs (which I'm not sure how to do), and attempting to catch crashes to trigger some code. The problem is I'm not sure if there's a consensus on what the proper way is to accomplish what I'm trying to do, which is to prevent duplicate logins and also logging out users automatically in the event of some system failure so that they can login again later.

  • 1
    Something I've done many years ago was when the user signed in, the client side app would update the user's account with the current timestamp... let's say every 10 seconds. So anything older than 15 seconds would be assumed signed off. – John Cappelletti May 29 '19 at 18:17
  • Could you create an option to close a previous session if another one is open you could also check if it's been idle for a certain amount of time? – Luis Cazares May 29 '19 at 18:27
  • 1
    @JohnCappelletti That's a good idea, thank you. – Missing Semicolon May 29 '19 at 20:18
  • @LuisCazares I'm still not too sure what sessions are or how to use them, but I will look into them, thank you. – Missing Semicolon May 29 '19 at 20:19
  • Is this a LAN we are talking about? Would the server be down with a power failure too? If so then run a stored procedure that set that column to false for the entire users table on start up. – Mary May 31 '19 at 04:01
  • @Mary Yes this is a LAN. My understanding is that the server is connected to a UPS. Regardless, that is an excellent point, I hadn't thought of that. I was more worried about system crashes or power failures for individual stations. I'll look into a stored procedure, thanks! – Missing Semicolon May 31 '19 at 21:46

0 Answers0