Development Framework
1. Orm, llbl Gen, nhib.pdf
2. Interface and implementation separation, interface and logic separation, divided into five projects,
Businesslogic, interface, Manager, validation, entryform
3. SQL and ORM
4. Communication integration remoting/WCF
5. control/component: numberieditor, texteditor, grid, ComboBox, ListBox, listview, tree
6. Exceptions
7. Metadata
ORM
Using ORM can reduce reading, writing, and binding a large amount of data.CodeTo do large projects, you must use ORM
With the codesmith code generator, you can read and write 90% of the Code.
Interface and logic Separation
There are four items in the inventory project of MIS.
Businesslogic business logic, Business Entity
Interface
Manager implementation Interface
System Administration/inventory, Interface
In this way,
1. New fields are added to the data table. No changes are required on the interface;
2. You can flexibly switch the interface to WPF/ASP. NET/sliverlight.
3. Plug-in-type addon, plug-in-type development, new features, no need to change the original project file
SQL and ORM
Orm is cross-platform. to be compatible with all mainstream databases, you must create a syntax to read and write various types of databases.
Familiar with this ing table, you can quickly get started with writing and writing data code. Although this step is not required (because the codesmith code generator will generate 90% of the Code ). Use the SQL parsing tool to input SQL statements.Program(Sqltranslate.exe) can automatically translate SQL statements into ORM statements.
If you are worried about poor ORM performance, you can directly use ADO. net
This writing method requires the cooperation of tools for rapid development.
This code generator is also a combination method. For example, the table name is backupset.
Entity entity |
Backupset |
Ado. Net (get, save, insert, update, getlist) |
Backupsetdal |
Interface |
Ibackupset |
Service Logic call |
Backupsetservice |
The ASP. NET application code generator interface is as follows. It is powerful as ADO. Net or Enterprise Library.
The latest ASP. NET application code generator, which is directly written as a codesmith template. In this way, no compilation action is required when the generated code is modified.
The current codesmith version only supports. NET 2.0 and does not support. Net 3.5 and. Net 4.0. Although codesmith 6.0 Alpha has been released, it is not stable.
No studio is available.
SQL Profiler trace Query
Run SQL profile directly
Run the self-developed SQL profiler
Add configuration section in the Startup Program
<System. Diagnostics>
<! -- Llblgen trace
Trace Level: 0-Disabled
3-Info
4-verbose
-->
<Switches>
<Add name = "sqlserverdqe" value = "4"/>
<Add name = "ormgeneral" value = "0"/>
<Add name = "ormstatemanagement" value = "0"/>
<Add name = "ormpersistenceexecution" value = "0"/>
</Switches>
<Trace autoflush = "true">
<Listeners>
<Add name = "socketwritertracelistener"
Type = "Avatar. ormtracelistener, ormtracelistener"/>
</Listeners>
</Trace>
</System. Diagnostics>
Enable the listener
Source codeAs follows:
Or run the following tracing program:
Improved smart notification support
When you move the cursor over the object name, the table name corresponding to the object is displayed.
When hovering over a field, the table name corresponding to the field can be displayed.
In the SQL query manager, When you hover the mouse over the table name, you can display the comment of the table.
Table creation description
Description of the created Field
Description of existing fields in the import table to minimize labor costs
Design evolution of smart prompts
1. Place the prompt content in the ACCESS database. Copy it to the Project Development Directory. If provider = Microsoft. Jet. oledb.4.0 does not have a 64bit version, you must set the X86 platform format instead of anycpu.
Provider = Microsoft. Ace. oledb.12.0 is added. However, it is not feasible to install this component on each developer machine.
2. If sqlexpress is used, you still need to configure SQL. You can try to use an object database such as dbo4 and copy a file to a specified directory (feasible, doable)
3. built-in implementation of SQL Server, as shown in figure
Open SQL profiler, the secret is in the Stored Procedure sp_addextendedproperty
Finally, a tool is used to update the field description, which is much more convenient.
Remoting/WCF Communication Technology
Function Objectives
1. Application Server remoting/WCF Server
2. Report Server
3. Workflow Server
4. concurrent user control, trace output, and component authorization Verification
License Control
Use RSA to sign XML files and generate unchangeable XML files to Protect Software authorization
It is bound to hardware (CPU, harddisk) information. When generating a license file, you must first run a utility to generate a hardware sinature file, license generator generates license files based on this file.
Bind to the software. For example, the demo version does not allow the database capacity to exceed 2 GB (the size of the database specified by SQL express cannot exceed 4 GB); it can only run within the specified time, usually one month, the software cannot be started after expiration. It cannot be run on a virtual machine. Due to a virtual machine, the entire system can be restored without restrictions by the ghost;
Report Extension
The typical SQL query statement is written in this way, and the customer report can be produced.
Now let's replace this statement for database query.
Two Methods: SQL procedure and. Net assembly. The maintainability is certainly better than the former, and the performance loss also exists.
Only programmers can maintain reports, and customers cannot understand. net.
However, in the face of increasingly complex business logic, the use of. Net assembly should be a trend for customers who require multiple databases (some customers specify to use ORACLE.
Database Management
One framework database drives multiple business databases.
A business database can be regarded as a set of accounts, which can be used for version management and function control independently. It can also be customized for different customer needs ).
On the following registration company Interface, driver assembly and driver type are the custom assembly of the registered customer to achieve the same product and maintain the use of multiple customers and customers in different industries.
The loss of performance (reflection) is inevitable, and it also brings considerable flexibility.
Microsoft products often reflection. Why can't we handle performance?
Authentication, authorization mode (AD/Forms/Windows)
Because we have designed an application server, you can do whatever you like.
View K3 login Method
The activity directory method is a recommended method for building enterprise lan. The relationship between PCs that ad brings about is an undeniable benefit.
Forms, which can encrypt the user name and password, remember the user name and password, and regularly ask the user to change the password
The Default Login method of reporting services is windows. We need to rewrite it to Forms
Unfortunately, even Microsoft SQL Server 2008 R2 still needs to manually modify the configuration file to change to Forms authentication. In the plan, you need to create a small tool to modify the authentication method of reporting services. Manual configuration is complicated and error-prone.
Next, let's look at the login method of report manager integrated into ERP.
Let's take a look at authorization. There are three permissions: function permission, field permission, and data permission.
Function permission: Role-based authentication and authorization of the execution permission on the function modules of each subsystem
Set User Group Permissions first
Set the group to which the user belongs when registering the user.
60% of the permissions in the ERP system are required.
Field permissions are also implemented. For example, the demo user cannot access all reports, but can read all customer and supplier information.
Field permissions control certain special fields. For example, the warehouse personnel cannot see the unit price of the materials entered by the buyer, the clerk a cannot see the contact information of the customer of the Clerk B,
Data permission is the operation permission for specific data.
For example, when the purchase amount reaches 0.1 million, the Finance Manager cannot be directly modified;
So I made a data permission editor.
As shown in, the total amount of the purchase order is greater than 1000000, the cost is greater than 5000, and the supplier is MASKEY.
This condition can be dynamically added or deleted. At runtime, the expression engine is responsible for parsing expressions and returning the results of expression execution.
Exception Handling
In the business system, an exception can be exploited to cancel rollback at Layer n.
To avoid exposing specific product implementation details and display exceptions, design the following exception dialog box.
The implementation is to register the unhandledexception event of the current application domain and display the exception in the Custom dialog box.
Appdomain. currentdomain. unhandledexception + = new unhandledexceptioneventhandler (currentdomain_unhandledexception );
Observe the Microsoft Product error prompt, Microsoft report Builder
Microsoft SQL Server
At the bottom left of the SQL Server Error form, there are three buttons, help, copy message text, and show technical details.
Show technical details opens a stack trace form to diagnose error details.
There are two ways to implement abnormal transmission.
1. Use the log Application Block of the Enterprise Library to set various output settings for exception redirection (console, file, database)
2. Use TCP socket technology to send exceptions to the specified server and record user operation steps. Because the application server has been created, it is easy to implement this place. When an error occurs during sending, the current operation user name, stack information, or even copy screen can be used to send the screen image with the error to the specified directory on the server.
The application framework code will use the. Net trace mechanism in large quantities to output the running status of the framework.
Public class sqlservertracelistener: tracelistener {
Public override void write (string message)
{
Using (sqlconnection conn =
New sqlconnection ("Server = (local); database = tracedatabase; Integrated Security = true ;")){
Using (sqlcommand cmd = conn. createcommand ()){
Cmd. commandtext = "insert into logs (Message) values (@ message )";
Cmd. Parameters. Add (New sqlparameter ("@ message", message ));
Conn. open ();
Cmd. executenonquery ();
Conn. Close ();
}
}
}
Public override void writeline (string message)
{
Write (Message );
}
}
In this way, reading and writing SQL statements will cause performance degradation. The recommended method is the TCP socket technology, which sends exceptions to the server (Application Server). A large number of exceptions are not needed, for example, when a user logs on, he or she enters the wrong password and does not need to write the password to the database on the server in large quantities.
Framework code can identify critical code errors, and these exceptions must be recorded in persistent media for diagnosis by developers.
Metadata Management
Schema viewer ERP maintenance personnel are most concerned about the data table fields, what content is stored, the relationship between data
Data Relationship
. Net Property Code
We can see that the table name has been placed in the summary of the XML annotation, so that we can make full use of. Net Smart sensing.
Framework database, there is a lot of metadata management: Report, lookup, query, workflow, form layout, user/User Group