There are 2 ways to capture menu events – Pre & Post.
- Pre – runs after the menu is clicked but before its execution
- Post – runs after the menu is clicked & executed.
Below is an example of the Plugin Code
////summary
//// The Execute method to execute on the basis of parameter passed
////summary
////Params UnicontaBaseEntity master :- To pass the master record
////Params UnicontaBaseEntity currentRow :- To pass the selceted record
////Params IEnurable<UnicontaBaseEntity> source :- To pass dataGrid datasource
////Params String Command :- pass the command
////Params String args :- pass the argument
////Returns ErrorCodes
public ErrorCodes Execute(UnicontaBaseEntity master, UnicontaBaseEntity currentRow, IEnumerable<UnicontaBaseEntity> source, string command, string args)
{
ErrorCodes result = ErrorCodes.NoSucces;
try
{
var str = command.Split('_');
if (str[0] == "Pre" && str[1] == "EditDebtor")
{
MessageBox.Show(string.Format("Handled" + command));
errorDescription = "Pre - EditDebtor: You can continue";
result = ErrorCodes.Succes;
}
else if (str[0] == "Pre" && str[1] != "EditDebtor")
{
MessageBox.Show(string.Format("NotHandled" + command));
errorDescription = "Pre - str: You can continue";
result = ErrorCodes.NoSucces;
}
else if (str[0] == "Pre")
{
MessageBox.Show(string.Format("NotHandled" + command));
errorDescription = "Pre: You can continue";
result = ErrorCodes.NoSucces;
}
else if (str[0] == "Post")
{
MessageBox.Show(string.Format("AfterAction" + command));
errorDescription = "Post: This is the Post Message";
result = ErrorCodes.NoSucces;
}
}
catch(Exception ex)
{
errorDescription = ex.Message;
}
return result;
}Now you can add Pre or Post command that needs to be handled in the User Plugin.
- Pre_ : To handle all pre actions
- Pre_actionName: To handle specific pre action
- Post_: To handle all post actions
- Post_actionName: To handle specific post action