ERP/MIS development and development llbl Gen plug-in (Plun-in) implementing a plug-in

Source: Internet
Author: User

With llbl Gen as the preferred development tool for Orm, after several projects, we have gained a new level of understanding of it. On the one hand, you must be familiar with the query API so that you can write a query statement. On the other hand, you are also trying to implement it from the Orm,Source codeAnalysis and expansion to understand this ORM tool, so that the project can be easily handled in case of project emergency.

This articleArticleThis section describes the content in the llbl Gen SDK and how to develop the llbl Gen plugin. This entity visualizer plug-in comes from the idea that you want to view the content of the data table while designing the Orm. The function is like the data set visualizer built in. net. Running Effect

Select a table from the table. The following DataGrid displays all the data of the table.
As we all know, the main task of developing plug-ins is to familiarize yourself with the interfaces left behind by the software. I used to design plug-ins for others. Now I have to turn this into a framework designed by others, so if you have developed a plug-in framework, you can avoid any detours.
The llbl gender is stored in the pluginsdirectory of the installation directory. You can also modify it by modifying the options in the llblgenpro.exe. config configuration file.
<! -- Specification of the root folder where llblgen pro will search for plugin assemblies -->
<! -- This path is always relative to the application folder. -->
<Add key = "pluginsrootfolder" value = "plugins"/>

The plug-in is encoded in. net. Multiple plug-ins can be placed in oneProgramSet. You can also separate multiple sets.

The plug-in runs in the llbl Gen container. There are two types of user interface. ipluginwindow is used for independent windows. For example, in a tab window, our plug-in dock is on this tab page, the other is to run on the specified interface in the form of controls, such


If you want to design a plug-in for this interface type, it is derived from ipluginconfigurationcontrol.

Start Visual Studio, create a class library project, go to the installation directory of llbl Gen, find and add reference to the following Assembly

Add a new type derived from pluginbase. First, rewrite the Describe method, which is used to display the description of our plug-in.
Public override plugindescription describe ()
{
Plugindescription toreturn = base. Describe ();

Toreturn. Build = _ build;
Toreturn. Description = "display the data of the specific ing entity ";
Toreturn. ID = new GUID ("{1cceedd1-ad19-49c9-b711-be2087d0f94a }");
Toreturn. Name = "entity visualizer plug-in ";
Toreturn. showprogressviewerduringexecution = false;
Toreturn. targettype = plugintargettype. entity;
// Toreturn. typeofplugin = plugintype. singleelementplugin;
Toreturn. typeofplugin = plugintype. directrun;
Toreturn. Vendor = "EPN solution ";
Toreturn. Version = _ version;
Toreturn. surpressprojectexplorerredraw = false;
Return toreturn;
}

Showprogressviewerduringexecution is used to describe whether to display a progress bar when executing the plug-in function.
Let's look at the type of targettype, that is, the object to which the plug-in applies, such as project, type view, object, and stored procedure.

[Flags]
Public Enum plugintargettype
{
None = 0,
Entity = 1,
Typedlist = 2,
Typedview = 4,
Actionspcall = 8,
Retrievalspcall = 16,
Project = 32,
Object = 64,
}
My entity visualizder plug-in is used to display table data. The targettype to be applied is entity.
Typeofplugin refers to the plug-in type. This value determines the scope of the plug-in to be applied.
Public Enum plugintype
{
Singleelementplugin = 0, // an element
Multielementplugin = 1, // plug-in for Multiple Elements
Singleandmultielementplugin = 2, // plug-in for one or more elements
Directrun = 3, // run directly
System = 4, // System
}
Entity visualizder plug-in is independent and can be run directly, so its typeofplugin = directrun.
If typeofplugin = singleelementplugin, its interface is as follows:

The container control running the plug-in automatically loads target element: entity: customer, which is automatically generated by the framework. When typeofplugin = multielementplugin, its interface is as follows:

Two tabs are displayed. The first tab is the object to be applied. You can select multiple tabs. The second tab is the same as the preceding interface.
The surpressprojectexplorerredraw attribute is used to indicate whether the main interface is suspended when the plug-in is running. Please compare the two figures below

Figure 2

The difference is that when surpressprojectexplorerredraw = true, project explorer hides the content in the second image for re-painting, and when its value is false, the content in project explorer is still displayed.

Add a control for the plug-in. As mentioned earlier, to run the plug-in an independent tab form, add a new form and derive from ipluginwindow.
Public partial class entityvisualizercontrol: form, ipluginwindow
If you are running in the standard container interface, add a Windows Control and derive from ipluginconfigurationcontrol.
Public class assigntypeconverterscontrol: usercontrol, ipluginconfigurationcontrol

To explain, the standard container interface, such as the target element tag, and two buttons run! /Cancel, which is the standard container interface.

for controls, add the following Code for the standard container interface to load some controls
Public override system. windows. forms. control getconfigurationcontrol ()
{_ control = new addcustompropertiesconfigurationcontrol ();
return _ control;
}< br> the last step is, add the Running code of the plug-in, that is, what to do when the plug-in is running. Rewrite the execute method
Public override void execute ()
{< br> entityvisualizercontrol _ control = new entityvisualizercontrol (base. projecttotarget. connectionstring, this);
base. opendockedwindow (_ control);
}< br> here is an independent tab page form. If it is a control, generally,
Public override void execute ()
{< br> _ typeconversionsselected = _ control. selectedtypeconversions;

// 2 main tasks: entity, typed View
Base. progresstaskinit (2 );

Base. progresstaskstart ("processing entities ");
Base. progresssubtaskinit (base. Entities. Count );
Foreach (entitydefinition entity in base. Entities)
{

}

}
_ Control is the control we designed. After receiving user input, when the user clicks run! Return value to the plug-in container and execute the execute method.
Some Variables passed back by the framework, such as base. Entities, are the entity elements of the selected application plug-in, and the base. typedviews view.

After talking so much about how to deal with the plug-in framework of llbl Gen, the plug-in functions are not described yet. When the plug-in is running, it connects to the database based on the connection string of the project and applies the following SQL statement to read all the table names.
Select name from sysobjects where type = 'U'
Subscribe to the selectedindexchanged event of cmbtables and reload the data table grid.

If you are interested in source code, please download the latest source code from source code of epn.codeplex.com.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.