Username: Save?
Password:
Home Forum Links Search Login Register*
    News: Keep The TechnoWorldInc.com Community Clean: Read Guidelines Here.
Recent Updates
[November 08, 2024, 04:31:03 PM]

[November 08, 2024, 04:31:03 PM]

[November 08, 2024, 04:31:03 PM]

[November 08, 2024, 04:31:03 PM]

[November 08, 2024, 04:31:03 PM]

[October 17, 2024, 05:05:06 PM]

[October 17, 2024, 04:53:18 PM]

[October 17, 2024, 04:53:18 PM]

[October 17, 2024, 04:53:18 PM]

[October 17, 2024, 04:53:18 PM]

[September 09, 2024, 12:27:25 PM]

[September 09, 2024, 12:27:25 PM]

[September 09, 2024, 12:27:25 PM]
Subscriptions
Get Latest Tech Updates For Free!
Resources
   Travelikers
   Funistan
   PrettyGalz
   Techlap
   FreeThemes
   Videsta
   Glamistan
   BachatMela
   GlamGalz
   Techzug
   Vidsage
   Funzug
   WorldHostInc
   Funfani
   FilmyMama
   Uploaded.Tech
   MegaPixelShop
   Netens
   Funotic
   FreeJobsInc
   FilesPark
Participate in the fastest growing Technical Encyclopedia! This website is 100% Free. Please register or login using the login box above if you have already registered. You will need to be logged in to reply, make new topics and to access all the areas. Registration is free! Click Here To Register.
+ Techno World Inc - The Best Technical Encyclopedia Online! » Forum » THE TECHNO CLUB [ TECHNOWORLDINC.COM ] » Computer / Technical Issues » Web Design / Graphics Design/ Animation » Website Development
 Custom Hooks in TierDeveloper
Pages: [1]   Go Down
  Print  
Author Topic: Custom Hooks in TierDeveloper  (Read 471 times)
Shawn Tracer
TWI Hero
**********


Karma: 2
Offline Offline

Posts: 16072


View Profile
Custom Hooks in TierDeveloper
« Posted: February 15, 2008, 04:33:13 PM »


Custom Hooks in TierDeveloper
 by: 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 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;
}
}

About The Author

Ann Morris - I work in a software development Organization and interested in writing technical articles.
[email protected]

Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Copyright © 2006-2023 TechnoWorldInc.com. All Rights Reserved. Privacy Policy | Disclaimer
Page created in 0.069 seconds with 25 queries.