Hook Request

This forum is for programmers who have questions about the source code.
Post Reply
SPHCDave
Posts: 7
Joined: Mon Jul 29, 2019 6:32 am
Location: Jacksonville, FL

Hook Request

Post by SPHCDave » Wed Aug 21, 2019 11:11 am

Hi,
I need to have 3 modifications made to version 18.0 and newer.
I need to add 2 Hooks.
1) The first hook is in the method listPayType_Click

private void listPayType_Click(object sender,EventArgs e) {
*********************** begin new hook **************************************
if (Plugins.HookMethod(this, "FormPayment.PayType",listPayType.SelectedItem))
{
return;
}
*********************** end new hook **************************************

2) The second hook is in the SavePaymentToDb method. It needs to be inserted right before the line - if (_isCCDeclined) {

*********************** begin new hook **************************************
object[] ResText = { textAmount.Text, listPayType.SelectedItem, 0, 0 };
Plugins.HookAddCode(this, "FormPayment.Payment", ResText);
if ((bool)ResText[2]) //The transaction was processed
{
textNote.Text = textNote.Text + ResText[1].ToString();
textAmount.Text = ResText[0].ToString();
if (!(bool)ResText[3])
{
_isCCDeclined = true;
}
}
*********************** end new hook **************************************
if (_isCCDeclined) {

3) I will also need to have the SavePaymentToDb method changed from Private to Public so that we can call it from our plugin.

Let me know if you need more information or if you are Ok with these three changes.

Thanks,
Dave

PatrickC
Posts: 56
Joined: Thu Jun 06, 2019 11:37 am

Re: Hook Request

Post by PatrickC » Wed Aug 21, 2019 2:01 pm

I can add the following hooks with some amendments.

Per policy, hooks will not be added to stable versions of Open Dental. Currently 19.1 is Stable, and the hooks would be included in 19.2 beta, and 19.3(Development head)

1)
Adjusted the naming to match our pattern.

Code: Select all

private void listPayType_Click(object sender,EventArgs e) {
			if(Plugins.HookMethod(this,"FormPayment.listPayType_Click",listPayType.SelectedItem)) {
				return;
			}
			textDepositAccount.Visible=false;
			SetComboDepositAccounts();
		}
2)
Adjusted naming to match our Pattern. Changed the structure so that _isCCDeclined isn't changed inadvertently. Perform the checks within the plugin and apply to the passed in parameters.

Code: Select all

}
			object[] parameters={textAmount.Text,listPayType.SelectedItem,textNote.Text,_isCCDeclined};
			Plugins.HookAddCode(this,"FormPayment.SavePaymentToDb_afterUnearnedCurCheck",parameters);
			textAmount.Text=(string)parameters[0];
			textNote.Text=(string)parameters[2];
			_isCCDeclined=(bool)parameters[3];
			if(_isCCDeclined) {
3) Concerning the method protection level, you should be able to access the method through reflection.

Let me know if this will work for you and I will implement them.
Patrick Carlson
Open Dental Software
http://www.opendental.com

SPHCDave
Posts: 7
Joined: Mon Jul 29, 2019 6:32 am
Location: Jacksonville, FL

Re: Hook Request

Post by SPHCDave » Wed Aug 21, 2019 4:56 pm

Thanks Patrick.
Can we go ahead with number 1 only right now?

I found a possible change that I need to make for the other hook and I want to test reflection.
I'll resubmit the other hook when I'm all set.

Thanks,
Dave

PatrickC
Posts: 56
Joined: Thu Jun 06, 2019 11:37 am

Re: Hook Request

Post by PatrickC » Fri Aug 23, 2019 8:47 am

Hi Dave,

Request number 1 has been included in beta 19.2.19

Thanks,

Patrick
Patrick Carlson
Open Dental Software
http://www.opendental.com

Post Reply