Signal OD to refresh

For complex topics that regular users would not be interested in. For power users and database administrators.
Post Reply
User avatar
Ardavan
Posts: 106
Joined: Sat May 15, 2010 9:10 am

Signal OD to refresh

Post by Ardavan » Thu Nov 10, 2016 1:26 pm

Hello again,

I am a database guy so I make alot of changes directly from the database, which work well, except that I have to ask users to restart OpenDental or at the very least log out then back in in order for them to see my changes. I know that when making changes directly from the application the application, as well as other clients connected to the server see the changes almost instantly. After ignoring the SignalOD table for the better half of a decade I decided to try writing to it in hopes of signaling clients to refresh but have not had any success even though I'm sending the exact same signal that OD sends when making changes. Perhaps an example is in order:

Lets say I made changes to the grouppermission table from within OpenDental, a row is created in the signalOD table that looks something like this:

SignalNum: 192
FromUser:
ITypes: 19
DateViewing: 0001-01-01
SigType: 1
SigText:
SigDateTime: 2016-11-10 16:09:33
ToUser:
AckTime: 0001-01-01 00:00:00
TaskNum: 0
FKey: 0
FKeyType: Undefined


So I wrote the following query to send my own signal:

INSERT INTO signalod(SigDateTime, AckTime, FKeyType, SigText, SigType, ITypes)
VALUES(NOW(), '0001-01-01 00:00:00', 'Undefined', '', 1, '19');

Which produces the following row in the table:

SignalNum: 193
FromUser:
ITypes: 19
DateViewing: 0001-01-01
SigType: 1
SigText:
SigDateTime: 2016-11-10 16:11:09
ToUser:
AckTime: 0001-01-01 00:00:00
TaskNum: 0
FKey: 0
FKeyType: Undefined

As far as I can tell my signal is identical to the one produced by the OpenDental application, however when I send my signal clients do not refresh their settings. Am I barking up the wrong tree in trying to force clients to refresh by writing to the signalOD table? If so what is the best way for me to force clients to refresh after I make changes from the MySQL console?

Thanks,
~ardy
There are 10 types of people in this world, those who will laugh at this joke, and those who won't. ~Annonymous Bug Writer

User avatar
cmcgehee
Posts: 711
Joined: Tue Aug 25, 2015 5:06 pm
Location: Salem, Oregon

Re: Signal OD to refresh

Post by cmcgehee » Thu Nov 10, 2016 3:44 pm

You are pursuing the proper line of attack. That is the correct way to send a refresh signal. I copied your same query and used it to insert a row into the signalod table, and it caused the Open Dental instance that I had open to refresh. Do you have a high value or a blank value for your process signal interval?

Another thing to note, we significantly changed our signalod table in 16.3. Many of its columns we split off into different tables.
Chris McGehee
Open Dental Software
http://www.opendental.com

User avatar
jsalmon
Posts: 1551
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: Signal OD to refresh

Post by jsalmon » Thu Nov 10, 2016 5:20 pm

cmcgehee wrote:Another thing to note, we significantly changed our signalod table in 16.3. Many of its columns we split off into different tables.
^^This is significant. Ardy, you are making it hard on yourself by being a "database guy" instead of using our methods. Updating your plugins each major version release of Open Dental might be very time consuming if we've changed our database schema (we try not to, but it does happen).
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

User avatar
Ardavan
Posts: 106
Joined: Sat May 15, 2010 9:10 am

Re: Signal OD to refresh

Post by Ardavan » Mon Nov 14, 2016 9:03 am

Thank you Chris for the prompt reply letting me know I'm not crazy, and thank you Jason for your wisdom and guiding me toward best practices.

After further testing over the weekend I realized that I was wrong in my initial assumption. Despite a signal being generated in the database upon changes made to users/groups/permissions using the application, the changes are actually not reflected in other clients until either the user logs out then back in again, or they actually goto Setup > Security.

I came to this conclusion after lots of testing, head scratching, then finally digging through the source (of version 16.2 checked out several months ago). The method GroupPermissions.RefreshCache() seems to be what does the trick, but it only appears in the following files:

FormCentralSecurity.cs
FormCentralLogOn.cs
GroupPermissionC.cs
Cache.cs
FormLogOn.cs
FormSecurity.cs


The file Signalods.cs which I assume is responsible for signal processing has explicit references to the following invalid types, and of course InvalidType.Security is not listed:

InvalidType.ShutDownNow
InvalidType.Fees
InvalidType.AllLocal
InvalidType.Appointment
InvalidType.SmsTextMsgReceivedUnreadCount
InvalidType.TaskPopup
InvalidType.Task

Though its a bit of a blunt instrument, I will be using the ShutDownNow signal to force refreshing of the cache for now.

Thanks again,
~ardy
There are 10 types of people in this world, those who will laugh at this joke, and those who won't. ~Annonymous Bug Writer

User avatar
jsalmon
Posts: 1551
Joined: Tue Nov 30, 2010 12:33 pm
Contact:

Re: Signal OD to refresh

Post by jsalmon » Mon Nov 14, 2016 10:03 am

Ardavan wrote:After further testing over the weekend I realized that I was wrong in my initial assumption. Despite a signal being generated in the database upon changes made to users/groups/permissions using the application, the changes are actually not reflected in other clients until either the user logs out then back in again, or they actually goto Setup > Security.
Hmmmm maybe it would help us to know more about what you mean when you say "the changes are actually not reflected".
The fact that the user goes to Setup > Security and sees what other workstations have done means that your signal is working correctly.
Ardavan wrote:I came to this conclusion after lots of testing, head scratching, then finally digging through the source (of version 16.2 checked out several months ago). The method GroupPermissions.RefreshCache() seems to be what does the trick, but it only appears in the following files:

FormCentralSecurity.cs
FormCentralLogOn.cs
GroupPermissionC.cs
Cache.cs
FormLogOn.cs
FormSecurity.cs
Cache.cs is the money maker here. That is the class that all other workstations should be getting hit if your database row was successful. You could easily test that out by debugging one instance of OD, placing a breakpoint on that line and sitting there for a little bit (making sure it is not getting hit for another reason) and then manually do your insert and within your Signal Process Interval (defaults to 6 - 7 seconds) your breakpoint should hit.
Ardavan wrote:Though its a bit of a blunt instrument, I will be using the ShutDownNow signal to force refreshing of the cache for now.
This sounds very annoying from a users standpoint. I never like being kicked out of whatever program I'm in the middle of using due to something someone else has done in the office. What if a Dr. is in the middle of seeing a patient and is turned around and talking with them and doesn't notice that their Open Dental is getting killed behind them and they loose all of their notes? That sounds invigorating.

You might get more helpful ideas from us if you explain in vague terms what you are wanting to accomplish.
The best thing about a boolean is even if you are wrong, you are only off by a bit.

Jason Salmon
Open Dental Software
http://www.opendental.com

User avatar
dgraffeo
Posts: 147
Joined: Wed Sep 24, 2014 3:19 pm

Re: Signal OD to refresh

Post by dgraffeo » Tue Nov 15, 2016 8:21 am

User permissions are loaded when the user logs in and don't change until that user logs out. Their permissions will not change in the middle of their session, as far as I'm aware. I think that's perhaps what you're trying to do?
There is a reasoning for this, and that is if they're inside a form or section of the program that requires a permission they once had, but now do not have, they can be suddenly halted from progressing, or the information in the form can be halfway saved and lead to bad information.
"To understand what recursion is, you must first understand recursion."

David Graffeo
Open Dental Software
http://www.opendental.com

User avatar
Ardavan
Posts: 106
Joined: Sat May 15, 2010 9:10 am

Re: Signal OD to refresh

Post by Ardavan » Tue Nov 22, 2016 8:40 am

Thank you Jason for pointing out the flaws with my heavy handed workaround, I didn't even think about the disruption that would be caused. Also thank you very much for your recommendations for debugging, using a breakpoint is a great idea! I'm sorry for my lack of clarity in earlier posts, David basically confirmed my findings and explained the reasoning behind it which makes sense (thank you David), user permissions are not updated by the signal mid session because of the potential adverse effects.
An amendment to David's explanation: a user's permissions can change within a session if the user navigates to Setup > Security.
There are 10 types of people in this world, those who will laugh at this joke, and those who won't. ~Annonymous Bug Writer

Post Reply