Plugin not loading (16.4 beta)

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

Plugin not loading (16.4 beta)

Post by wjstarck » Sat Dec 31, 2016 2:02 am

Hello-

My plugin suddenly won't load in 16.4b.

No errors in the debugger, it simply doesn't load at all.

I downloaded and installed the Perio Voice Chart plugin which seems to load, although a popup window says "There was an error with the Voice Command Plugin" before the perio chart loads.

How do I track this down?
Last edited by wjstarck on Sun Jan 01, 2017 5:40 pm, edited 1 time in total.
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: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Plugin not loading 16.4 beta

Post by wjstarck » Sat Dec 31, 2016 7:58 am

FYI, I reverted all the way back to revision 15861, but the problems persists.

Then I hopped into my way back machine and went back to revision 15497, which was around November 1st. And the plugin loads then, so it seems something might have changed on your side between now and then.

Thanks
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: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Plugin not loading 16.4 beta

Post by wjstarck » Sun Jan 01, 2017 11:35 am

OK I tracked down the source of the problem

The change from

Code: Select all

 public static long CurPatNum;
to

Code: Select all

        public static long CurPatNum {
			get {	return _curPatNum; }
			set {
				if(value==_curPatNum) {
					return;
				}
				_curPatNum=value;
				ODEvent.Fire(new ODEventArgs("PatNumChanged",value));
			}
		}
on FormOpenDental.cs (lines 464-473) is causing an exception "FormOpenDental.CurPatNum not found" to be thrown on OpenDentBusiness.Plugins.cs at line 146 when my plugin tries to load, and so the plugin does not load at all.

What do you recommend?
Cheers,

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

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

Re: Plugin not loading (16.4 beta)

Post by cmcgehee » Mon Jan 02, 2017 12:12 pm

In regards to the Perio Chart Voice plugin, there should be a folder in the Open Dental installation directory (or in the Debug or Release folder if you're running compiled) that is named "VoiceCommandPlugin". If you could email me the contents of error log file, I can take a look.

chris@opendental.com
Chris McGehee
Open Dental Software
http://www.opendental.com

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

Re: Plugin not loading (16.4 beta)

Post by jsalmon » Tue Jan 03, 2017 10:25 am

I recommend just utilizing the public static directly like FormOpenDental.CurPatNum if you aren't already. Heed the following plugin example:

Code: Select all

using OpenDental;
using OpenDentBusiness;
using System.Windows.Forms;

namespace PluginSimple {
	public class Plugin:PluginBase {
		public override bool HookAddCode(object sender,string hookName,params object[] parameters) {//required method
			return false;
		}

		public override bool HookMethod(object sender,string hookName,params object[] parameters) {//required method
			switch(hookName) {
				case "FormOpenDental.OnCommlog_Click":
					if(sender.GetType()==typeof(FormOpenDental)) {
						MessageBox.Show("The currently selected PatNum is: "+((FormOpenDental)sender).CurPatNum);
					}
					return true;
				default:
					return false;
			}
		}
	}
}
The above code will no longer work and the message box section needs to be replaced with:

Code: Select all

MessageBox.Show("The currently selected PatNum is: "+FormOpenDental.CurPatNum);
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
wjstarck
Posts: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Plugin not loading (16.4 beta)

Post by wjstarck » Tue Jan 03, 2017 1:29 pm

Hmmnm, that's what I'm already doing?

Here is a sample of some of my HookAddCode:

Code: Select all

public override bool HookAddCode(object sender, string hookName, params object[] parameters){//required method
            switch (hookName){	 //generally in alphabetical order unless grouped by function
				case "ContrAppt.ContrApptSheet2_MouseLeave_end": //sets number of saved IV or GA anesthetic records in Anesthetic Record subMenuItems
                    FormOpenDentalA.RefreshMenuItems((ContrAppt)sender, FormOpenDental.CurPatNum);
                    return true;
				case "ContrChart.gridProg_MouseUp_end": //Adds an enhanced contextual menu to menuProgRight that allows user to set ProcStatus without having to enter each individual Proc
                    if (AnesthPrefs.AddEnhancedMenuItems() == true) {//toggle pref depending on user pref
                        contrChartA = new ContrChartA();
                        contrChartA.AddEnhancedMenu((ContrChart)sender, (ContextMenu)parameters[0], (OpenDental.UI.ODGrid)parameters[1],(Patient)parameters[2]);
                    }
                    return true;
                case "ContrChart.ModuleSelected_end":  //Dynamic chart refresh
					contrChartA = new ContrChartA();
                    object sender2 = new object();
                    sender2 = sender;
                    contrChart = (ContrChart)sender2;
					try {//in the event that anesthesia prefs are selected from formOpenDental
						sender2 = contrChart.ParentForm;
					} catch { }
                    if (AnesthPrefs.DynChartRefresh() == true && !runOnce) {
                        FormOpenDentalA formOpenDentalA = new FormOpenDentalA();
						contrChartA.ModuleSelected_end((FormOpenDental)sender2, FormOpenDental.CurPatNum);
					runOnce = true;
                    }
                    return true;
}
Cheers,

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

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

Re: Plugin not loading (16.4 beta)

Post by jsalmon » Tue Jan 03, 2017 3:55 pm

Your code worked just fine for me and I implemented it as follows:

Code: Select all

using OpenDental;
using OpenDentBusiness;
using System.Windows.Forms;
using System;
using OpenDental.UI;

namespace PluginSimple {
	public class Plugin:PluginBase {
		private ContrChart contrChart;
		private ContrChartA contrChartA;
		private bool runOnce;

		public override bool HookAddCode(object sender,string hookName,params object[] parameters) {//required method
			switch(hookName) {    //generally in alphabetical order unless grouped by function
				case "ContrAppt.ContrApptSheet2_MouseLeave_end": //sets number of saved IV or GA anesthetic records in Anesthetic Record subMenuItems
					FormOpenDentalA.RefreshMenuItems((ContrAppt)sender,FormOpenDental.CurPatNum);
					return true;
				case "ContrChart.gridProg_MouseUp_end": //Adds an enhanced contextual menu to menuProgRight that allows user to set ProcStatus without having to enter each individual Proc
					if(AnesthPrefs.AddEnhancedMenuItems() == true) {//toggle pref depending on user pref
						contrChartA = new ContrChartA();
						contrChartA.AddEnhancedMenu((ContrChart)sender,(ContextMenu)parameters[0],(OpenDental.UI.ODGrid)parameters[1],(Patient)parameters[2]);
					}
					return true;
				case "ContrChart.ModuleSelected_end":  //Dynamic chart refresh
					contrChartA = new ContrChartA();
					object sender2 = new object();
					sender2 = sender;
					contrChart = (ContrChart)sender2;
					try {//in the event that anesthesia prefs are selected from formOpenDental
						sender2 = contrChart.ParentForm;
					}
					catch { }
					if(AnesthPrefs.DynChartRefresh() == true && !runOnce) {
						FormOpenDentalA formOpenDentalA = new FormOpenDentalA();
						contrChartA.ModuleSelected_end((FormOpenDental)sender2,FormOpenDental.CurPatNum);
						runOnce = true;
					}
					return true;
				default:
					return false;
			}
		}

		public override bool HookMethod(object sender,string hookName,params object[] parameters) {//required method
			switch(hookName) {
				case "FormOpenDental.OnCommlog_Click":
					if(sender.GetType()==typeof(FormOpenDental)) {
						MessageBox.Show("The currently select PatNum is: "+FormOpenDental.CurPatNum);
					}
					return true;
				default:
					return false;
			}
		}

		public override void HookException(Exception e) {
			MessageBox.Show(e.Message);
		}
	}

	internal class ContrChartA {
		public ContrChartA() {
		}

		internal void AddEnhancedMenu(ContrChart sender,ContextMenu contextMenu,ODGrid oDGrid,Patient patient) {
			throw new NotImplementedException();
		}

		internal void ModuleSelected_end(FormOpenDental sender2,long curPatNum) {
			throw new NotImplementedException();
		}
	}

	internal class AnesthPrefs {
		internal static bool AddEnhancedMenuItems() {
			throw new NotImplementedException();
		}

		internal static bool DynChartRefresh() {
			throw new NotImplementedException();
		}
	}

	internal class FormOpenDentalA {
		internal static void RefreshMenuItems(ContrAppt sender,long curPatNum) {
			throw new NotImplementedException();
		}
	}
}
Maybe your project references are bad or simply need to be recompiled for the new version?
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
wjstarck
Posts: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Plugin not loading (16.4 beta)

Post by wjstarck » Tue Jan 03, 2017 4:38 pm

Wow.

I hereby officially proclaim January 3rd as "Jason Salmon is a Genius" day!

Turns out all my OD references were pointing to 16.3 folders. :oops:

Fixed now, thanks Jason.
Cheers,

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

Post Reply