1.Define the interface of software (named : IGlobalService),like DB operation, contains: InsertAlarm(string sql),UpdateAlarm(),SearchAlarm().
2.Create class like OracleGlobalService to implement the interface of
IGlobalService.
The duty of OracleGlobalService is to realize the function of SQL-opeartion Or other functions.
3.OracleService ,then we can create another class which our OracleGlobalService can inherite from it,
because in the OracleService,we may include function like :
<1>.CheckConnectionStatus()
<2>.IDBTransaction
<3>.Commit()
<4>.RollBack()
4.Then,above all,we create a class of OracleGlobalSercice which has method named CreateService,signature like:
public static IGlobalService CreateService()
{
string gc=Configuration.AppSettings["FDCOracleService"];
//this FDCOracleService is get from App.config.
if (gc.EmptyOrNull())
{
gc="FDC.Service.DB.FDCOracleService";
}
return (IGlobalService)Activator.CreateInstance(Type.GetType(gc));
}
OracleGlobalService Implement Interface contains : IGlobalService.
OracleGlobalService Inherite from OracleService : Mainly use the method of CheckConnectionStatus(),IDBTransaction.
5.App.config contains :
| | | | | | | | | | |
阅读(807) | 评论(0) | 转发(0) |