|
|
|
|
Custom Hooks in TierDeveloper |
| Custom Hooks is another powerful and most demanding feature provided by TierDeveloper. Custom Hooks work like database triggers. It could be your own business logic that you can activate before or after performing some database action(s). PreHooks and PostHooks are two ways, provided by TierDeveloper, through which you can embed your own logic in the generated code. Pre hook methods are called before the database access is performed whereas post hook methods are called after the database operations are performed.
Custom hooks can be specified wherever database access is performed. It includes standard operations, query methods, bulk operations and custom operations. User can generate skeleton code for custom hooks of the selected methods or he/she can use his/her own hooks class.
For your convenience and better understanding I have listed sample code here which shows how TierDeveloper embed custom hooks in the generated code. It is pretty self-explanatory.
public void UpdateCustomerInfo(Customers objInfo)
{
try
{
... ... .... .......
... ... .... .......
CustomersHooks hooks = new CustomersHooks();
status = hooks.PreUpdateCustomerInfo((System.Data.SqlClient.SqlConnection)getConnection(), objInfo);
if (status != CustomersHooks.SUCCESS_CONTINUE)
{
SetStatus(status == CustomersHooks.FAIL_NONCONTINUE ? EStatus.eFail : EStatus.eSuccess);
ReleaseCommand();
return;
}
AddCmdParameter("@CompanyName", TDevFramework.EDataType.eVarchar, objInfo.CompanyName, TDevFramework.EParamDirection.eInput, objInfo.IsNull("CompanyName"));
... ... .... .......
... ... .... .......
... ... .... .......
ExecuteNonQuery();
status = hooks.PostUpdateCustomerInfo((System.Data.SqlClient.SqlConnection)getConnection(), objInfo);
if (status != CustomersHooks.SUCCESS_CONTINUE)
{
... ... .... .......
... ... .... .......
return;
}
SetStatus(EStatus.eSuccess);
ReleaseCommand();
}
catch (Exception e)
{
... ... .... .......
... ... .... .......
throw e;
}
}
public class CustomersHooks
{
public const int SUCCESS_CONTINUE = 0;
public const int SUCCESS_NONCONTINUE = 1;
public const int FAIL_NONCONTINUE = 2;
public int PreUpdateCustomerInfo( System.Data.SqlClient.SqlConnection Conn, Customers objInfo)
{
//.. .. .. . .. ..
// . .. .. .. .. Put your own code here
return SUCCESS_CONTINUE;
}
public int PostUpdateCustomerInfo( System.Data.SqlClient.SqlConnection Conn, Customers objInfo)
{
// .. .. .. .. . .. .. ..
// .. .. .. .. put your own code here.
return SUCCESS_CONTINUE;
}
}
| Author Info: Ann Morris - I work in a software development Organization and interested in writing technical articles.
ann@alachisoft.com
Articles distributed free by http://www.ArticleInfoz.net
|
|
| Most Recent
Free Articles added to our site : |
Vodafone Smart Tab 7 Tablet Device Vodafone has fixed their steps into the market of top gadgets. Vodafone is planning to step out in the tough air of competition. Vodafone is an Australian brand and has the business of providing the network connectivity to mobile or broadband. In India, Vodafone has acquired the Hutch few years ago.[ Read Article] LG A290 Triple 3 SIM Mobile Phone LG is very popular and reliable brand in the view of many people. LG Mobile Smart Phones introduced many advanced and heavily loaded featured smartphones in the market. Brand manufactures the ph[ Read Article]
Making Articles Work for You about Custom Hooks in TierDeveloper from our free Computers article resources.
|
| Rules to using other peoples free reprint articles |
The good thing with articles is that you can write about things that people would want to know about. This can be achieved in the lightest mood but professional manner, with a little not-so-obvious sales pitch added.
|
|
|
|