ABP front end development series --- development framework (14) before and after the rapid development based Winform ABP, ABP development frame end frame series development --- (. 8) Winform interface development framework ABP

Introduced in front of a lot of ABP series of articles, step by step our daily development related to the Web API service building, login log and operational audit logs, dictionary management module, information province city maintenance organization rights management module, users, roles, permissions, menus and other content, and advanced query processing configuration management module, interface content, we developed the whole concept of combining our code generation tools Database2Sharp rapid development, rapid development is divided into two parts: a is ABP skeleton code Web API portion generating, including the field of the physical layer, application service layer, the common DTO and the interface layer, the API invokes the generate content Caller layer or the like, and the integration of the base class our package, so that the generated code is more compact, but with more powerful, easy to use performance function; the other part is the rapid generation of interface generation, we Winform based on our years in the field of development, integration of basic paging, public libraries and Winform class on the basis of the interface enables fast the Winform interface generation, and interface green Winform You can be configured according to the list of search criteria, the list display, editing interface field shows and much more, and the resulting Winform interface automatically have the overall framework and ABP quick call to the general rule.

1, ABP frame Background Information

ABP is short for ASP.NET Boilerplate, ABP is an open source and document-friendly application framework . ABP is not just a framework, it provides a best practice Wa -based domain-driven design (DDD) structure model system. ABP also learn to use the framework for some time, always I wanted to fully understand the whole context of this framework, and to want to use it as a finishing course of the series came out, but I did not write this article begins to write, it is hoped to gain insight and then in-depth understanding of some, we hope to be able to thoroughly understand some can not fraught, do not want content and online stereotyped translation official website, the official website of the English presentation is also very detailed, so I think it is to actual use of certain the consolidation will be better.

ABP first understand the framework, it is still very stunning, it is basically a master .NET architecture field, including almost all kinds of technology we .NET row on the field name, and it can support itself and .net framework .net core two technologies genre, its introduction is also very interested.

1) the characteristics of the framework ABP

We come to know about the contents of ABP under the framework involved.

  • Dependency injection , this section uses Castle windsor (dependency injection container) to achieve dependency injection, this is the way we often use IOC processed;
  • Storage Repository pattern has been achieved Entity Framework, NHibernate, MangoDB, memory database, storage mode can be implemented quickly call data interfaces;
  • Authentication and authorization management , you can use the property is declared the way the user is logged in, or interfaces authority to verify, through a very fine-grained way, for permission to call each interface settings;
  • Data validation , the ABP object interface input parameters automatically be determined non-empty, and the validity can be verified in accordance with attribute information request attribute;
  • Audit logging , that is our record, modify call records for each interface, and the creation of records, delete records, processing personnel;
  • Unit Of Work unit of work mode for the application layer and the storage layer method of database transactions automatically, by default all the application service layer interfaces are running in the way work unit, even if they call a different storage object processing, all in a which logical transaction;
  • Exception handling , the ABP framework provides a set of fairly complete process flow operation, abnormality can easily be recorded and transmitted;
  • Logging , what can I use Log4Net routine logging, tracking program to help us process information and error messages;
  • Multi-language / localization support , ABP frame processing for multiple languages is relatively friendly, provides configuration processing XML, JSON language information;
  • Auto Mapping automatic mapping , this is a very important target of the ABP concept isolation, to achieve the object and attribute mapping domain DTO object by using AutoMaper, you can isolate the logical relationship between the two, but can easily assign attribute information;
  • Dynamic Web API layer , take advantage of this dynamic process, the Application Service can be published directly to Web API layer, without the need for cumbersome create a business object for each Web API manual controller's very convenient;
  • JavaScript's dynamic AJax proxy processing , can automatically create proxy layer Javascript to be more convenient to use Web Api, the use of the Web tier.

In addition to these important features, ABP framework there are a lot of special features or concepts.

  • Multi-tenant support (automatically isolating each tenant's data, business module developers do not need to write corresponding code when you save and query data;
  • Soft delete support (the corresponding inherited base class or implement the appropriate interface will automatically soft-deleted)
  • Management system setting (level system, tenant-level, user-level, automatic management scope)
  • EventBus achieve field events (Domain Events)
  • Dependency modules and modules to implement the module of processing plug-ins, etc.

ABP framework is primarily to build the entire infrastructure is based on field-driven philosophy, the concept of which areas of the drive that contains are domain objects Entities, warehousing Object Repositories, field service interface layer Domain Services, Domain Events Domain Events, application service interface Application Services, data transmission DTOs and other objects.

ABP official website: http: //www.aspnetboilerplate.com, from which you can see a very detailed case and documentation, you can download different types of basic framework necessary.

ABP GitHub source address: https: //github.com/aspnetboilerplate, you can download the entire content-based framework, and the related model case code.

 

Based on the framework on the basis of ABP, we've put together improved the whole system of authority, as well as business systems based on the basis of this rapid development, rapid development framework framework icon ABP after we've put together, as shown below (as an example to the dictionary module )

Web API interface calls for the package, in order to adapt quickly to call the client object, the package as a separate encapsulation layer to facilitate calls between the various modules together.

 

2, rapid development framework based on ABP function Winform introduction

1) the login screen

2) main frame interface

Interface using the body frame is dynamically generated based on the menu, as well as the layout of multiple document interface, having a very good appearance and ease of use.

The function tree on the left and a list of the top menu module can be based on the dynamic role has permission to build, different roles have different menu functions point, as is the test user has a login interface.

 

3) user management interface

Users list includes paging query, import, export user data, and can use the right-click menu to add, edit customer records, or to specify a user password reset operations.

User editing interface shown below.

当然可以查看这个用户本身拥有的权限功能点,如下界面所示。

用户数据导入 ,可以根据指定模板的格式进行填写后,然后导入指定的文件内容,如下所示。

导出文件则是把列表中现有的数据进行导入,导出后提示是否打开Excel文件进行查看。

 

4)组织机构管理

组织机构主要就是一个层级的对象关系,一般包含但不限于公司、部门、工作组等的定义,其中组织机构包含用户成员和角色成员的关系,如下界面所示。

组织机构的树形列表可以进行拖动实现不同层级的变化

或者通过右键菜单进行编辑修改操作

 

组织机构可以修改机构名称和对应的父类节点,如下界面所示。

组织机构包含的成员可以添加多个人员记录,添加界面如下所示。

 

添加角色界面如下所示。

 

5)角色管理

角色信息没有层级关系,可以通过列表展示。

其中角色包含权限分配、角色成员和拥有菜单的维护,如下是角色编辑界面,包含角色基本信息、拥有权限、包含成员、拥有菜单的管理等。菜单对于角色来说,应该是一种界面资源,可以通过配置进行管理对应角色用户的菜单。

菜单编辑界面如下所示。

角色的权限包含系统可以用的权限,并可以勾选为角色设置所需的功能点,如下界面所示。

用户成员则和机构的用户管理一样,可以指定多个用户,这里不再赘述。

而菜单对于角色来说,应该是一种界面资源,可以通过配置进行管理对应角色用户的菜单,如下界面所示。

通过配置好的菜单,用户登录系统后,系统根据当前用户具有的菜单项目,动态构建显示对应的列表菜单和工具栏菜单。

 

 

6)功能管理

 严格来说,ABP框架并没有统一管理好权限功能点的,它没有任何表来存储这个功能集合,而是通过派生AuthorizationProvider的子类来定义权限功能点

我在这个基础上引入了一个权限功能的表用来存储功能点的,然后提供管理界面来动态维护这些功能点。如下界面所示。

我们刚才在角色里面看到可以分配的权限内容,就是基于这个权限表的信息展示。

这样我们可以动态添加或者批量添加所需要的功能点,并且和整个权限管理模块串联起来,形成一个完整的控制体系。

 

另外我们还可以通过左侧树列表的右键菜单管理列表,如下所示可以级联删除对应的节点及其下面所有子节点。

系统登录后,客户端自动获取对应用户的角色功能点,然后我们每次打开一个新的业务窗体,客户端会进行界面的权限逻辑控制,如果没有权限的,那么不可以访问操作,如下是禁止了产品信息的导入、导出、新增、编辑等操作功能,如下界面所示产品界面被动态取消相关权限后,界面禁止了某些操作功能。

 

7)菜单管理

Winform主界面的开发,基本上都是标准的界面,在顶部放置工具栏,中间区域则放置多文档的内容,但是在顶部菜单比较多的时候,就需要把菜单分为几级处理,如可以在顶部菜单放置一二级菜单,这种方式在一般功能点不算太多的情况下,呈现的界面效果较为直观、也较为美观。不过随着一些系统功能的增多,这种方式可能就会显得工具栏比较拥挤,那么我们是否可以在左侧放置一个树形列表,这样通过树形列表的收缩折叠,就可以放置非常多的菜单功能了。

在ABP快速开发框架里面,我们依旧采用Winform开发框架里面用到的菜单维护方式,在权限模块系统中维护菜单内容,并在用户登录系统后,动态加载菜单展示,并通过菜单的配置信息,可以动态展示不同的窗体信息。

菜单资源管理的列表界面界面如下所示

左侧列表依旧可以通过右键菜单进行维护管理。

双击树列表或者右侧的列表,都可以对已有的菜单进行编辑,菜单编辑界面如下所示。

我们可以通过选择图标按钮进行菜单图标的选择,如下是选择菜单图片的界面。

这样我们可以采用DevExpress内置漂亮的系统图标,也可选择系统文件里面的图标文件。

如果用户登录系统后,觉得自己管理的菜单有些多,那么可以通过菜单配置的方式,选择性的呈现某些菜单,把其他部分的菜单隐藏起来,这个就是自定义应用菜单界面,界面如下所示。

 

8)系统登录日志

登录日志,这个就是用户尝试登录的时候,留下的记录信息,其中包括用户的登录用户名,ID,IP地址、登录时间,以及登录是否成功的状态等信息。

 这个登录日志,就是在系统登录尝试的时候,留下的记录,可供管理员进行跟踪了解某个账户的使用情况,也可以根据这些登录信息进行一个统计报表的分析。

 

9)系统审计日志 

审计日志,设置我们在访问或者调用某个应用服务层接口的时候,横切面流下的一系列操作记录,其中记录我们访问的服务接口,参数,客户端IP地址,访问时间,以及异常等信息,这些操作都是在ABP系统自动记录的,如果我们需要屏蔽某些服务类或者接口,则这些就不会记录在里面,否则默认是记录的。

审计日志的明细展示界面如下所示。

 

10)字典管理

字典管理界面,左侧列出字典类型,并对字典类型下的字典数据进行分页展示,右侧则利用分页展示对应字典类型的字典数据,字典管理界面如下所示。

新增或者编辑窗体界面如下

批量添加字典内容的界面如下所示。

省份城市行政区的模块管理,也主要是为了提供一个三级联动的字典列表给界面使用,因此这里对这些统计局的数据进行一个维护和展示出来,如下界面所示。

 

11)参数配置模块

一般来说,一个系统或多或少都会涉及到一些系统参数或者用户信息的配置,而ABP框架也提供了一套配置信息的管理模块,ABP框架的配置信息,必须提前定义好配置的各项内容,然后才能在系统中初始化或者通过接口查询来使用,本ABP快速开发框架引入了另外一种配置信息的定义,实现更加简化的处理。

参数配置管理模块界面如下所示。

配置模块使用主要特点是以键为操作对象,然后内容是JSON序列化后的内容,可以存储用户自定义的类的序列号字符串,通过整合了SettingsProvider.net组件,使得我们操作配置内容更加方便和动态化。

 

以上就是框架里面主要的模块内容展示,当然我们可以结合代码生成工具来快速开发自己的业务管理模块,而这些主要就是设计好数据库后,对框架代码和界面代码的统一生成后进行整合到主体框架里面即可,可以获得高效、统一、快速的开发体验。

详细的代码生成工具开发过程,可以了解随笔《利用代码生成工具生成基于ABP框架的代码 》、《ABP开发框架前后端开发系列---(8)ABP框架之Winform界面的开发过程

ABP框架代码生成

最终根据根据选择数据库表信息,一键生成相关ABP架构分层代码,文件结构如下所示。

ABP框架的Winform界面开发

设置好后直接生成,代码工具就可以依照模板来生成所需要的WInform列表界面和编辑界面的内容了,如下是生成的界面代码。

放到VS项目里面,就看到对应的窗体界面效果了。

生成界面后,进行一定的布局调整就可以实际用于生产环境了,省却了很多时间。

Guess you like

Origin www.cnblogs.com/wuhuacong/p/11125693.html