In the cooperative version of the data room charging system, the framework is used for the first time: Three Layers + spring. NET + nhibernet framework.
I. Overall framework diagram:
The architecture of the second and third layers is as follows:
Dal layer:
Adapter:
Structure:
Implement irepositorydal interface: Extension
Inherit repositorybasedal parent class: Reuse
Function:
Operation class: encapsulate basic operations-add, delete, modify, and query
This. hibernatetemplate. Save (entity)
This. hibernatetemplate. Delete (entity)
This. hibernatetemplate. Update (entity)
This. hibernatetemplate. saveorupdate (entity)
This. hibernatetemplate. Find <t> ()
This. hibernatetemplate. Get <t> (ID)
This. hibernatetemplate. Load <t> (ID)
Entity:
. CS: entity class
. Xml: ing File
Collection: Collection class
Base. xml:
Inject hibernatetemplate into layer D for basic method call
Inject the adapter of layer D in layer B to call the method under the adapter.
Bll layer:
Structure:
Function:
Business logic:
Base Class: encapsulate the most basic logic
Adapterbase. getbycondition (columnname, columvalue)
Adapterbase. Get (ID)
Adapterbase. Load (ID)
Adapterbase. Save (entity)
Adapterbase. loadall ()
Adapterbase. Update (entity)
Adapterbase. Delete (entity)
Adapterbase. saveorupdate (entity)
Specific Class: Inherit the parent class; Extend your own logical method
<Span style = "font-size: 18px;"> public class addusersbll: genericbasebll <user, usercollection>, iaddusersbll {// <summary> // Add User Information /// </Summary> /// <Param name = "enuser"> </param> Public void adduserinfo (user enuser) {If (base. get (enuser. id. tostring () = NULL) {// Add user base. save (enuser);} else {Throw new argumentnullexception ("this user already exists. Please enter the user name again! ") ;}}</Span>
U I layer:
. Appconfig: Configuration File
Iii. Summary:
After completing the framework with LH, I suddenly felt that writing code alone was actually the simplest thing. After the framework is set up, the entire system is completed by more than half. The rest is the logic part. The logic part can only be written for three or four days at most. The first time I became a group leader, I had trouble with everything. Fortunately, I had some friends with me all the way.
The system is small and the logic is clear. In order to practice, some new things have also been attempted: Jenkins (automatic release, error checking), Zen Road (assigning tasks to team members), and SVN (Version Control ).
Data room fee system cooperation edition (I)-framework construction