(相关资料图)
Known是基于C#和Blazor开发的前后端分离快速开发框架,开箱即用,跨平台,一处代码,多处运行。开源地址: https://gitee.com/known/Known
-- 安装模板dotnet new install KnownTemplate-- 创建项目dotnet new known --name=KIMS
说明:KIMS为测试项目名称
├─KIMS ->项目前后端共用库,客户端和实体类等。├─KIMS.Client ->Web前端,Blazor WebAssembly。├─KIMS.Core ->项目后端库,控制器、服务、数据访问等。├─KIMS.Razor ->项目前端库,模块页面和表单。├─KIMS.Server ->Web后端。├─KIMS.WinForm ->WinForm窗体及Razor页面。├─KIMSAlone ->桌面exe程序。├─KIMS.db ->默认SQLite数据库。├─KIMS.sln ->VS解决方案文件。
public class AppConfig{ public static void Initialize() { Config.AppId = "KIMS"; //系统ID,自动生成,默认项目名称 Config.AppName = "Known管理系统"; //在此配置你的系统名称 Config.SysVersion = "1.0.0"; //系统版本号 Config.AppAssembly = typeof(AppConfig).Assembly; //实体模型程序集,用于模块管理配置列表字段 PagingCriteria.DefaultPageSize = 20; //默认分页大小 DicCategory.AddCategories(); //自动加载数据字典类别,在AppDictionary中增加类别 Cache.AttachCodes(typeof(AppConfig).Assembly); //自动加载CodeTable特性类常量进入缓存 //在此配置你的系统其他全局配置 }}
-- SQLite -- Access -- MySQL
-- 打开项目下 AppServer.cs 文件修改数据库连接,示例代码如下:
class AppServer{ internal static void Initialize(WebApplicationBuilder builder) { //配置环境目录 KCConfig.WebRoot = builder.Environment.WebRootPath; KCConfig.ContentRoot = builder.Environment.ContentRootPath; //读取appsettings.json配置 var configuration = builder.Configuration; var dbFile = configuration.GetSection("DBFile").Get();//数据库配置 var uploadPath = configuration.GetSection("UploadPath").Get();//上传文件存储路径 Initialize(dbFile, uploadPath); } internal static void Initialize(string? dbFile, string? uploadPath) { //初始化配置 AppConfig.Initialize(); AppCore.Initialize(); //转换绝对路径 var path = KCConfig.ContentRoot; dbFile = Path.GetFullPath(Path.Combine(path, dbFile)); uploadPath = Path.GetFullPath(Path.Combine(path, uploadPath)); //注册数据访问提供者和初始化数据库连接 Database.RegisterProviders(new Dictionary { ["SQLite"] = typeof(Microsoft.Data.Sqlite.SqliteFactory) }); var connInfo = new Known.Core.ConnectionInfo { Name = "Default", ProviderName = "SQLite", ConnectionString = $"Data Source={dbFile};" }; KCConfig.App = new AppInfo { Connections = new List { connInfo }, UploadPath = uploadPath }; }}
标签:
X 关闭
X 关闭