From 6bd05f5a6a013a73eb161f68bd82a4167d431963 Mon Sep 17 00:00:00 2001 From: lilin Date: Fri, 17 Jun 2022 13:21:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=88=B0net6.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Apis/CodeTableApp/CodeTableController.cs | 2 +- SoEasyPlatform/Code/AppStart/Services.cs | 12 +--- SoEasyPlatform/Program.cs | 44 ++++++------- SoEasyPlatform/SoEasyPlatform.csproj | 18 ++--- SoEasyPlatform/Startup.cs | 66 ++----------------- 5 files changed, 40 insertions(+), 102 deletions(-) diff --git a/SoEasyPlatform/Apis/CodeTableApp/CodeTableController.cs b/SoEasyPlatform/Apis/CodeTableApp/CodeTableController.cs index 50fcb0b..4dc1818 100644 --- a/SoEasyPlatform/Apis/CodeTableApp/CodeTableController.cs +++ b/SoEasyPlatform/Apis/CodeTableApp/CodeTableController.cs @@ -352,7 +352,7 @@ namespace SoEasyPlatform.Apis var tableDb = base.GetTryDb(dbid); var dts = Export(model, tableDb); var bytes = Table_ToExcel.ExportExcel(dts, "数据库文档.xlsx"); - var url = FileSugar.MergeUrl(Startup.GetCurrentDirectory(), "excel/数据库文档" + SqlSugar.SnowFlakeSingle.Instance.getID() + ".xlsx"); + var url = FileSugar.MergeUrl(Startup.CurrentDirectory, "excel/数据库文档" + SqlSugar.SnowFlakeSingle.Instance.getID() + ".xlsx"); FileSugar.CreateFile(url, bytes); OpenPath(url); return result; diff --git a/SoEasyPlatform/Code/AppStart/Services.cs b/SoEasyPlatform/Code/AppStart/Services.cs index 97900b1..90e45e4 100644 --- a/SoEasyPlatform/Code/AppStart/Services.cs +++ b/SoEasyPlatform/Code/AppStart/Services.cs @@ -1,13 +1,8 @@ -using AutoMapper; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -namespace SoEasyPlatform +namespace SoEasyPlatform { public class Services { @@ -18,8 +13,7 @@ namespace SoEasyPlatform services.AddAutoMapper(typeof(SoEasyPlatform.MapperProfiles).Assembly); #if DEBUG //启用动态编译 - services.AddControllersWithViews() - .AddRazorRuntimeCompilation(); + services.AddControllersWithViews().AddRazorRuntimeCompilation(); #endif services.AddControllersWithViews().AddNewtonsoftJson(opt => { diff --git a/SoEasyPlatform/Program.cs b/SoEasyPlatform/Program.cs index 7c36f43..04927ac 100644 --- a/SoEasyPlatform/Program.cs +++ b/SoEasyPlatform/Program.cs @@ -1,26 +1,26 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Builder; +using SoEasyPlatform; +using SqlSugar.IOC; -namespace SoEasyPlatform +var builder = WebApplication.CreateBuilder(args); +Services.AddServices(builder.Services); +builder.Services.AddSqlSugar(new SqlSugar.IOC.IocConfig() { - public class Program + ConfigId = "master1", + DbType = IocDbType.Sqlite, + IsAutoCloseConnection = true, + ConnectionString = "DataSource=" + Startup.CurrentDirectory + @"\database\sqlite.db" +}); +builder.Services.ConfigurationSugar(db => +{ + if (!db.ConfigQuery.Any()) { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); + db.ConfigQuery.SetTable