System initialization of Rookey. Frame, and initialization of rookey. frame
I introduced the Database Configuration yesterday. Today I will continue to introduce the system initialization function. It is also an important part of system initialization. It can automatically initialize relevant data to the system in advance, at the same time, it can also provide convenience for online testing and facilitate system testing drills to prevent hidden dangers caused by human processing and save a lot of deployment time.
In this framework, system initialization includes database (including default and custom databases) initialization, data table initialization, system data initialization, and custom data initialization. frame. controllers \ UserController. in the cs user controller, In the Login (Action) on the logon page, the system determines whether the current system needs initialization and determines whether the user table contains user data, at the same time, the system checks whether the database exists. If the database does not exist, it first initializes the database. The initialization code is as follows:
/// <Summary> /// whether Initialization is required /// </summary> /// <returns> </returns> public static bool IsNeedInit () {try {DbLinkArgs dbLinkArgs = ModelConfigHelper. getLocalDbLinkArgs (); if (dbLinkArgs = null) return true; if (! SystemOperate. dbIsExists (dbLinkArgs) {// register the Stored Procedure SystemOperate with each database. regStoredProcedure (); // automatically registers the external link database server SystemOperate in the current database. regCrossDbServer ();} string errMsg = string. empty; long count = CommonOperate. count <Sys_User> (out errMsg, false); return count = 0 ;}catch {return true ;}}
After determining whether data needs to be initialized, the system will initialize the data table and fix the fields in sequence (currently only adding fields is supported) module data initialization, list information and list field initialization, list button initialization, form information and form field initialization, icon initialization, adding administrator roles and users, initializing system menus, and calling custom Initialization
/// <Summary> /// custom initialization, including menu, module, field, dictionary, and other data initialization /// </summary> public abstract void CustomerInit ();
In each project, you only need to override this method in the InitFactory class in the inheritance framework to initialize the method.
The following is the custom initialization code for Rookey. Demo:
/// <Summary> /// custom initialization /// </summary> public class InitOperate: initFactory {// <summary> // custom initialization /// </summary> public override void CustomerInit () {string errMsg = string. empty; CommonOperate. deleteRecordsByExpression <Sys_Menu> (x => x. name = "administrative" | x. name = "gift application", out errMsg); Sys_Menu XZMenu = new Sys_Menu () {Name = "", Display = "", IsLeaf = false, isValid = true}; Guid XZMenuId = CommonOperate. operateRecord <Sys_Menu> (XZMenu, Frame. operate. base. operateHandle. modelRecordOperateType. add, out errMsg); Guid detpModuleId = SystemOperate. getModuleIdByName ("gift application"); if (xZMenuId! = Guid. empty) {List <Sys_Menu> list = new List <Sys_Menu> (); list. add (new Sys_Menu () {Name = "gift application", Display = "gift application", ParentId = xZMenuId, Sys_ModuleId = detpModuleId, IsLeaf = true, IsValid = true }); commonOperate. operateRecords <Sys_Menu> (list, Frame. operate. base. operateHandle. modelRecordOperateType. add, out errMsg );}}}
OK. The initialization part of today will be introduced here. Next time, I will introduce you to common system classes and wish you a happy life!