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



To provide some examples of web design and development I give you here:

10 latest blog posts by Web Developer Jim Westergren

I’m an SEO and I have been working a lot with WordPress, here I give you all my tips for you to rank very well in Google with your blog. UPDATE: Check this blog post for a better guide. Quick Facts There are 55 million blogs out there, if you don’t stand out you will have no chance. The [...]

Update, March 9th I have now changed it again and put some color into it. What do you guys think? Sunday today and I was away from work with clients so I decided to work with my blog today from home. I made a new design for this site. Check out the navigation links at the top left [...]

This article is written for my friend “honey” (site). I have been bidding against honey on web site auctions for almost 2 years now. I have won maybe 60 auctions and I have now over 100 web sites. Honey owns over 300 … So here comes my checklist that I want to show honey as I [...]

Have you also heard of those horror stories of Google banning Adsense accounts for the smallest mistakes? You have read the Terms and Conditions and you know the basics but what do you do when you show your friend your site on your computer and the first thing he does is to click the Adsense ad [...]

This article is written more for myself so I remember how I do it the next time but probably a few people will also benefit from this for different uses and purposes. Today I updated all the PR values for the directories listed on my directory list. I had to update each listing in the MySQL [...]

Official site of a children’s hospital in Japan Hey, your “logo” is not blinking! MSY Technology Pty. Ltd. Are you sure product X is HOT? Personal site of Franz Magnus Incredible that you got several awards for that site. Angren.net, electronic shop Can’t you squeeze in something more on the home page? Official site of Northbridge Police Department Still being updated in 2006. Perhaps [...]

The last days I have been fighting in the war against the latest spam bot soldiers like a maniac. I own and manage over 70 web sites. This includes different forums, directories, blogs, topsites, article submission sites and you name it. Very recently there is a new wave of spam. The default captcha for vBulletin is now [...]

This is a WordPress plugin that will give you more links and higher rankings in the search engines. Most bloggers knows the importance of getting links in order to get high rankings in search engines. But did you know that the best links are those that are natural recommendations? Additionally I experienced better rankings across all [...]

To improve the navigation of your users as well as search engine traffic and ranking to your WordPress blog I suggest making a good site map of your posts - a map of your site. A kind of user friendly archive of your posts. This is not “Google sitemap”! The benefits: The user can quickly find a [...]

How I rank on different keywords and links to the different SE queries.

home | site map

Articles



Loans | Loan | Web Advertising | Mortgages | Car Insurance