From cd681069cc2300d3c84dbe4bebb1493c8e115ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E6=98=8E=E9=94=8B?= Date: Tue, 5 May 2020 00:12:32 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=E7=B1=BB=EF=BC=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 16 +- OSharp.CodeGenerator.sln | 9 +- .../Data/Entities/CodeEntity.cs | 61 ++++ .../Data/Entities/CodeEntityConfiguration.cs | 28 ++ .../Data/Entities/CodeModule.cs | 56 ++++ .../Data/Entities/CodeModuleConfiguration.cs | 28 ++ .../Data/Entities/CodeProject.cs | 61 ++++ .../Data/Entities/CodeProjectConfiguration.cs | 26 ++ .../Data/Entities/CodeProperty.cs | 90 ++++++ .../Entities/CodePropertyConfiguration.cs | 28 ++ .../Data/Entities/KeyValueConfiguration.cs | 27 ++ .../OSharp.CodeGeneration.csproj | 14 + src/OSharp.CodeGenerator/App.xaml.cs | 96 +++++- src/OSharp.CodeGenerator/Bootstrapper.cs | 61 +++- .../SqliteDefaultDbContextMigrationPack.cs | 39 +++ ...SqliteDesignTimeDefaultDbContextFactory.cs | 87 ++++++ .../20200504160451_Init.Designer.cs | 286 ++++++++++++++++++ .../Migrations/20200504160451_Init.cs | 204 +++++++++++++ .../DefaultDbContextModelSnapshot.cs | 284 +++++++++++++++++ .../OSharp.CodeGenerator.csproj | 33 +- .../Resources/osharp128-2.ico | Bin 0 -> 6784 bytes .../Resources/osharp128-2.png | Bin 0 -> 6762 bytes .../Resources/osharp128.ico | Bin 0 -> 6506 bytes .../Resources/osharp128.png | Bin 0 -> 6484 bytes .../Resources/osharp128.svg | 9 + src/OSharp.CodeGenerator/Views/MainView.xaml | 15 +- .../Views/MainView.xaml.cs | 20 ++ .../Views/MainViewModel.cs | 11 +- .../Views/Menus/MainMenuView.xaml | 43 +++ .../Views/Menus/MainMenuView.xaml.cs | 26 ++ .../Views/Menus/MainMenuViewModel.cs | 103 +++++++ .../Views/Project/ProjectView.xaml | 13 + .../Views/Project/ProjectView.xaml.cs | 26 ++ .../Views/Project/ProjectViewModel.cs | 49 +++ .../Views/Statusbar/StatusBarViewModel.cs | 23 ++ .../Views/Statusbar/StatusbarView.xaml | 13 + .../Views/Statusbar/StatusbarView.xaml.cs | 25 ++ .../Views/ViewModelsModule.cs | 2 +- src/OSharp.CodeGenerator/appsettings.json | 14 + 39 files changed, 1899 insertions(+), 27 deletions(-) create mode 100644 src/OSharp.CodeGeneration/Data/Entities/CodeEntity.cs create mode 100644 src/OSharp.CodeGeneration/Data/Entities/CodeEntityConfiguration.cs create mode 100644 src/OSharp.CodeGeneration/Data/Entities/CodeModule.cs create mode 100644 src/OSharp.CodeGeneration/Data/Entities/CodeModuleConfiguration.cs create mode 100644 src/OSharp.CodeGeneration/Data/Entities/CodeProject.cs create mode 100644 src/OSharp.CodeGeneration/Data/Entities/CodeProjectConfiguration.cs create mode 100644 src/OSharp.CodeGeneration/Data/Entities/CodeProperty.cs create mode 100644 src/OSharp.CodeGeneration/Data/Entities/CodePropertyConfiguration.cs create mode 100644 src/OSharp.CodeGeneration/Data/Entities/KeyValueConfiguration.cs create mode 100644 src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj create mode 100644 src/OSharp.CodeGenerator/Data/SqliteDefaultDbContextMigrationPack.cs create mode 100644 src/OSharp.CodeGenerator/Data/SqliteDesignTimeDefaultDbContextFactory.cs create mode 100644 src/OSharp.CodeGenerator/Migrations/20200504160451_Init.Designer.cs create mode 100644 src/OSharp.CodeGenerator/Migrations/20200504160451_Init.cs create mode 100644 src/OSharp.CodeGenerator/Migrations/DefaultDbContextModelSnapshot.cs create mode 100644 src/OSharp.CodeGenerator/Resources/osharp128-2.ico create mode 100644 src/OSharp.CodeGenerator/Resources/osharp128-2.png create mode 100644 src/OSharp.CodeGenerator/Resources/osharp128.ico create mode 100644 src/OSharp.CodeGenerator/Resources/osharp128.png create mode 100644 src/OSharp.CodeGenerator/Resources/osharp128.svg create mode 100644 src/OSharp.CodeGenerator/Views/Menus/MainMenuView.xaml create mode 100644 src/OSharp.CodeGenerator/Views/Menus/MainMenuView.xaml.cs create mode 100644 src/OSharp.CodeGenerator/Views/Menus/MainMenuViewModel.cs create mode 100644 src/OSharp.CodeGenerator/Views/Project/ProjectView.xaml create mode 100644 src/OSharp.CodeGenerator/Views/Project/ProjectView.xaml.cs create mode 100644 src/OSharp.CodeGenerator/Views/Project/ProjectViewModel.cs create mode 100644 src/OSharp.CodeGenerator/Views/Statusbar/StatusBarViewModel.cs create mode 100644 src/OSharp.CodeGenerator/Views/Statusbar/StatusbarView.xaml create mode 100644 src/OSharp.CodeGenerator/Views/Statusbar/StatusbarView.xaml.cs create mode 100644 src/OSharp.CodeGenerator/appsettings.json diff --git a/.editorconfig b/.editorconfig index 29d1335..8c63803 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,24 +2,24 @@ root = true [*] -#񣺿ո +#缩进风格:空格 indent_style = space -#С2 +#缩进大小2 indent_size = 4 -#зlf +#换行符lf end_of_line = lf -#ַutf-8 +#字符集utf-8 charset = utf-8 -#ǷɾβĿո +#是否删除行尾的空格 trim_trailing_whitespace = true -#Ƿļһ +#是否在文件的最后插入一个空行 insert_final_newline = true -[*.xaml] +[*.{xaml,json,csproj}] indent_size = 2 [*.md] trim_trailing_whitespace = false [Makefile] -indent_style = tab \ No newline at end of file +indent_style = tab diff --git a/OSharp.CodeGenerator.sln b/OSharp.CodeGenerator.sln index 0916186..ef756fb 100644 --- a/OSharp.CodeGenerator.sln +++ b/OSharp.CodeGenerator.sln @@ -10,7 +10,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{CE0E16CA EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{87C5555B-87C3-46FE-9BF0-ACA575890EC6}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OSharp.CodeGenerator", "src\OSharp.CodeGenerator\OSharp.CodeGenerator.csproj", "{5AF55A1E-7A19-4886-B4B0-D840694AA997}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OSharp.CodeGenerator", "src\OSharp.CodeGenerator\OSharp.CodeGenerator.csproj", "{5AF55A1E-7A19-4886-B4B0-D840694AA997}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OSharp.CodeGeneration", "src\OSharp.CodeGeneration\OSharp.CodeGeneration.csproj", "{B05EB364-E7CA-4EB5-93EA-3FD33BCAAFAA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -22,12 +24,17 @@ Global {5AF55A1E-7A19-4886-B4B0-D840694AA997}.Debug|Any CPU.Build.0 = Debug|Any CPU {5AF55A1E-7A19-4886-B4B0-D840694AA997}.Release|Any CPU.ActiveCfg = Release|Any CPU {5AF55A1E-7A19-4886-B4B0-D840694AA997}.Release|Any CPU.Build.0 = Release|Any CPU + {B05EB364-E7CA-4EB5-93EA-3FD33BCAAFAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B05EB364-E7CA-4EB5-93EA-3FD33BCAAFAA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B05EB364-E7CA-4EB5-93EA-3FD33BCAAFAA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B05EB364-E7CA-4EB5-93EA-3FD33BCAAFAA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {5AF55A1E-7A19-4886-B4B0-D840694AA997} = {87C5555B-87C3-46FE-9BF0-ACA575890EC6} + {B05EB364-E7CA-4EB5-93EA-3FD33BCAAFAA} = {87C5555B-87C3-46FE-9BF0-ACA575890EC6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {AFCE6A5E-D5ED-4BAA-8CCF-45A229EF3405} diff --git a/src/OSharp.CodeGeneration/Data/Entities/CodeEntity.cs b/src/OSharp.CodeGeneration/Data/Entities/CodeEntity.cs new file mode 100644 index 0000000..0140a6a --- /dev/null +++ b/src/OSharp.CodeGeneration/Data/Entities/CodeEntity.cs @@ -0,0 +1,61 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-04 23:06 +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.ComponentModel; + +using OSharp.Entity; + + +namespace OSharp.CodeGeneration.Entities +{ + /// + /// 实体类:代码实体信息 + /// + [Description("代码实体信息")] + [TableNamePrefix("CodeGen")] + public class CodeEntity : EntityBase + { + /// + /// 获取或设置 类型名称 + /// + public string Name { get; set; } + + /// + /// 获取或设置 类型显示名称 + /// + public string Display { get; set; } + + /// + /// 获取或设置 主键类型全名 + /// + public string PrimaryKeyTypeFullName { get; set; } + + /// + /// 获取或设置 是否数据权限控制 + /// + public bool IsDataAuth { get; set; } + + /// + /// 获取或设置 所属模块编号 + /// + public Guid ModuleId { get; set; } + + /// + /// 获取或设置 所属模块 + /// + public virtual CodeModule Module { get; set; } + + /// + /// 获取或设置 实体的属性集合 + /// + public virtual ICollection Properties { get; set; } = new List(); + } +} diff --git a/src/OSharp.CodeGeneration/Data/Entities/CodeEntityConfiguration.cs b/src/OSharp.CodeGeneration/Data/Entities/CodeEntityConfiguration.cs new file mode 100644 index 0000000..a137c56 --- /dev/null +++ b/src/OSharp.CodeGeneration/Data/Entities/CodeEntityConfiguration.cs @@ -0,0 +1,28 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-04 23:06 +// ----------------------------------------------------------------------- + +using System; + +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +using OSharp.Entity; + + +namespace OSharp.CodeGeneration.Entities +{ + public class CodeEntityConfiguration : EntityTypeConfigurationBase + { + /// 重写以实现实体类型各个属性的数据库配置 + /// 实体类型创建器 + public override void Configure(EntityTypeBuilder builder) + { + builder.HasOne(m => m.Module).WithMany(n => n.Entities).HasForeignKey(m => m.ModuleId).IsRequired(); + } + } +} diff --git a/src/OSharp.CodeGeneration/Data/Entities/CodeModule.cs b/src/OSharp.CodeGeneration/Data/Entities/CodeModule.cs new file mode 100644 index 0000000..55727d0 --- /dev/null +++ b/src/OSharp.CodeGeneration/Data/Entities/CodeModule.cs @@ -0,0 +1,56 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-04 23:06 +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.ComponentModel; + +using OSharp.Entity; + + +namespace OSharp.CodeGeneration.Entities +{ + /// + /// 实体类:代码模块信息 + /// + [Description("代码模块信息")] + [TableNamePrefix("CodeGen")] + public class CodeModule : EntityBase + { + /// + /// 获取或设置 模块名称 + /// + public string Name { get; set; } + + /// + /// 获取或设置 模块显示名称 + /// + public string Display { get; set; } + + /// + /// 获取或设置 所属项目编号 + /// + public Guid ProjectId { get; set; } + + /// + /// 获取或设置 所属项目 + /// + public virtual CodeProject Project { get; set; } + + /// + /// 获取或设置 模块的实体集合 + /// + public virtual ICollection Entities { get; set; } = new List(); + + /// + /// 获取 模块命名空间,由“项目命名空间前缀.模块名称”组成 + /// + public string Namespace => $"{(Project == null ? "" : Project.NamespacePrefix + ".")}{Name}"; + } +} diff --git a/src/OSharp.CodeGeneration/Data/Entities/CodeModuleConfiguration.cs b/src/OSharp.CodeGeneration/Data/Entities/CodeModuleConfiguration.cs new file mode 100644 index 0000000..d40ffc5 --- /dev/null +++ b/src/OSharp.CodeGeneration/Data/Entities/CodeModuleConfiguration.cs @@ -0,0 +1,28 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-04 23:06 +// ----------------------------------------------------------------------- + +using System; + +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +using OSharp.Entity; + + +namespace OSharp.CodeGeneration.Entities +{ + public class CodeModuleConfiguration : EntityTypeConfigurationBase + { + /// 重写以实现实体类型各个属性的数据库配置 + /// 实体类型创建器 + public override void Configure(EntityTypeBuilder builder) + { + builder.HasOne(m => m.Project).WithMany(n => n.Modules).HasForeignKey(m => m.ProjectId).IsRequired(); + } + } +} diff --git a/src/OSharp.CodeGeneration/Data/Entities/CodeProject.cs b/src/OSharp.CodeGeneration/Data/Entities/CodeProject.cs new file mode 100644 index 0000000..0da9b8d --- /dev/null +++ b/src/OSharp.CodeGeneration/Data/Entities/CodeProject.cs @@ -0,0 +1,61 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-04 23:06 +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.ComponentModel; + +using OSharp.Entity; + + +namespace OSharp.CodeGeneration.Entities +{ + /// + /// 实体类:代码项目信息 + /// + [Description("代码项目信息")] + [TableNamePrefix("CodeGen")] + public class CodeProject : EntityBase + { + /// + /// 获取或设置 项目名称 + /// + public string Name { get; set; } + + /// + /// 获取或设置 公司 + /// + public string Company { get; set; } + + /// + /// 获取或设置 项目命名空间前缀,通常形如“公司.项目” + /// + public string NamespacePrefix { get; set; } + + /// + /// 获取或设置 站点地址 + /// + public string SiteUrl { get; set; } + + /// + /// 获取或设置 创建者 + /// + public string Creator { get; set; } + + /// + /// 获取或设置 Copyright + /// + public string Copyright { get; set; } + + /// + /// 获取或设置 模块信息集合 + /// + public virtual ICollection Modules { get; set; } = new List(); + } +} diff --git a/src/OSharp.CodeGeneration/Data/Entities/CodeProjectConfiguration.cs b/src/OSharp.CodeGeneration/Data/Entities/CodeProjectConfiguration.cs new file mode 100644 index 0000000..07aaa43 --- /dev/null +++ b/src/OSharp.CodeGeneration/Data/Entities/CodeProjectConfiguration.cs @@ -0,0 +1,26 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-04 23:06 +// ----------------------------------------------------------------------- + +using System; + +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +using OSharp.Entity; + + +namespace OSharp.CodeGeneration.Entities +{ + public class CodeProjectConfiguration : EntityTypeConfigurationBase + { + /// 重写以实现实体类型各个属性的数据库配置 + /// 实体类型创建器 + public override void Configure(EntityTypeBuilder builder) + { } + } +} diff --git a/src/OSharp.CodeGeneration/Data/Entities/CodeProperty.cs b/src/OSharp.CodeGeneration/Data/Entities/CodeProperty.cs new file mode 100644 index 0000000..76991c8 --- /dev/null +++ b/src/OSharp.CodeGeneration/Data/Entities/CodeProperty.cs @@ -0,0 +1,90 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-04 23:06 +// ----------------------------------------------------------------------- + +using System; +using System.ComponentModel; + +using OSharp.Entity; + + +namespace OSharp.CodeGeneration.Entities +{ + /// + /// 实体类:代码实体属性信息 + /// + [Description("代码实体属性")] + [TableNamePrefix("CodeGen")] + public class CodeProperty : EntityBase + { + /// + /// 获取或设置 属性名称 + /// + public string Name { get; set; } + + /// + /// 获取或设置 属性类型名称 + /// + public string TypeName { get; set; } + + /// + /// 获取或设置 显示名称 + /// + public string Display { get; set; } + + /// + /// 获取或设置 是否必须 + /// + public bool? IsRequired { get; set; } + + /// + /// 获取或设置 最大长度 + /// + public int? MaxLength { get; set; } + + /// + /// 获取或设置 最小长度 + /// + public int? MinLength { get; set; } + + /// + /// 获取或设置 是否值类型可空 + /// + public bool IsNullable { get; set; } + + /// + /// 获取或设置 是否虚属性 + /// + public bool IsVirtual { get; set; } + + /// + /// 获取或设置 是否外键 + /// + public bool IsForeignKey { get; set; } + + /// + /// 获取或设置 是否包含在输入Dto + /// + public bool IsInputDto { get; set; } = true; + + /// + /// 获取或设置 是否包含在输出Dto + /// + public bool IsOutputDto { get; set; } = true; + + /// + /// 获取或设置 实体编号 + /// + public Guid EntityId { get; set; } + + /// + /// 获取或设置 所属实体信息 + /// + public virtual CodeEntity Entity { get; set; } + } +} diff --git a/src/OSharp.CodeGeneration/Data/Entities/CodePropertyConfiguration.cs b/src/OSharp.CodeGeneration/Data/Entities/CodePropertyConfiguration.cs new file mode 100644 index 0000000..30083b8 --- /dev/null +++ b/src/OSharp.CodeGeneration/Data/Entities/CodePropertyConfiguration.cs @@ -0,0 +1,28 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-04 23:06 +// ----------------------------------------------------------------------- + +using System; + +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +using OSharp.Entity; + + +namespace OSharp.CodeGeneration.Entities +{ + public class CodePropertyConfiguration : EntityTypeConfigurationBase + { + /// 重写以实现实体类型各个属性的数据库配置 + /// 实体类型创建器 + public override void Configure(EntityTypeBuilder builder) + { + builder.HasOne(m => m.Entity).WithMany(n => n.Properties).HasForeignKey(m => m.EntityId).IsRequired(); + } + } +} diff --git a/src/OSharp.CodeGeneration/Data/Entities/KeyValueConfiguration.cs b/src/OSharp.CodeGeneration/Data/Entities/KeyValueConfiguration.cs new file mode 100644 index 0000000..ab5a80b --- /dev/null +++ b/src/OSharp.CodeGeneration/Data/Entities/KeyValueConfiguration.cs @@ -0,0 +1,27 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-05 0:00 +// ----------------------------------------------------------------------- + +using System; + +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +using OSharp.Core.Systems; +using OSharp.Entity; + + +namespace OSharp.CodeGeneration.Data.Entities +{ + public class KeyValueConfiguration : EntityTypeConfigurationBase + { + /// 重写以实现实体类型各个属性的数据库配置 + /// 实体类型创建器 + public override void Configure(EntityTypeBuilder builder) + { } + } +} diff --git a/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj b/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj new file mode 100644 index 0000000..dc599fe --- /dev/null +++ b/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj @@ -0,0 +1,14 @@ + + + + netcoreapp3.1 + + + + + + + + + + diff --git a/src/OSharp.CodeGenerator/App.xaml.cs b/src/OSharp.CodeGenerator/App.xaml.cs index bd803a4..9f1400f 100644 --- a/src/OSharp.CodeGenerator/App.xaml.cs +++ b/src/OSharp.CodeGenerator/App.xaml.cs @@ -1,10 +1,16 @@ -using System; +using System; using System.Collections.Generic; -using System.Configuration; -using System.Data; -using System.Linq; using System.Threading.Tasks; using System.Windows; +using System.Windows.Threading; + +using Microsoft.Extensions.Logging; + +using OSharp.Collections; +using OSharp.Dependency; + +using MessageBox = HandyControl.Controls.MessageBox; + namespace OSharp.CodeGenerator { @@ -13,5 +19,87 @@ namespace OSharp.CodeGenerator /// public partial class App : Application { + private ILogger _logger; + + /// + /// 初始化一个类型的新实例 + /// + public App() + { + //注册全局事件 + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + DispatcherUnhandledException += App_DispatcherUnhandledException; + TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; + } + + private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs args) + { + const string msg = "主线程异常"; + try + { + if (args.ExceptionObject is Exception && Dispatcher != null) + { + Dispatcher.Invoke(() => + { + Exception ex = (Exception)args.ExceptionObject; + HandleException(msg, ex); + }); + } + } + catch (Exception ex) + { + HandleException(msg, ex); + } + } + + private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs args) + { + const string msg = "子线程异常"; + try + { + HandleException(msg, args.Exception); + args.Handled = true; + } + catch (Exception ex) + { + HandleException(msg, ex); + } + } + + private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs args) + { + const string msg = "异步异常"; + try + { + HandleException(msg, args.Exception); + args.SetObserved(); + } + catch (Exception ex) + { + HandleException(msg, ex); + } + } + + private void HandleException(string msg, Exception ex) + { + if (_logger == null) + { + _logger = ServiceLocator.Instance.GetLogger(typeof(App)); + } + + List lines = new List(); + Exception innerEx = ex; + while (innerEx != null) + { + lines.Add(innerEx.Message); + innerEx = innerEx.InnerException; + } + + string detail = lines.ExpandAndToString("\r\n---"); + msg = $"{msg}: {detail}"; + _logger?.LogCritical(ex, msg); + MessageBox.Show($"错误消息:{detail}", "错误提示", MessageBoxButton.OK, MessageBoxImage.Error); + } + } } diff --git a/src/OSharp.CodeGenerator/Bootstrapper.cs b/src/OSharp.CodeGenerator/Bootstrapper.cs index e77ee3a..cca24d8 100644 --- a/src/OSharp.CodeGenerator/Bootstrapper.cs +++ b/src/OSharp.CodeGenerator/Bootstrapper.cs @@ -7,13 +7,72 @@ // 2020-05-03 14:58 // ----------------------------------------------------------------------- +using System; + +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +using OSharp.CodeGenerator.Data; using OSharp.CodeGenerator.Views; +using OSharp.Entity.Sqlite; +using OSharp.Wpf.Data; +using OSharp.Wpf.Stylet; using Stylet; +using StyletIoC; + namespace OSharp.CodeGenerator { public class Bootstrapper : Bootstrapper - { } + { + private ILogger _logger; + + /// Override to add your own types to the IoC container. + /// StyletIoC builder to use to configure the container + protected override void ConfigureIoC(IStyletIoCBuilder builder) + { + builder.AddModule(new ViewModelsModule()); + } + + /// Hook called after the IoC container has been set up + protected override void Configure() + { + IoC.Initialize(Container); + StatusBarViewModel statusBar = IoC.Get(); + Output.StatusBar = msg => statusBar.Message = msg; + OsharpInit(); + } + + #region 私有方法 + + private void OsharpInit() + { + IServiceCollection services = new ServiceCollection(); + IConfigurationBuilder builder = new ConfigurationBuilder(); + builder.AddJsonFile("appsettings.json"); + IConfiguration configuration = builder.Build(); + services.AddSingleton(configuration); + + services.AddLogging(opts => + { +#if DEBUG + opts.SetMinimumLevel(LogLevel.Debug); +#else + opts.SetMinimumLevel(LogLevel.Information); +#endif + }); + + services.AddOSharp() + .AddPack(); + + IServiceProvider provider = services.BuildServiceProvider(); + provider.UseOsharp(); + _logger = provider.GetLogger(); + } + + #endregion + } } diff --git a/src/OSharp.CodeGenerator/Data/SqliteDefaultDbContextMigrationPack.cs b/src/OSharp.CodeGenerator/Data/SqliteDefaultDbContextMigrationPack.cs new file mode 100644 index 0000000..222aecb --- /dev/null +++ b/src/OSharp.CodeGenerator/Data/SqliteDefaultDbContextMigrationPack.cs @@ -0,0 +1,39 @@ +using System; +using System.ComponentModel; + +using OSharp.Core.Packs; +using OSharp.Entity; +using OSharp.Entity.Sqlite; + + +namespace OSharp.CodeGenerator.Data +{ + /// + /// Sqlite-DefaultDbContext迁移模块 + /// + [DependsOnPacks(typeof(SqliteEntityFrameworkCorePack))] + [Description("Sqlite-DefaultDbContext迁移模块")] + public class SqliteDefaultDbContextMigrationPack : MigrationPackBase + { + /// + /// 获取 模块启动顺序,模块启动的顺序先按级别启动,级别内部再按此顺序启动, + /// 级别默认为0,表示无依赖,需要在同级别有依赖顺序的时候,再重写为>0的顺序值 + /// + public override int Order => 2; + + /// + /// 获取 数据库类型 + /// + protected override DatabaseType DatabaseType => DatabaseType.Sqlite; + + /// + /// 重写实现获取数据上下文实例 + /// + /// 服务提供者 + /// + protected override DefaultDbContext CreateDbContext(IServiceProvider scopedProvider) + { + return new SqliteDesignTimeDefaultDbContextFactory(scopedProvider).CreateDbContext(new string[0]); + } + } +} diff --git a/src/OSharp.CodeGenerator/Data/SqliteDesignTimeDefaultDbContextFactory.cs b/src/OSharp.CodeGenerator/Data/SqliteDesignTimeDefaultDbContextFactory.cs new file mode 100644 index 0000000..fc4f726 --- /dev/null +++ b/src/OSharp.CodeGenerator/Data/SqliteDesignTimeDefaultDbContextFactory.cs @@ -0,0 +1,87 @@ +using System; +using System.Reflection; + +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +using OSharp.Core.Options; +using OSharp.Data; +using OSharp.Entity; +using OSharp.Exceptions; +using OSharp.Extensions; +using OSharp.Reflection; + + +namespace OSharp.CodeGenerator.Data +{ + public class SqliteDesignTimeDefaultDbContextFactory : DesignTimeDbContextFactoryBase + { + private readonly IServiceProvider _serviceProvider; + + public SqliteDesignTimeDefaultDbContextFactory() + { } + + public SqliteDesignTimeDefaultDbContextFactory(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + public override string GetConnectionString() + { + if (_serviceProvider == null) + { + IConfigurationBuilder builder = new ConfigurationBuilder(); + builder.AddJsonFile("appsettings.json"); + IConfiguration configuration = builder.Build(); + Singleton.Instance = configuration; + Console.WriteLine($"configuration == null: {configuration == null}"); + string str = configuration["OSharp:DbContexts:Sqlite:ConnectionString"]; + return str; + } + OsharpOptions options = _serviceProvider.GetOSharpOptions(); + OsharpDbContextOptions contextOptions = options.GetDbContextOptions(typeof(DefaultDbContext)); + if (contextOptions == null) + { + throw new OsharpException($"上下文“{typeof(DefaultDbContext)}”的配置信息不存在"); + } + return contextOptions.ConnectionString; + } + + public override IEntityManager GetEntityManager() + { + if (_serviceProvider != null) + { + return _serviceProvider.GetService(); + } + IEntityConfigurationTypeFinder typeFinder = new EntityConfigurationTypeFinder(new AppDomainAllAssemblyFinder()); + IEntityManager entityManager = new EntityManager(typeFinder); + entityManager.Initialize(); + return entityManager; + } + + public override bool LazyLoadingProxiesEnabled() + { + if (_serviceProvider == null) + { + IConfiguration configuration = Singleton.Instance; + return configuration["OSharp:DbContexts:Sqlite:LazyLoadingProxiesEnabled"].CastTo(false); + } + OsharpOptions options = _serviceProvider.GetOSharpOptions(); + OsharpDbContextOptions contextOptions = options.GetDbContextOptions(typeof(DefaultDbContext)); + if (contextOptions == null) + { + throw new OsharpException($"上下文“{typeof(DefaultDbContext)}”的配置信息不存在"); + } + + return contextOptions.LazyLoadingProxiesEnabled; + } + + public override DbContextOptionsBuilder UseSql(DbContextOptionsBuilder builder, string connString) + { + string entryAssemblyName = Assembly.GetExecutingAssembly().GetName().Name; + Console.WriteLine($"entryAssemblyName: {entryAssemblyName}"); + return builder.UseSqlite(connString, b => b.MigrationsAssembly(entryAssemblyName)); + } + } +} diff --git a/src/OSharp.CodeGenerator/Migrations/20200504160451_Init.Designer.cs b/src/OSharp.CodeGenerator/Migrations/20200504160451_Init.Designer.cs new file mode 100644 index 0000000..48f1087 --- /dev/null +++ b/src/OSharp.CodeGenerator/Migrations/20200504160451_Init.Designer.cs @@ -0,0 +1,286 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using OSharp.Entity; + +namespace OSharp.CodeGenerator.Migrations +{ + [DbContext(typeof(DefaultDbContext))] + [Migration("20200504160451_Init")] + partial class Init + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.2"); + + modelBuilder.Entity("OSharp.Authorization.EntityInfos.EntityInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AuditEnabled") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PropertyJson") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("TypeName") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("TypeName") + .IsUnique() + .HasName("ClassFullNameIndex"); + + b.ToTable("Auth_EntityInfo"); + }); + + modelBuilder.Entity("OSharp.Authorization.Functions.Function", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AccessType") + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasColumnType("TEXT"); + + b.Property("Area") + .HasColumnType("TEXT"); + + b.Property("AuditEntityEnabled") + .HasColumnType("INTEGER"); + + b.Property("AuditOperationEnabled") + .HasColumnType("INTEGER"); + + b.Property("CacheExpirationSeconds") + .HasColumnType("INTEGER"); + + b.Property("Controller") + .HasColumnType("TEXT"); + + b.Property("IsAccessTypeChanged") + .HasColumnType("INTEGER"); + + b.Property("IsAjax") + .HasColumnType("INTEGER"); + + b.Property("IsCacheSliding") + .HasColumnType("INTEGER"); + + b.Property("IsController") + .HasColumnType("INTEGER"); + + b.Property("IsLocked") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Area", "Controller", "Action") + .IsUnique() + .HasName("AreaControllerActionIndex"); + + b.ToTable("Auth_Function"); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Display") + .HasColumnType("TEXT"); + + b.Property("IsDataAuth") + .HasColumnType("INTEGER"); + + b.Property("ModuleId") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("PrimaryKeyTypeFullName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ModuleId"); + + b.ToTable("CodeGen_CodeEntity"); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeModule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Display") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("ProjectId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ProjectId"); + + b.ToTable("CodeGen_CodeModule"); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeProject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Company") + .HasColumnType("TEXT"); + + b.Property("Copyright") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("NamespacePrefix") + .HasColumnType("TEXT"); + + b.Property("SiteUrl") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("CodeGen_CodeProject"); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeProperty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Display") + .HasColumnType("TEXT"); + + b.Property("EntityId") + .HasColumnType("TEXT"); + + b.Property("IsForeignKey") + .HasColumnType("INTEGER"); + + b.Property("IsInputDto") + .HasColumnType("INTEGER"); + + b.Property("IsNullable") + .HasColumnType("INTEGER"); + + b.Property("IsOutputDto") + .HasColumnType("INTEGER"); + + b.Property("IsRequired") + .HasColumnType("INTEGER"); + + b.Property("IsVirtual") + .HasColumnType("INTEGER"); + + b.Property("MaxLength") + .HasColumnType("INTEGER"); + + b.Property("MinLength") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("TypeName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("EntityId"); + + b.ToTable("CodeGen_CodeProperty"); + }); + + modelBuilder.Entity("OSharp.Core.Systems.KeyValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("IsLocked") + .HasColumnType("INTEGER"); + + b.Property("Key") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ValueJson") + .HasColumnType("TEXT"); + + b.Property("ValueType") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Systems_KeyValue"); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeEntity", b => + { + b.HasOne("OSharp.CodeGeneration.Entities.CodeModule", "Module") + .WithMany("Entities") + .HasForeignKey("ModuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeModule", b => + { + b.HasOne("OSharp.CodeGeneration.Entities.CodeProject", "Project") + .WithMany("Modules") + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeProperty", b => + { + b.HasOne("OSharp.CodeGeneration.Entities.CodeEntity", "Entity") + .WithMany("Properties") + .HasForeignKey("EntityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/OSharp.CodeGenerator/Migrations/20200504160451_Init.cs b/src/OSharp.CodeGenerator/Migrations/20200504160451_Init.cs new file mode 100644 index 0000000..d3bb02f --- /dev/null +++ b/src/OSharp.CodeGenerator/Migrations/20200504160451_Init.cs @@ -0,0 +1,204 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace OSharp.CodeGenerator.Migrations +{ + public partial class Init : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Auth_EntityInfo", + columns: table => new + { + Id = table.Column(nullable: false), + Name = table.Column(nullable: false), + TypeName = table.Column(nullable: false), + AuditEnabled = table.Column(nullable: false), + PropertyJson = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Auth_EntityInfo", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Auth_Function", + columns: table => new + { + Id = table.Column(nullable: false), + Name = table.Column(nullable: true), + Area = table.Column(nullable: true), + Controller = table.Column(nullable: true), + Action = table.Column(nullable: true), + IsController = table.Column(nullable: false), + IsAjax = table.Column(nullable: false), + AccessType = table.Column(nullable: false), + IsAccessTypeChanged = table.Column(nullable: false), + AuditOperationEnabled = table.Column(nullable: false), + AuditEntityEnabled = table.Column(nullable: false), + CacheExpirationSeconds = table.Column(nullable: false), + IsCacheSliding = table.Column(nullable: false), + IsLocked = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Auth_Function", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CodeGen_CodeProject", + columns: table => new + { + Id = table.Column(nullable: false), + Name = table.Column(nullable: true), + Company = table.Column(nullable: true), + NamespacePrefix = table.Column(nullable: true), + SiteUrl = table.Column(nullable: true), + Creator = table.Column(nullable: true), + Copyright = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CodeGen_CodeProject", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Systems_KeyValue", + columns: table => new + { + Id = table.Column(nullable: false), + ValueJson = table.Column(nullable: true), + ValueType = table.Column(nullable: true), + Key = table.Column(nullable: false), + IsLocked = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Systems_KeyValue", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "CodeGen_CodeModule", + columns: table => new + { + Id = table.Column(nullable: false), + Name = table.Column(nullable: true), + Display = table.Column(nullable: true), + ProjectId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CodeGen_CodeModule", x => x.Id); + table.ForeignKey( + name: "FK_CodeGen_CodeModule_CodeGen_CodeProject_ProjectId", + column: x => x.ProjectId, + principalTable: "CodeGen_CodeProject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CodeGen_CodeEntity", + columns: table => new + { + Id = table.Column(nullable: false), + Name = table.Column(nullable: true), + Display = table.Column(nullable: true), + PrimaryKeyTypeFullName = table.Column(nullable: true), + IsDataAuth = table.Column(nullable: false), + ModuleId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CodeGen_CodeEntity", x => x.Id); + table.ForeignKey( + name: "FK_CodeGen_CodeEntity_CodeGen_CodeModule_ModuleId", + column: x => x.ModuleId, + principalTable: "CodeGen_CodeModule", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CodeGen_CodeProperty", + columns: table => new + { + Id = table.Column(nullable: false), + Name = table.Column(nullable: true), + TypeName = table.Column(nullable: true), + Display = table.Column(nullable: true), + IsRequired = table.Column(nullable: true), + MaxLength = table.Column(nullable: true), + MinLength = table.Column(nullable: true), + IsNullable = table.Column(nullable: false), + IsVirtual = table.Column(nullable: false), + IsForeignKey = table.Column(nullable: false), + IsInputDto = table.Column(nullable: false), + IsOutputDto = table.Column(nullable: false), + EntityId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CodeGen_CodeProperty", x => x.Id); + table.ForeignKey( + name: "FK_CodeGen_CodeProperty_CodeGen_CodeEntity_EntityId", + column: x => x.EntityId, + principalTable: "CodeGen_CodeEntity", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "ClassFullNameIndex", + table: "Auth_EntityInfo", + column: "TypeName", + unique: true); + + migrationBuilder.CreateIndex( + name: "AreaControllerActionIndex", + table: "Auth_Function", + columns: new[] { "Area", "Controller", "Action" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_CodeGen_CodeEntity_ModuleId", + table: "CodeGen_CodeEntity", + column: "ModuleId"); + + migrationBuilder.CreateIndex( + name: "IX_CodeGen_CodeModule_ProjectId", + table: "CodeGen_CodeModule", + column: "ProjectId"); + + migrationBuilder.CreateIndex( + name: "IX_CodeGen_CodeProperty_EntityId", + table: "CodeGen_CodeProperty", + column: "EntityId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Auth_EntityInfo"); + + migrationBuilder.DropTable( + name: "Auth_Function"); + + migrationBuilder.DropTable( + name: "CodeGen_CodeProperty"); + + migrationBuilder.DropTable( + name: "Systems_KeyValue"); + + migrationBuilder.DropTable( + name: "CodeGen_CodeEntity"); + + migrationBuilder.DropTable( + name: "CodeGen_CodeModule"); + + migrationBuilder.DropTable( + name: "CodeGen_CodeProject"); + } + } +} diff --git a/src/OSharp.CodeGenerator/Migrations/DefaultDbContextModelSnapshot.cs b/src/OSharp.CodeGenerator/Migrations/DefaultDbContextModelSnapshot.cs new file mode 100644 index 0000000..191d803 --- /dev/null +++ b/src/OSharp.CodeGenerator/Migrations/DefaultDbContextModelSnapshot.cs @@ -0,0 +1,284 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using OSharp.Entity; + +namespace OSharp.CodeGenerator.Migrations +{ + [DbContext(typeof(DefaultDbContext))] + partial class DefaultDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.2"); + + modelBuilder.Entity("OSharp.Authorization.EntityInfos.EntityInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AuditEnabled") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PropertyJson") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("TypeName") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("TypeName") + .IsUnique() + .HasName("ClassFullNameIndex"); + + b.ToTable("Auth_EntityInfo"); + }); + + modelBuilder.Entity("OSharp.Authorization.Functions.Function", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AccessType") + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasColumnType("TEXT"); + + b.Property("Area") + .HasColumnType("TEXT"); + + b.Property("AuditEntityEnabled") + .HasColumnType("INTEGER"); + + b.Property("AuditOperationEnabled") + .HasColumnType("INTEGER"); + + b.Property("CacheExpirationSeconds") + .HasColumnType("INTEGER"); + + b.Property("Controller") + .HasColumnType("TEXT"); + + b.Property("IsAccessTypeChanged") + .HasColumnType("INTEGER"); + + b.Property("IsAjax") + .HasColumnType("INTEGER"); + + b.Property("IsCacheSliding") + .HasColumnType("INTEGER"); + + b.Property("IsController") + .HasColumnType("INTEGER"); + + b.Property("IsLocked") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Area", "Controller", "Action") + .IsUnique() + .HasName("AreaControllerActionIndex"); + + b.ToTable("Auth_Function"); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Display") + .HasColumnType("TEXT"); + + b.Property("IsDataAuth") + .HasColumnType("INTEGER"); + + b.Property("ModuleId") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("PrimaryKeyTypeFullName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ModuleId"); + + b.ToTable("CodeGen_CodeEntity"); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeModule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Display") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("ProjectId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ProjectId"); + + b.ToTable("CodeGen_CodeModule"); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeProject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Company") + .HasColumnType("TEXT"); + + b.Property("Copyright") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("NamespacePrefix") + .HasColumnType("TEXT"); + + b.Property("SiteUrl") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("CodeGen_CodeProject"); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeProperty", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Display") + .HasColumnType("TEXT"); + + b.Property("EntityId") + .HasColumnType("TEXT"); + + b.Property("IsForeignKey") + .HasColumnType("INTEGER"); + + b.Property("IsInputDto") + .HasColumnType("INTEGER"); + + b.Property("IsNullable") + .HasColumnType("INTEGER"); + + b.Property("IsOutputDto") + .HasColumnType("INTEGER"); + + b.Property("IsRequired") + .HasColumnType("INTEGER"); + + b.Property("IsVirtual") + .HasColumnType("INTEGER"); + + b.Property("MaxLength") + .HasColumnType("INTEGER"); + + b.Property("MinLength") + .HasColumnType("INTEGER"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("TypeName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("EntityId"); + + b.ToTable("CodeGen_CodeProperty"); + }); + + modelBuilder.Entity("OSharp.Core.Systems.KeyValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("IsLocked") + .HasColumnType("INTEGER"); + + b.Property("Key") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ValueJson") + .HasColumnType("TEXT"); + + b.Property("ValueType") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Systems_KeyValue"); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeEntity", b => + { + b.HasOne("OSharp.CodeGeneration.Entities.CodeModule", "Module") + .WithMany("Entities") + .HasForeignKey("ModuleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeModule", b => + { + b.HasOne("OSharp.CodeGeneration.Entities.CodeProject", "Project") + .WithMany("Modules") + .HasForeignKey("ProjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("OSharp.CodeGeneration.Entities.CodeProperty", b => + { + b.HasOne("OSharp.CodeGeneration.Entities.CodeEntity", "Entity") + .WithMany("Properties") + .HasForeignKey("EntityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj b/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj index e0b80fd..b99f378 100644 --- a/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj +++ b/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj @@ -4,17 +4,44 @@ WinExe netcoreapp3.1 true + OsharpCodeGenerator - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - - + + + + + + + + + + + + + + + + + + + + + + Always + \ No newline at end of file diff --git a/src/OSharp.CodeGenerator/Resources/osharp128-2.ico b/src/OSharp.CodeGenerator/Resources/osharp128-2.ico new file mode 100644 index 0000000000000000000000000000000000000000..bc7aee97423b6d7a6e1b164a5df1d87bfa712db8 GIT binary patch literal 6784 zcmV-`8h_;g009620Dyo10096X0BRZl02TlM0EtjeM-2)Z3IG5A4M|8uQUCw|fB*mh zfCvTv006^2Vaosj00DDSM?wMF$t-^W000SaNLh0L01m_e01m_fl`9S#000^fNkl zJ>Pr2?>pyw=NyBfOS+^>y5y`8ah$;@<{5ed7Xr6Q#io13e8bDYSkYqqr)V}*;r9h` zuo&N#O1hP>=L&?ErSVz!%N4nINyS;;vd-v#j(x#JS-jt^OIit(-2=D+xK}g_uLBG4 z`)1%M6xjf{05{-kh5!&$0sXtb*>i3M4WdOj2~z9=mH-7(N!FusW$yKId2UbMZSWr@ zP;56~xKv<#4!wI0e&30o^-z*cQ8raz2#5eAg@^)SrF=>XJ8%NldbgBNb(h6bp={`1b}h{1HF~Jc?3Mspw=uzuyZYSb?Lk4m&{3 za(QCT{njbH&bL+dGx2W2j1;-N`#CVPx51?6L+PKOkq;}qE~xZIo=Q&)Gb4lp^`>N~ zm5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svv-zaofiewf>NEV?~ zG_#vY)7zj5XpBJj>)B?GV0-uNH9vw+zlS(#?!v#n$Mz9eD=uLdL-DF3I*AWhjJA3R z1Q@_ucPSH*P8L~&L1KaM0$z~L8tUgXQoX<|)I;f0(CcqOukXQIXDJuCEJwiTpf_G} z6v$8`(nAY5Km;Q&1U~vT#Tqz89UV}eMg-9j z;1Y!yQ2t1{qG#tPbLdHE+A?1J9yGvA^n!nh999%L0ai~q1$X#?RBU_+fpX{N@MVI) z8eAae2~VP776OMwJse8WIfx(#mYLPF7%fs+&P}%Y1NpAx=}F-G=(6(fVGWimL^wMv zf|)8_kkR9}ibckWQc2eBuzuOR+gq2SoJ=wppu1X^vRy8*7=gbclScr`KMuujfzl_) z<+FEyO7<&6QxUzDL<42;$_u}1l zXPuz2jUd4Y#YMaa?1P&S6*obxL#UH2L_~~jlXr_WIm2wI6AOiPh~^8V((E5N77jZ5 zCUEpDY{6-q;TGTzKn<{6Ap~7_@QATI#ehPLkfOk78=(ImR-O$ipZ7K?+#(!AFaHQA zLQj8CuE@Q-Vf76r-tEvOiqN?QU?50vD|+WI;D;^rjC^1fl(zwY`$lme>M$GXr6S`t zJdZKDX$f75l?shdA&9$6F3-8tI;|JK4BRehU%Cj;C0)`bU6PFa8>X9kFQAL1g8%>k M07*qoM6N<$f>Ed4i2wiq literal 0 HcmV?d00001 diff --git a/src/OSharp.CodeGenerator/Resources/osharp128.ico b/src/OSharp.CodeGenerator/Resources/osharp128.ico new file mode 100644 index 0000000000000000000000000000000000000000..bfa41dd6889597e814ac0ac84fb77e538d34741a GIT binary patch literal 6506 zcmV-w8I|S$009620Dyo10096X08|+O02TlM0EtjeM-2)Z3IG5A4M|8uQUCw|fB*mh zfCvTv006^2Vaosj00DDSM?wMF$t-^W000SaNLh0L01m_e01m_fl`9S#000>INkl0PP{&n7JU~$*vZ@Sy8GXwd<_`ADu3J8}N>FwQus?7n53~D$x%mA}U=Qoo{Dsx(wpguErqVMbY!IRmsLRJ9rap&m;w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5oY6rxq(C8ZQ5bB5m=2fkSSjbLcGFbz8CSom$-Q> z4(%iO!q`kHuZ%we^C7GAKmb?gHo7%&nkq=43{l0zgV>6Wh z4HUl=O0Uvui;qps?pvH)3i)Itk?{9}S9~rUr6)LTbvCzLQ}^Iqhmp=H2pg+}U%KCu6}WsEh|D19P}>xr9LoT6drrflZdewp!S35hN4n^KI6%TdemtHY+^B zR-%>v1&E`ipQ}$R-gn)ivA*mj%_moqwR}4OBsdza^AbS|K;~Al7oohx_}^-)`>;n? zStH`=yLcXBbRVt#CqzvB9h|t6_1eM_$@)@x5xDu3J>?0IPx+Kj`P7m0|FXaAK|uGP QRR91007*qoM6N<$f>*Rg5C8xG literal 0 HcmV?d00001 diff --git a/src/OSharp.CodeGenerator/Resources/osharp128.png b/src/OSharp.CodeGenerator/Resources/osharp128.png new file mode 100644 index 0000000000000000000000000000000000000000..d7f068d9091a863e4c275aba659e23bc0ac18db7 GIT binary patch literal 6484 zcmV-a8LQ@rP)Rm{Y_vM6uA!A0DKSp*aDk@EjFP4Z))+}_ZHUi z2>TAC_yAY{L`Av(V!f{TP`$Rehin=AtP&Jk0E`h)^#-)=r||px__+p3N?FP#1#Shl z13z^kb^zO~{D~9|z_+j_AMzM`23F=ay}Ixh$@*R;vSqYeB`BDQn6H7{$6X7%yOmSIjNy|$2J+i@~%1yZQX$0DXahi>8~QCYD6`bA^&R-tu*;`ae=0OmvSE4bO8d$*-` z3_Cys>L$KIH})z<7x!ayF)mL8#Zdepn93WW^aa35V50{V)}2;i3oP6k;1v<~-2*>i zv}_%?o#_ue7XpVt>E&qkpWvr#VK-q%3&<{ui3s}^-NF+XEu5;? z73coY5sL2%oDTdK6yGRK(P2f0aNh@BK;JtHe^2L8-&7IzS3%%Y@ytW`-(&dsCzSII z;2S^|F*d_L`YXDG8}#bJy;@=wDO!3JJnZw5Gs*@4YA5QjC-7?^guLD` z2<3KN&?ShN`Y=d4J~^vbQFrOA%Tf#FN4PnC>u#&pl+{qy6QbOAZ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Bj({w_H>A;9ZB2&M62RtAt;`zgdLx->TOX9+;Zd=jY|%b!D?O@7 zSCX}SI{+j&8m;pZK?^|UR + + + + + + \ No newline at end of file diff --git a/src/OSharp.CodeGenerator/Views/MainView.xaml b/src/OSharp.CodeGenerator/Views/MainView.xaml index 7cdbade..1a2a583 100644 --- a/src/OSharp.CodeGenerator/Views/MainView.xaml +++ b/src/OSharp.CodeGenerator/Views/MainView.xaml @@ -8,12 +8,17 @@ xmlns:views="clr-namespace:OSharp.CodeGenerator.Views" mc:Ignorable="d" d:DataContext="{d:DesignInstance views:MainViewModel}" - WindowStartupLocation="Manual" + WindowStartupLocation="Manual" Icon="../Resources/osharp128-2.ico" Title="{Binding DisplayName}" Height="800" Width="1280"> - - + + + + diff --git a/src/OSharp.CodeGenerator/Data/SingletonAttribute.cs b/src/OSharp.CodeGenerator/Views/ProjectView.xaml.cs similarity index 55% rename from src/OSharp.CodeGenerator/Data/SingletonAttribute.cs rename to src/OSharp.CodeGenerator/Views/ProjectView.xaml.cs index 49ed613..0c64a25 100644 --- a/src/OSharp.CodeGenerator/Data/SingletonAttribute.cs +++ b/src/OSharp.CodeGenerator/Views/ProjectView.xaml.cs @@ -1,21 +1,25 @@ // ----------------------------------------------------------------------- -// +// // Copyright (c) 2014-2020 OSharp. All rights reserved. // // http://www.osharp.org // 郭明锋 -// 2020-05-03 14:52 +// 2020-05-05 12:38 // ----------------------------------------------------------------------- -using System; +using OSharp.Wpf.Stylet; namespace OSharp.CodeGenerator.Views { ///

- /// 标注类型的注册到IoC的生命周期为Singleton + /// ProjectView.xaml 的交互逻辑 /// - [AttributeUsage(AttributeTargets.Class)] - public class SingletonAttribute : Attribute - { } + public partial class ProjectView + { + public ProjectView() + { + InitializeComponent(); + } + } } diff --git a/src/OSharp.CodeGenerator/Views/Project/ProjectViewModel.cs b/src/OSharp.CodeGenerator/Views/ProjectViewModel.cs similarity index 47% rename from src/OSharp.CodeGenerator/Views/Project/ProjectViewModel.cs rename to src/OSharp.CodeGenerator/Views/ProjectViewModel.cs index e36d2bd..0d0434e 100644 --- a/src/OSharp.CodeGenerator/Views/Project/ProjectViewModel.cs +++ b/src/OSharp.CodeGenerator/Views/ProjectViewModel.cs @@ -7,31 +7,74 @@ // 2020-05-04 10:54 // ----------------------------------------------------------------------- +using System; using System.ComponentModel.DataAnnotations; -using System.Data; using FluentValidation; +using HandyControl.Controls; +using HandyControl.Data; + +using OSharp.Extensions; +using OSharp.Wpf.Stylet; + using Stylet; -namespace OSharp.CodeGenerator.Views.Project +namespace OSharp.CodeGenerator.Views { - [Singleton] public class ProjectViewModel : Screen { - public string Name { get; set; } + public ProjectViewModel(IModelValidator validator) : base(validator) + { + Validate(); + } - public string NamespacePrefix { get; set; } + public string Name { get; set; } = "项目名称"; + + public string NamespacePrefix { get; set; } = "Liuliu.Demo"; public string Company { get; set; } - public string SiteUrl { get; set; } + public string SiteUrl { get; set; } = "https://www.osharp.org"; public string Creator { get; set; } public string Copyright { get; set; } + public Func> CheckName { get; set; } = name => + { + if (string.IsNullOrEmpty(name)) + { + return OperationResult.Failed("项目名称不能为空"); + } + + if (!name.IsMatch("^[a-zA-Z_\u2E80-\u9FFF][0-9a-zA-Z_\u2E80-\u9FFF]*$")) + { + return OperationResult.Failed("项目名称不符合标识符命名规则"); + } + + return OperationResult.Success(); + }; + + public bool CanSaveProject => !HasErrors; + + public void SaveProject() + { + if (!Validate()) + { + Growl.Warning("数据验证失败,请检查!"); + return; + } + IoC.Get().Message = "保存项目: " + Name; + } + + public bool CanCloseDrawer => true; + public void CloseDrawer() + { + MainViewModel main = IoC.Get(); + main.IsProjectOpen = false; + } } diff --git a/src/OSharp.CodeGenerator/Views/Statusbar/StatusBarViewModel.cs b/src/OSharp.CodeGenerator/Views/StatusBarViewModel.cs similarity index 96% rename from src/OSharp.CodeGenerator/Views/Statusbar/StatusBarViewModel.cs rename to src/OSharp.CodeGenerator/Views/StatusBarViewModel.cs index 5ce8203..cc08dd1 100644 --- a/src/OSharp.CodeGenerator/Views/Statusbar/StatusBarViewModel.cs +++ b/src/OSharp.CodeGenerator/Views/StatusBarViewModel.cs @@ -7,6 +7,8 @@ // 2020-05-04 11:32 // ----------------------------------------------------------------------- +using OSharp.Wpf.Stylet; + using Stylet; diff --git a/src/OSharp.CodeGenerator/Views/Statusbar/StatusbarView.xaml b/src/OSharp.CodeGenerator/Views/StatusbarView.xaml similarity index 79% rename from src/OSharp.CodeGenerator/Views/Statusbar/StatusbarView.xaml rename to src/OSharp.CodeGenerator/Views/StatusbarView.xaml index ec30c58..7f8b173 100644 --- a/src/OSharp.CodeGenerator/Views/Statusbar/StatusbarView.xaml +++ b/src/OSharp.CodeGenerator/Views/StatusbarView.xaml @@ -7,7 +7,7 @@ xmlns:local="clr-namespace:OSharp.CodeGenerator.Views" mc:Ignorable="d" d:DesignHeight="30" d:DesignWidth="800" d:DataContext="{d:DesignInstance local:StatusBarViewModel}"> - - + + diff --git a/src/OSharp.CodeGenerator/Views/Statusbar/StatusbarView.xaml.cs b/src/OSharp.CodeGenerator/Views/StatusbarView.xaml.cs similarity index 100% rename from src/OSharp.CodeGenerator/Views/Statusbar/StatusbarView.xaml.cs rename to src/OSharp.CodeGenerator/Views/StatusbarView.xaml.cs diff --git a/src/OSharp.CodeGenerator/Views/ViewModelLocator.cs b/src/OSharp.CodeGenerator/Views/ViewModelLocator.cs new file mode 100644 index 0000000..c676997 --- /dev/null +++ b/src/OSharp.CodeGenerator/Views/ViewModelLocator.cs @@ -0,0 +1,19 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-05 23:51 +// ----------------------------------------------------------------------- + +using OSharp.Wpf.Stylet; + + +namespace OSharp.CodeGenerator.Views +{ + public class ViewModelLocator + { + public MainViewModel Main => IoC.Get(); + } +} diff --git a/src/OSharp.CodeGenerator/Views/ViewModelPack.cs b/src/OSharp.CodeGenerator/Views/ViewModelPack.cs new file mode 100644 index 0000000..274c688 --- /dev/null +++ b/src/OSharp.CodeGenerator/Views/ViewModelPack.cs @@ -0,0 +1,35 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-05 15:38 +// ----------------------------------------------------------------------- + +using System.Reflection; + +using Microsoft.Extensions.DependencyInjection; + +using OSharp.Core.Packs; +using OSharp.Wpf.Stylet; + + +namespace OSharp.CodeGenerator.Views +{ + public class ViewModelPack : OsharpPack + { + /// 将模块服务添加到依赖注入服务容器中 + /// 依赖注入服务容器 + /// + public override IServiceCollection AddServices(IServiceCollection services) + { + Assembly assembly = Assembly.GetExecutingAssembly(); + services.AddValidators(assembly); + services.AddViewModels(assembly); + services.AddViews(assembly); + + return services; + } + } +} diff --git a/src/OSharp.CodeGenerator/Views/ViewModelsModule.cs b/src/OSharp.CodeGenerator/Views/ViewModelsModule.cs deleted file mode 100644 index 64244d1..0000000 --- a/src/OSharp.CodeGenerator/Views/ViewModelsModule.cs +++ /dev/null @@ -1,53 +0,0 @@ -// ----------------------------------------------------------------------- -// -// Copyright (c) 2014-2020 OSharp. All rights reserved. -// -// http://www.osharp.org -// 郭明锋 -// 2020-05-03 15:04 -// ----------------------------------------------------------------------- - -using System; -using System.Linq; -using System.Reflection; - -using FluentValidation; - -using OSharp.Reflection; -using OSharp.Wpf.FluentValidation; - -using Stylet; - -using StyletIoC; - - -namespace OSharp.CodeGenerator.Views -{ - public class ViewModelsModule : StyletIoCModule - { - /// - /// Override, and use 'Bind' to add bindings to the module - /// - protected override void Load() - { - // Validator - Bind(typeof(IValidator<>)).ToAllImplementations(true); - Bind(typeof(IModelValidator<>)).To(typeof(FluentModelValidator<>)); - - // ViewModels - Type baseType = typeof(Screen); - Type[] types = Assembly.GetExecutingAssembly().GetTypes().Where(m => !m.IsAbstract && m.IsBaseOn(baseType)).ToArray(); - Type[] singletonTypes = types.Where(m => m.HasAttribute()).ToArray(); - - foreach (Type type in singletonTypes) - { - Bind(type).ToSelf().InSingletonScope(); - } - - foreach (Type type in types.Except(singletonTypes)) - { - Bind(type).ToSelf(); - } - } - } -} diff --git a/src/OSharp.CodeGenerator/log4net.config b/src/OSharp.CodeGenerator/log4net.config new file mode 100644 index 0000000..b98cb82 --- /dev/null +++ b/src/OSharp.CodeGenerator/log4net.config @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- Gitee From a42eddea68c0949af09277262fae00a6f9a37ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E6=98=8E=E9=94=8B?= Date: Mon, 1 Jun 2020 18:32:37 +0800 Subject: [PATCH 3/5] =?UTF-8?q?1.=20=E5=87=86=E5=A4=87=E5=A5=BD=E6=90=9E?= =?UTF-8?q?=E5=BC=B9=E7=AA=97UI=E4=BA=86=202.=20=E4=B8=8B=E4=B8=80?= =?UTF-8?q?=E6=AD=A5=E5=87=86=E5=A4=87=E7=BB=93=E5=90=88OSharp.Site?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E5=8A=9F=E8=83=BD=E6=95=B4=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Data/Entities/CodeModule.cs | 2 +- .../Data/Entities/CodeProject.cs | 8 +- .../OSharp.CodeGeneration.csproj | 1 + src/OSharp.CodeGenerator/App.xaml | 8 +- src/OSharp.CodeGenerator/App.xaml.cs | 3 - src/OSharp.CodeGenerator/Bootstrapper.cs | 2 + .../OSharp.CodeGenerator.csproj | 6 +- .../Views/EntityViewModel.cs | 80 ++++++++++++++ .../Views/MainMenuView.xaml | 93 ++++++++++------ .../Views/MainMenuView.xaml.cs | 46 ++++++-- .../Views/MainMenuViewModel.cs | 2 + src/OSharp.CodeGenerator/Views/MainView.xaml | 66 +++++++----- .../Views/MainView.xaml.cs | 2 - .../Views/MainViewModel.cs | 17 +++ .../Views/ModuleViewModel.cs | 59 ++++++++++ .../Views/ProjectView.xaml | 102 +++++++++--------- .../Views/ProjectViewModel.cs | 70 +++++++----- .../Views/PropertyViewModel.cs | 86 +++++++++++++++ 18 files changed, 497 insertions(+), 156 deletions(-) create mode 100644 src/OSharp.CodeGenerator/Views/EntityViewModel.cs create mode 100644 src/OSharp.CodeGenerator/Views/ModuleViewModel.cs create mode 100644 src/OSharp.CodeGenerator/Views/PropertyViewModel.cs diff --git a/src/OSharp.CodeGeneration/Data/Entities/CodeModule.cs b/src/OSharp.CodeGeneration/Data/Entities/CodeModule.cs index 55727d0..99f25c4 100644 --- a/src/OSharp.CodeGeneration/Data/Entities/CodeModule.cs +++ b/src/OSharp.CodeGeneration/Data/Entities/CodeModule.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) 2014-2020 OSharp. All rights reserved. // diff --git a/src/OSharp.CodeGeneration/Data/Entities/CodeProject.cs b/src/OSharp.CodeGeneration/Data/Entities/CodeProject.cs index 0da9b8d..2f4da41 100644 --- a/src/OSharp.CodeGeneration/Data/Entities/CodeProject.cs +++ b/src/OSharp.CodeGeneration/Data/Entities/CodeProject.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) 2014-2020 OSharp. All rights reserved. // @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using OSharp.Data; using OSharp.Entity; @@ -23,6 +24,11 @@ namespace OSharp.CodeGeneration.Entities [TableNamePrefix("CodeGen")] public class CodeProject : EntityBase { + public CodeProject() + { + Id = SequentialGuid.Create(DatabaseType.Sqlite); + } + /// /// 获取或设置 项目名称 /// diff --git a/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj b/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj index 5d364c7..b59e982 100644 --- a/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj +++ b/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj @@ -5,6 +5,7 @@ + diff --git a/src/OSharp.CodeGenerator/App.xaml b/src/OSharp.CodeGenerator/App.xaml index 5f5d153..87848ce 100644 --- a/src/OSharp.CodeGenerator/App.xaml +++ b/src/OSharp.CodeGenerator/App.xaml @@ -8,8 +8,12 @@ - - + + + + + diff --git a/src/OSharp.CodeGenerator/App.xaml.cs b/src/OSharp.CodeGenerator/App.xaml.cs index 9f1400f..5ef7c24 100644 --- a/src/OSharp.CodeGenerator/App.xaml.cs +++ b/src/OSharp.CodeGenerator/App.xaml.cs @@ -9,9 +9,6 @@ using Microsoft.Extensions.Logging; using OSharp.Collections; using OSharp.Dependency; -using MessageBox = HandyControl.Controls.MessageBox; - - namespace OSharp.CodeGenerator { /// diff --git a/src/OSharp.CodeGenerator/Bootstrapper.cs b/src/OSharp.CodeGenerator/Bootstrapper.cs index 23896e8..c84c0d5 100644 --- a/src/OSharp.CodeGenerator/Bootstrapper.cs +++ b/src/OSharp.CodeGenerator/Bootstrapper.cs @@ -13,6 +13,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using OSharp.AutoMapper; using OSharp.CodeGenerator.Data; using OSharp.CodeGenerator.Views; using OSharp.Core.Builders; @@ -47,6 +48,7 @@ namespace OSharp.CodeGenerator services.AddOSharp() .AddPack() .AddPack() + .AddPack() .AddPack(); } diff --git a/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj b/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj index b7521bd..2641efd 100644 --- a/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj +++ b/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj @@ -9,12 +9,14 @@ - + - + + all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/OSharp.CodeGenerator/Views/EntityViewModel.cs b/src/OSharp.CodeGenerator/Views/EntityViewModel.cs new file mode 100644 index 0000000..907a225 --- /dev/null +++ b/src/OSharp.CodeGenerator/Views/EntityViewModel.cs @@ -0,0 +1,80 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-07 1:11 +// ----------------------------------------------------------------------- + +using FluentValidation; + +using OSharp.CodeGeneration.Entities; +using OSharp.Mapping; + +using Stylet; + + +namespace OSharp.CodeGenerator.Views +{ + [MapTo(typeof(CodeEntity))] + public class EntityViewModel : Screen + { + /// + /// 初始化一个类型的新实例 + /// + public EntityViewModel(IModelValidator validator) + : base(validator) + { + Validate(); + Properties = new BindableCollection(); + } + + public ModuleViewModel Module { get; set; } + + public IObservableCollection Properties { get; set; } + + public string Name { get; set; } + + public string Display { get; set; } + + public string PrimaryKeyTypeFullName { get; set; } + + public bool Listable { get; set; } + + public bool Addable { get; set; } + + public bool Updatable { get; set; } + + public bool Deletable { get; set; } + + public bool IsDataAuth { get; set; } + + public bool HasCreatedTime { get; set; } + + public bool HasLocked { get; set; } + + public bool HasSoftDeleted { get; set; } + + public bool HasCreationAudited { get; set; } + + public bool HasUpdateAudited { get; set; } + + public CodeEntity ToEntity() + { + CodeEntity entity = this.MapTo(); + return entity; + } + } + + + public class EntityViewModelValidator : AbstractValidator + { + public EntityViewModelValidator() + { + RuleFor(m => m.Name) + .NotEmpty().WithMessage("实体类名称不能为空") + .Matches("^[a-zA-Z_\u2E80-\u9FFF][0-9a-zA-Z_\u2E80-\u9FFF]*$").WithMessage("实体名称不符合标识符命名规则,只能是字母、数值、下划线、汉字,并且不能以数值开关"); + } + } +} diff --git a/src/OSharp.CodeGenerator/Views/MainMenuView.xaml b/src/OSharp.CodeGenerator/Views/MainMenuView.xaml index f850ba8..fe3c472 100644 --- a/src/OSharp.CodeGenerator/Views/MainMenuView.xaml +++ b/src/OSharp.CodeGenerator/Views/MainMenuView.xaml @@ -1,4 +1,4 @@ - - - - - + d:DesignHeight="29" d:DesignWidth="400"> - - - - - - - - - - - - - - - - - - - - - + + + + - - - - + diff --git a/src/OSharp.CodeGenerator/Views/MainMenuView.xaml.cs b/src/OSharp.CodeGenerator/Views/MainMenuView.xaml.cs index bf44321..3cbdc86 100644 --- a/src/OSharp.CodeGenerator/Views/MainMenuView.xaml.cs +++ b/src/OSharp.CodeGenerator/Views/MainMenuView.xaml.cs @@ -1,15 +1,19 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-06 2:03 +// ----------------------------------------------------------------------- + using System; -using System.Collections.Generic; -using System.Text; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; + +using MahApps.Metro.Controls; + namespace OSharp.CodeGenerator.Views { @@ -22,5 +26,31 @@ namespace OSharp.CodeGenerator.Views { InitializeComponent(); } + + private void MenuButton_OnInitialized(object sender, EventArgs e) + { + if (!(sender is Button)) + { + return; + } + + Button btn = (Button)sender; + btn.ContextMenu = null; + } + + private void MenuButton_OnClick(object sender, RoutedEventArgs e) + { + if (!(sender is Button)) + { + return; + } + Button btn = (Button)sender; + string name = btn.Name.Replace("Btn", "Menu"); + if (btn.FindName(name) is ContextMenu menu) + { + menu.PlacementTarget = btn; + menu.IsOpen = true; + } + } } } diff --git a/src/OSharp.CodeGenerator/Views/MainMenuViewModel.cs b/src/OSharp.CodeGenerator/Views/MainMenuViewModel.cs index 8dc1082..6c93d51 100644 --- a/src/OSharp.CodeGenerator/Views/MainMenuViewModel.cs +++ b/src/OSharp.CodeGenerator/Views/MainMenuViewModel.cs @@ -7,6 +7,7 @@ // 2020-05-03 18:09 // ----------------------------------------------------------------------- +using System; using System.Windows; using OSharp.Wpf.Stylet; @@ -32,6 +33,7 @@ namespace OSharp.CodeGenerator.Views public void New() { + //_windowManager.ShowDialog(IoC.Get().Project); MainViewModel main = IoC.Get(); main.IsProjectOpen = true; } diff --git a/src/OSharp.CodeGenerator/Views/MainView.xaml b/src/OSharp.CodeGenerator/Views/MainView.xaml index 9a332d4..fd537b8 100644 --- a/src/OSharp.CodeGenerator/Views/MainView.xaml +++ b/src/OSharp.CodeGenerator/Views/MainView.xaml @@ -1,42 +1,52 @@ - - - - - - - - - - - - - - - - - - - - + Title="{Binding DisplayName}" Height="800" Width="1280" MinHeight="450" MinWidth="720" + ResizeMode="CanResizeWithGrip" GlowBrush="{DynamicResource AccentColorBrush}"> + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + - - - + + + diff --git a/src/OSharp.CodeGenerator/Views/MainView.xaml.cs b/src/OSharp.CodeGenerator/Views/MainView.xaml.cs index b781237..cc75e59 100644 --- a/src/OSharp.CodeGenerator/Views/MainView.xaml.cs +++ b/src/OSharp.CodeGenerator/Views/MainView.xaml.cs @@ -1,8 +1,6 @@ using System.ComponentModel; using System.Windows; -using MessageBox = HandyControl.Controls.MessageBox; - namespace OSharp.CodeGenerator.Views { diff --git a/src/OSharp.CodeGenerator/Views/MainViewModel.cs b/src/OSharp.CodeGenerator/Views/MainViewModel.cs index 9b7e271..688fe01 100644 --- a/src/OSharp.CodeGenerator/Views/MainViewModel.cs +++ b/src/OSharp.CodeGenerator/Views/MainViewModel.cs @@ -7,6 +7,9 @@ // 2020-05-03 14:53 // ----------------------------------------------------------------------- +using Notifications.Wpf.Core; +using Notifications.Wpf.Core.Controls; + using OSharp.Wpf.Stylet; using Stylet; @@ -17,12 +20,15 @@ namespace OSharp.CodeGenerator.Views [Singleton] public class MainViewModel : Screen { + private readonly INotificationManager _notificationManager; + /// /// 初始化一个类型的新实例 /// public MainViewModel() { DisplayName = "OSharp代码生成器"; + _notificationManager = new NotificationManager(NotificationPosition.BottomRight); } public bool IsProjectOpen { get; set; } = false; @@ -32,5 +38,16 @@ namespace OSharp.CodeGenerator.Views public StatusBarViewModel StatusBar { get; set; } = IoC.Get(); public ProjectViewModel Project { get; set; } = IoC.Get(); + + public async void Notify(string message, NotificationType type = NotificationType.Information, string title = "消息提示") + { + NotificationContent content = new NotificationContent() + { + Title = title, + Message = message, + Type = type + }; + await _notificationManager.ShowAsync(content, "MainNotifyArea"); + } } } diff --git a/src/OSharp.CodeGenerator/Views/ModuleViewModel.cs b/src/OSharp.CodeGenerator/Views/ModuleViewModel.cs new file mode 100644 index 0000000..ebd8898 --- /dev/null +++ b/src/OSharp.CodeGenerator/Views/ModuleViewModel.cs @@ -0,0 +1,59 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-07 0:17 +// ----------------------------------------------------------------------- + +using FluentValidation; + +using OSharp.CodeGeneration.Entities; +using OSharp.Mapping; + +using Stylet; + + +namespace OSharp.CodeGenerator.Views +{ + [MapTo(typeof(CodeModule))] + public class ModuleViewModel : Screen + { + /// + /// 初始化一个类型的新实例 + /// + public ModuleViewModel(IModelValidator validator) : base(validator) + { + Validate(); + Entities = new BindableCollection(); + } + + public ProjectViewModel Project { get; set; } + + public IObservableCollection Entities { get; set; } + + public string Name { get; set; } + + public string Display { get; set; } + + public string Namespace => $"{(Project == null ? "" : Project.NamespacePrefix + ".")}{Name}"; + + public CodeModule ToModule() + { + CodeModule module = this.MapTo(); + return module; + } + } + + + public class ModuleViewModelValidator : AbstractValidator + { + public ModuleViewModelValidator() + { + RuleFor(m => m.Name) + .NotEmpty().WithMessage("模块名称不能为空") + .Matches("^[a-zA-Z_\u2E80-\u9FFF][0-9a-zA-Z_\u2E80-\u9FFF]*$").WithMessage("模块名称不符合标识符命名规则,只能是字母、数值、下划线、汉字,并且不能以数值开关"); + } + } +} diff --git a/src/OSharp.CodeGenerator/Views/ProjectView.xaml b/src/OSharp.CodeGenerator/Views/ProjectView.xaml index 1ef618f..3d6da74 100644 --- a/src/OSharp.CodeGenerator/Views/ProjectView.xaml +++ b/src/OSharp.CodeGenerator/Views/ProjectView.xaml @@ -4,65 +4,65 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:hc="https://handyorg.github.io/handycontrol" + xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" xmlns:s="https://github.com/canton7/Stylet" xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" xmlns:local="clr-namespace:OSharp.CodeGenerator.Views" mc:Ignorable="d" d:DataContext="{d:DesignInstance local:ProjectViewModel}" - d:DesignHeight="800" d:DesignWidth="500" DataContext="{Binding Main.Project, Source={StaticResource Locator}}"> - + d:DesignHeight="800" d:DesignWidth="500"> + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/OSharp.CodeGenerator/Views/ProjectViewModel.cs b/src/OSharp.CodeGenerator/Views/ProjectViewModel.cs index 0d0434e..b96c27c 100644 --- a/src/OSharp.CodeGenerator/Views/ProjectViewModel.cs +++ b/src/OSharp.CodeGenerator/Views/ProjectViewModel.cs @@ -8,14 +8,18 @@ // ----------------------------------------------------------------------- using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.IO; using FluentValidation; -using HandyControl.Controls; -using HandyControl.Data; +using Notifications.Wpf.Core; +using OSharp.CodeGeneration.Entities; using OSharp.Extensions; +using OSharp.Json; +using OSharp.Mapping; using OSharp.Wpf.Stylet; using Stylet; @@ -23,58 +27,70 @@ using Stylet; namespace OSharp.CodeGenerator.Views { + [MapTo(typeof(CodeProject))] public class ProjectViewModel : Screen { public ProjectViewModel(IModelValidator validator) : base(validator) { Validate(); + Modules = new BindableCollection(); } - public string Name { get; set; } = "项目名称"; + public IObservableCollection Modules { get; set; } + + public string Name { get; set; } = "示例项目"; public string NamespacePrefix { get; set; } = "Liuliu.Demo"; - public string Company { get; set; } + public string Company { get; set; } = "柳柳软件"; public string SiteUrl { get; set; } = "https://www.osharp.org"; - public string Creator { get; set; } - - public string Copyright { get; set; } - - public Func> CheckName { get; set; } = name => - { - if (string.IsNullOrEmpty(name)) - { - return OperationResult.Failed("项目名称不能为空"); - } - - if (!name.IsMatch("^[a-zA-Z_\u2E80-\u9FFF][0-9a-zA-Z_\u2E80-\u9FFF]*$")) - { - return OperationResult.Failed("项目名称不符合标识符命名规则"); - } + public string Creator { get; set; } = "郭明锋"; - return OperationResult.Success(); - }; + public string Copyright { get; set; } = "Copyright OSHARP.ORG @2020"; public bool CanSaveProject => !HasErrors; public void SaveProject() { + MainViewModel main = IoC.Get(); if (!Validate()) { - Growl.Warning("数据验证失败,请检查!"); + main.Notify("项目信息验证失败", NotificationType.Warning); return; } - IoC.Get().Message = "保存项目: " + Name; + + CodeProject project = ToProject(); + string json = project.ToJsonString(); + File.WriteAllText("1.txt", json); + main.Notify($"项目“{Name}[{NamespacePrefix}]”保存成功", NotificationType.Success); + main.IsProjectOpen = false; } - public bool CanCloseDrawer => true; - public void CloseDrawer() + public void CloseProject() { MainViewModel main = IoC.Get(); main.IsProjectOpen = false; } + + /// + /// Called whenever the error state of any properties changes. Calls NotifyOfPropertyChange("HasErrors") by default + /// + /// List of property names which have changed validation state + protected override void OnValidationStateChanged(IEnumerable changedProperties) + { + base.OnValidationStateChanged(changedProperties); + + // Fody 无法编织其他组件,所以我们必须手动提高这个值 + this.NotifyOfPropertyChange(() => CanSaveProject); + } + + public CodeProject ToProject() + { + CodeProject project = this.MapTo(); + return project; + } } @@ -84,9 +100,9 @@ namespace OSharp.CodeGenerator.Views { RuleFor(m => m.Name) .NotEmpty().WithMessage("项目名称不能为空") - .Matches("^[a-zA-Z_\u2E80-\u9FFF][0-9a-zA-Z_\u2E80-\u9FFF]*$").WithMessage("项目名称不符合标识符命名规则,只能是字母、数值、下划线、汉字,并且不能以数值开关"); + .Matches("^[a-zA-Z_\u2E80-\u9FFF][0-9a-zA-Z_\u2E80-\u9FFF]*$").WithMessage("项目名称不符合标识符命名规则,只能是字母、数值、下划线、汉字,并且不能以数值开关"); RuleFor(m => m.NamespacePrefix).NotEmpty().WithMessage("命名空间前缀不能为空"); - RuleFor(m => m.SiteUrl).Must(m => new UrlAttribute().IsValid(m)).WithMessage("网站Url不符合URL格式"); + RuleFor(m => m.SiteUrl).Must(m => m.IsNullOrEmpty() || new UrlAttribute().IsValid(m)).WithMessage("网站Url不符合URL格式"); } } } diff --git a/src/OSharp.CodeGenerator/Views/PropertyViewModel.cs b/src/OSharp.CodeGenerator/Views/PropertyViewModel.cs new file mode 100644 index 0000000..a5ba292 --- /dev/null +++ b/src/OSharp.CodeGenerator/Views/PropertyViewModel.cs @@ -0,0 +1,86 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-05-07 1:27 +// ----------------------------------------------------------------------- + +using FluentValidation; + +using OSharp.CodeGeneration.Entities; +using OSharp.Mapping; + +using Stylet; + + +namespace OSharp.CodeGenerator.Views +{ + [MapTo(typeof(CodeProperty))] + public class PropertyViewModel : Screen + { + /// + /// 初始化一个类型的新实例 + /// + public PropertyViewModel(IModelValidatorvalidator) : base(validator) + { + Validate(); + } + + public EntityViewModel Entity { get; set; } + + public string Name { get; set; } + + public string Display { get; set; } + + public string TypeName { get; set; } + + public bool Readonly { get; set; } + + public bool Updatable { get; set; } + + public bool Sortable { get; set; } + + public bool Filterable { get; set; } + + public bool IsRequired { get; set; } + + public int? MinLength { get; set; } + + public int? MaxLength { get; set; } + + public bool IsNullable { get; set; } + + public bool IsForeignKey { get; set; } + + public bool IsNavigation { get; set; } + + public string RelateEntity { get; set; } + + public string DataAuthFlag { get; set; } + + public bool IsInputDto { get; set; } + + public bool IsOutputDto { get; set; } + + public string DefaultValue { get; set; } + + public CodeProperty ToProperty() + { + CodeProperty property = this.MapTo(); + return property; + } + } + + + public class PropertyViewModelValidator : AbstractValidator + { + public PropertyViewModelValidator() + { + RuleFor(m => m.Name) + .NotEmpty().WithMessage("实体类名称不能为空") + .Matches("^[a-zA-Z_\u2E80-\u9FFF][0-9a-zA-Z_\u2E80-\u9FFF]*$").WithMessage("实体名称不符合标识符命名规则,只能是字母、数值、下划线、汉字,并且不能以数值开关"); + } + } +} -- Gitee From dd2e7a4ca5d90e741ae02fe8d9eb13af78b969d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E6=98=8E=E9=94=8B?= Date: Wed, 26 Aug 2020 11:20:35 +0800 Subject: [PATCH 4/5] =?UTF-8?q?osharp=E5=8D=87=E7=BA=A7=E8=87=B33.1.7-prev?= =?UTF-8?q?iew0826?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OSharp.CodeGeneration.csproj | 6 +- src/OSharp.CodeGenerator/App.xaml | 4 +- src/OSharp.CodeGenerator/Bootstrapper.cs | 42 ++------- .../Data/DesignTimeDefaultDbContextFactory.cs | 42 +++++++++ .../SqliteDefaultDbContextMigrationPack.cs | 4 +- ...SqliteDesignTimeDefaultDbContextFactory.cs | 87 ------------------- ...ner.cs => 20200826024343_Init.Designer.cs} | 4 +- ...4160451_Init.cs => 20200826024343_Init.cs} | 0 .../DefaultDbContextModelSnapshot.cs | 2 +- .../OSharp.CodeGenerator.csproj | 12 +-- src/OSharp.CodeGenerator/Startup.cs | 38 ++++++++ src/OSharp.CodeGenerator/appsettings.json | 4 +- 12 files changed, 105 insertions(+), 140 deletions(-) create mode 100644 src/OSharp.CodeGenerator/Data/DesignTimeDefaultDbContextFactory.cs delete mode 100644 src/OSharp.CodeGenerator/Data/SqliteDesignTimeDefaultDbContextFactory.cs rename src/OSharp.CodeGenerator/Migrations/{20200504160451_Init.Designer.cs => 20200826024343_Init.Designer.cs} (98%) rename src/OSharp.CodeGenerator/Migrations/{20200504160451_Init.cs => 20200826024343_Init.cs} (100%) create mode 100644 src/OSharp.CodeGenerator/Startup.cs diff --git a/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj b/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj index b59e982..12103d3 100644 --- a/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj +++ b/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj @@ -5,11 +5,11 @@ - + - + - + diff --git a/src/OSharp.CodeGenerator/App.xaml b/src/OSharp.CodeGenerator/App.xaml index 87848ce..6779d8b 100644 --- a/src/OSharp.CodeGenerator/App.xaml +++ b/src/OSharp.CodeGenerator/App.xaml @@ -1,4 +1,4 @@ - - + diff --git a/src/OSharp.CodeGenerator/Bootstrapper.cs b/src/OSharp.CodeGenerator/Bootstrapper.cs index c84c0d5..d97bbbf 100644 --- a/src/OSharp.CodeGenerator/Bootstrapper.cs +++ b/src/OSharp.CodeGenerator/Bootstrapper.cs @@ -1,63 +1,35 @@ -// ----------------------------------------------------------------------- +// ----------------------------------------------------------------------- // // Copyright (c) 2014-2020 OSharp. All rights reserved. // // http://www.osharp.org // 郭明锋 -// 2020-05-03 14:58 +// 2020-08-26 10:41 // ----------------------------------------------------------------------- -using System; - -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using OSharp.AutoMapper; -using OSharp.CodeGenerator.Data; using OSharp.CodeGenerator.Views; -using OSharp.Core.Builders; -using OSharp.Log4Net; using OSharp.Wpf.Data; -using OSharp.Wpf.FluentValidation; using OSharp.Wpf.Stylet; -using Stylet; - namespace OSharp.CodeGenerator { public class Bootstrapper : ServiceProviderBootstrapper { + private readonly Startup _startup = new Startup(); + protected override void ConfigureIoC(IServiceCollection services) { - IConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); - configurationBuilder.AddJsonFile("appsettings.json"); - IConfiguration configuration = configurationBuilder.Build(); - services.AddSingleton(configuration); - - services.AddLogging(opts => - { -#if DEBUG - opts.SetMinimumLevel(LogLevel.Debug); -#else - opts.SetMinimumLevel(LogLevel.Information); -#endif - }); - - services.AddOSharp() - .AddPack() - .AddPack() - .AddPack() - .AddPack(); + _startup.ConfigureServices(services); } /// Hook called after the IoC container has been set up protected override void Configure() { - IServiceProvider provider = ServiceProvider; - provider.UseOsharp(); - IoC.Initialize(provider); + _startup.Configure(ServiceProvider); + IoC.Initialize(ServiceProvider); MainViewModel main = IoC.Get(); Output.StatusBar = msg => main.StatusBar.Message = msg; } diff --git a/src/OSharp.CodeGenerator/Data/DesignTimeDefaultDbContextFactory.cs b/src/OSharp.CodeGenerator/Data/DesignTimeDefaultDbContextFactory.cs new file mode 100644 index 0000000..9d6dbac --- /dev/null +++ b/src/OSharp.CodeGenerator/Data/DesignTimeDefaultDbContextFactory.cs @@ -0,0 +1,42 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-08-25 23:16 +// ----------------------------------------------------------------------- + +using System; + +using Microsoft.Extensions.DependencyInjection; + +using OSharp.Entity; + + +namespace OSharp.CodeGenerator.Data +{ + public class DesignTimeDefaultDbContextFactory : DesignTimeDbContextFactoryBase + { + public DesignTimeDefaultDbContextFactory() + : base(null) + { } + + public DesignTimeDefaultDbContextFactory(IServiceProvider serviceProvider) + : base(serviceProvider) + { } + + /// + /// 创建设计时使用的ServiceProvider,主要用于执行 Add-Migration 功能 + /// + /// + protected override IServiceProvider CreateDesignTimeServiceProvider() + { + IServiceCollection services = new ServiceCollection(); + Startup startup = new Startup(); + startup.ConfigureServices(services); + IServiceProvider provider = services.BuildServiceProvider(); + return provider; + } + } +} diff --git a/src/OSharp.CodeGenerator/Data/SqliteDefaultDbContextMigrationPack.cs b/src/OSharp.CodeGenerator/Data/SqliteDefaultDbContextMigrationPack.cs index 222aecb..9940d7e 100644 --- a/src/OSharp.CodeGenerator/Data/SqliteDefaultDbContextMigrationPack.cs +++ b/src/OSharp.CodeGenerator/Data/SqliteDefaultDbContextMigrationPack.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using OSharp.Core.Packs; @@ -33,7 +33,7 @@ namespace OSharp.CodeGenerator.Data /// protected override DefaultDbContext CreateDbContext(IServiceProvider scopedProvider) { - return new SqliteDesignTimeDefaultDbContextFactory(scopedProvider).CreateDbContext(new string[0]); + return new DesignTimeDefaultDbContextFactory(scopedProvider).CreateDbContext(new string[0]); } } } diff --git a/src/OSharp.CodeGenerator/Data/SqliteDesignTimeDefaultDbContextFactory.cs b/src/OSharp.CodeGenerator/Data/SqliteDesignTimeDefaultDbContextFactory.cs deleted file mode 100644 index fc4f726..0000000 --- a/src/OSharp.CodeGenerator/Data/SqliteDesignTimeDefaultDbContextFactory.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Reflection; - -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; - -using OSharp.Core.Options; -using OSharp.Data; -using OSharp.Entity; -using OSharp.Exceptions; -using OSharp.Extensions; -using OSharp.Reflection; - - -namespace OSharp.CodeGenerator.Data -{ - public class SqliteDesignTimeDefaultDbContextFactory : DesignTimeDbContextFactoryBase - { - private readonly IServiceProvider _serviceProvider; - - public SqliteDesignTimeDefaultDbContextFactory() - { } - - public SqliteDesignTimeDefaultDbContextFactory(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - } - - public override string GetConnectionString() - { - if (_serviceProvider == null) - { - IConfigurationBuilder builder = new ConfigurationBuilder(); - builder.AddJsonFile("appsettings.json"); - IConfiguration configuration = builder.Build(); - Singleton.Instance = configuration; - Console.WriteLine($"configuration == null: {configuration == null}"); - string str = configuration["OSharp:DbContexts:Sqlite:ConnectionString"]; - return str; - } - OsharpOptions options = _serviceProvider.GetOSharpOptions(); - OsharpDbContextOptions contextOptions = options.GetDbContextOptions(typeof(DefaultDbContext)); - if (contextOptions == null) - { - throw new OsharpException($"上下文“{typeof(DefaultDbContext)}”的配置信息不存在"); - } - return contextOptions.ConnectionString; - } - - public override IEntityManager GetEntityManager() - { - if (_serviceProvider != null) - { - return _serviceProvider.GetService(); - } - IEntityConfigurationTypeFinder typeFinder = new EntityConfigurationTypeFinder(new AppDomainAllAssemblyFinder()); - IEntityManager entityManager = new EntityManager(typeFinder); - entityManager.Initialize(); - return entityManager; - } - - public override bool LazyLoadingProxiesEnabled() - { - if (_serviceProvider == null) - { - IConfiguration configuration = Singleton.Instance; - return configuration["OSharp:DbContexts:Sqlite:LazyLoadingProxiesEnabled"].CastTo(false); - } - OsharpOptions options = _serviceProvider.GetOSharpOptions(); - OsharpDbContextOptions contextOptions = options.GetDbContextOptions(typeof(DefaultDbContext)); - if (contextOptions == null) - { - throw new OsharpException($"上下文“{typeof(DefaultDbContext)}”的配置信息不存在"); - } - - return contextOptions.LazyLoadingProxiesEnabled; - } - - public override DbContextOptionsBuilder UseSql(DbContextOptionsBuilder builder, string connString) - { - string entryAssemblyName = Assembly.GetExecutingAssembly().GetName().Name; - Console.WriteLine($"entryAssemblyName: {entryAssemblyName}"); - return builder.UseSqlite(connString, b => b.MigrationsAssembly(entryAssemblyName)); - } - } -} diff --git a/src/OSharp.CodeGenerator/Migrations/20200504160451_Init.Designer.cs b/src/OSharp.CodeGenerator/Migrations/20200826024343_Init.Designer.cs similarity index 98% rename from src/OSharp.CodeGenerator/Migrations/20200504160451_Init.Designer.cs rename to src/OSharp.CodeGenerator/Migrations/20200826024343_Init.Designer.cs index 48f1087..507b666 100644 --- a/src/OSharp.CodeGenerator/Migrations/20200504160451_Init.Designer.cs +++ b/src/OSharp.CodeGenerator/Migrations/20200826024343_Init.Designer.cs @@ -9,14 +9,14 @@ using OSharp.Entity; namespace OSharp.CodeGenerator.Migrations { [DbContext(typeof(DefaultDbContext))] - [Migration("20200504160451_Init")] + [Migration("20200826024343_Init")] partial class Init { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.1.2"); + .HasAnnotation("ProductVersion", "3.1.7"); modelBuilder.Entity("OSharp.Authorization.EntityInfos.EntityInfo", b => { diff --git a/src/OSharp.CodeGenerator/Migrations/20200504160451_Init.cs b/src/OSharp.CodeGenerator/Migrations/20200826024343_Init.cs similarity index 100% rename from src/OSharp.CodeGenerator/Migrations/20200504160451_Init.cs rename to src/OSharp.CodeGenerator/Migrations/20200826024343_Init.cs diff --git a/src/OSharp.CodeGenerator/Migrations/DefaultDbContextModelSnapshot.cs b/src/OSharp.CodeGenerator/Migrations/DefaultDbContextModelSnapshot.cs index 191d803..3bffb77 100644 --- a/src/OSharp.CodeGenerator/Migrations/DefaultDbContextModelSnapshot.cs +++ b/src/OSharp.CodeGenerator/Migrations/DefaultDbContextModelSnapshot.cs @@ -14,7 +14,7 @@ namespace OSharp.CodeGenerator.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "3.1.2"); + .HasAnnotation("ProductVersion", "3.1.7"); modelBuilder.Entity("OSharp.Authorization.EntityInfos.EntityInfo", b => { diff --git a/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj b/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj index 2641efd..9840e2b 100644 --- a/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj +++ b/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj @@ -9,15 +9,15 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/src/OSharp.CodeGenerator/Startup.cs b/src/OSharp.CodeGenerator/Startup.cs new file mode 100644 index 0000000..90955df --- /dev/null +++ b/src/OSharp.CodeGenerator/Startup.cs @@ -0,0 +1,38 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) 2014-2020 OSharp. All rights reserved. +// +// http://www.osharp.org +// 郭明锋 +// 2020-08-26 10:26 +// ----------------------------------------------------------------------- + +using System; + +using Microsoft.Extensions.DependencyInjection; + +using OSharp.AutoMapper; +using OSharp.CodeGenerator.Data; +using OSharp.CodeGenerator.Views; +using OSharp.Log4Net; + + +namespace OSharp.CodeGenerator +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddOSharp() + .AddPack() + .AddPack() + .AddPack() + .AddPack(); + } + + public void Configure(IServiceProvider provider) + { + provider.UseOsharp(); + } + } +} diff --git a/src/OSharp.CodeGenerator/appsettings.json b/src/OSharp.CodeGenerator/appsettings.json index 9b886db..2607c17 100644 --- a/src/OSharp.CodeGenerator/appsettings.json +++ b/src/OSharp.CodeGenerator/appsettings.json @@ -1,9 +1,9 @@ -{ +{ "OSharp": { "DbContexts": { "Sqlite": { "DbContextTypeName": "OSharp.Entity.DefaultDbContext,OSharp.EntityFrameworkCore", - "ConnectionString": "data source=LocalData.db", + "ConnectionString": "data source=osharp-code-generator.db", "DatabaseType": "Sqlite", "LazyLoadingProxiesEnabled": true, "AuditEntityEnabled": true, -- Gitee From dda69e0920a751c4940a4aed078252c83c6465f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E6=98=8E=E9=94=8B?= Date: Sat, 3 Apr 2021 17:41:05 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0osharp=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=88=B05.0.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OSharp.CodeGeneration.csproj | 9 +-- ...SqliteDesignTimeDefaultDbContextFactory.cs | 79 +++---------------- src/OSharp.CodeGenerator/Data/Startup.cs | 16 ++++ src/OSharp.CodeGenerator/FodyWeavers.xsd | 10 +++ .../OSharp.CodeGenerator.csproj | 12 +-- 5 files changed, 45 insertions(+), 81 deletions(-) create mode 100644 src/OSharp.CodeGenerator/Data/Startup.cs diff --git a/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj b/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj index b59e982..8c70e87 100644 --- a/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj +++ b/src/OSharp.CodeGeneration/OSharp.CodeGeneration.csproj @@ -1,15 +1,14 @@ - netcoreapp3.1 + net5.0-windows - - - + + - + diff --git a/src/OSharp.CodeGenerator/Data/SqliteDesignTimeDefaultDbContextFactory.cs b/src/OSharp.CodeGenerator/Data/SqliteDesignTimeDefaultDbContextFactory.cs index fc4f726..e5d169e 100644 --- a/src/OSharp.CodeGenerator/Data/SqliteDesignTimeDefaultDbContextFactory.cs +++ b/src/OSharp.CodeGenerator/Data/SqliteDesignTimeDefaultDbContextFactory.cs @@ -1,87 +1,26 @@ using System; -using System.Reflection; - -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; - -using OSharp.Core.Options; -using OSharp.Data; using OSharp.Entity; -using OSharp.Exceptions; -using OSharp.Extensions; -using OSharp.Reflection; namespace OSharp.CodeGenerator.Data { public class SqliteDesignTimeDefaultDbContextFactory : DesignTimeDbContextFactoryBase { - private readonly IServiceProvider _serviceProvider; - - public SqliteDesignTimeDefaultDbContextFactory() + public SqliteDesignTimeDefaultDbContextFactory() : base(null) { } public SqliteDesignTimeDefaultDbContextFactory(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - } - - public override string GetConnectionString() - { - if (_serviceProvider == null) - { - IConfigurationBuilder builder = new ConfigurationBuilder(); - builder.AddJsonFile("appsettings.json"); - IConfiguration configuration = builder.Build(); - Singleton.Instance = configuration; - Console.WriteLine($"configuration == null: {configuration == null}"); - string str = configuration["OSharp:DbContexts:Sqlite:ConnectionString"]; - return str; - } - OsharpOptions options = _serviceProvider.GetOSharpOptions(); - OsharpDbContextOptions contextOptions = options.GetDbContextOptions(typeof(DefaultDbContext)); - if (contextOptions == null) - { - throw new OsharpException($"上下文“{typeof(DefaultDbContext)}”的配置信息不存在"); - } - return contextOptions.ConnectionString; - } - - public override IEntityManager GetEntityManager() - { - if (_serviceProvider != null) - { - return _serviceProvider.GetService(); - } - IEntityConfigurationTypeFinder typeFinder = new EntityConfigurationTypeFinder(new AppDomainAllAssemblyFinder()); - IEntityManager entityManager = new EntityManager(typeFinder); - entityManager.Initialize(); - return entityManager; - } - - public override bool LazyLoadingProxiesEnabled() - { - if (_serviceProvider == null) - { - IConfiguration configuration = Singleton.Instance; - return configuration["OSharp:DbContexts:Sqlite:LazyLoadingProxiesEnabled"].CastTo(false); - } - OsharpOptions options = _serviceProvider.GetOSharpOptions(); - OsharpDbContextOptions contextOptions = options.GetDbContextOptions(typeof(DefaultDbContext)); - if (contextOptions == null) - { - throw new OsharpException($"上下文“{typeof(DefaultDbContext)}”的配置信息不存在"); - } - - return contextOptions.LazyLoadingProxiesEnabled; - } + : base(serviceProvider) + { } - public override DbContextOptionsBuilder UseSql(DbContextOptionsBuilder builder, string connString) + protected override IServiceProvider CreateDesignTimeServiceProvider() { - string entryAssemblyName = Assembly.GetExecutingAssembly().GetName().Name; - Console.WriteLine($"entryAssemblyName: {entryAssemblyName}"); - return builder.UseSqlite(connString, b => b.MigrationsAssembly(entryAssemblyName)); + IServiceCollection services = new ServiceCollection(); + Startup startup = new Startup(); + startup.ConfigureServices(services); + IServiceProvider provider = services.BuildServiceProvider(); + return provider; } } } diff --git a/src/OSharp.CodeGenerator/Data/Startup.cs b/src/OSharp.CodeGenerator/Data/Startup.cs new file mode 100644 index 0000000..bc0e8f9 --- /dev/null +++ b/src/OSharp.CodeGenerator/Data/Startup.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; + +namespace OSharp.CodeGenerator.Data +{ + class Startup + { + public void ConfigureServices(IServiceCollection services) + { + } + } +} diff --git a/src/OSharp.CodeGenerator/FodyWeavers.xsd b/src/OSharp.CodeGenerator/FodyWeavers.xsd index 221aeb8..69dbe48 100644 --- a/src/OSharp.CodeGenerator/FodyWeavers.xsd +++ b/src/OSharp.CodeGenerator/FodyWeavers.xsd @@ -11,6 +11,16 @@ Used to control if the On_PropertyName_Changed feature is enabled. + + + Used to control if the Dependent properties feature is enabled. + + + + + Used to control if the IsChanged property feature is enabled. + + Used to change the name of the method that fires the notify event. This is a string that accepts multiple values in a comma separated form. diff --git a/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj b/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj index 2641efd..a4d7f41 100644 --- a/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj +++ b/src/OSharp.CodeGenerator/OSharp.CodeGenerator.csproj @@ -2,7 +2,7 @@ WinExe - netcoreapp3.1 + net5.0-windows true OSharp.CodeGenerator Resources\osharp128-2.ico @@ -10,15 +10,15 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + -- Gitee