This is a project that I have recently started with .NET technology.

xiaoxiao2021-03-06  75

?

?

Program Development Guide (First Edition)

?

1. ???? Summary

2. ???? System Physical Structure

3. ???? system architecture diagram

4. ??? Representation of the development of the layer 4.1 Overview 4.2 Development

4.2.1 Use of Web Service

4.2.2 Use of screen components

1. The use of DataGrid control

2 text box control

3. DataGrid control

4.2.3 Displaying the use of Message in the screen

4.2.4 Use of logs in the screen

4.2.5 Saving in the picture in the picture

4.2.6 Data between the screen

5. ???? the development of the Business layer part

5.1 Overview

5.2 development

6.???? DAO layer development

6.1 Overview

6.2 development

6.2.1 inheritance

6.2.2 call

6.2.3 Convenience of single table operation

6.2.4Message

6.2.5log use

6.2.5 Abnormally handling 7. Common part

8. Program test

9. Engineering structure

?

1.??

This document is developed documentation. It is desirable that developers can familiarize with Framework for the entire project through this document, and can develop in Framework, efficient development.

?

2. ??? System Physical Structure

?

3. ??? System architecture

?

4. The development of the layer portion 4.1 Overview The representation is mainly composed of Windows Form, and the complex part is a picture of the DataGrid, which is relatively cumbersome. The figure below is a directory diagram showing a layer.

The figure below shows a class diagram of a layer.

?

4.2 Development 4.2.1 Web Service

Quote Web Service

Name Chuou.Service.login;

Chuou.service.initial; chuou.service.masuta

Chuou.Service.Hattyuu

URL

http://localhost/chuou_service/src/chuou/service/init/initialservice.asmx; http://localhost/chuou_service/src/chuou/service/login/loginservice.asmx; http:// localhost / chuou_service / src / Chuou / Service / Masuta / Masutasempice.asmx

http://localhost/chuou_service/src/chuou/service/masuta/hattyuuservice.asmx

?

(Note that the first two WebService cannot be manually updated)

The procedure example is as follows

Private mASutaservice masutasempice = null;

......

Private Void Form_2_17_Load (Object Sender, System.Eventargs E)

{

......

MASUTASERVICE = mainframe.masutasempice;

......

|

Private void btnkensaku_click (Object Sender, System.EventArgs E)

{??????

......

DataSet DS = MASUTASERVICE.DOSEARCH_FORM2_17 (NULL); ???????????????????????????????????????????????????????????????????????????????????

......

}

4.2.2 Using the Screen Component 1. The use of DataGrid control

DataGrid in all screens uses chuou.common.view.Component.superGrid components.

The procedure example is as follows

Private supergrid extendedDataGrid1; this.extendeddataGrid1 = new supergrid ();

2 text box control

Use the text box in all screens (including custom controls) using chuou.common.view.Component. SupertextBox component. The procedure example is as follows

Private SuperTextBox txtmodelname;

This.txtModelname = new supertextBox (mask.digit);

// Type control

Public enum mask

{

??????? none, // does not do any processing

??????? dateonly, // date type

??????? decimal, // numeric

??????? Digit // digital type

}

// IME input method Control public enum IMEMASK

{

??????? none, // does not do any processing

??????? OFF, // IME close

??????? ON // IME open ????

} // Operation of the Enter key PUBLIC DELEGATE VOID ENTERKEYDOWN ();

4.2.3 Display Message is displayed in the screen.

?? Consider the convenience of the program development, use the chuou.common.view.Message.AppMessage class.

The procedure example is as follows

AppMessage.show (this, "e1001");

"E1001" is the number of Message.

4.2.4 Use of logs in the screen

In order to facilitate future debugging, each method, the key processing requires writing log.

The procedure example is as follows

Using chuou.common.log;

... ILOG log = clientlog.getinstance (). GetLogger (TypeOf (form_2_2));

......

LOG.INFO ("Step Into the Form2_Load");

Log's output location defaults to C: / chuou.log

4.2.5 Saving in the picture in the picture

?? Taking into account the development of the development, the status in the screen is saved in the file, the processing process is defined to define an object first, put the data you want to save in the screen to the object, then sequence this object into the file. When you want to read the picture status, you will reach an object from this file, and the specific implementation is implemented by the chuou.common.util.objectsave class. The program example is first step, first define an object class. Using system;

Using system.runtime.serialization;

Namespace chuou.view.hattyuu.view.save

{

??????? [serializable]

??????? public class form_3_2_1save

??????? {

??????? public form_3_2_1save () {???????}

??????? private bool _chkzenka;

??????? private bool _chksetsu1;

??????? private bool _chksetsu2;

??????? public bool chkzenka

??????? {

??????????????? get {return this._chkzenka;}

??????????????? set {THIS._CHKZENKA = Value

???????}

??????? public bool chksetsu1

??????? {

??????????????? get {return this._chksetsu1;}

??????????????? set {this._chksetsu1 = value;

???????}

??????? public bool chksetsu2

??????? {??????????????? get {return this._chksetsu2;}

??????????????? set {this._chksetsu2 = value;

???????}} Note? You must add the serializable property.

Step 2, write objects into the file. FORM_3_2_1SAVE SAVE = New Form_3_2_1Save ();

Save.chksetsu1 = chksetsu1.checked; ??????????????

Save.chkzenka = chkzenka.checked;

Objectsave.putObject (this.gettype (), save); ?????????????

this.close ();??

In the third step, read the file into the object.

FORM_3_2_1SAVE OBJ = Objectsave.getObject (this.gettype ()) AS FORM_3_2_1SAVE; ???????????? IF (OBJ! = Null) {

??????????????????????? chkzenka.checked = Obj.chkzenka;

??????????????? chksetsu1.checked = obj.chksetsu1; ???????????????????????????? ????????????}

4.2.6 Data between the screen

??????? When the development, it is called to call when transmitting data between pictures.

Development of three steps

The first step, first to define a data model that you need to accept this screen, named space is namespace chuou.view. *. View.trans, name form, name, refer to the following Namespace Chuou.View.hattyuu.View .trans

{

Public class form_3_2_12trans: itrans {

??????? public form_3_2_12trans (String StrolDsaiban) {

??????????????? _StrolDsaiban = stroldsaiban;

??????? private string _stroldsaiban;

??????? public string stroldsaiban {

??????????????? Get {return _stroldsaiban;}}

??????? public bool check () {

??????????????? IF (stroldsaiban == null || Stroldsaiban.trim (). Length == 0) {

??????????????????????? Return False;}

??????????????????????? Return True;}}}

Note? ITRANS interface must be implemented. In the second step, store data, refer to the following

Private void btnseibanikkatsuhenkou_click (Object Sender, System.EventArgs E)

{

??????? form_3_2_12trans trans = new form_3_2_12trans ("test");

??????? ObjectTrans.puttransObject (TypeOf (Form_3_2_12), Trans);

??????? form_3_2_12 form = new form_3_2_12 ();

??????? form.show ();

}

In the third step, read data, refer to the following

Private void form_3_2_12_load (Object Sender, System.Eventargs E) {

FORM_3_2_12TRANS TRANS = ObjectTrans.getTransObject (TypeOf (Form_3_2_12)) AS FORM_3_2_12TRANS;

??????????????? console.writeline ("Trans value =" trans.stroldsaiban);

}

Development 5.1 Overview This layer is mainly written * service.asmx.cs files, divided into different web services, such as Masutaservice.asmx, Hattyuuservice.asmx, etc. LoginService.asmx is designed to handle user login, development, not allowed to be updated, if there is an update, I will notify you to update from CVS. InitialService.asmx is Framework and is not allowed to be manually updated. 5.2 Development of Web Service is shown below. Directory diagram The following drawings are noted below. Taking into account the convenience and management of development, each screen, each operation, such as initialization, retrieval, and update operation, plus method in WebService in the corresponding module, Name Rules is doinit_form * _ *, dosearch_form * _ *, doupdate_form * _ *. 2, in principle, do not write specific business logic in the webservice file, but write a class in the background business layer, which is to make the developer's convenient to write test code test background business logic. 3, some MASUTA tables are placed directly in the Application field, as the application [constant.application_key_data] = DS; development is the use method is DataTable DTDPTCD = DS.TABLES [0];

DataTable dtsyain = ds.tables [1];

DataRow Rowdptcd = MSthelp.SearchTableBypk (DTDPTCD, DPTID);

DataRow Rowsyain = msthelp.searchtableBypk (dtsyain, id);

6. DAO Layer Development 6.1 Overview?? All business logic is written in this layer, the location of the class is ???? chuou.service. *. Process.business _ * _ *. CS? In principle, each picture corresponds to one The class, the common part is placed in the chuou.service.common directory. The class diagram is developed as follows ?? 6.2.1 Inheritance? Each business class must inherit the SuperDao class, SuperDao implements a series of methods such as getConnection, CloseConnection, Updateexecute, QueryExecute, so that only focuses on business logic, do not consider. ADO.NET in NET. Class diagram 6.2.2 Call Get Database Connection To call getConnection (), turn off the database connection to call CloseConnection (OracleConnection Conn), the query table is called QueryExecute (), update the table as call UpdateExecute (). 6.2.3 Convenience of single table operation Taking into account the convenience of development, if you are a single table query, update, insert, delete, you can directly call the DAO development package. Class diagram The following procedure examples are as follows DAO = DAOFACTORY.CREATEDAO (New Daoconfig (DatabaseType.Oracle, Help.conn_Str)); DAO.Open ();

LoginManagemodel model = new loginmanagemodel ();

Model. Field 1 = New NSTRING (ID);

Model. Field 2 = new nstring (dptid); ??????????????

Model. Field 3 ?? = new ndatetime (system.datetime.now);

DAO.Insert (Model); DAO.CLOSE (); 6.2.4Message usage example below

Message.getMessage ("S1001"));

6.2.5 Log's usage procedure examples

Using chuou.common.log;

... private ilog log = serverlog.getinstance (). Getlogger (IPEOF (Business_3_2_1);

......

Log.info ("Step Into The Dosearch");

Log.Error ("Error In Queryexecute () Method", e);

Log's output location defaults to c: / chuou_server.log

6.2.5 Exception Processing • The DAO layer program uniformly throws the DAOException exception, and the business layer is uniformly throwing the businessexception exception. Class diagram is as follows

7. Common partial diagram

?

?

8. Program Test In order to ensure the development of the quality, it is necessary to write test code for the business logic part of the background, using NUNIT tools to test. The use of the project map is as follows.

The code demonstration is as follows [TestFixTure]

Public class testdao {

Private const string conn = "User ID = chuou; password = chuou; data source = order;";

Public Testdao () {??????}

[TEST]

PUBLIC VOID TESTSELECT () ??????????????? {

Idao Dao = DAOFACTORY.CREATEDAO (New Daoconfig (DAOCONFIG (DatabaseType.Oracle, CONN); DAO.Open ();

Test2Model model = new test2model ();

Model.username = new nstring ("luohao");

Console.writeline (DAO.FINDRECORDS (Model) .count;

Dao.close ();

[TEST]

Public void testinsert () {

Idao Dao = DAOFACTORY.CREATEDAO (New Daoconfig (DatabaseType.Oracle, Conn);

DAO.OPEN ();

Test2Model model = new test2model ();

Model.userid = new nstring (datetime.now.tostring ());

Model.username = new nstring ("luohao");

Model.date1 = new ndatetime (datetime.now);

Model.float1 = New NDECIMAL (New Decimal (517.12F));

Model.Number1 = New NDECIMAL (12345);

Console.writeline (DAO.INSERT (Model));

Dao.close ();

?

[TestFixTure]

Public Class Testbusiness_2_17

{

Ilog log = serverlog.getinstance (). GetLogger (Testbusiness_2_17);

Public Testbusiness_2_17 ()

{

}

[TEST]

Public void testdosearch ()

{

??????? dataset result1 = new business_2_17 (). Dosearch (null);

??????? assert.isnotnull (result1);

??????? DataSet results2 = new business_2_17 (). Dosearch ("000101");

??????? assert.isnotnull (result2);

}

}

9. Engineering structure

described as follows

CHUOU_APP is the engineering engineering, chuou_service is the engineering layer and the DAO layer. Chuou_test is the test engineering, Commonlib is a public library, and ModelGenerator is a tool that automatically generates Model.

?

?

转载请注明原文地址:https://www.9cbs.com/read-120445.html

New Post(0)