FormOpenDental.Load_end hook problem

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
wjstarck
Posts: 936
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

FormOpenDental.Load_end hook problem

Post by wjstarck » Wed Sep 15, 2010 7:55 am

I have two separate plugin projects which need to operate on the OD file menu.

So each has the following in Plugin.cs (one uses FormOpenDentalA and the other FormOpenDentalT):

Code: Select all

        public override bool HookAddCode(object sender, string hookName, params object[] parameters){//required method
            switch (hookName){
                case "FormOpenDental.Load_end":
	FormOpenDentalA.Load_end((OpenDental.FormOpenDental)sender, patNum);
	return true;
                default:
                    return false;
            }
        }
The problem I'm running into: Whichever plugin is listed first alphabetically seems to prevent the other's HookAddCode from executing.

The declarations look like

Code: Select all

namespace Anesthesia{
	///<summary></summary>
	public class FormOpenDentalA : Control{
		
                //Adds Anesthesia Menu to Main OpenDental Menu Bar
	public static FormOpenDentalA formOpenDentalA;

                public FormOpenDentalA(){
Does anything obvious stick out?
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
wjstarck
Posts: 936
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: FormOpenDental.Load_end hook problem

Post by wjstarck » Wed Sep 15, 2010 8:49 am

I confirmed this by creating 2 different versions of the PluginExample.dll code, making some changes to the second version (launching two of the same form from Plugin2 for example).

Whichever Plugin is listed first alphabetically will have its changes applied. The second one is SOL. :cry:
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

michael
Posts: 38
Joined: Wed Aug 04, 2010 8:49 am

Re: FormOpenDental.Load_end hook problem

Post by michael » Thu Sep 16, 2010 5:58 am

I'm not sure exactly what your goal is. Are you trying to get both plugins to run, or just the right one in a specific case? Some additional background information may help.

I'm guessing you want to run a different hook in each place. The standard we use is to have the hook name match the class name of the object that contains it (http://www.opendental.com/manual/patternplugins.html). So if you have a FormOpenDentalA and a FormOpenDentalT, then you should probably change the hook name from "FormOpenDental.Load_end" to "FormOpenDentalA.Load_end" and "FormOpenDentalT.Load_end" in the respective cases.

Again, I'm shooting in the dark here. This may be irrelevant as I am making a lot of assumptions. More information about exactly what you are doing will allow me to better assist you.

User avatar
wjstarck
Posts: 936
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: FormOpenDental.Load_end hook problem

Post by wjstarck » Thu Sep 16, 2010 6:58 am

Thanks, Michael.

One of the plugins or both might be installed on a user system. So yes, I'd need them to run at the same time.

I see now that if I add a second distinct Load_end hook to my local copy of FormOpenDental that everything works OK:

Code: Select all

			Plugins.HookAddCode(this,"FormOpenDentalA.Load_end");
			Plugins.HookAddCode(this, "FormOpenDentalT.Load_end");
So, just to make sure I'm understanding correctly - if I want to publish another plugin I'll have you add another distinct hook at the bottom of FormOpenDental_Load?

If so, do you want me to rename these something more descriptive than A and T?
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
jordansparks
Site Admin
Posts: 5744
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: FormOpenDental.Load_end hook problem

Post by jordansparks » Thu Sep 16, 2010 8:26 pm

OK, I've altered the head to make it run the code from all plugins. Let me know if it works, and then I'll backport it to 7.2.
Jordan Sparks, DMD
http://www.opendental.com

User avatar
wjstarck
Posts: 936
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: FormOpenDental.Load_end hook problem

Post by wjstarck » Fri Sep 17, 2010 5:16 am

That works great Jordan.

Thanks.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
jordansparks
Site Admin
Posts: 5744
Joined: Sun Jun 17, 2007 3:59 pm
Location: Salem, Oregon
Contact:

Re: FormOpenDental.Load_end hook problem

Post by jordansparks » Fri Sep 17, 2010 5:37 am

Backported to 7.2
Jordan Sparks, DMD
http://www.opendental.com

Post Reply