Continuous Improvement Framework
1. WCF operation name
2. SQL => ORM statement Generation Tool
3. Export of database comment content
4. syntax highlighting Control
5. Standard Form login, splash, and about
6. C #, VB language conversion
7. component communication mode
8. Custom Enterprise Library
WCF operation name
As a communication technology frameworkCodeThe communication part
If the interface file is written in C #,
[Servicecontract]
Public interface imath
{
[Operationcontract]
Void add (int A int B );
[Operationcontract]
Void add (double A, double B)
}
Unfortunately, this code cannot run because WCF does not allow the method overload. The solution is to add name to it.
[Servicecontract]
Public interface imath
{
[Operationcontract (name = "addint")]
Void add (int A int B );
[Operationcontract (name = "adddouble")]
Void add (double A, double B)
}
This can solve the problem. However, the upgrade now requires the name alias for thousands of interfaces and operations. Manual name hitting will inevitably lead to errors.
Check that a large number of methods have been overloaded in an interface.
Therefore, C # parser is used to automatically complete the upgrade. Analyzes the content of the interface file and regenerates an operation with name. The problem is not solved.
When you press the name on the keyboard, it is prone to errors. The above overload method signature mainly involves different parameters. Therefore, as a small tool, the parameter of the Input Method automatically generates the name attribute and the problem is solved.
In the left-side pane, enter the parameter information and set the keypreview of the form to true. The receiving shortcut key F5 is used for conversion. The right side is the name signature generated based on the parameter of the method, and the clipboard has been called. settext. Now you have to go to the C # interface file, paste.
The effect is as follows:
Such an approach is neither error-prone, nor standardized and unified. All the code looks like the code generated by a machine.
SQL => ORM statement Generation Tool
In milestone 3, we should gradually consider the familiarity of the framework with end users for rapid development. . NET developers are familiar with ADO. net, Enterprise Library, or nhib.pdf. Another common technology is SQL. To enable users to quickly get started with the framework, read and write databases, skilled ORM operations, and give full play to the skills they have mastered is a prerequisite for rapid development. See the following SQL and ORM statement table.
My goal is to implement a tool to convert SQL and Orm, and forget the existence of ORM.ProgramStaff quick development.
At the beginning of the project, a large number of tool programs have been developed to retrieve the correspondence between SQL and Orm, such
1. query the database name and implementation name
2. query corresponding table field names and attributes
3. query the relationship between entities
Write the SQL statement in the query analyzer, copy it to the Query Builder form, and run the conversion.
As shown in, the SQL statement in the upper pane has been converted to An ORM statement and is displayed in the following pane.
Why are the two results different from the preceding SQL and ORM statements?
Explanation: the SQL and ORM statements table shows basic ORM operations that can be run independently. The result of software conversion is the most required statement in the actual project. For example, when you create a Bom, you usually select a material number to automatically display the name and Group of the materials. Let's look at the ORM statement for program conversion, which is the code we need most. Put it in the project file and add the BOM material name. It looks like this.
Iitemmanager itemmanager = clientproxyfactory. createproxyinstance <iitemmanager> ();
Excludeincludefieldslist fieldlist = new excludeincludefieldslist (false );
Fieldlist. Add (itemfields. itemno );
Fieldlist. Add (itemfields. Description );
Fieldlist. Add (itemfields. itemgroup );
Itementity item = itemmanager. getitem (this. partitemno, null, fieldlist );
The tool easily implements 99% of the code input for this function.
Export Database comment content
In the improved smart notification Support Section, we have implemented the database annotation tool, which is used to export the annotation content as SQL and run it in other databases, to simplify the annotation.
This time, we focus on implementing export description and export comments as SQL statements.
The secrets of most of the skills are in sp_addextendedproperty, for example
Sp_addextendedproperty 'description', 'Directory number', 'schema', 'dbo', 'table', 'category', 'column', 'categoryid'
The purpose of the program is to retrieve the above information and save it as an XML file. Then, select a database name and write the information to the comment content.
SQL Server 2000 provides three system stored procedures and a function for operating extended attributes. They are:
• Sp_addextendedproperty (Add the new extended property to the database object .)
• Sp_updateextendedproperty (update the value of an existing extended property .)
• Sp_dropextendedproperty (excluding existing extended attributes .)
• Fn_listextendedproperty (list extended attributes)
Syntax highlight Control
Icsharpcode. texteditor was used in code generation tools. The effect is good, as shown in figure
Later, I found a problem. No matter whether the text in the content exceeds a screen, it will display a horizontal scrollbar. I still cannot find a way to not display it.
Later, I checked a large number of other. Net syntax highlight controls and basically had scrollbar. no matter whether the text exceeded the screen or not, I was always dissatisfied.
Codeproject has an articleArticleDescribes fastcoloredtextbox. This control can solve the problem of horizontal scrollbar, and the effect is good.
The basic functions are available. The best thing is that there is no horizontal scrollbar.
Standard form login, splash, about
See the three forms of the EPN application.
Login form
After login, the splash form
About form in menu help
Formstyle = none, the acceptbutton of the login form = btnlogin. the backgrounds of the three forms are the same image to achieve the same size.
A software window is usually used to check whether the three standard forms have the same font, font size, size, and style.
C #, VB language conversion
Implement mutual conversion between VB and C,
For more information, see Information InfrastructureProgramming LanguageDescription in development.
Three Component communication methods: local, remoting, and WCF
When the client code remains unchanged, the EPN framework can switch among the following three communication modes flexibly.
Public Enum communicationplatform
{
Local,
Remoting,
WCF,
}
The local mode calls the implementation of interfaces in reflection mode,
Remoting implements communication between the client and the server in the. NET remoting mode.
Uses the WCF technology to implement client-to-server communication.
For example, use clientproxy as the client proxy Interface
Public interface imath
{
Void add (int A int B );
Void add (double A, double B)
}
In local mode, clientproxy will directly find an imath implementation to return it to the client for calling.
In remoting mode, clientproxy constructs the remoting client code based on the requested service name and configuration, and sends the request to the server. In this way, the WCF mode also works.
A major problem with remoting upgrading to WCF is that the overload method is not supported. The client also needs to regenerate the proxy unless the name attribute is added.
Custom Enterprise Library
Enterprise Library is undoubtedly a good practice for ADO. net. In the EPN framework code, Enterprise Library will be widely used to access the database. In actual use, you must make some configuration, add dataconfiguration, and add connectionstrings, as shown in the following code:
<Configsections>
<Section name = "dataconfiguration" type = "Microsoft. Practices. enterpriselibrary. Data. configuration. databasesettings, Microsoft. Practices. enterpriselibrary. Data"/>
<Connectionstrings>
<Add
Name = "service_dflt"
Providername = "system. Data. sqlclient"
Connectionstring = "Server = (local) \ sqlexpress; database = northwind; Integrated Security = true"/>
This is not good in a highly encapsulated development library. Because the database connection string may have been created or encrypted in the database, the developer does not need to know where the database is and how to write the connection. The developer only needs to know that the SQL command is passed in, expected result
Database m_commondb;
String sqlget_shiftcodelist = @ "select * From DBO. MERs ";
Dataset dsshiftcode = m_commondb.executedataset (CMD );
To achieve this, open the file databaseconfigurationview. CS and modify the getconnectionstringsettings method.
Public connectionstringsettings getconnectionstringsettings (string name)
{
// Validateinstancename (name );
Connectionstringsettings;
Configurationsection configsection = configurationsource. getsection ("connectionstrings ");
If (configsection! = NULL) & (configsection is connectionstringssection ))
{
Connectionstringssection = configsection as connectionstringssection;
Connectionstringsettings = connectionstringssection. connectionstrings [name];
}
Else
Connectionstringsettings = configurationmanager. connectionstrings [name];
// By James
If (connectionstringsettings = NULL | string. isnullorempty (connectionstringsettings. connectionstring ))
{
Connectionstringsettings = new connectionstringsettings (name, enterpriselibraryshared. connectonstring, "system. Data. sqlclient ");
}
// End
Validateconnectionstringsettings (name, connectionstringsettings );
Return connectionstringsettings;
}
As shown in the code, by James is the place I modified. I added a enterpriselibraryshared type to store the connection string. When the system starts, call the following statement to test the connection.
Enterpriselibraryshared. connectonstring = "Server = (local); database = northwind; uid = sa; Pwd = holiday ";
If the application needs to write a log, extend it directly, so that the code written is highly scalable.