Custom Hooks in TierDeveloper


Ann Morris

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 actions. 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 UpdateCustomerInfoCustomers objInfo

{

try

{

... ... .... .......

... ... .... .......



CustomersHooks hooks = new CustomersHooks;

status = hooks.PreUpdateCustomerInfoSystem.Data.SqlClient.SqlConnectiongetConnection, objInfo;



if status != CustomersHooks.SUCCESS_CONTINUE

{

SetStatusstatus == 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.PostUpdateCustomerInfoSystem.Data.SqlClient.SqlConnectiongetConnection, objInfo;



if status != CustomersHooks.SUCCESS_CONTINUE

{

... ... .... .......

... ... .... .......

return;

}



SetStatusEStatus.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;

}

}





About The Author

Ann Morris - I work in a software development Organization and interested in writing technical articles.
ann@alachisoft.com

home | site map


© Web Traffic Promotions .Com 2005


Web Traffic Promotions Our Domain Names Buy Domain Names Web Traffic Promotions Shop Monetize Your Website
ViralDX
TrafficDx Email Advertising Affiliate Marketing Website Marketing
Domain Name Online Promotion Targeted Website Traffic Turnkey Website Solutions Search Engine Optimization
Affiliate Program Free Website Hits Web Banner Exchange
Viral Website Scripts Email Marketing
WebSite Hosting
Hamptons Real Estate
Mortage Calculator
Spyware Info
Traffic Blaster Biz
Traffic Jogger
Debt Financing
WebSite Development
WebSite Promotion
Website Directory
Web Hosting Reseller Funny Tshirts Targeted Website Traffic Auto Traffic Exchange Script Web Design
Traffic Exchange Script $4 Per Tshirt Sale Website Hits Turnkey Websites Traffic Cook
Mucho Traffic Traffic Blender Excessive Traffic EZ Safelist Submitter Visitor Flood
Internet Cash Matrix Internet Cash Randomizer FlyAdsDx Internet Website Promotions Exchange Links