Page 1 of 1

Hook Request

Posted: Wed Aug 21, 2019 11:11 am
by SPHCDave
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

Re: Hook Request

Posted: Wed Aug 21, 2019 2:01 pm
by PatrickC
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.

Re: Hook Request

Posted: Wed Aug 21, 2019 4:56 pm
by SPHCDave
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

Re: Hook Request

Posted: Fri Aug 23, 2019 8:47 am
by PatrickC
Hi Dave,

Request number 1 has been included in beta 19.2.19

Thanks,

Patrick