This commit is contained in:
owenchen committed 2026-05-12 10:32:46 +08:00
commit 5959bae57b
56 files changed
+5152

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.37111.16 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CloudBuilder.CodeGenerator", "CloudBuilder.CodeGenerator\CloudBuilder.CodeGenerator.csproj", "{A905410A-CD69-B6DB-264C-5796F8D57CE7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A905410A-CD69-B6DB-264C-5796F8D57CE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A905410A-CD69-B6DB-264C-5796F8D57CE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A905410A-CD69-B6DB-264C-5796F8D57CE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A905410A-CD69-B6DB-264C-5796F8D57CE7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {467DD073-1E3D-4419-B580-A5A324C45BDE}
EndGlobalSection
EndGlobal
@@ -0,0 +1,69 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.json" />
<None Remove="Config\tool-init-config.xml" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Config\tool-init-config.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.OLE.Interop" Version="17.8.37221" />
<PackageReference Include="Krypton.Docking" Version="80.23.11.321" />
<PackageReference Include="Krypton.Navigator" Version="80.23.11.321" />
<PackageReference Include="Krypton.Ribbon" Version="80.23.11.321" />
<PackageReference Include="Krypton.Toolkit" Version="80.23.11.321" />
<PackageReference Include="Krypton.Workspace" Version="80.23.11.321" />
<PackageReference Include="RazorEngineCore" Version="2023.11.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
</ItemGroup>
<ItemGroup>
<Reference Include="CloudBuilder.Core">
<HintPath>..\Lib\CloudBuilder.Core.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Update="ConfigUserControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Update="MainFunctionView.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="OperationUserControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Update="OutputUserControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Update="TableControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Update="TemplateUserControl.cs">
<SubType>UserControl</SubType>
</Compile>
</ItemGroup>
</Project>
@@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace CloudBuilder.CodeGenerator.Config
{
public class ToolInitConfig
{
private static ToolInitConfig instance = null;
private static string filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config\\tool-init-config.xml");
private static ToolInitConfig Load()
{
if (!System.IO.File.Exists(filename))
{
throw new ValidationException("ToolInitConfig config file not found");
}
StringReader textReader = new StringReader(System.IO.File.ReadAllText(filename, Encoding.UTF8));
XmlSerializer serializer = new XmlSerializer(typeof(ToolInitConfig));
return (ToolInitConfig)serializer.Deserialize(textReader);
}
public static void ClearInstance()
{
instance = null;
}
public static ToolInitConfig GetInstance()
{
if (instance == null)
{
instance = Load();
}
return instance;
}
public string TemplatePath { get; set; }
public string CurrentAssembly { get; set; }
public string Using { get; set; }
public NamespaceObject[] NamespaceObjects { get; set; }
public AssemblyReference[] AssemblyReferences { get; set; }
public string[] ExculdePropertyTypes { get; set; }
public static void Save(ToolInitConfig toolInitConfig)
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(ToolInitConfig));
string xml = null;
using (MemoryStream stream = new MemoryStream())
{
StreamWriter writer = new StreamWriter(stream, Encoding.UTF8);
xmlSerializer.Serialize((TextWriter)writer, toolInitConfig);
stream.Seek(0L, SeekOrigin.Begin);
StreamReader reader = new StreamReader(stream, Encoding.UTF8);
xml = reader.ReadToEnd();
}
StreamWriter sw = new StreamWriter(filename, false);
sw.WriteLine(xml);
sw.Close();
sw.Dispose();
}
}
public class AssemblyReference
{
public string AssemblyFileName { get; set; }
}
public class NamespaceObject
{
public const string OUT_FILE_PATH = "OutFilePath";
public const string ASSEMBLY = "Assembly";
public const string NAMESPACE = "Namespace";
public string TemplateType { get; set; }
public string TemplateFileName { get; set; }
public string OutFilePath { get; set; }
public string Assembly { get; set; }
public string Namespace { get; set; }
public string FileNameSuffix { get; set; }
public string FileNamePrefix { get; set; }
}
}
@@ -0,0 +1,354 @@
<?xml version="1.0" encoding="utf-8"?>
<ToolInitConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<TemplatePath>D:\NET8\Templates</TemplatePath>
<CurrentAssembly>CloudBuilder.Hr</CurrentAssembly>
<Using>@using CloudBuilder.CodeGenerator.Config;
@using CloudBuilder.CodeGenerator.Data;
@using CloudBuilder.CodeGenerator.Entity;
@using CloudBuilder.Core.Application.Builders;
@using CloudBuilder.Core.DatabaseAccessor.Entity;
@using CloudBuilder.Core.DependencyInjection.Form;
@using CloudBuilder.Core.Extensions;
@using CloudBuilder.Core.Utility;
@using Microsoft.Extensions.DependencyInjection;
@using System.Data;
@using System;
@using System.Reflection;</Using>
<NamespaceObjects>
<NamespaceObject>
<TemplateType>Entity</TemplateType>
<TemplateFileName>IEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master\Entity</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>Entity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IEntityKey</TemplateType>
<TemplateFileName>IEntityKey.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master\Entity</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>EntityKey.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IService</TemplateType>
<TemplateFileName>IService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master\Service</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
<FileNamePrefix>I</FileNamePrefix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Permission</TemplateType>
<TemplateFileName>Permission.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master\Policy</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>PermissionPolicy.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>RegistEntity</TemplateType>
<TemplateFileName>RegistEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master\Entity</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>RegistEntity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>SearchCriteria</TemplateType>
<TemplateFileName>SearchCriteria.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master\SearchCriteria</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>SearchCriteria.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Service</TemplateType>
<TemplateFileName>Service.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master.Service</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScript</TemplateType>
<TemplateFileName>TypeScript.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\data\auto</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Controller</TemplateType>
<TemplateFileName>Controller.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Web.Entry\Controllers\Master</OutFilePath>
<Assembly>CloudBuilder.Master.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Master</Namespace>
<FileNameSuffix>Controller.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScriptService</TemplateType>
<TemplateFileName>TypeScriptService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\service\master</OutFilePath>
<Assembly>CloudBuilder.Master.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Master</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Entity</TemplateType>
<TemplateFileName>IEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security\Entity</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>Entity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IEntityKey</TemplateType>
<TemplateFileName>IEntityKey.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security\Entity</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>EntityKey.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IService</TemplateType>
<TemplateFileName>IService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security\Service</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
<FileNamePrefix>I</FileNamePrefix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Permission</TemplateType>
<TemplateFileName>Permission.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security\Policy</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>PermissionPolicy.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>RegistEntity</TemplateType>
<TemplateFileName>RegistEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security\Entity</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>RegistEntity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>SearchCriteria</TemplateType>
<TemplateFileName>SearchCriteria.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security\SearchCriteria</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>SearchCriteria.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Service</TemplateType>
<TemplateFileName>Service.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security.Service</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScript</TemplateType>
<TemplateFileName>TypeScript.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\data\auto</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Controller</TemplateType>
<TemplateFileName>Controller.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Web.Entry\Controllers\Security</OutFilePath>
<Assembly>CloudBuilder.Security.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Security</Namespace>
<FileNameSuffix>Controller.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScriptService</TemplateType>
<TemplateFileName>TypeScriptService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\service\security</OutFilePath>
<Assembly>CloudBuilder.Security.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Security</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Entity</TemplateType>
<TemplateFileName>IEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr\Entity</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>Entity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IEntityKey</TemplateType>
<TemplateFileName>IEntityKey.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr\Entity</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>EntityKey.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IService</TemplateType>
<TemplateFileName>IService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr\Service</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
<FileNamePrefix>I</FileNamePrefix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Permission</TemplateType>
<TemplateFileName>Permission.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr\Policy</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>PermissionPolicy.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>RegistEntity</TemplateType>
<TemplateFileName>RegistEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr\Entity</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>RegistEntity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>SearchCriteria</TemplateType>
<TemplateFileName>SearchCriteria.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr\SearchCriteria</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>SearchCriteria.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Service</TemplateType>
<TemplateFileName>Service.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr.Service</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScript</TemplateType>
<TemplateFileName>TypeScript.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\data\auto</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Controller</TemplateType>
<TemplateFileName>Controller.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Web.Entry\Controllers\Hr</OutFilePath>
<Assembly>CloudBuilder.Hr.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Hr</Namespace>
<FileNameSuffix>Controller.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScriptService</TemplateType>
<TemplateFileName>TypeScriptService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\service\hr</OutFilePath>
<Assembly>CloudBuilder.Hr.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Hr</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Entity</TemplateType>
<TemplateFileName>IEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Novel\Entity</OutFilePath>
<Assembly>CloudBuilder.Novel</Assembly>
<Namespace>CloudBuilder.Novel</Namespace>
<FileNameSuffix>Entity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IEntityKey</TemplateType>
<TemplateFileName>IEntityKey.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Novel\Entity</OutFilePath>
<Assembly>CloudBuilder.Novel</Assembly>
<Namespace>CloudBuilder.Novel</Namespace>
<FileNameSuffix>EntityKey.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IService</TemplateType>
<TemplateFileName>IService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Novel\Service</OutFilePath>
<Assembly>CloudBuilder.Novel</Assembly>
<Namespace>CloudBuilder.Novel</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
<FileNamePrefix>I</FileNamePrefix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Permission</TemplateType>
<TemplateFileName>Permission.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Novel\Policy</OutFilePath>
<Assembly>CloudBuilder.Novel</Assembly>
<Namespace>CloudBuilder.Novel</Namespace>
<FileNameSuffix>PermissionPolicy.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>RegistEntity</TemplateType>
<TemplateFileName>RegistEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Novel\Entity</OutFilePath>
<Assembly>CloudBuilder.Novel</Assembly>
<Namespace>CloudBuilder.Novel</Namespace>
<FileNameSuffix>RegistEntity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>SearchCriteria</TemplateType>
<TemplateFileName>SearchCriteria.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Novel\SearchCriteria</OutFilePath>
<Assembly>CloudBuilder.Novel</Assembly>
<Namespace>CloudBuilder.Novel</Namespace>
<FileNameSuffix>SearchCriteria.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Service</TemplateType>
<TemplateFileName>Service.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Novel.Service</OutFilePath>
<Assembly>CloudBuilder.Novel</Assembly>
<Namespace>CloudBuilder.Novel</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScript</TemplateType>
<TemplateFileName>TypeScript.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\data\auto</OutFilePath>
<Assembly>CloudBuilder.Novel</Assembly>
<Namespace>CloudBuilder.Novel</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Controller</TemplateType>
<TemplateFileName>Controller.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Web.Entry\Controllers\Novel</OutFilePath>
<Assembly>CloudBuilder.Novel.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Novel</Namespace>
<FileNameSuffix>Controller.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScriptService</TemplateType>
<TemplateFileName>TypeScriptService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\service\Novel</OutFilePath>
<Assembly>CloudBuilder.Novel.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Novel</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
</NamespaceObjects>
<AssemblyReferences>
<AssemblyReference>
<AssemblyFileName>D:\NET8\CloudBuilder\CloudBuilder.Security.Service\bin\Debug\net8.0\CloudBuilder.Security.Service.dll</AssemblyFileName>
</AssemblyReference>
<AssemblyReference>
<AssemblyFileName>D:\NET8\CloudBuilder\CloudBuilder.Security\bin\Debug\net8.0\CloudBuilder.Security.dll</AssemblyFileName>
</AssemblyReference>
</AssemblyReferences>
<ExculdePropertyTypes>
<string>Dictionary</string>
</ExculdePropertyTypes>
</ToolInitConfig>
+527
View File
@@ -0,0 +1,527 @@
namespace CloudBuilder.CodeGenerator
{
partial class ConfigUserControl
{
/// <summary>
/// 設計工具所需的變數。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清除任何使用中的資源。
/// </summary>
/// <param name="disposing">如果應該處置受控資源則為 true,否則為 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 元件設計工具產生的程式碼
/// <summary>
/// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
folderBrowserDialog1 = new FolderBrowserDialog();
kryptonLabel1 = new Krypton.Toolkit.KryptonLabel();
kryptonLabel2 = new Krypton.Toolkit.KryptonLabel();
kryptonLabel3 = new Krypton.Toolkit.KryptonLabel();
kryptonLabel4 = new Krypton.Toolkit.KryptonLabel();
kryptonLabel5 = new Krypton.Toolkit.KryptonLabel();
kryptonHeader1 = new Krypton.Toolkit.KryptonHeader();
tableLayoutPanel1 = new TableLayoutPanel();
outFilePathTxt = new Krypton.Toolkit.KryptonTextBox();
outFilePathBut = new Krypton.Toolkit.KryptonButton();
assemblyTxt = new Krypton.Toolkit.KryptonTextBox();
kryptonLabel8 = new Krypton.Toolkit.KryptonLabel();
templatePathTxt = new Krypton.Toolkit.KryptonTextBox();
templatePathBut = new Krypton.Toolkit.KryptonButton();
templateTypeTxt = new Krypton.Toolkit.KryptonTextBox();
kryptonLabel9 = new Krypton.Toolkit.KryptonLabel();
templateFileNameTxt = new Krypton.Toolkit.KryptonTextBox();
kryptonHeader3 = new Krypton.Toolkit.KryptonHeader();
kryptonLabel7 = new Krypton.Toolkit.KryptonLabel();
assemblyComboBox = new Krypton.Toolkit.KryptonComboBox();
templateTypeCombox = new Krypton.Toolkit.KryptonComboBox();
kryptonHeader4 = new Krypton.Toolkit.KryptonHeader();
dbConnTxt = new Krypton.Toolkit.KryptonTextBox();
kryptonHeader2 = new Krypton.Toolkit.KryptonHeader();
kryptonHeader6 = new Krypton.Toolkit.KryptonHeader();
kryptonLabel6 = new Krypton.Toolkit.KryptonLabel();
usingTxt = new Krypton.Toolkit.KryptonRichTextBox();
kryptonLabel10 = new Krypton.Toolkit.KryptonLabel();
fileNameSuffixTxt = new Krypton.Toolkit.KryptonTextBox();
tableLayoutPanel2 = new TableLayoutPanel();
saveConfigBut = new Krypton.Toolkit.KryptonButton();
deleteConfigBut = new Krypton.Toolkit.KryptonButton();
namespaceTxt = new Krypton.Toolkit.KryptonTextBox();
kryptonLabel11 = new Krypton.Toolkit.KryptonLabel();
fileNamePrefixTxt = new Krypton.Toolkit.KryptonTextBox();
tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)assemblyComboBox).BeginInit();
((System.ComponentModel.ISupportInitialize)templateTypeCombox).BeginInit();
tableLayoutPanel2.SuspendLayout();
SuspendLayout();
//
// kryptonLabel1
//
kryptonLabel1.Location = new Point(4, 45);
kryptonLabel1.Margin = new Padding(4, 6, 4, 4);
kryptonLabel1.Name = "kryptonLabel1";
kryptonLabel1.Size = new Size(75, 20);
kryptonLabel1.TabIndex = 0;
kryptonLabel1.Values.Text = "模板路径:";
//
// kryptonLabel2
//
kryptonLabel2.Location = new Point(4, 272);
kryptonLabel2.Margin = new Padding(4);
kryptonLabel2.Name = "kryptonLabel2";
kryptonLabel2.Size = new Size(75, 20);
kryptonLabel2.TabIndex = 1;
kryptonLabel2.Values.Text = "输出路径:";
//
// kryptonLabel3
//
kryptonLabel3.Location = new Point(4, 303);
kryptonLabel3.Margin = new Padding(4);
kryptonLabel3.Name = "kryptonLabel3";
kryptonLabel3.Size = new Size(62, 20);
kryptonLabel3.TabIndex = 2;
kryptonLabel3.Values.Text = "程序集:";
//
// kryptonLabel4
//
kryptonLabel4.Location = new Point(4, 334);
kryptonLabel4.Margin = new Padding(4);
kryptonLabel4.Name = "kryptonLabel4";
kryptonLabel4.Size = new Size(75, 20);
kryptonLabel4.TabIndex = 3;
kryptonLabel4.Values.Text = "命名空间:";
//
// kryptonLabel5
//
kryptonLabel5.Location = new Point(4, 74);
kryptonLabel5.Margin = new Padding(4);
kryptonLabel5.Name = "kryptonLabel5";
kryptonLabel5.Size = new Size(88, 20);
kryptonLabel5.TabIndex = 8;
kryptonLabel5.Values.Text = "程序集集合:";
//
// kryptonHeader1
//
tableLayoutPanel1.SetColumnSpan(kryptonHeader1, 4);
kryptonHeader1.Dock = DockStyle.Fill;
kryptonHeader1.Location = new Point(4, 4);
kryptonHeader1.Margin = new Padding(4);
kryptonHeader1.Name = "kryptonHeader1";
kryptonHeader1.Size = new Size(792, 31);
kryptonHeader1.TabIndex = 12;
kryptonHeader1.Values.Description = "";
kryptonHeader1.Values.Heading = "模块化设置";
kryptonHeader1.Values.Image = null;
//
// tableLayoutPanel1
//
tableLayoutPanel1.AutoSize = true;
tableLayoutPanel1.AutoSizeMode = AutoSizeMode.GrowAndShrink;
tableLayoutPanel1.ColumnCount = 4;
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 20F));
tableLayoutPanel1.Controls.Add(kryptonLabel2, 0, 10);
tableLayoutPanel1.Controls.Add(kryptonLabel3, 0, 11);
tableLayoutPanel1.Controls.Add(kryptonLabel4, 0, 12);
tableLayoutPanel1.Controls.Add(outFilePathTxt, 1, 10);
tableLayoutPanel1.Controls.Add(outFilePathBut, 2, 10);
tableLayoutPanel1.Controls.Add(assemblyTxt, 1, 11);
tableLayoutPanel1.Controls.Add(kryptonHeader1, 0, 0);
tableLayoutPanel1.Controls.Add(kryptonLabel1, 0, 1);
tableLayoutPanel1.Controls.Add(kryptonLabel8, 0, 6);
tableLayoutPanel1.Controls.Add(templatePathTxt, 1, 1);
tableLayoutPanel1.Controls.Add(templatePathBut, 2, 1);
tableLayoutPanel1.Controls.Add(templateTypeTxt, 1, 6);
tableLayoutPanel1.Controls.Add(kryptonLabel9, 0, 7);
tableLayoutPanel1.Controls.Add(templateFileNameTxt, 1, 7);
tableLayoutPanel1.Controls.Add(kryptonHeader3, 0, 5);
tableLayoutPanel1.Controls.Add(kryptonLabel5, 0, 2);
tableLayoutPanel1.Controls.Add(kryptonLabel7, 0, 4);
tableLayoutPanel1.Controls.Add(assemblyComboBox, 1, 2);
tableLayoutPanel1.Controls.Add(templateTypeCombox, 1, 4);
tableLayoutPanel1.Controls.Add(kryptonHeader4, 0, 3);
tableLayoutPanel1.Controls.Add(dbConnTxt, 1, 21);
tableLayoutPanel1.Controls.Add(kryptonHeader2, 0, 19);
tableLayoutPanel1.Controls.Add(kryptonHeader6, 0, 17);
tableLayoutPanel1.Controls.Add(kryptonLabel6, 0, 21);
tableLayoutPanel1.Controls.Add(usingTxt, 0, 18);
tableLayoutPanel1.Controls.Add(kryptonLabel10, 0, 9);
tableLayoutPanel1.Controls.Add(fileNameSuffixTxt, 1, 9);
tableLayoutPanel1.Controls.Add(tableLayoutPanel2, 1, 15);
tableLayoutPanel1.Controls.Add(namespaceTxt, 1, 12);
tableLayoutPanel1.Controls.Add(kryptonLabel11, 0, 8);
tableLayoutPanel1.Controls.Add(fileNamePrefixTxt, 1, 8);
tableLayoutPanel1.Dock = DockStyle.Fill;
tableLayoutPanel1.Location = new Point(0, 0);
tableLayoutPanel1.Margin = new Padding(4);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 22;
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 8F));
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 8F));
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.Size = new Size(800, 600);
tableLayoutPanel1.TabIndex = 1;
//
// outFilePathTxt
//
outFilePathTxt.Location = new Point(100, 272);
outFilePathTxt.Margin = new Padding(4);
outFilePathTxt.Name = "outFilePathTxt";
outFilePathTxt.Size = new Size(599, 23);
outFilePathTxt.TabIndex = 4;
//
// outFilePathBut
//
outFilePathBut.AutoSize = true;
outFilePathBut.Location = new Point(707, 272);
outFilePathBut.Margin = new Padding(4);
outFilePathBut.Name = "outFilePathBut";
outFilePathBut.Size = new Size(89, 22);
outFilePathBut.TabIndex = 5;
outFilePathBut.Values.Text = "选择文件夹(...)";
outFilePathBut.Click += outFilePathBut_Click;
//
// assemblyTxt
//
assemblyTxt.Location = new Point(100, 303);
assemblyTxt.Margin = new Padding(4);
assemblyTxt.Name = "assemblyTxt";
assemblyTxt.Size = new Size(347, 23);
assemblyTxt.TabIndex = 9;
//
// kryptonLabel8
//
kryptonLabel8.Location = new Point(4, 148);
kryptonLabel8.Margin = new Padding(4);
kryptonLabel8.Name = "kryptonLabel8";
kryptonLabel8.Size = new Size(75, 20);
kryptonLabel8.TabIndex = 3;
kryptonLabel8.Values.Text = "模板名称:";
//
// templatePathTxt
//
templatePathTxt.Location = new Point(100, 43);
templatePathTxt.Margin = new Padding(4);
templatePathTxt.Name = "templatePathTxt";
templatePathTxt.Size = new Size(599, 23);
templatePathTxt.TabIndex = 4;
//
// templatePathBut
//
templatePathBut.AutoSize = true;
templatePathBut.Location = new Point(707, 43);
templatePathBut.Margin = new Padding(4);
templatePathBut.Name = "templatePathBut";
templatePathBut.Size = new Size(89, 22);
templatePathBut.TabIndex = 5;
templatePathBut.Values.Text = "选择文件夹(...)";
templatePathBut.Click += templatePathBut_Click;
//
// templateTypeTxt
//
templateTypeTxt.Location = new Point(100, 148);
templateTypeTxt.Margin = new Padding(4);
templateTypeTxt.Name = "templateTypeTxt";
templateTypeTxt.Size = new Size(347, 23);
templateTypeTxt.TabIndex = 4;
//
// kryptonLabel9
//
kryptonLabel9.Location = new Point(4, 179);
kryptonLabel9.Margin = new Padding(4);
kryptonLabel9.Name = "kryptonLabel9";
kryptonLabel9.Size = new Size(62, 20);
kryptonLabel9.TabIndex = 3;
kryptonLabel9.Values.Text = "文件名:";
//
// templateFileNameTxt
//
templateFileNameTxt.Location = new Point(100, 179);
templateFileNameTxt.Margin = new Padding(4);
templateFileNameTxt.Name = "templateFileNameTxt";
templateFileNameTxt.Size = new Size(347, 23);
templateFileNameTxt.TabIndex = 4;
//
// kryptonHeader3
//
tableLayoutPanel1.SetColumnSpan(kryptonHeader3, 3);
kryptonHeader3.Dock = DockStyle.Fill;
kryptonHeader3.Location = new Point(3, 139);
kryptonHeader3.Name = "kryptonHeader3";
kryptonHeader3.Size = new Size(794, 2);
kryptonHeader3.TabIndex = 14;
kryptonHeader3.Values.Description = "";
kryptonHeader3.Values.Heading = "";
kryptonHeader3.Values.Image = null;
//
// kryptonLabel7
//
kryptonLabel7.Location = new Point(4, 111);
kryptonLabel7.Margin = new Padding(4);
kryptonLabel7.Name = "kryptonLabel7";
kryptonLabel7.Size = new Size(75, 20);
kryptonLabel7.TabIndex = 3;
kryptonLabel7.Values.Text = "模板名称:";
//
// assemblyComboBox
//
assemblyComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
assemblyComboBox.DropDownWidth = 362;
assemblyComboBox.IntegralHeight = false;
assemblyComboBox.Location = new Point(100, 74);
assemblyComboBox.Margin = new Padding(4);
assemblyComboBox.Name = "assemblyComboBox";
assemblyComboBox.Size = new Size(347, 21);
assemblyComboBox.TabIndex = 6;
assemblyComboBox.SelectionChangeCommitted += assemblyComboBox_SelectionChangeCommitted;
//
// templateTypeCombox
//
templateTypeCombox.DropDownStyle = ComboBoxStyle.DropDownList;
templateTypeCombox.DropDownWidth = 362;
templateTypeCombox.IntegralHeight = false;
templateTypeCombox.Location = new Point(100, 111);
templateTypeCombox.Margin = new Padding(4);
templateTypeCombox.Name = "templateTypeCombox";
templateTypeCombox.Size = new Size(347, 21);
templateTypeCombox.TabIndex = 6;
templateTypeCombox.SelectionChangeCommitted += templateTypeCombox_SelectionChangeCommitted;
//
// kryptonHeader4
//
tableLayoutPanel1.SetColumnSpan(kryptonHeader4, 3);
kryptonHeader4.Dock = DockStyle.Fill;
kryptonHeader4.Location = new Point(3, 102);
kryptonHeader4.Name = "kryptonHeader4";
kryptonHeader4.Size = new Size(794, 2);
kryptonHeader4.TabIndex = 14;
kryptonHeader4.Values.Description = "";
kryptonHeader4.Values.Heading = "";
kryptonHeader4.Values.Image = null;
//
// dbConnTxt
//
tableLayoutPanel1.SetColumnSpan(dbConnTxt, 2);
dbConnTxt.Location = new Point(100, 573);
dbConnTxt.Margin = new Padding(4);
dbConnTxt.Name = "dbConnTxt";
dbConnTxt.ReadOnly = true;
dbConnTxt.Size = new Size(696, 23);
dbConnTxt.StateCommon.Back.Color1 = Color.Silver;
dbConnTxt.TabIndex = 11;
//
// kryptonHeader2
//
tableLayoutPanel1.SetColumnSpan(kryptonHeader2, 4);
kryptonHeader2.Dock = DockStyle.Fill;
kryptonHeader2.Location = new Point(4, 534);
kryptonHeader2.Margin = new Padding(4);
kryptonHeader2.Name = "kryptonHeader2";
kryptonHeader2.Size = new Size(792, 31);
kryptonHeader2.TabIndex = 13;
kryptonHeader2.Values.Description = "";
kryptonHeader2.Values.Heading = "数据库连接设置";
kryptonHeader2.Values.Image = null;
//
// kryptonHeader6
//
tableLayoutPanel1.SetColumnSpan(kryptonHeader6, 4);
kryptonHeader6.Dock = DockStyle.Fill;
kryptonHeader6.Location = new Point(4, 398);
kryptonHeader6.Margin = new Padding(4);
kryptonHeader6.Name = "kryptonHeader6";
kryptonHeader6.Size = new Size(792, 31);
kryptonHeader6.TabIndex = 13;
kryptonHeader6.Values.Description = "";
kryptonHeader6.Values.Heading = "Using设置";
kryptonHeader6.Values.Image = null;
//
// kryptonLabel6
//
kryptonLabel6.Location = new Point(4, 573);
kryptonLabel6.Margin = new Padding(4);
kryptonLabel6.Name = "kryptonLabel6";
kryptonLabel6.Size = new Size(88, 20);
kryptonLabel6.TabIndex = 10;
kryptonLabel6.Values.Text = "数据库连接:";
//
// usingTxt
//
tableLayoutPanel1.SetColumnSpan(usingTxt, 3);
usingTxt.Dock = DockStyle.Fill;
usingTxt.Location = new Point(3, 436);
usingTxt.Name = "usingTxt";
usingTxt.Size = new Size(794, 91);
usingTxt.TabIndex = 15;
usingTxt.Text = "";
//
// kryptonLabel10
//
kryptonLabel10.Location = new Point(4, 241);
kryptonLabel10.Margin = new Padding(4);
kryptonLabel10.Name = "kryptonLabel10";
kryptonLabel10.Size = new Size(75, 20);
kryptonLabel10.TabIndex = 3;
kryptonLabel10.Values.Text = "文件后缀:";
//
// fileNameSuffixTxt
//
fileNameSuffixTxt.Location = new Point(100, 241);
fileNameSuffixTxt.Margin = new Padding(4);
fileNameSuffixTxt.Name = "fileNameSuffixTxt";
fileNameSuffixTxt.Size = new Size(347, 23);
fileNameSuffixTxt.TabIndex = 4;
//
// tableLayoutPanel2
//
tableLayoutPanel2.AutoSize = true;
tableLayoutPanel2.AutoSizeMode = AutoSizeMode.GrowAndShrink;
tableLayoutPanel2.ColumnCount = 2;
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel2.Controls.Add(saveConfigBut, 0, 0);
tableLayoutPanel2.Controls.Add(deleteConfigBut, 1, 0);
tableLayoutPanel2.Location = new Point(96, 361);
tableLayoutPanel2.Margin = new Padding(0);
tableLayoutPanel2.Name = "tableLayoutPanel2";
tableLayoutPanel2.RowCount = 1;
tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel2.Size = new Size(226, 33);
tableLayoutPanel2.TabIndex = 7;
//
// saveConfigBut
//
saveConfigBut.Location = new Point(4, 4);
saveConfigBut.Margin = new Padding(4);
saveConfigBut.Name = "saveConfigBut";
saveConfigBut.Size = new Size(105, 25);
saveConfigBut.TabIndex = 0;
saveConfigBut.Values.Text = "保存";
saveConfigBut.Click += saveConfigBut_Click;
//
// deleteConfigBut
//
deleteConfigBut.Location = new Point(117, 4);
deleteConfigBut.Margin = new Padding(4);
deleteConfigBut.Name = "deleteConfigBut";
deleteConfigBut.Size = new Size(105, 25);
deleteConfigBut.TabIndex = 1;
deleteConfigBut.Values.Text = "删除";
deleteConfigBut.Click += deleteConfigBut_Click;
//
// namespaceTxt
//
namespaceTxt.Location = new Point(100, 334);
namespaceTxt.Margin = new Padding(4);
namespaceTxt.Name = "namespaceTxt";
namespaceTxt.Size = new Size(347, 23);
namespaceTxt.TabIndex = 4;
//
// kryptonLabel11
//
kryptonLabel11.Location = new Point(4, 210);
kryptonLabel11.Margin = new Padding(4);
kryptonLabel11.Name = "kryptonLabel11";
kryptonLabel11.Size = new Size(75, 20);
kryptonLabel11.TabIndex = 3;
kryptonLabel11.Values.Text = "文件前缀:";
//
// fileNamePrefixTxt
//
fileNamePrefixTxt.Location = new Point(100, 210);
fileNamePrefixTxt.Margin = new Padding(4);
fileNamePrefixTxt.Name = "fileNamePrefixTxt";
fileNamePrefixTxt.Size = new Size(347, 23);
fileNamePrefixTxt.TabIndex = 4;
//
// ConfigUserControl
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(tableLayoutPanel1);
Name = "ConfigUserControl";
Size = new Size(800, 600);
tableLayoutPanel1.ResumeLayout(false);
tableLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)assemblyComboBox).EndInit();
((System.ComponentModel.ISupportInitialize)templateTypeCombox).EndInit();
tableLayoutPanel2.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
#endregion
private FolderBrowserDialog folderBrowserDialog1;
private Krypton.Toolkit.KryptonLabel kryptonLabel1;
private Krypton.Toolkit.KryptonLabel kryptonLabel2;
private Krypton.Toolkit.KryptonLabel kryptonLabel3;
private Krypton.Toolkit.KryptonLabel kryptonLabel4;
private Krypton.Toolkit.KryptonLabel kryptonLabel5;
private TableLayoutPanel tableLayoutPanel1;
private Krypton.Toolkit.KryptonHeader kryptonHeader1;
private Krypton.Toolkit.KryptonLabel kryptonLabel8;
private Krypton.Toolkit.KryptonLabel kryptonLabel9;
private Krypton.Toolkit.KryptonHeader kryptonHeader3;
private Krypton.Toolkit.KryptonTextBox outFilePathTxt;
private Krypton.Toolkit.KryptonTextBox namespaceTxt;
private Krypton.Toolkit.KryptonButton outFilePathBut;
private TableLayoutPanel tableLayoutPanel2;
private Krypton.Toolkit.KryptonButton saveConfigBut;
private Krypton.Toolkit.KryptonButton deleteConfigBut;
private Krypton.Toolkit.KryptonTextBox assemblyTxt;
public Krypton.Toolkit.KryptonComboBox assemblyComboBox;
private Krypton.Toolkit.KryptonTextBox templatePathTxt;
private Krypton.Toolkit.KryptonButton templatePathBut;
private Krypton.Toolkit.KryptonTextBox templateTypeTxt;
private Krypton.Toolkit.KryptonTextBox templateFileNameTxt;
private Krypton.Toolkit.KryptonLabel kryptonLabel7;
private Krypton.Toolkit.KryptonComboBox templateTypeCombox;
private Krypton.Toolkit.KryptonHeader kryptonHeader4;
private Krypton.Toolkit.KryptonHeader kryptonHeader6;
private Krypton.Toolkit.KryptonTextBox dbConnTxt;
private Krypton.Toolkit.KryptonHeader kryptonHeader2;
private Krypton.Toolkit.KryptonLabel kryptonLabel6;
private Krypton.Toolkit.KryptonRichTextBox usingTxt;
private Krypton.Toolkit.KryptonLabel kryptonLabel10;
private Krypton.Toolkit.KryptonTextBox fileNameSuffixTxt;
private Krypton.Toolkit.KryptonLabel kryptonLabel11;
private Krypton.Toolkit.KryptonTextBox fileNamePrefixTxt;
}
}
@@ -0,0 +1,255 @@
using CloudBuilder.CodeGenerator.Config;
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Core.DependencyInjection.Form;
using CloudBuilder.Core.Utility;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Routing.Template;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CloudBuilder.CodeGenerator
{
public partial class ConfigUserControl : UserControl, IUserControl
{
private readonly IApplicationService app;
private readonly OperationUserControl operationUserControl;
public ToolInitConfig toolInitConfig;
public ConfigUserControl(IApplicationService app,
[FromKeyedServices("OperationUserControl")] OperationUserControl operationUserControl)
{
InitializeComponent();
this.app = app;
this.operationUserControl = operationUserControl;
InitUserControl();
}
public void InitUserControl()
{
dbConnTxt.Text = app.CloudBuilder.CloudBuilderOptions.DbContexts[MasterDbContext.MASTER_DB_CONTEXT].ConnectionString;
toolInitConfig = ToolInitConfig.GetInstance();
app.CloudBuilder.Services.AddSingleton(toolInitConfig);
usingTxt.Text = toolInitConfig.Using;
assemblyComboBox.DisplayMember = "Text";
assemblyComboBox.ValueMember = "Value";
List<ComboBoxItem> l = new List<ComboBoxItem>();
foreach (NamespaceObject nso in toolInitConfig.NamespaceObjects)
{
if (l.Select(x => x.Text).Contains(nso.Assembly)) continue;
l.Add(CreateNewComboBoxItem(nso.Assembly, nso.Assembly));
}
DataTable dtbl = DataTableConvertor.ToDataTable<ComboBoxItem>(l);
assemblyComboBox.DataSource = dtbl;
assemblyComboBox.SelectedValue = toolInitConfig.CurrentAssembly;
templateTypeCombox.DisplayMember = "Text";
templateTypeCombox.ValueMember = "Value";
NamespaceObject namespaceObject = toolInitConfig.NamespaceObjects.Where(x => x.Assembly == toolInitConfig.CurrentAssembly).FirstOrDefault();
l = new List<ComboBoxItem>();
foreach (NamespaceObject nso in toolInitConfig.NamespaceObjects.Where(x => x.Assembly == toolInitConfig.CurrentAssembly).ToArray())
{
if (l.Select(x => x.Text).Contains(nso.TemplateType)) continue;
l.Add(CreateNewComboBoxItem(nso.TemplateType, nso.TemplateType));
}
dtbl = DataTableConvertor.ToDataTable<ComboBoxItem>(l);
templateTypeCombox.DataSource = dtbl;
templateTypeCombox.SelectedValue = namespaceObject.TemplateType;
templatePathTxt.Text = toolInitConfig.TemplatePath;
BindData(namespaceObject);
}
public string GetTemplateType()
{
return (string)templateTypeCombox.SelectedValue;
}
public string GetAssembly()
{
return (string)assemblyComboBox.SelectedValue;
}
private void BindData(NamespaceObject namespaceObject)
{
if (namespaceObject == null)
{
templateTypeCombox.SelectedIndex = -1;
fileNamePrefixTxt.Text = fileNameSuffixTxt.Text = templateTypeTxt.Text = outFilePathTxt.Text = templateFileNameTxt.Text = assemblyTxt.Text = namespaceTxt.Text = null;
return;
}
templateTypeCombox.SelectedValue= namespaceObject.TemplateType;
templateTypeTxt.Text = namespaceObject.TemplateType;
outFilePathTxt.Text = namespaceObject.OutFilePath;
templateFileNameTxt.Text = namespaceObject.TemplateFileName;
fileNameSuffixTxt.Text = namespaceObject.FileNameSuffix;
fileNamePrefixTxt.Text = namespaceObject.FileNamePrefix;
assemblyTxt.Text = namespaceObject.Assembly;
namespaceTxt.Text = namespaceObject.Namespace;
}
public class ComboBoxItem
{
public string Text { get; set; }
public string Value { get; set; }
}
private ComboBoxItem CreateNewComboBoxItem(string text, string value)
{
ComboBoxItem item = new ComboBoxItem();
item.Text = text;
item.Value = value;
return item;
}
private void assemblyComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
if (assemblyComboBox.SelectedValue == null) return;
NamespaceObject namespaceObject = toolInitConfig.NamespaceObjects.Where(x => x.Assembly == (string)assemblyComboBox.SelectedValue).FirstOrDefault();
List<ComboBoxItem> l = new List<ComboBoxItem>();
foreach (NamespaceObject nso in toolInitConfig.NamespaceObjects.Where(x => x.Assembly == (string)assemblyComboBox.SelectedValue).ToArray())
{
if (l.Select(x => x.Text).Contains(nso.TemplateType)) continue;
l.Add(CreateNewComboBoxItem(nso.TemplateType, nso.TemplateType));
}
DataTable dtbl = DataTableConvertor.ToDataTable<ComboBoxItem>(l);
templateTypeCombox.DataSource = dtbl;
BindData(namespaceObject);
((MainFunctionView)(this.ParentForm)).SetOperationUserControl(assemblyComboBox.SelectedValue);
}
private void templateTypeCombox_SelectionChangeCommitted(object sender, EventArgs e)
{
if (templateTypeCombox.SelectedValue == null) return;
NamespaceObject namespaceObject = toolInitConfig.NamespaceObjects.Where(x => x.Assembly == (string)assemblyComboBox.SelectedValue && x.TemplateType == (string)templateTypeCombox.SelectedValue).FirstOrDefault();
BindData(namespaceObject);
}
private void saveConfigBut_Click(object sender, EventArgs e)
{
toolInitConfig.TemplatePath = templatePathTxt.Text.Trim();
toolInitConfig.CurrentAssembly = assemblyTxt.Text.Trim();
toolInitConfig.Using = usingTxt.Text.Trim();
NamespaceObject namespaceObject = new NamespaceObject();
namespaceObject.TemplateType = templateTypeTxt.Text.Trim();
namespaceObject.TemplateFileName = templateFileNameTxt.Text.Trim();
namespaceObject.FileNameSuffix = fileNameSuffixTxt.Text.Trim();
namespaceObject.FileNamePrefix = fileNamePrefixTxt.Text.Trim();
namespaceObject.OutFilePath = outFilePathTxt.Text.Trim();
namespaceObject.Assembly = assemblyTxt.Text.Trim();
namespaceObject.Namespace = namespaceTxt.Text.Trim();
NamespaceObject obj = toolInitConfig.NamespaceObjects.Where(x => x.Assembly == assemblyTxt.Text.Trim()).FirstOrDefault();
//如果不存在,插入
if (obj == null)
{
List<NamespaceObject> l = new List<NamespaceObject>();
l.Add(namespaceObject);
if (toolInitConfig.NamespaceObjects != null && toolInitConfig.NamespaceObjects.Length > 0)
l.AddRange(toolInitConfig.NamespaceObjects);
toolInitConfig.NamespaceObjects = l.ToArray();
}
else
{
obj = toolInitConfig.NamespaceObjects.Where(x => x.Assembly == assemblyTxt.Text.Trim() && x.TemplateType == templateTypeTxt.Text.Trim()).FirstOrDefault();
if (obj == null)
{
List<NamespaceObject> ls = new List<NamespaceObject>();
ls.AddRange(toolInitConfig.NamespaceObjects);
ls.Add(namespaceObject);
toolInitConfig.NamespaceObjects = ls.OrderBy(x => x.Assembly).ThenBy(x => x.TemplateType).ToArray();
}
else
{
foreach (NamespaceObject t in toolInitConfig.NamespaceObjects)
{
if (t.Assembly != assemblyTxt.Text.Trim()) continue;
if (t.TemplateType != templateTypeTxt.Text.Trim()) continue;
t.Assembly = namespaceObject.Assembly;
t.Namespace = namespaceObject.Namespace;
t.OutFilePath = namespaceObject.OutFilePath;
t.TemplateType = namespaceObject.TemplateType;
t.TemplateFileName = namespaceObject.TemplateFileName;
t.FileNameSuffix = namespaceObject.FileNameSuffix;
t.FileNamePrefix = namespaceObject.FileNamePrefix;
}
}
}
ToolInitConfig.Save(toolInitConfig);
InitUserControl();
((OperationUserControl)operationUserControl).InitUserControl();
}
private void deleteConfigBut_Click(object sender, EventArgs e)
{
NamespaceObject obj = toolInitConfig.NamespaceObjects.Where(x => x.Assembly == assemblyTxt.Text.Trim() && x.TemplateType == templateTypeTxt.Text.Trim()).FirstOrDefault();
//如果存在,删除,如果只有一个,不能删除
if (obj != null && toolInitConfig.NamespaceObjects != null && toolInitConfig.NamespaceObjects.Length > 1)
{
toolInitConfig.NamespaceObjects = toolInitConfig.NamespaceObjects.Where(x => !(x.Assembly == obj.Assembly && x.TemplateType == obj.TemplateType)).ToArray();
var current = toolInitConfig.NamespaceObjects.Where(x => x.Assembly == assemblyComboBox.Text.Trim()).FirstOrDefault();
if (current == null)
{
toolInitConfig.CurrentAssembly = toolInitConfig.NamespaceObjects.FirstOrDefault().Assembly;
}
ToolInitConfig.Save(toolInitConfig);
InitUserControl();
((OperationUserControl)operationUserControl).InitUserControl();
}
else
{
MessageBox.Show("最后一个选项不能删除", "提示");
}
}
private void templatePathBut_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() != DialogResult.OK) return;
templatePathTxt.Text = folderBrowserDialog1.SelectedPath;
}
private void outFilePathBut_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() != DialogResult.OK) return;
outFilePathTxt.Text = folderBrowserDialog1.SelectedPath;
}
}
}
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="folderBrowserDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
@@ -0,0 +1,86 @@
using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.CodeGenerator.Data
{
public class ClassInfo
{
public string ClassName { get; set; }
public string InterfaceName { get; set; }
public string ImplementTypeName { get; set; }
public string[] Usings { get; set; }
public bool IsDownload { get; set; } = false;
public ClassConstructorInfo[] ClassConstructorInfos;
public ClassMethodInfo[] ClassMethodInfos;
public ClassPropertyInfo[] ClassProperties;
public ClassFieldInfo[] ClassFields;
}
public class ClassFieldInfo
{
public bool IsValueType { get; set; } = false;
public string FieldName { get; set; }
public string FieldTypeName { get; set; }
public string FieldValue { get; set; }
}
public class ClassPropertyInfo
{
public bool IsValueType { get; set; } = false;
public string PropertyName { get; set; }
public string PropertyTypeName { get; set; }
}
public class ClassConstructorInfo
{
public string ConstructorName { get; set; }
public MethodParameter[] Parameters { get; set; }
}
public class ClassMethodInfo
{
public string MethodName { get; set; }
public string HttpName { get; set; } = "[HttpPost]";
public string UnitOfWorkName { get; set; } = "[UnitOfWork]";
public string AuthorizeName { get; set; } = "[AllowAnonymous]";
public string PermissionOperate { get; set; } = "[PermissionOperate(name: {0}, operate: {1})]";
public PermissionOperateAttribute PermissionOperateAttribute { get; set; }
public string MethodReturnName { get; set; }
public bool IsValueType { get; set; } = false;
public MethodParameter[] Parameters { get; set; }
}
public class MethodParameter
{
public bool IsValueType { get; set; } = false;
public string ParameterName { get; set; }
public string ParameterTypeName { get; set; }
public static bool CheckValueType(Type type)
{
var typeInfo = type.GetTypeInfo();
if (typeInfo.IsGenericType && typeInfo.GetGenericTypeDefinition() == typeof(Nullable<>))
{
// nullable type, check if the nested type is simple.
return CheckValueType(typeInfo.GetGenericArguments()[0]);
}
return typeInfo.IsPrimitive
|| typeInfo.BaseType?.Name == "ValueType"
|| typeInfo.IsEnum
|| type.Equals(typeof(string))
|| type.Equals(typeof(DateTime))
|| type.Equals(typeof(decimal));
}
}
}
@@ -0,0 +1,28 @@
using CloudBuilder.CodeGenerator.Config;
using CloudBuilder.CodeGenerator.Data;
using CloudBuilder.CodeGenerator.Entity;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.LinkLabel;
namespace CloudBuilder.CodeGenerator.Data
{
public class ModelData
{
public SysTableSchemaViewEntity[] sysTableSchemas;
public NamespaceObject NamespaceObject;
public ClassInfo[] ClassInfos;
public ClassInfo ClassInfo;
public string KeyType;
public int KeyCount;
}
}
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.CodeGenerator.Data
{
public class SysTable
{
public string Selected { get; set; } = null!;
public string TableName { get; set; } = null!;
}
}
@@ -0,0 +1,39 @@
using CloudBuilder.Core.DependencyInjection.EFCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.CodeGenerator.Entity
{
public partial class CodeGeneratorRegistEntity : IMasterRegistEntityType<ModelBuilder>
{
/// <summary>
/// 注入模块内的所有实体类
/// </summary>
/// <param name="builder"></param>
public void RegistEntity(ModelBuilder builder)
{
string _assemblyName = Assembly.GetExecutingAssembly().GetName().Name;
//注入所有Entity实体类
AddEntityType(builder, _assemblyName);
//如果Entity实体类不是单一主键,要单独重写注入
RegistKeys(builder);
}
public void AddEntityType(ModelBuilder builder, string _assemblyName)
{
RegistEntityHelper.AddMasterEntityType(builder, _assemblyName);
}
public void RegistKeys(ModelBuilder builder)
{
//***BEGIN***
builder.Entity<SysTableSchemaViewEntity>(eb => { eb.HasNoKey(); });
//***END***
}
}
}
@@ -0,0 +1,134 @@
using CloudBuilder.Core.DatabaseAccessor.Entity;
using System.ComponentModel.DataAnnotations.Schema;
namespace CloudBuilder.CodeGenerator.Entity
{
[Table("sys_table_schema_view")]
public class SysTableSchemaViewEntity : ViewEntityBase
{
[Column("table_name")]
public string TableName { get; set; }
[Column("field_name")]
public string FieldName { get; set; }
[Column("type_name")]
public string TypeName { get; set; }
[Column("type_of_name")]
public string TypeOfName { get; set; }
[Column("max_length")]
public int MaxLength { get; set; }
[Column("scale")]
public int Scale { get; set; }
[Column("is_null_able")]
public string IsNullAble { get; set; }
[Column("field_default_value")]
public string FieldDefaultValue { get; set; }
[Column("xtype")]
public string Xtype { get; set; }
[Column("find_by")]
public int FindBy { get; set; }
[Column("operation")]
public int Operation { get; set; }
[Column("pk")]
public int Pk { get; set; }
[Column("pk_name")]
public string PkName { get; set; }
[Column("is_identity")]
public int IsIdentity { get; set; }
[Column("colid")]
public int Colid { get; set; }
public const string TABLE_NAME = "TableName";
public const string FIELD_NAME = "FieldName";
public const string TYPE_NAME = "TypeName";
public const string TYPE_OF_NAME = "TypeOfName";
public const string MAX_LENGTH = "MaxLength";
public const string SCALE = "Scale";
public const string IS_NULL_ABLE = "IsNullAble";
public const string FIELD_DEFAULT_VALUE = "FieldDefaultValue";
public const string XTYPE = "Xtype";
public const string FIND_BY = "FindBy";
public const string OPERATION = "operation";
public const string PK = "Pk";
public const string PK_NAME = "PkName";
public const string IS_IDENTITY = "IsIdentity";
public const string COLID = "Colid";
public const string DB_NAME_SYS_TABLE_SCHEMA = "sys_table_schema_view";
public const string DB_NAME_FIELDS = "table_name,field_name,type_name,type_of_name,max_length,scale,is_null_able,field_default_value,xtype,find_by,operation,pk,pk_name,is_identity,colid";
public const string DB_TABLE_NAME = "table_name";
public const string DB_FIELD_NAME = "field_name";
public const string DB_TYPE_NAME = "type_name";
public const string DB_TYPE_OF_NAME = "type_of_name";
public const string DB_MAX_LENGTH = "max_length";
public const string DB_SCALE = "scale";
public const string DB_IS_NULL_ABLE = "is_null_able";
public const string DB_FIELD_DEFAULT_VALUE = "field_default_value";
public const string DB_XTYPE = "xtype";
public const string DB_FIND_BY = "find_by";
public const string DB_OPERATION = "operation";
public const string DB_PK = "pk";
public const string DB_PK_NAME = "pk_name";
public const string DB_IS_IDENTITY = "is_identity";
public const string DB_COLID = "colid";
public static SysTableSchemaViewEntity GetInstance()
{
return new SysTableSchemaViewEntity();
}
public SysTableSchemaViewEntity()
: base()
{
}
public virtual void CopyFrom(SysTableSchemaViewEntity source)
{
CopyFrom(source, true);
}
public virtual void CopyFrom(SysTableSchemaViewEntity source, bool includeSystemFields)
{
if (source == null)
{
throw new NullReferenceException("Source entity is null.");
}
this.TableName = source.TableName;
this.FieldName = source.FieldName;
this.TypeName = source.TypeName;
this.TypeOfName = source.TypeOfName;
this.MaxLength = source.MaxLength;
this.Scale = source.Scale;
this.IsNullAble = source.IsNullAble;
this.FieldDefaultValue = source.FieldDefaultValue;
this.Xtype = source.Xtype;
this.FindBy = source.FindBy;
this.Operation = source.Operation;
this.Pk = source.Pk;
this.PkName = source.PkName;
this.IsIdentity = source.IsIdentity;
this.Colid = source.Colid;
if (includeSystemFields)
{
}
}
public string GetSelectFrom()
{
return $" select {DB_NAME_FIELDS} from {DB_NAME_SYS_TABLE_SCHEMA} ";
}
public SysTableSchemaViewEntity Clone()
{
SysTableSchemaViewEntity result = new SysTableSchemaViewEntity();
result.CopyFrom(this);
return result;
}
}
}
+90
View File
@@ -0,0 +1,90 @@
namespace CloudBuilder.CodeGenerator
{
partial class MainFunctionView
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
kryptonDockingManager = new Krypton.Docking.KryptonDockingManager();
kryptonDockableWorkspace = new Krypton.Docking.KryptonDockableWorkspace();
mainPanel = new Krypton.Toolkit.KryptonPanel();
((System.ComponentModel.ISupportInitialize)kryptonDockableWorkspace).BeginInit();
((System.ComponentModel.ISupportInitialize)mainPanel).BeginInit();
mainPanel.SuspendLayout();
SuspendLayout();
//
// kryptonDockableWorkspace
//
kryptonDockableWorkspace.ActivePage = null;
kryptonDockableWorkspace.AutoHiddenHost = false;
kryptonDockableWorkspace.CompactFlags = Krypton.Workspace.CompactFlags.RemoveEmptyCells | Krypton.Workspace.CompactFlags.RemoveEmptySequences | Krypton.Workspace.CompactFlags.PromoteLeafs;
kryptonDockableWorkspace.ContainerBackStyle = Krypton.Toolkit.PaletteBackStyle.PanelClient;
kryptonDockableWorkspace.Dock = DockStyle.Fill;
kryptonDockableWorkspace.Location = new Point(0, 0);
kryptonDockableWorkspace.Name = "kryptonDockableWorkspace";
//
//
//
kryptonDockableWorkspace.Root.UniqueName = "9b8557cebb92477fa6d1f0b015e0ff50";
kryptonDockableWorkspace.Root.WorkspaceControl = kryptonDockableWorkspace;
kryptonDockableWorkspace.SeparatorStyle = Krypton.Toolkit.SeparatorStyle.LowProfile;
kryptonDockableWorkspace.ShowMaximizeButton = false;
kryptonDockableWorkspace.Size = new Size(1008, 761);
kryptonDockableWorkspace.SplitterWidth = 5;
kryptonDockableWorkspace.TabIndex = 0;
kryptonDockableWorkspace.TabStop = true;
//
// mainPanel
//
mainPanel.Controls.Add(kryptonDockableWorkspace);
mainPanel.Dock = DockStyle.Fill;
mainPanel.Location = new Point(0, 0);
mainPanel.Name = "mainPanel";
mainPanel.Size = new Size(1008, 761);
mainPanel.TabIndex = 1;
//
// MainFunctionView
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1008, 761);
Controls.Add(mainPanel);
Name = "MainFunctionView";
Text = "代码生成器";
Load += MainFunctionView_Load;
((System.ComponentModel.ISupportInitialize)kryptonDockableWorkspace).EndInit();
((System.ComponentModel.ISupportInitialize)mainPanel).EndInit();
mainPanel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private Krypton.Docking.KryptonDockingManager kryptonDockingManager;
private Krypton.Docking.KryptonDockableWorkspace kryptonDockableWorkspace;
private Krypton.Toolkit.KryptonPanel mainPanel;
}
}
@@ -0,0 +1,103 @@
using CloudBuilder.CodeGenerator.Entity;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Core.DependencyInjection.Form;
using Krypton.Docking;
using Krypton.Navigator;
using Krypton.Toolkit;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CloudBuilder.CodeGenerator
{
public partial class MainFunctionView : KryptonForm, IForm
{
public TableControl tableControl;
public ConfigUserControl configUserControl;
private readonly TemplateUserControl templateUserControl;
private readonly OutputUserControl outputUserControl;
private readonly OperationUserControl operationUserControl;
public void SetConfigUserControl(object? value)
{
configUserControl.assemblyComboBox.SelectedValue = value;
}
public void SetOperationUserControl(object? value)
{
operationUserControl.assemblyComboBox.SelectedValue = value;
}
public MainFunctionView(
[FromKeyedServices("TableControl")] TableControl tableControl,
[FromKeyedServices("ConfigUserControl")] ConfigUserControl configUserControl,
[FromKeyedServices("TemplateUserControl")] TemplateUserControl templateUserControl,
[FromKeyedServices("OutputUserControl")] OutputUserControl outputUserControl,
[FromKeyedServices("OperationUserControl")] OperationUserControl operationUserControl)
{
InitializeComponent();
this.tableControl = tableControl;
this.configUserControl = configUserControl;
this.templateUserControl = templateUserControl;
this.outputUserControl = outputUserControl;
this.operationUserControl = operationUserControl;
}
private void MainFunctionView_Load(object sender, EventArgs e)
{
KryptonDockingWorkspace w = kryptonDockingManager.ManageWorkspace(kryptonDockableWorkspace);
kryptonDockingManager.ManageControl(mainPanel, w);
kryptonDockingManager.ManageFloating(this);
kryptonDockingManager.AddDockspace("Control", DockingEdge.Right, new KryptonPage[] { NewOperationUserControl() });
kryptonDockingManager.AddToWorkspace("Workspace", new KryptonPage[] { NewTableControl(), NewConfigUserControl(), NewTemplateUserControl(), NewOutputUserControl() });
}
private KryptonPage NewTableControl()
{
return NewOutputControl("数据操作", 1, tableControl);
}
private KryptonPage NewConfigUserControl()
{
return NewOutputControl("模板设置", 2, configUserControl);
}
private KryptonPage NewTemplateUserControl()
{
return NewOutputControl("模板內容", 3, templateUserControl);
}
private KryptonPage NewOutputUserControl()
{
return NewOutputControl("模板生成內容", 4, outputUserControl);
}
private KryptonPage NewOperationUserControl()
{
return NewOutputControl("模板输出", 4, operationUserControl);
}
private KryptonPage NewOutputControl(string text, int imageIndex, UserControl userControl)
{
KryptonPage p = new KryptonPage();
p.TextTitle = p.Text = text;
p.MinimumSize = new Size(200, 250);
userControl.Dock = DockStyle.Fill;
p.Controls.Add(userControl);
return p;
}
}
}
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="kryptonDockingManager.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>
@@ -0,0 +1,178 @@
namespace CloudBuilder.CodeGenerator
{
partial class OperationUserControl
{
/// <summary>
/// 設計工具所需的變數。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清除任何使用中的資源。
/// </summary>
/// <param name="disposing">如果應該處置受控資源則為 true,否則為 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 元件設計工具產生的程式碼
/// <summary>
/// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
assemblyComboBox = new Krypton.Toolkit.KryptonComboBox();
kryptonHeader1 = new Krypton.Toolkit.KryptonHeader();
kryptonCheckedListBox1 = new Krypton.Toolkit.KryptonCheckedListBox();
kryptonHeader2 = new Krypton.Toolkit.KryptonHeader();
kryptonHeader3 = new Krypton.Toolkit.KryptonHeader();
templateBut = new Krypton.Toolkit.KryptonButton();
tableLayoutPanel1 = new TableLayoutPanel();
outputFileBut = new Krypton.Toolkit.KryptonCheckButton();
((System.ComponentModel.ISupportInitialize)assemblyComboBox).BeginInit();
tableLayoutPanel1.SuspendLayout();
SuspendLayout();
//
// assemblyComboBox
//
assemblyComboBox.Dock = DockStyle.Fill;
assemblyComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
assemblyComboBox.DropDownWidth = 362;
assemblyComboBox.IntegralHeight = false;
assemblyComboBox.Location = new Point(4, 43);
assemblyComboBox.Margin = new Padding(4);
assemblyComboBox.Name = "assemblyComboBox";
assemblyComboBox.Size = new Size(275, 21);
assemblyComboBox.TabIndex = 7;
assemblyComboBox.SelectionChangeCommitted += assemblyComboBox_SelectionChangeCommitted;
assemblyComboBox.SelectedValueChanged += assemblyComboBox_SelectedValueChanged;
//
// kryptonHeader1
//
kryptonHeader1.Dock = DockStyle.Fill;
kryptonHeader1.Location = new Point(4, 4);
kryptonHeader1.Margin = new Padding(4);
kryptonHeader1.Name = "kryptonHeader1";
kryptonHeader1.Size = new Size(275, 31);
kryptonHeader1.TabIndex = 0;
kryptonHeader1.Values.Description = "";
kryptonHeader1.Values.Heading = "当前程序集";
kryptonHeader1.Values.Image = null;
//
// kryptonCheckedListBox1
//
kryptonCheckedListBox1.Dock = DockStyle.Fill;
kryptonCheckedListBox1.Location = new Point(4, 111);
kryptonCheckedListBox1.Margin = new Padding(4);
kryptonCheckedListBox1.Name = "kryptonCheckedListBox1";
kryptonCheckedListBox1.Size = new Size(275, 227);
kryptonCheckedListBox1.TabIndex = 8;
//
// kryptonHeader2
//
kryptonHeader2.Dock = DockStyle.Fill;
kryptonHeader2.Location = new Point(4, 72);
kryptonHeader2.Margin = new Padding(4);
kryptonHeader2.Name = "kryptonHeader2";
kryptonHeader2.Size = new Size(275, 31);
kryptonHeader2.TabIndex = 9;
kryptonHeader2.Values.Description = "";
kryptonHeader2.Values.Heading = "输出项显示";
kryptonHeader2.Values.Image = null;
//
// kryptonHeader3
//
kryptonHeader3.Dock = DockStyle.Fill;
kryptonHeader3.Location = new Point(4, 346);
kryptonHeader3.Margin = new Padding(4);
kryptonHeader3.Name = "kryptonHeader3";
kryptonHeader3.Size = new Size(275, 4);
kryptonHeader3.TabIndex = 10;
kryptonHeader3.Values.Description = "";
kryptonHeader3.Values.Heading = "";
kryptonHeader3.Values.Image = null;
//
// templateBut
//
templateBut.Location = new Point(4, 391);
templateBut.Margin = new Padding(4);
templateBut.Name = "templateBut";
templateBut.Size = new Size(105, 25);
templateBut.TabIndex = 12;
templateBut.Values.Text = "模板生成";
templateBut.Click += templateBut_Click;
//
// tableLayoutPanel1
//
tableLayoutPanel1.AutoSize = true;
tableLayoutPanel1.AutoSizeMode = AutoSizeMode.GrowAndShrink;
tableLayoutPanel1.ColumnCount = 1;
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel1.Controls.Add(assemblyComboBox, 0, 1);
tableLayoutPanel1.Controls.Add(kryptonHeader1, 0, 0);
tableLayoutPanel1.Controls.Add(kryptonCheckedListBox1, 0, 3);
tableLayoutPanel1.Controls.Add(kryptonHeader2, 0, 2);
tableLayoutPanel1.Controls.Add(kryptonHeader3, 0, 4);
tableLayoutPanel1.Controls.Add(outputFileBut, 0, 7);
tableLayoutPanel1.Controls.Add(templateBut, 0, 8);
tableLayoutPanel1.Dock = DockStyle.Fill;
tableLayoutPanel1.Location = new Point(0, 0);
tableLayoutPanel1.Margin = new Padding(4);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 9;
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.Size = new Size(283, 649);
tableLayoutPanel1.TabIndex = 1;
//
// outputFileBut
//
outputFileBut.Location = new Point(4, 358);
outputFileBut.Margin = new Padding(4);
outputFileBut.Name = "outputFileBut";
outputFileBut.Size = new Size(105, 25);
outputFileBut.TabIndex = 13;
outputFileBut.Values.Text = "输出文件";
outputFileBut.Click += outputFileBut_Click;
//
// OperationUserControl
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(tableLayoutPanel1);
MinimumSize = new Size(240, 0);
Name = "OperationUserControl";
Size = new Size(283, 649);
((System.ComponentModel.ISupportInitialize)assemblyComboBox).EndInit();
tableLayoutPanel1.ResumeLayout(false);
tableLayoutPanel1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
public Krypton.Toolkit.KryptonComboBox assemblyComboBox;
private Krypton.Toolkit.KryptonHeader kryptonHeader1;
private Krypton.Toolkit.KryptonCheckedListBox kryptonCheckedListBox1;
private Krypton.Toolkit.KryptonHeader kryptonHeader2;
private Krypton.Toolkit.KryptonHeader kryptonHeader3;
private Krypton.Toolkit.KryptonButton templateBut;
private TableLayoutPanel tableLayoutPanel1;
private Krypton.Toolkit.KryptonCheckButton outputFileBut;
}
}
@@ -0,0 +1,286 @@
using CloudBuilder.CodeGenerator.Config;
using CloudBuilder.CodeGenerator.Data;
using CloudBuilder.CodeGenerator.Utility;
using CloudBuilder.Core.Application.Builders;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Core.DependencyInjection.Form;
using CloudBuilder.Core.Extensions;
using CloudBuilder.Core.Service;
using CloudBuilder.Core.Utility;
using Krypton.Toolkit;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.OLE.Interop;
using RazorEngineCore;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Windows.Forms.Design;
namespace CloudBuilder.CodeGenerator
{
public partial class OperationUserControl : UserControl, IUserControl
{
private readonly IApplicationService app;
private readonly TableControl tableControl;
private ConfigUserControl configUserControl;
private readonly TemplateUserControl templateUserControl;
private readonly OutputUserControl outputUserControl;
private ToolInitConfig toolInitConfig;
public OperationUserControl(IApplicationService app,
[FromKeyedServices("TableControl")] TableControl tableControl,
[FromKeyedServices("TemplateUserControl")] TemplateUserControl templateUserControl,
[FromKeyedServices("OutputUserControl")] OutputUserControl outputUserControl)
{
InitializeComponent();
this.app = app;
this.tableControl = tableControl;
this.templateUserControl = templateUserControl;
this.outputUserControl = outputUserControl;
InitUserControl();
}
public void InitUserControl()
{
assemblyComboBox.DisplayMember = "Text";
assemblyComboBox.ValueMember = "Value";
toolInitConfig = ToolInitConfig.GetInstance();
List<ComboBoxItem> l = new List<ComboBoxItem>();
List<string> types = new List<string>();
foreach (NamespaceObject nso in toolInitConfig.NamespaceObjects)
{
if (l.Select(x => x.Text).Contains(nso.Assembly)) continue;
l.Add(CreateNewComboBoxItem(nso.Assembly, nso.Assembly));
}
DataTable dtbl = DataTableConvertor.ToDataTable<ComboBoxItem>(l);
assemblyComboBox.DataSource = dtbl;
assemblyComboBox.SelectedValue = toolInitConfig.CurrentAssembly;
InitkryptonCheckedListBox1(toolInitConfig.CurrentAssembly);
}
private void InitkryptonCheckedListBox1(string currentAssembly)
{
if (string.IsNullOrEmpty(currentAssembly)) return;
int i = 0;
kryptonCheckedListBox1.Items.Clear();
foreach (NamespaceObject nso in toolInitConfig.NamespaceObjects.Where(x => x.Assembly == currentAssembly).ToList())
{
if (nso.TemplateType.Contains("Entity") && nso.TemplateType != "Entity") continue;
if (nso.TemplateType.Contains("TypeScript")) continue;
kryptonCheckedListBox1.Items.Add(CreateNewItem(nso.TemplateType));
if (!nso.TemplateType.Contains("Entity"))
{
i++;
continue;
}
kryptonCheckedListBox1.SetItemCheckState(i++, CheckState.Checked);
}
}
private void outputFileBut_Click(object sender, EventArgs e)
{
ModelData model = GetModelData();
if (model.sysTableSchemas == null || model.sysTableSchemas.Length == 0)
{
MessageBox.Show("请选择要生成的数据表", "提示");
return;
}
for (var i = 0; i < kryptonCheckedListBox1.Items.Count; i++)
{
if (kryptonCheckedListBox1.GetItemCheckState(i) == CheckState.Checked)
{
KryptonListItem a = (KryptonListItem)kryptonCheckedListBox1.Items[i];
WriteAllText(model, a.ShortText);
}
}
MessageBox.Show("生成成功", "提示");
}
private void WriteAllText(ModelData model, string templateType)
{
NamespaceObject namespaceObject = toolInitConfig.NamespaceObjects.Where(x => x.Assembly == assemblyComboBox.Text.Trim() && x.TemplateType == templateType).FirstOrDefault();
if (namespaceObject == null) return;
string fileName = Path.Combine(toolInitConfig.TemplatePath, namespaceObject.TemplateFileName);
if (!File.Exists(fileName)) return;
if (!Path.Exists(namespaceObject.OutFilePath)) return;
var tp = File.ReadAllText(fileName);
string outputFileName = Path.Combine(namespaceObject.OutFilePath, namespaceObject.FileNamePrefix + model.sysTableSchemas[0].TableName.StringToProerty() + namespaceObject.FileNameSuffix);
if (templateType == "RegistEntity")
{
outputFileName = Path.Combine(namespaceObject.OutFilePath, namespaceObject.Assembly.Replace(".", "") + namespaceObject.FileNameSuffix);
//文件不存在,先初始化文件
if (!File.Exists(outputFileName)) File.WriteAllText(outputFileName, RazorEngineHelper.CompiledTemplate(tp, model));
string allTxt = File.ReadAllText(outputFileName);
tp = File.ReadAllText(Path.Combine(toolInitConfig.TemplatePath, namespaceObject.TemplateFileName.Replace(".cshtml", ".Key.cshtml")));
var temp = RazorEngineHelper.CompiledTemplate(tp, model);
if (allTxt.Contains("<" + model.sysTableSchemas[0].TableName.StringToProerty() + "Entity>()")) return;
int end = allTxt.IndexOf("//***END***", StringComparison.OrdinalIgnoreCase);
allTxt = allTxt.Substring(0, end) + temp + allTxt.Substring(end, allTxt.Length - end);
File.WriteAllText(outputFileName, allTxt);
return;
}
else if (templateType == "Permission")
{
outputFileName = Path.Combine(namespaceObject.OutFilePath, namespaceObject.Assembly.Split('.')[namespaceObject.Assembly.Split('.').Length - 1] + namespaceObject.FileNameSuffix);
//文件存在不覆盖,插入
if (File.Exists(outputFileName))
{
string allTxt = File.ReadAllText(outputFileName);
tp = File.ReadAllText(Path.Combine(toolInitConfig.TemplatePath, namespaceObject.TemplateFileName));
var temp = RazorEngineHelper.CompiledTemplate(tp, model);
if (allTxt.Contains(model.sysTableSchemas[0].TableName.StringToProerty())) return;
int end = allTxt.IndexOf("//***END***", StringComparison.OrdinalIgnoreCase);
allTxt = allTxt.Substring(0, end) + temp + allTxt.Substring(end, allTxt.Length - end);
File.WriteAllText(outputFileName, allTxt);
return;
}
else
{
tp = File.ReadAllText(Path.Combine(toolInitConfig.TemplatePath, namespaceObject.TemplateFileName.Replace(".cshtml", ".auto.cshtml")));
var temp = RazorEngineHelper.CompiledTemplate(tp, model);
File.WriteAllText(outputFileName, temp);
}
}
//Entity可以直接輸出,其他要文件不存在才生成
if (templateType == "Entity" || templateType == "IEntityKey" || !File.Exists(outputFileName))
File.WriteAllText(outputFileName, RazorEngineHelper.CompiledTemplate(tp, model));
if ((model.KeyCount >= 0) && templateType == "Entity")
{
if (model.KeyCount > 1)
WriteAllText(model, "IEntityKey");
WriteAllText(model, "RegistEntity");
}
else if (templateType == "Service")
{
WriteAllText(model, "Permission");
}
}
private void templateBut_Click(object sender, EventArgs e)
{
try
{
ModelData modelData = GetModelData();
((OutputUserControl)outputUserControl).contextTxt.Text = RazorEngineHelper.CompiledTemplate(((TemplateUserControl)templateUserControl).contextTxt.Text, modelData);
MessageBox.Show("生成成功", "提示");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "出错");
}
}
private ModelData GetModelData()
{
configUserControl = app.ServiceProvider.GetKeyedService<ConfigUserControl>("ConfigUserControl");
ModelData modelData = new ModelData();
modelData.sysTableSchemas = ((TableControl)tableControl).GetDataSource();
modelData.NamespaceObject = toolInitConfig.NamespaceObjects.Where(x => x.TemplateType == configUserControl.GetTemplateType() && x.Assembly == configUserControl.GetAssembly()).FirstOrDefault();
if (modelData.sysTableSchemas != null && modelData.sysTableSchemas.Length > 0)
{
modelData.KeyCount = modelData.sysTableSchemas.Where(x => x.Pk > 0).Count();
if (modelData.KeyCount == 1)
{
modelData.KeyType = modelData.sysTableSchemas.Where(x => x.Pk > 0).FirstOrDefault().TypeOfName;
}
else if (modelData.KeyCount > 1)
{
modelData.KeyType = $"{modelData.sysTableSchemas[0].TableName.StringToProerty()}EntityKey";
}
else
{
modelData.KeyType = "string";
}
}
List<Assembly> assemblies = new List<Assembly>();
if (toolInitConfig.AssemblyReferences != null)
{
foreach (var reference in toolInitConfig.AssemblyReferences)
{
if (string.IsNullOrEmpty(reference.AssemblyFileName)) continue;
if (!File.Exists(reference.AssemblyFileName)) continue;
assemblies.Add(Assembly.LoadFrom(reference.AssemblyFileName));
}
}
if (configUserControl.GetTemplateType() == "Controller" || configUserControl.GetTemplateType() == "TypeScriptService")
modelData.ClassInfos = RazorEngineHelper.PackIServiceClassInfo(assemblies.Where(x => Path.GetFileNameWithoutExtension(x.ManifestModule.Name) == modelData.NamespaceObject.Assembly).FirstOrDefault());
else
if (configUserControl.GetTemplateType() == "TypeScript")
modelData.ClassInfos = RazorEngineHelper.PackTypeScriptClassInfo(assemblies.Where(x => Path.GetFileNameWithoutExtension(x.ManifestModule.Name) == modelData.NamespaceObject.Assembly).FirstOrDefault());
return modelData;
}
public class ComboBoxItem
{
public string Text { get; set; }
public string Value { get; set; }
}
private ComboBoxItem CreateNewComboBoxItem(string text, string value)
{
ComboBoxItem item = new ComboBoxItem();
item.Text = text;
item.Value = value;
return item;
}
private object CreateNewItem(string text)
{
KryptonListItem item = new KryptonListItem();
item.ShortText = text;
return item;
}
private void assemblyComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
((MainFunctionView)(this.ParentForm)).SetConfigUserControl(assemblyComboBox.SelectedValue);
}
private void assemblyComboBox_SelectedValueChanged(object sender, EventArgs e)
{
InitkryptonCheckedListBox1((string)assemblyComboBox.SelectedValue);
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+93
View File
@@ -0,0 +1,93 @@
namespace CloudBuilder.CodeGenerator
{
partial class OutputUserControl
{
/// <summary>
/// 設計工具所需的變數。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清除任何使用中的資源。
/// </summary>
/// <param name="disposing">如果應該處置受控資源則為 true,否則為 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 元件設計工具產生的程式碼
/// <summary>
/// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
tableLayoutPanel1 = new TableLayoutPanel();
kryptonHeader1 = new Krypton.Toolkit.KryptonHeader();
contextTxt = new Krypton.Toolkit.KryptonRichTextBox();
tableLayoutPanel1.SuspendLayout();
SuspendLayout();
//
// tableLayoutPanel1
//
tableLayoutPanel1.ColumnCount = 1;
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel1.Controls.Add(kryptonHeader1, 0, 0);
tableLayoutPanel1.Controls.Add(contextTxt, 0, 2);
tableLayoutPanel1.Dock = DockStyle.Fill;
tableLayoutPanel1.Location = new Point(0, 0);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 3;
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 35F));
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutPanel1.Size = new Size(779, 531);
tableLayoutPanel1.TabIndex = 1;
//
// kryptonHeader1
//
tableLayoutPanel1.SetColumnSpan(kryptonHeader1, 4);
kryptonHeader1.Dock = DockStyle.Fill;
kryptonHeader1.Location = new Point(4, 4);
kryptonHeader1.Margin = new Padding(4);
kryptonHeader1.Name = "kryptonHeader1";
kryptonHeader1.Size = new Size(771, 27);
kryptonHeader1.TabIndex = 13;
kryptonHeader1.Values.Description = "";
kryptonHeader1.Values.Heading = "模板生成內容";
kryptonHeader1.Values.Image = null;
//
// contextTxt
//
contextTxt.Dock = DockStyle.Fill;
contextTxt.Location = new Point(3, 38);
contextTxt.Name = "contextTxt";
contextTxt.Size = new Size(773, 490);
contextTxt.TabIndex = 15;
contextTxt.Text = "";
//
// OutputUserControl
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(tableLayoutPanel1);
Name = "OutputUserControl";
Size = new Size(779, 531);
tableLayoutPanel1.ResumeLayout(false);
tableLayoutPanel1.PerformLayout();
ResumeLayout(false);
}
#endregion
private TableLayoutPanel tableLayoutPanel1;
private Krypton.Toolkit.KryptonHeader kryptonHeader1;
public Krypton.Toolkit.KryptonRichTextBox contextTxt;
}
}
@@ -0,0 +1,21 @@
using CloudBuilder.Core.DependencyInjection.Form;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CloudBuilder.CodeGenerator
{
public partial class OutputUserControl : UserControl, IUserControl
{
public OutputUserControl()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+29
View File
@@ -0,0 +1,29 @@
using CloudBuilder.CodeGenerator;
using Microsoft.Extensions.DependencyInjection;
namespace WinFormsApp
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var services = new ServiceCollection();
services.Initialize();
var serviceProvider = services.BuildServiceProvider();
MainFunctionView mainFunctionView = serviceProvider.GetRequiredKeyedService<MainFunctionView>(typeof(MainFunctionView).Name);
Application.Run(mainFunctionView);
}
}
}
@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 這段程式碼是由工具產生的。
// 執行階段版本:4.0.30319.42000
//
// 對這個檔案所做的變更可能會造成錯誤的行為,而且如果重新產生程式碼,
// 變更將會遺失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace CloudBuilder.CodeGenerator.Properties {
using System;
/// <summary>
/// 用於查詢當地語系化字串等的強類型資源類別。
/// </summary>
// 這個類別是自動產生的,是利用 StronglyTypedResourceBuilder
// 類別透過 ResGen 或 Visual Studio 這類工具。
// 若要加入或移除成員,請編輯您的 .ResX 檔,然後重新執行 ResGen
// (利用 /str 選項),或重建您的 VS 專案。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 傳回這個類別使用的快取的 ResourceManager 執行個體。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CloudBuilder.CodeGenerator.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 覆寫目前執行緒的 CurrentUICulture 屬性,對象是所有
/// 使用這個強類型資源類別的資源查閱。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
+418
View File
@@ -0,0 +1,418 @@
namespace CloudBuilder.CodeGenerator
{
partial class TableControl
{
/// <summary>
/// 設計工具所需的變數。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清除任何使用中的資源。
/// </summary>
/// <param name="disposing">如果應該處置受控資源則為 true,否則為 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 元件設計工具產生的程式碼
/// <summary>
/// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
DataGridViewCellStyle dataGridViewCellStyle8 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle9 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle10 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle11 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle12 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle13 = new DataGridViewCellStyle();
DataGridViewCellStyle dataGridViewCellStyle14 = new DataGridViewCellStyle();
kryptonPanel1 = new Krypton.Toolkit.KryptonPanel();
splitContainer1 = new SplitContainer();
leftPanel = new TableLayoutPanel();
tableNameGv = new Krypton.Toolkit.KryptonDataGridView();
selectedCol = new Krypton.Toolkit.KryptonDataGridViewCheckBoxColumn();
tableNameCol = new Krypton.Toolkit.KryptonDataGridViewTextBoxColumn();
tableLayoutPanel3 = new TableLayoutPanel();
kryptonLabel1 = new Krypton.Toolkit.KryptonLabel();
dtTxt = new Krypton.Toolkit.KryptonTextBox();
dtSearchBut = new Krypton.Toolkit.KryptonButton();
dtResetBut = new Krypton.Toolkit.KryptonButton();
loadDbBut = new Krypton.Toolkit.KryptonButton();
tableLayoutPanel2 = new TableLayoutPanel();
fieldNameGv = new Krypton.Toolkit.KryptonDataGridView();
pkCol = new Krypton.Toolkit.KryptonDataGridViewCheckBoxColumn();
operationCol = new Krypton.Toolkit.KryptonDataGridViewCheckBoxColumn();
fieldNameCol = new Krypton.Toolkit.KryptonDataGridViewTextBoxColumn();
typeNameCol = new Krypton.Toolkit.KryptonDataGridViewTextBoxColumn();
typeOfNameCol = new Krypton.Toolkit.KryptonDataGridViewTextBoxColumn();
tableLayoutPanel4 = new TableLayoutPanel();
kryptonLabel2 = new Krypton.Toolkit.KryptonLabel();
fieldTxt = new Krypton.Toolkit.KryptonTextBox();
fieldSearchBut = new Krypton.Toolkit.KryptonButton();
fieldResetBut = new Krypton.Toolkit.KryptonButton();
((System.ComponentModel.ISupportInitialize)kryptonPanel1).BeginInit();
kryptonPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
splitContainer1.Panel1.SuspendLayout();
splitContainer1.Panel2.SuspendLayout();
splitContainer1.SuspendLayout();
leftPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)tableNameGv).BeginInit();
tableLayoutPanel3.SuspendLayout();
tableLayoutPanel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)fieldNameGv).BeginInit();
tableLayoutPanel4.SuspendLayout();
SuspendLayout();
//
// kryptonPanel1
//
kryptonPanel1.Controls.Add(splitContainer1);
kryptonPanel1.Dock = DockStyle.Fill;
kryptonPanel1.Location = new Point(0, 0);
kryptonPanel1.Name = "kryptonPanel1";
kryptonPanel1.Size = new Size(1024, 600);
kryptonPanel1.TabIndex = 0;
//
// splitContainer1
//
splitContainer1.BackColor = Color.Transparent;
splitContainer1.BorderStyle = BorderStyle.FixedSingle;
splitContainer1.Dock = DockStyle.Fill;
splitContainer1.Location = new Point(0, 0);
splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
splitContainer1.Panel1.Controls.Add(leftPanel);
//
// splitContainer1.Panel2
//
splitContainer1.Panel2.Controls.Add(tableLayoutPanel2);
splitContainer1.Size = new Size(1024, 600);
splitContainer1.SplitterDistance = 512;
splitContainer1.SplitterWidth = 10;
splitContainer1.TabIndex = 0;
//
// leftPanel
//
leftPanel.ColumnCount = 1;
leftPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
leftPanel.Controls.Add(tableNameGv, 0, 1);
leftPanel.Controls.Add(tableLayoutPanel3, 0, 0);
leftPanel.Dock = DockStyle.Fill;
leftPanel.Location = new Point(0, 0);
leftPanel.Name = "leftPanel";
leftPanel.RowCount = 2;
leftPanel.RowStyles.Add(new RowStyle());
leftPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
leftPanel.Size = new Size(510, 598);
leftPanel.TabIndex = 0;
//
// tableNameGv
//
tableNameGv.BorderStyle = BorderStyle.None;
tableNameGv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
tableNameGv.Columns.AddRange(new DataGridViewColumn[] { selectedCol, tableNameCol });
tableNameGv.Dock = DockStyle.Fill;
tableNameGv.Location = new Point(4, 37);
tableNameGv.Margin = new Padding(4);
tableNameGv.Name = "tableNameGv";
tableNameGv.RowHeadersVisible = false;
tableNameGv.RowTemplate.Height = 23;
tableNameGv.Size = new Size(502, 557);
tableNameGv.TabIndex = 3;
tableNameGv.CellClick += tableNameGv_CellClick;
//
// selectedCol
//
dataGridViewCellStyle8.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle8.NullValue = false;
selectedCol.DefaultCellStyle = dataGridViewCellStyle8;
selectedCol.FalseValue = "N";
selectedCol.HeaderText = "选择";
selectedCol.IndeterminateValue = null;
selectedCol.Name = "selectedCol";
selectedCol.TrueValue = "Y";
selectedCol.Width = 50;
//
// tableNameCol
//
tableNameCol.DataPropertyName = "TableName";
tableNameCol.DefaultCellStyle = dataGridViewCellStyle9;
tableNameCol.HeaderText = "数据表";
tableNameCol.Name = "tableNameCol";
tableNameCol.Width = 260;
//
// tableLayoutPanel3
//
tableLayoutPanel3.AutoSize = true;
tableLayoutPanel3.AutoSizeMode = AutoSizeMode.GrowAndShrink;
tableLayoutPanel3.ColumnCount = 5;
tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel3.Controls.Add(kryptonLabel1, 0, 0);
tableLayoutPanel3.Controls.Add(dtTxt, 1, 0);
tableLayoutPanel3.Controls.Add(dtSearchBut, 2, 0);
tableLayoutPanel3.Controls.Add(dtResetBut, 3, 0);
tableLayoutPanel3.Controls.Add(loadDbBut, 4, 0);
tableLayoutPanel3.Location = new Point(0, 0);
tableLayoutPanel3.Margin = new Padding(0);
tableLayoutPanel3.Name = "tableLayoutPanel3";
tableLayoutPanel3.RowCount = 1;
tableLayoutPanel3.RowStyles.Add(new RowStyle());
tableLayoutPanel3.Size = new Size(382, 33);
tableLayoutPanel3.TabIndex = 2;
//
// kryptonLabel1
//
kryptonLabel1.Location = new Point(4, 6);
kryptonLabel1.Margin = new Padding(4, 6, 4, 4);
kryptonLabel1.Name = "kryptonLabel1";
kryptonLabel1.Size = new Size(49, 20);
kryptonLabel1.TabIndex = 0;
kryptonLabel1.Values.Text = "表名:";
//
// dtTxt
//
dtTxt.Dock = DockStyle.Fill;
dtTxt.Location = new Point(61, 6);
dtTxt.Margin = new Padding(4, 6, 4, 4);
dtTxt.Name = "dtTxt";
dtTxt.Size = new Size(97, 23);
dtTxt.TabIndex = 1;
//
// dtSearchBut
//
dtSearchBut.Location = new Point(166, 4);
dtSearchBut.Margin = new Padding(4);
dtSearchBut.Name = "dtSearchBut";
dtSearchBut.Size = new Size(58, 25);
dtSearchBut.TabIndex = 2;
dtSearchBut.Values.Text = "查询";
dtSearchBut.Click += dtSearchBut_Click;
//
// dtResetBut
//
dtResetBut.Location = new Point(232, 4);
dtResetBut.Margin = new Padding(4);
dtResetBut.Name = "dtResetBut";
dtResetBut.Size = new Size(58, 25);
dtResetBut.TabIndex = 3;
dtResetBut.Values.Text = "重置";
dtResetBut.Click += dtResetBut_Click;
//
// loadDbBut
//
loadDbBut.Location = new Point(298, 4);
loadDbBut.Margin = new Padding(4);
loadDbBut.Name = "loadDbBut";
loadDbBut.Size = new Size(80, 25);
loadDbBut.TabIndex = 3;
loadDbBut.Values.Text = "加载数据库";
loadDbBut.Click += loadDbBut_Click;
//
// tableLayoutPanel2
//
tableLayoutPanel2.ColumnCount = 1;
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel2.Controls.Add(fieldNameGv, 0, 1);
tableLayoutPanel2.Controls.Add(tableLayoutPanel4, 0, 0);
tableLayoutPanel2.Dock = DockStyle.Fill;
tableLayoutPanel2.Location = new Point(0, 0);
tableLayoutPanel2.Margin = new Padding(4);
tableLayoutPanel2.Name = "tableLayoutPanel2";
tableLayoutPanel2.RowCount = 2;
tableLayoutPanel2.RowStyles.Add(new RowStyle());
tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutPanel2.Size = new Size(500, 598);
tableLayoutPanel2.TabIndex = 3;
//
// fieldNameGv
//
fieldNameGv.BorderStyle = BorderStyle.None;
fieldNameGv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
fieldNameGv.Columns.AddRange(new DataGridViewColumn[] { pkCol, operationCol, fieldNameCol, typeNameCol, typeOfNameCol });
fieldNameGv.Dock = DockStyle.Fill;
fieldNameGv.Location = new Point(4, 37);
fieldNameGv.Margin = new Padding(4);
fieldNameGv.Name = "fieldNameGv";
fieldNameGv.RowHeadersVisible = false;
fieldNameGv.RowTemplate.Height = 23;
fieldNameGv.Size = new Size(492, 557);
fieldNameGv.TabIndex = 0;
//
// pkCol
//
pkCol.DataPropertyName = "Pk";
dataGridViewCellStyle10.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle10.NullValue = false;
pkCol.DefaultCellStyle = dataGridViewCellStyle10;
pkCol.FalseValue = "0";
pkCol.HeaderText = "主键";
pkCol.IndeterminateValue = null;
pkCol.Name = "pkCol";
pkCol.TrueValue = "1";
pkCol.Width = 60;
//
// operationCol
//
operationCol.DataPropertyName = "Operation";
dataGridViewCellStyle11.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle11.NullValue = false;
operationCol.DefaultCellStyle = dataGridViewCellStyle11;
operationCol.FalseValue = "0";
operationCol.HeaderText = "差异";
operationCol.IndeterminateValue = null;
operationCol.Name = "operationCol";
operationCol.TrueValue = "1";
operationCol.Width = 60;
//
// fieldNameCol
//
fieldNameCol.DataPropertyName = "FieldName";
fieldNameCol.DefaultCellStyle = dataGridViewCellStyle12;
fieldNameCol.HeaderText = "字段名";
fieldNameCol.Name = "fieldNameCol";
fieldNameCol.Width = 260;
//
// typeNameCol
//
typeNameCol.DataPropertyName = "TypeName";
typeNameCol.DefaultCellStyle = dataGridViewCellStyle13;
typeNameCol.HeaderText = "类型";
typeNameCol.Name = "typeNameCol";
typeNameCol.Width = 60;
//
// typeOfNameCol
//
typeOfNameCol.DataPropertyName = "TypeOfName";
typeOfNameCol.DefaultCellStyle = dataGridViewCellStyle14;
typeOfNameCol.HeaderText = "映射";
typeOfNameCol.Name = "typeOfNameCol";
typeOfNameCol.Width = 60;
//
// tableLayoutPanel4
//
tableLayoutPanel4.AutoSize = true;
tableLayoutPanel4.AutoSizeMode = AutoSizeMode.GrowAndShrink;
tableLayoutPanel4.ColumnCount = 5;
tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel4.Controls.Add(kryptonLabel2, 0, 0);
tableLayoutPanel4.Controls.Add(fieldTxt, 1, 0);
tableLayoutPanel4.Controls.Add(fieldSearchBut, 2, 0);
tableLayoutPanel4.Controls.Add(fieldResetBut, 3, 0);
tableLayoutPanel4.Location = new Point(0, 0);
tableLayoutPanel4.Margin = new Padding(0);
tableLayoutPanel4.Name = "tableLayoutPanel4";
tableLayoutPanel4.RowCount = 1;
tableLayoutPanel4.RowStyles.Add(new RowStyle());
tableLayoutPanel4.Size = new Size(340, 33);
tableLayoutPanel4.TabIndex = 1;
//
// kryptonLabel2
//
kryptonLabel2.Location = new Point(4, 6);
kryptonLabel2.Margin = new Padding(4, 6, 4, 4);
kryptonLabel2.Name = "kryptonLabel2";
kryptonLabel2.Size = new Size(62, 20);
kryptonLabel2.TabIndex = 0;
kryptonLabel2.Values.Text = "字段名:";
//
// fieldTxt
//
fieldTxt.Location = new Point(74, 6);
fieldTxt.Margin = new Padding(4, 6, 4, 4);
fieldTxt.Name = "fieldTxt";
fieldTxt.Size = new Size(130, 23);
fieldTxt.TabIndex = 1;
//
// fieldSearchBut
//
fieldSearchBut.Location = new Point(212, 4);
fieldSearchBut.Margin = new Padding(4);
fieldSearchBut.Name = "fieldSearchBut";
fieldSearchBut.Size = new Size(58, 25);
fieldSearchBut.TabIndex = 2;
fieldSearchBut.Values.Text = "查询";
fieldSearchBut.Click += fieldSearchBut_Click;
//
// fieldResetBut
//
fieldResetBut.Location = new Point(278, 4);
fieldResetBut.Margin = new Padding(4);
fieldResetBut.Name = "fieldResetBut";
fieldResetBut.Size = new Size(58, 25);
fieldResetBut.TabIndex = 3;
fieldResetBut.Values.Text = "重置";
fieldResetBut.Click += fieldResetBut_Click;
//
// TableControl
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(kryptonPanel1);
Name = "TableControl";
Size = new Size(1024, 600);
((System.ComponentModel.ISupportInitialize)kryptonPanel1).EndInit();
kryptonPanel1.ResumeLayout(false);
splitContainer1.Panel1.ResumeLayout(false);
splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
splitContainer1.ResumeLayout(false);
leftPanel.ResumeLayout(false);
leftPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)tableNameGv).EndInit();
tableLayoutPanel3.ResumeLayout(false);
tableLayoutPanel3.PerformLayout();
tableLayoutPanel2.ResumeLayout(false);
tableLayoutPanel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)fieldNameGv).EndInit();
tableLayoutPanel4.ResumeLayout(false);
tableLayoutPanel4.PerformLayout();
ResumeLayout(false);
}
#endregion
private Krypton.Toolkit.KryptonPanel kryptonPanel1;
private SplitContainer splitContainer1;
private TableLayoutPanel leftPanel;
private Krypton.Toolkit.KryptonDataGridView tableNameGv;
private TableLayoutPanel tableLayoutPanel3;
private Krypton.Toolkit.KryptonLabel kryptonLabel1;
private Krypton.Toolkit.KryptonTextBox dtTxt;
private Krypton.Toolkit.KryptonButton dtSearchBut;
private TableLayoutPanel tableLayoutPanel2;
private Krypton.Toolkit.KryptonDataGridView fieldNameGv;
private TableLayoutPanel tableLayoutPanel4;
private Krypton.Toolkit.KryptonLabel kryptonLabel2;
private Krypton.Toolkit.KryptonTextBox fieldTxt;
private Krypton.Toolkit.KryptonButton fieldSearchBut;
private Krypton.Toolkit.KryptonButton fieldResetBut;
private Krypton.Toolkit.KryptonButton loadDbBut;
private Krypton.Toolkit.KryptonDataGridViewCheckBoxColumn selectedCol;
private Krypton.Toolkit.KryptonDataGridViewTextBoxColumn tableNameCol;
private Krypton.Toolkit.KryptonDataGridViewCheckBoxColumn pkCol;
private Krypton.Toolkit.KryptonDataGridViewCheckBoxColumn operationCol;
private Krypton.Toolkit.KryptonDataGridViewTextBoxColumn fieldNameCol;
private Krypton.Toolkit.KryptonDataGridViewTextBoxColumn typeNameCol;
private Krypton.Toolkit.KryptonDataGridViewTextBoxColumn typeOfNameCol;
private Krypton.Toolkit.KryptonButton dtResetBut;
}
}
+191
View File
@@ -0,0 +1,191 @@
using CloudBuilder.CodeGenerator.Config;
using CloudBuilder.CodeGenerator.Data;
using CloudBuilder.CodeGenerator.Entity;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Core.DependencyInjection.Form;
using CloudBuilder.Core.Extensions;
using CloudBuilder.Core.Utility;
using Krypton.Toolkit;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CloudBuilder.CodeGenerator
{
public partial class TableControl : UserControl, IUserControl
{
private readonly IApplicationService service;
private readonly ConfigUserControl configUserControl;
private IRepository<SysTableSchemaViewEntity> repository;
public SysTableSchemaViewEntity[] sysTableSchemas;
public SysTableSchemaViewEntity[] sysTableFields;
private SysTable[] sysTables;
private DataTable sysTableField;
public TableControl(IApplicationService service)
{
InitializeComponent();
this.service = service;
tableNameGv.AutoGenerateColumns = false;
fieldNameGv.AutoGenerateColumns = false;
}
private void loadDbBut_Click(object sender, EventArgs e)
{
LoadData();
}
public void LoadData()
{
repository = service.GetRepository<IRepository<SysTableSchemaViewEntity>>();
sysTableSchemas = repository.DetachedEntities.ToArray();
if (sysTableSchemas == null || sysTableSchemas.Length == 0) return;
sysTables = sysTableSchemas.Select(x => x.TableName).OrderBy(x => x).Distinct()
.Select(x => new SysTable() { TableName = x, Selected = "N" }).ToArray();
tableNameGv.DataSource = sysTables;
}
public SysTableSchemaViewEntity[] GetDataSource()
{
sysTableField = (DataTable)fieldNameGv.DataSource;
return DataTableConvertor.ConvertToList<SysTableSchemaViewEntity>(sysTableField).Where(x => x.Operation == 0).ToArray();
}
private void tableNameGv_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0) return;
if (e.ColumnIndex != selectedCol.Index) return;
if (tableNameGv.CurrentRow.Cells[tableNameCol.Name].Value == System.DBNull.Value) return;
foreach (DataGridViewRow dgrow in tableNameGv.Rows)
{
if (tableNameGv.CurrentRow.Cells[tableNameCol.Name].EditedFormattedValue == dgrow.Cells[tableNameCol.Name].EditedFormattedValue) continue;
dgrow.Cells[selectedCol.Name].Value = "N";
}
sysTableFields = sysTableSchemas.Where(x => x.TableName == (string)tableNameGv.CurrentRow.Cells[tableNameCol.Name].Value).ToArray();
sysTableField = DataTableConvertor.ToDataTable<SysTableSchemaViewEntity>(sysTableFields);
fieldNameGv.DataSource = sysTableField;
SetDataGrivViewCellColor((string)tableNameGv.CurrentRow.Cells[tableNameCol.Name].Value);
}
private void SetDataGrivViewCellColor(string tableName)
{
ConfigUserControl configUserControl = service.ServiceProvider.GetKeyedService<ConfigUserControl>("ConfigUserControl");
NamespaceObject namespaceObject = configUserControl.toolInitConfig.NamespaceObjects.Where(x => x.Assembly == configUserControl.toolInitConfig.CurrentAssembly
&& x.TemplateType == "Entity").FirstOrDefault();
if (namespaceObject == null) return;
string path = Path.Combine(namespaceObject.OutFilePath, tableName.StringToProerty() + namespaceObject.FileNameSuffix);
//目录先处理对比Entity.cs
if (string.IsNullOrEmpty(path)) return;
if (!File.Exists(path)) return;
List<SysTableSchemaViewEntity> ents = new List<SysTableSchemaViewEntity>();
string[] lines = File.ReadAllLines(path);
SysTableSchemaViewEntity ent;
bool key = false;
foreach (string l in lines)
{
if (l.Contains("[Key]"))
{
key = true;
continue;
}
if (!l.Contains("[Column")) continue;
ent = new SysTableSchemaViewEntity();
ent.TableName = tableName;
ent.FieldName = l.Split('"')[1];//.Replace("[Column(\"", "").Replace("\")]", "").Trim();
if (key) ent.Pk = 1;
ents.Add(ent);
key = false;
}
if (ents == null || ents.Count == 0) return;
string fileName = null;
foreach (DataGridViewRow row in fieldNameGv.Rows)
{
row.DefaultCellStyle.BackColor = Color.White;
fileName = (string)row.Cells[fieldNameCol.Index].Value;
if (string.IsNullOrEmpty(fileName)) continue;
ent = ents.Where(x => x.FieldName == fileName).FirstOrDefault();
if (ent == null)
{
row.DefaultCellStyle.BackColor = Color.Pink;
row.Cells[operationCol.Index].Value = 1;
}
else
{
if (ent.Pk > 0 && Convert.ToInt32(row.Cells[pkCol.Index].Value) == 0)
{
row.DefaultCellStyle.BackColor = Color.Red;
}
}
}
}
private void dtSearchBut_Click(object sender, EventArgs e)
{
if (sysTableSchemas == null) return;
var sysTable = DataTableConvertor.ToDataTable<SysTable>(sysTables.Where(x => x.TableName.Contains(dtTxt.Text.ToLower().Trim())).ToArray());
tableNameGv.DataSource = sysTable;
}
private void dtResetBut_Click(object sender, EventArgs e)
{
if (sysTableSchemas == null) return;
var sysTable = DataTableConvertor.ToDataTable<SysTable>(sysTables);
tableNameGv.DataSource = sysTable;
}
private void fieldSearchBut_Click(object sender, EventArgs e)
{
if (sysTableSchemas == null) return;
if (sysTableField == null) return;
sysTableFields = sysTableSchemas.Where(x => x.TableName == (string)tableNameGv.CurrentRow.Cells[tableNameCol.Name].Value
&& x.FieldName.StartsWith(fieldTxt.Text.ToLower().Trim())).ToArray();
sysTableField = DataTableConvertor.ToDataTable<SysTableSchemaViewEntity>(sysTableFields);
fieldNameGv.DataSource = sysTableField;
}
private void fieldResetBut_Click(object sender, EventArgs e)
{
if (sysTableSchemas == null) return;
if (sysTableField == null) return;
sysTableField.Rows.Clear();
sysTableFields = sysTableSchemas.Where(x => x.TableName == (string)tableNameGv.CurrentRow.Cells[tableNameCol.Name].Value).ToArray();
sysTableField = DataTableConvertor.ToDataTable<SysTableSchemaViewEntity>(sysTableFields);
fieldNameGv.DataSource = sysTableField;
}
}
}
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="selectedCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="pkCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="operationCol.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>
+168
View File
@@ -0,0 +1,168 @@
namespace CloudBuilder.CodeGenerator
{
partial class TemplateUserControl
{
/// <summary>
/// 設計工具所需的變數。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清除任何使用中的資源。
/// </summary>
/// <param name="disposing">如果應該處置受控資源則為 true,否則為 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region 元件設計工具產生的程式碼
/// <summary>
/// 此為設計工具支援所需的方法 - 請勿使用程式碼編輯器修改
/// 這個方法的內容。
/// </summary>
private void InitializeComponent()
{
tableLayoutPanel1 = new TableLayoutPanel();
kryptonHeader1 = new Krypton.Toolkit.KryptonHeader();
tableLayoutPanel2 = new TableLayoutPanel();
templatePathBut = new Krypton.Toolkit.KryptonButton();
templatePathTxt = new Krypton.Toolkit.KryptonTextBox();
kryptonLabel1 = new Krypton.Toolkit.KryptonLabel();
contextTxt = new Krypton.Toolkit.KryptonRichTextBox();
saveFileBut = new Krypton.Toolkit.KryptonButton();
tableLayoutPanel1.SuspendLayout();
tableLayoutPanel2.SuspendLayout();
SuspendLayout();
//
// tableLayoutPanel1
//
tableLayoutPanel1.ColumnCount = 1;
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel1.Controls.Add(kryptonHeader1, 0, 0);
tableLayoutPanel1.Controls.Add(tableLayoutPanel2, 0, 1);
tableLayoutPanel1.Controls.Add(contextTxt, 0, 2);
tableLayoutPanel1.Dock = DockStyle.Fill;
tableLayoutPanel1.Location = new Point(0, 0);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 3;
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 35F));
tableLayoutPanel1.RowStyles.Add(new RowStyle());
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutPanel1.Size = new Size(800, 600);
tableLayoutPanel1.TabIndex = 0;
//
// kryptonHeader1
//
tableLayoutPanel1.SetColumnSpan(kryptonHeader1, 4);
kryptonHeader1.Dock = DockStyle.Fill;
kryptonHeader1.Location = new Point(4, 4);
kryptonHeader1.Margin = new Padding(4);
kryptonHeader1.Name = "kryptonHeader1";
kryptonHeader1.Size = new Size(792, 27);
kryptonHeader1.TabIndex = 13;
kryptonHeader1.Values.Description = "";
kryptonHeader1.Values.Heading = "模板加載";
kryptonHeader1.Values.Image = null;
//
// tableLayoutPanel2
//
tableLayoutPanel2.AutoSize = true;
tableLayoutPanel2.AutoSizeMode = AutoSizeMode.GrowAndShrink;
tableLayoutPanel2.ColumnCount = 4;
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle());
tableLayoutPanel2.Controls.Add(templatePathBut, 0, 0);
tableLayoutPanel2.Controls.Add(templatePathTxt, 0, 0);
tableLayoutPanel2.Controls.Add(kryptonLabel1, 0, 0);
tableLayoutPanel2.Controls.Add(saveFileBut, 3, 0);
tableLayoutPanel2.Dock = DockStyle.Fill;
tableLayoutPanel2.Location = new Point(3, 38);
tableLayoutPanel2.Name = "tableLayoutPanel2";
tableLayoutPanel2.RowCount = 1;
tableLayoutPanel2.RowStyles.Add(new RowStyle());
tableLayoutPanel2.Size = new Size(794, 31);
tableLayoutPanel2.TabIndex = 14;
//
// templatePathBut
//
templatePathBut.AutoSize = true;
templatePathBut.Location = new Point(646, 4);
templatePathBut.Margin = new Padding(4);
templatePathBut.Name = "templatePathBut";
templatePathBut.Size = new Size(76, 22);
templatePathBut.TabIndex = 6;
templatePathBut.Values.Text = "选择文件(...)";
templatePathBut.Click += templatePathBut_Click;
//
// templatePathTxt
//
templatePathTxt.Dock = DockStyle.Fill;
templatePathTxt.Location = new Point(87, 4);
templatePathTxt.Margin = new Padding(4);
templatePathTxt.Name = "templatePathTxt";
templatePathTxt.Size = new Size(551, 23);
templatePathTxt.TabIndex = 5;
//
// kryptonLabel1
//
kryptonLabel1.Location = new Point(4, 6);
kryptonLabel1.Margin = new Padding(4, 6, 4, 4);
kryptonLabel1.Name = "kryptonLabel1";
kryptonLabel1.Size = new Size(75, 20);
kryptonLabel1.TabIndex = 1;
kryptonLabel1.Values.Text = "模板路径:";
//
// contextTxt
//
contextTxt.Dock = DockStyle.Fill;
contextTxt.Location = new Point(3, 75);
contextTxt.Name = "contextTxt";
contextTxt.Size = new Size(794, 522);
contextTxt.TabIndex = 15;
contextTxt.Text = "";
//
// saveFileBut
//
saveFileBut.AutoSize = true;
saveFileBut.Location = new Point(730, 4);
saveFileBut.Margin = new Padding(4);
saveFileBut.Name = "saveFileBut";
saveFileBut.Size = new Size(60, 22);
saveFileBut.TabIndex = 6;
saveFileBut.Values.Text = "保存文件";
saveFileBut.Click += saveFileBut_Click;
//
// TemplateUserControl
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(tableLayoutPanel1);
Name = "TemplateUserControl";
Size = new Size(800, 600);
tableLayoutPanel1.ResumeLayout(false);
tableLayoutPanel1.PerformLayout();
tableLayoutPanel2.ResumeLayout(false);
tableLayoutPanel2.PerformLayout();
ResumeLayout(false);
}
#endregion
private TableLayoutPanel tableLayoutPanel1;
private Krypton.Toolkit.KryptonHeader kryptonHeader1;
private TableLayoutPanel tableLayoutPanel2;
private Krypton.Toolkit.KryptonLabel kryptonLabel1;
private Krypton.Toolkit.KryptonTextBox templatePathTxt;
private Krypton.Toolkit.KryptonButton templatePathBut;
public Krypton.Toolkit.KryptonRichTextBox contextTxt;
private Krypton.Toolkit.KryptonButton saveFileBut;
}
}
@@ -0,0 +1,37 @@
using CloudBuilder.Core.DependencyInjection.Form;
using Microsoft.AspNetCore.Routing.Template;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CloudBuilder.CodeGenerator
{
public partial class TemplateUserControl : UserControl, IUserControl
{
public TemplateUserControl()
{
InitializeComponent();
}
private void templatePathBut_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (DialogResult.OK == ofd.ShowDialog())
{
templatePathTxt.Text = ofd.FileName;
contextTxt.Text = File.ReadAllText(ofd.FileName);
}
}
private void saveFileBut_Click(object sender, EventArgs e)
{
File.WriteAllText(templatePathTxt.Text, contextTxt.Text);
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,302 @@
using CloudBuilder.CodeGenerator.Config;
using CloudBuilder.CodeGenerator.Data;
using CloudBuilder.Core.Application.Builders;
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Core.Extensions;
using CloudBuilder.Core.Service;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using RazorEngineCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace CloudBuilder.CodeGenerator.Utility
{
public class RazorEngineHelper
{
public static string CompiledTemplate(string template, ModelData model)
{
ToolInitConfig toolInitConfig = ToolInitConfig.GetInstance();
IRazorEngine razorEngine = new RazorEngine();
List<string> args = new List<string>();
if (toolInitConfig.AssemblyReferences != null)
{
foreach (var reference in toolInitConfig.AssemblyReferences)
{
if (string.IsNullOrEmpty(reference.AssemblyFileName)) continue;
if (!File.Exists(reference.AssemblyFileName)) continue;
args.Add(reference.AssemblyFileName);
}
}
template = toolInitConfig.Using + template;
try
{
IRazorEngineCompiledTemplate compiledTemplate = razorEngine.Compile(template, builder =>
{
//builder.AddAssemblyReferenceByName("System.Security"); // by name
foreach (string arg in args)
{
builder.AddAssemblyReference(Assembly.LoadFrom(arg));
}
Assembly[] assemblies = CloudBuilderBuilder.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
builder.AddAssemblyReference(assembly);
}
builder.AddAssemblyReference(typeof(System.IO.File)); // by type
//builder.AddAssemblyReference(Assembly.Load("source")); // by reference
});
return compiledTemplate.Run(model);
}
catch (Exception ex)
{
throw ex;
}
return null;
}
public static ClassInfo[] PackIServiceClassInfo(Assembly assembly)
{
if (assembly == null) return null;
var baseServiceType = typeof(IService);
var typeServices = assembly.GetTypes()
.Where(type => type != baseServiceType && type.HasImplementedRawGeneric(baseServiceType))
.Where(x => x.IsClass).ToList();
List<ClassInfo> classInfos = new List<ClassInfo>();
List<string> usings = new List<string>();
foreach (var implementType in typeServices)
{
ClassInfo classInfo = new ClassInfo();
classInfo.ClassName = implementType.Name;
classInfo.InterfaceName = implementType.GetInterfaces().FirstOrDefault().Name;
if (!usings.Contains(implementType.GetInterfaces().FirstOrDefault().Namespace))
{
usings.Add(implementType.GetInterfaces().FirstOrDefault().Namespace);
}
var tors = implementType.GetConstructors();
ClassConstructorInfo constructorInfo = new ClassConstructorInfo();
List<MethodParameter> parameters = new List<MethodParameter>();
foreach (var item in tors)
{
ParameterInfo[] Parameters = item.GetParameters();
MethodParameter methodParameter;
foreach (var pi in Parameters)
{
methodParameter = new MethodParameter();
methodParameter.ParameterName = pi.Name;
methodParameter.ParameterTypeName = pi.ParameterType.Name;
if (!usings.Contains(pi.ParameterType.Namespace))
{
usings.Add(pi.ParameterType.Namespace);
}
parameters.Add(methodParameter);
}
}
constructorInfo.Parameters = parameters.ToArray();
classInfo.ClassConstructorInfos = new ClassConstructorInfo[] { constructorInfo };
List<ClassMethodInfo> classMethodInfos = new List<ClassMethodInfo>();
ClassMethodInfo classMethodInfo;
MethodInfo[] infos = implementType.GetMethods();
foreach (var item in infos)
{
var permissionOperate = item.GetCustomAttribute<PermissionOperateAttribute>();
var allowAnonymous = item.GetCustomAttribute<AllowAnonymousAttribute>();
if (permissionOperate == null && allowAnonymous == null) continue;
classMethodInfo = new ClassMethodInfo();
classMethodInfo.MethodName = item.Name;
var httpGet = item.GetCustomAttribute<HttpGetAttribute>();
if (httpGet != null) classMethodInfo.HttpName = "[HttpGet]";
if (permissionOperate != null)
{
classMethodInfo.AuthorizeName = null;
classMethodInfo.PermissionOperateAttribute = permissionOperate;
}
else
{
classMethodInfo.PermissionOperate = null;
}
var unitOfWork = item.GetCustomAttribute<UnitOfWorkAttribute>();
if (unitOfWork == null) classMethodInfo.UnitOfWorkName = null;
classMethodInfo.MethodReturnName = item.ReturnType.Name;
bool isValueType = MethodParameter.CheckValueType(item.ReturnType);
classMethodInfo.IsValueType = isValueType;
if (!isValueType && !usings.Contains(item.ReturnType.Namespace))
{
usings.Add(item.ReturnType.Namespace);
}
classMethodInfo.MethodReturnName = classMethodInfo.MethodReturnName == "Object" ? "dynamic" : classMethodInfo.MethodReturnName;
ParameterInfo[] methodParameters = item.GetParameters();
List<MethodParameter> methodParameterLs = new List<MethodParameter>();
MethodParameter methodParameter;
foreach (var pi in methodParameters)
{
methodParameter = new MethodParameter();
methodParameter.ParameterName = pi.Name;
methodParameter.ParameterTypeName = pi.ParameterType.Name;
if (!usings.Contains(pi.ParameterType.Namespace))
{
usings.Add(pi.ParameterType.Namespace);
}
methodParameter.IsValueType = MethodParameter.CheckValueType(pi.ParameterType);
if (methodParameter.IsValueType) methodParameter.ParameterTypeName = methodParameter.ParameterTypeName;
methodParameterLs.Add(methodParameter);
}
classMethodInfo.Parameters = methodParameterLs.ToArray();
classMethodInfos.Add(classMethodInfo);
}
classInfo.ClassMethodInfos = classMethodInfos.ToArray();
classInfo.Usings = usings.ToArray();
classInfos.Add(classInfo);
}
return classInfos.ToArray();
}
public static ClassInfo[] PackTypeScriptClassInfo(Assembly assembly)
{
var typeDatas = assembly.GetTypes()
.Where(x => x.GetCustomAttribute<TypeScriptAttribute>() != null)
.Where(x => x.IsClass).ToList();
List<ClassInfo> dataInfos = new List<ClassInfo>();
ClassInfo dataInfo;
List<ClassPropertyInfo> classPropertyInfos = new List<ClassPropertyInfo>();
ClassPropertyInfo classPropertyInfo;
List<string> baseTypes = new List<string>();
foreach (var implementType in typeDatas)
{
PackClassInfo(dataInfos, implementType);
}
return dataInfos.ToArray();
}
public static void PackClassInfo(List<ClassInfo> dataInfos, Type implementType)
{
ClassInfo dataInfo = new ClassInfo();
dataInfo.ClassName = implementType.Name;
if (implementType.BaseType != typeof(ViewEntityBase) &&
implementType.BaseType != typeof(object)
&& implementType.BaseType != null && !implementType.BaseType.Name.StartsWith("EntityBase"))
{
dataInfo.ImplementTypeName = implementType.BaseType.Name;
PackClassInfo(dataInfos, implementType.BaseType);
}
PropertyInfo[] properties = implementType.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance);
List<string> baseTypes = new List<string>();
List<ClassPropertyInfo> classPropertyInfos = new List<ClassPropertyInfo>();
ClassPropertyInfo classPropertyInfo;
ToolInitConfig toolInitConfig = ToolInitConfig.GetInstance();
foreach (var item in properties)
{
classPropertyInfo = new ClassPropertyInfo();
classPropertyInfo.PropertyName = item.Name;
Type type = item.PropertyType;
bool isContinue = false;
foreach (string exculdePropertyType in toolInitConfig.ExculdePropertyTypes)
{
if (item.PropertyType.Name.Contains(exculdePropertyType))
{
classPropertyInfo.PropertyTypeName = "any";
isContinue = true;
break;
}
}
if (isContinue)
{
classPropertyInfos.Add(classPropertyInfo);
continue;
}
if (item.PropertyType.BaseType != null && item.PropertyType.BaseType.Name == "Array")
{
string typeName = item.PropertyType.FullName.Replace("[]", string.Empty);
type = item.PropertyType.Assembly.GetType(typeName);
classPropertyInfo.IsValueType = MethodParameter.CheckValueType(type);
classPropertyInfo.PropertyTypeName = type.Name + "[]";
}
else if (item.PropertyType.Name == "List`1")
{
string typeName = item.PropertyType.FullName.Replace("[[", "|").Replace(",", "|").Split('|')[1];
type = item.PropertyType.Assembly.GetType(typeName);
classPropertyInfo.IsValueType = MethodParameter.CheckValueType(type);
classPropertyInfo.PropertyTypeName = type.Name + "[]";
}
else
{
classPropertyInfo.IsValueType = MethodParameter.CheckValueType(item.PropertyType);
classPropertyInfo.PropertyTypeName = item.PropertyType.Name;
}
if (!classPropertyInfo.IsValueType)
{
if (!baseTypes.Contains(type.Name))
baseTypes.Add(type.Name);
PackClassInfo(dataInfos, type);
}
classPropertyInfos.Add(classPropertyInfo);
}
dataInfo.ClassProperties = classPropertyInfos.ToArray();
if (baseTypes.Count > 0)
dataInfo.Usings = baseTypes.ToArray();
FieldInfo[] fields = implementType.GetFields();
List<ClassFieldInfo> fieldInfos = new List<ClassFieldInfo>();
ClassFieldInfo classFieldInfo;
foreach (var item in fields)
{
if (!item.IsStatic) continue;
bool IsValueType = MethodParameter.CheckValueType(item.FieldType);
if (!IsValueType) continue;
classFieldInfo = new ClassFieldInfo();
classFieldInfo.IsValueType = IsValueType;
classFieldInfo.FieldName = item.Name;
classFieldInfo.FieldTypeName = item.FieldType.Name;
classFieldInfo.FieldValue = Convert.ToString(item.GetValue(null));
fieldInfos.Add(classFieldInfo);
}
dataInfo.ClassFields = fieldInfos.ToArray();
dataInfos.Add(dataInfo);
}
}
}
@@ -0,0 +1,23 @@
{
"CloudBuilder": {
"DbContexts": {
"MasterDbContext": {
"DbContextTypeName": "MasterDbContext",
"ConnectionString": "Server=localhost\\SQLEXPRESS;Database=Furion_dev;User=sa;Password=owen123456;MultipleActiveResultSets=True;TrustServerCertificate=true",
"DatabaseType": "SqlServer",
"LazyLoadingProxiesEnabled": true,
"AuditEntityEnabled": true,
"AutoMigrationEnabled": true
},
"SecondaryDbContext": {
"DbContextTypeName": "SecondaryDbContext",
"ConnectionString": "Server=localhost\\SQLEXPRESS;Database=Furion_dev;User=sa;Password=owen123456;MultipleActiveResultSets=True;TrustServerCertificate=true",
"DatabaseType": "SqlServer",
"LazyLoadingProxiesEnabled": true,
"AuditEntityEnabled": true,
"AutoMigrationEnabled": true
}
}
},
"AllowedHosts": "*"
}
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.37111.16 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeGenerator", "CodeGenerator\CodeGenerator.csproj", "{98461068-4E23-136C-C53A-83F0DF4A6EFD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{98461068-4E23-136C-C53A-83F0DF4A6EFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{98461068-4E23-136C-C53A-83F0DF4A6EFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{98461068-4E23-136C-C53A-83F0DF4A6EFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98461068-4E23-136C-C53A-83F0DF4A6EFD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B758090B-1A94-4803-9CDC-A3A611F46C11}
EndGlobalSection
EndGlobal
Binary file not shown.
Binary file not shown.
+50
View File
@@ -0,0 +1,50 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Remove="Config\tool-init-config.xml" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Config\tool-init-config.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.VisualStudio.OLE.Interop" Version="17.8.37221" />
<PackageReference Include="RazorEngineCore" Version="2023.11.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="CloudBuilder.CodeGenerator">
<HintPath>..\CloudBuilder.CodeGenerator\bin\Debug\net8.0-windows\CloudBuilder.CodeGenerator.dll</HintPath>
</Reference>
<Reference Include="CloudBuilder.Core">
<HintPath>..\Lib\CloudBuilder.Core.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
+300
View File
@@ -0,0 +1,300 @@
<?xml version="1.0" encoding="utf-8"?>
<ToolInitConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<TemplatePath>D:\NET8\Templates</TemplatePath>
<CurrentAssembly>CloudBuilder.Hr</CurrentAssembly>
<Using>@using CloudBuilder.CodeGenerator.Config;
@using CloudBuilder.CodeGenerator.Data;
@using CloudBuilder.CodeGenerator.Entity;
@using CloudBuilder.Core.Application.Builders;
@using CloudBuilder.Core.DatabaseAccessor.Entity;
@using CloudBuilder.Core.DependencyInjection.Form;
@using CloudBuilder.Core.Extensions;
@using CloudBuilder.Core.Utility;
@using Microsoft.Extensions.DependencyInjection;
@using System.Data;
@using System;
@using System.Reflection;</Using>
<NamespaceObjects>
<NamespaceObject>
<TemplateType>Request</TemplateType>
<TemplateFileName>Request.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Request\Security</OutFilePath>
<Assembly>CloudBuilder.Request</Assembly>
<Namespace>CloudBuilder.Request.Security</Namespace>
<FileNameSuffix>Request.auto.cs</FileNameSuffix>
<FileNamePrefix />
</NamespaceObject>
<NamespaceObject>
<TemplateType>Request</TemplateType>
<TemplateFileName>Request.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Request\Master</OutFilePath>
<Assembly>CloudBuilder.Request</Assembly>
<Namespace>CloudBuilder.Request.Master</Namespace>
<FileNameSuffix>Request.auto.cs</FileNameSuffix>
<FileNamePrefix />
</NamespaceObject>
<NamespaceObject>
<TemplateType>Request</TemplateType>
<TemplateFileName>Request.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Request\Hr</OutFilePath>
<Assembly>CloudBuilder.Request</Assembly>
<Namespace>CloudBuilder.Request.Hr</Namespace>
<FileNameSuffix>Request.auto.cs</FileNameSuffix>
<FileNamePrefix />
</NamespaceObject>
<NamespaceObject>
<TemplateType>Entity</TemplateType>
<TemplateFileName>IEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master\Entity</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>Entity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IEntityKey</TemplateType>
<TemplateFileName>IEntityKey.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master\Entity</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>EntityKey.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IService</TemplateType>
<TemplateFileName>IService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master\Service</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
<FileNamePrefix>I</FileNamePrefix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Permission</TemplateType>
<TemplateFileName>Permission.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master\Policy</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>PermissionPolicy.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>RegistEntity</TemplateType>
<TemplateFileName>RegistEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master\Entity</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>RegistEntity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>SearchCriteria</TemplateType>
<TemplateFileName>SearchCriteria.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master\SearchCriteria</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>SearchCriteria.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Service</TemplateType>
<TemplateFileName>Service.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Master.Service</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScript</TemplateType>
<TemplateFileName>TypeScript.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\data\auto</OutFilePath>
<Assembly>CloudBuilder.Master</Assembly>
<Namespace>CloudBuilder.Master</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Controller</TemplateType>
<TemplateFileName>Controller.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Web.Entry\Controllers\Master</OutFilePath>
<Assembly>CloudBuilder.Master.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Master</Namespace>
<FileNameSuffix>Controller.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScriptService</TemplateType>
<TemplateFileName>TypeScriptService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\service\master</OutFilePath>
<Assembly>CloudBuilder.Master.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Master</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Entity</TemplateType>
<TemplateFileName>IEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security\Entity</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>Entity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IEntityKey</TemplateType>
<TemplateFileName>IEntityKey.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security\Entity</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>EntityKey.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IService</TemplateType>
<TemplateFileName>IService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security\Service</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
<FileNamePrefix>I</FileNamePrefix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Permission</TemplateType>
<TemplateFileName>Permission.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security\Policy</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>PermissionPolicy.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>RegistEntity</TemplateType>
<TemplateFileName>RegistEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security\Entity</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>RegistEntity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>SearchCriteria</TemplateType>
<TemplateFileName>SearchCriteria.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security\SearchCriteria</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>SearchCriteria.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Service</TemplateType>
<TemplateFileName>Service.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Security.Service</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScript</TemplateType>
<TemplateFileName>TypeScript.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\data\auto</OutFilePath>
<Assembly>CloudBuilder.Security</Assembly>
<Namespace>CloudBuilder.Security</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Controller</TemplateType>
<TemplateFileName>Controller.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Web.Entry\Controllers\Security</OutFilePath>
<Assembly>CloudBuilder.Security.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Security</Namespace>
<FileNameSuffix>Controller.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScriptService</TemplateType>
<TemplateFileName>TypeScriptService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\service\security</OutFilePath>
<Assembly>CloudBuilder.Security.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Security</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Entity</TemplateType>
<TemplateFileName>IEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr\Entity</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>Entity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IEntityKey</TemplateType>
<TemplateFileName>IEntityKey.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr\Entity</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>EntityKey.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>IService</TemplateType>
<TemplateFileName>IService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr\Service</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
<FileNamePrefix>I</FileNamePrefix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Permission</TemplateType>
<TemplateFileName>Permission.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr\Policy</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>PermissionPolicy.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>RegistEntity</TemplateType>
<TemplateFileName>RegistEntity.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr\Entity</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>RegistEntity.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>SearchCriteria</TemplateType>
<TemplateFileName>SearchCriteria.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr\SearchCriteria</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>SearchCriteria.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Service</TemplateType>
<TemplateFileName>Service.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Hr.Service</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>Service.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScript</TemplateType>
<TemplateFileName>TypeScript.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\data\auto</OutFilePath>
<Assembly>CloudBuilder.Hr</Assembly>
<Namespace>CloudBuilder.Hr</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>Controller</TemplateType>
<TemplateFileName>Controller.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\CloudBuilder\CloudBuilder.Web.Entry\Controllers\Hr</OutFilePath>
<Assembly>CloudBuilder.Hr.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Hr</Namespace>
<FileNameSuffix>Controller.auto.cs</FileNameSuffix>
</NamespaceObject>
<NamespaceObject>
<TemplateType>TypeScriptService</TemplateType>
<TemplateFileName>TypeScriptService.cshtml</TemplateFileName>
<OutFilePath>D:\NET8\Webmaster\src\service\hr</OutFilePath>
<Assembly>CloudBuilder.Hr.Service</Assembly>
<Namespace>CloudBuilder.Web.Entry.Controllers.Hr</Namespace>
<FileNameSuffix>.ts</FileNameSuffix>
</NamespaceObject>
</NamespaceObjects>
<AssemblyReferences>
<AssemblyReference>
<AssemblyFileName>D:\NET8\CloudBuilder\CloudBuilder.Security.Service\bin\Debug\net8.0\CloudBuilder.Security.Service.dll</AssemblyFileName>
</AssemblyReference>
<AssemblyReference>
<AssemblyFileName>D:\NET8\CloudBuilder\CloudBuilder.Security\bin\Debug\net8.0\CloudBuilder.Security.dll</AssemblyFileName>
</AssemblyReference>
</AssemblyReferences>
<ExculdePropertyTypes>
<string>Dictionary</string>
</ExculdePropertyTypes>
</ToolInitConfig>
+180
View File
@@ -0,0 +1,180 @@
// See https://aka.ms/new-console-template for more information
using CloudBuilder.CodeGenerator.Config;
using CloudBuilder.CodeGenerator.Data;
using CloudBuilder.CodeGenerator.Utility;
using CloudBuilder.Core.Application.Builders;
using CloudBuilder.Core.Authorization;
using CloudBuilder.Core.DatabaseAccessor;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Core.Extensions;
using CloudBuilder.Core.Service;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using RazorEngineCore;
using System.Diagnostics;
using System.Reflection;
using static System.Net.Mime.MediaTypeNames;
public partial class Program
{
static void Main(string[] args)
{
try
{
Assembly assembly = null;
if (args != null && args.Length > 0)
{
Console.WriteLine(args[0]);
assembly = Assembly.LoadFrom(args[0]);
}
if (assembly == null) return;
ModelData modelData = null;
ToolInitConfig toolInitConfig = ToolInitConfig.GetInstance();
string template = null;
string outputText = null;
string outputFileName = null;
string logFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log\\log.txt");
ClassInfo[] dataInfos = RazorEngineHelper.PackTypeScriptClassInfo(assembly);
foreach (var item in dataInfos)
{
modelData = new ModelData();
modelData.ClassInfo = item;
modelData.ClassInfos = new ClassInfo[] { item };
modelData.NamespaceObject = toolInitConfig.NamespaceObjects.Where(x => x.TemplateType == "TypeScript" && x.Assembly == Path.GetFileNameWithoutExtension(assembly.Location)).FirstOrDefault();
if (modelData.NamespaceObject == null) continue;
outputFileName = Path.Combine(modelData.NamespaceObject.OutFilePath, item.ClassName.StringToProtectedProerty() + modelData.NamespaceObject.FileNameSuffix);
if (string.IsNullOrEmpty(outputFileName)) continue;
template = File.ReadAllText(Path.Combine(toolInitConfig.TemplatePath, modelData.NamespaceObject.TemplateFileName));
if (string.IsNullOrEmpty(template)) continue;
outputText = RazorEngineHelper.CompiledTemplate(template, modelData);
if (string.IsNullOrEmpty(outputText)) continue;
if (!Directory.Exists(Path.GetDirectoryName(outputFileName))) Directory.CreateDirectory(Path.GetDirectoryName(outputFileName));
File.WriteAllText(outputFileName, outputText);
if (!Directory.Exists(Path.GetDirectoryName(logFileName))) Directory.CreateDirectory(Path.GetDirectoryName(logFileName));
using (StreamWriter w = File.AppendText(logFileName))
{
w.WriteLine($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}]Succeed:" + outputFileName);
}
}
template = null;
outputText = null;
outputFileName = null;
ClassInfo[] classInfos = RazorEngineHelper.PackIServiceClassInfo(assembly);
foreach (var item in classInfos)
{
//没有要生成公共方法的接口不处理
if (item.ClassMethodInfos.Length == 0) continue;
modelData = new ModelData();
modelData.ClassInfo = item;
if (item.ClassMethodInfos.Select(x => x.MethodName).Where(x => x.StartsWith("PrintBy")).Count() > 0)
{
modelData.ClassInfo.IsDownload = true;
}
modelData.ClassInfos = new ClassInfo[] { item };
modelData.NamespaceObject = toolInitConfig.NamespaceObjects.Where(x => x.TemplateType == "Controller" && x.Assembly == Path.GetFileNameWithoutExtension(assembly.Location)).FirstOrDefault();
if (modelData.NamespaceObject == null) continue;
outputFileName = Path.Combine(modelData.NamespaceObject.OutFilePath, item.ClassName.Replace("Service", "") + modelData.NamespaceObject.FileNameSuffix);
if (string.IsNullOrEmpty(outputFileName)) continue;
template = File.ReadAllText(Path.Combine(toolInitConfig.TemplatePath, modelData.NamespaceObject.TemplateFileName));
if (string.IsNullOrEmpty(template)) continue;
outputText = RazorEngineHelper.CompiledTemplate(template, modelData);
if (string.IsNullOrEmpty(outputText)) continue;
if (!Directory.Exists(Path.GetDirectoryName(outputFileName))) Directory.CreateDirectory(Path.GetDirectoryName(outputFileName));
File.WriteAllText(outputFileName, outputText);
if (!Directory.Exists(Path.GetDirectoryName(logFileName))) Directory.CreateDirectory(Path.GetDirectoryName(logFileName));
using (StreamWriter w = File.AppendText(logFileName))
{
w.WriteLine($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}]Succeed:" + outputFileName);
}
//================================CloudBuilder.Security.Service >.Security
modelData.NamespaceObject = toolInitConfig.NamespaceObjects.Where(x => x.TemplateType == "Request" &&
Path.GetFileNameWithoutExtension(assembly.Location).Contains(x.Namespace.Replace(x.Assembly, ""))).FirstOrDefault();
if (modelData.NamespaceObject == null) continue;
outputFileName = Path.Combine(modelData.NamespaceObject.OutFilePath, item.ClassName.Replace("Service", "") + modelData.NamespaceObject.FileNameSuffix);
if (string.IsNullOrEmpty(outputFileName)) continue;
template = File.ReadAllText(Path.Combine(toolInitConfig.TemplatePath, modelData.NamespaceObject.TemplateFileName));
if (string.IsNullOrEmpty(template)) continue;
outputText = RazorEngineHelper.CompiledTemplate(template, modelData);
if (string.IsNullOrEmpty(outputText)) continue;
if (!Directory.Exists(Path.GetDirectoryName(outputFileName))) Directory.CreateDirectory(Path.GetDirectoryName(outputFileName));
File.WriteAllText(outputFileName, outputText);
if (!Directory.Exists(Path.GetDirectoryName(logFileName))) Directory.CreateDirectory(Path.GetDirectoryName(logFileName));
using (StreamWriter w = File.AppendText(logFileName))
{
w.WriteLine($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}]Succeed:" + outputFileName);
}
//================================
modelData.NamespaceObject = toolInitConfig.NamespaceObjects.Where(x => x.TemplateType == "TypeScriptService" && x.Assembly == Path.GetFileNameWithoutExtension(assembly.Location)).FirstOrDefault();
if (modelData.NamespaceObject == null) continue;
outputFileName = Path.Combine(modelData.NamespaceObject.OutFilePath, item.ClassName.StringToProtectedProerty() + modelData.NamespaceObject.FileNameSuffix);
if (string.IsNullOrEmpty(outputFileName)) continue;
template = File.ReadAllText(Path.Combine(toolInitConfig.TemplatePath, modelData.NamespaceObject.TemplateFileName));
if (string.IsNullOrEmpty(template)) continue;
outputText = RazorEngineHelper.CompiledTemplate(template, modelData);
if (string.IsNullOrEmpty(outputText)) continue;
if (!Directory.Exists(Path.GetDirectoryName(outputFileName))) Directory.CreateDirectory(Path.GetDirectoryName(outputFileName));
File.WriteAllText(outputFileName, outputText);
if (!Directory.Exists(Path.GetDirectoryName(logFileName))) Directory.CreateDirectory(Path.GetDirectoryName(logFileName));
using (StreamWriter w = File.AppendText(logFileName))
{
w.WriteLine($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}]Succeed:" + outputFileName);
}
}
}
catch (Exception ex)
{
string logFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log\\log.txt");
if (!Directory.Exists(Path.GetDirectoryName(logFileName))) Directory.CreateDirectory(Path.GetDirectoryName(logFileName));
using (StreamWriter w = File.AppendText(logFileName))
{
w.WriteLine($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}]Exception:" + ex.Message);
}
}
}
}
@@ -0,0 +1,8 @@
{
"profiles": {
"CodeGenerator": {
"commandName": "Project",
"commandLineArgs": "D:\\NET8\\CloudBuilder\\CloudBuilder.Security.Service\\bin\\Debug\\net8.0\\CloudBuilder.Security.Service.dll"
}
}
}
+83
View File
@@ -0,0 +1,83 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"CloudBuilder": {
"DbContexts": {
"MasterDbContext": {
"DbContextTypeName": "MasterDbContext",
"ConnectionString": "Server=localhost\\SQLEXPRESS;Database=Furion;User=sa;Password=owen123456;MultipleActiveResultSets=True;TrustServerCertificate=true",
"DatabaseType": "SqlServer",
"LazyLoadingProxiesEnabled": true,
"AuditEntityEnabled": true,
"AutoMigrationEnabled": true
},
"SecondaryDbContext": {
"DbContextTypeName": "SecondaryDbContext",
"ConnectionString": "Server=localhost\\SQLEXPRESS;Database=Furion_dev;User=sa;Password=owen123456;MultipleActiveResultSets=True;TrustServerCertificate=true",
"DatabaseType": "SqlServer",
"LazyLoadingProxiesEnabled": true,
"AuditEntityEnabled": true,
"AutoMigrationEnabled": true
}
},
"MailSender": {
"Host": "smtp.mxhichina.com",
"Port": 587,
"EnableSsl": true,
"DisplayName": "OSharp邮件发送",
"UserName": "osharpsender@66soft.net",
"Password": "OSharp147963"
},
"Jwt": {
"Issuer": "Cloud Builder identity",
"Audience": "Cloud Builder",
"Secret": "{8619F7C3-B53C-4B85-99F0-983D351ECD82}",
"AccessExpireMins": 1440, //1天过期
"RefreshExpireMins": 10080, // 7天
"IsRefreshAbsoluteExpired": false
},
"Redis": {
"Configuration": "localhost",
"InstanceName": "CloudBuilder:"
}
},
"IpRateLimiting": {
"EnableEndpointRateLimiting": true, //False: globally executed, true: executed for each
"StackBlockedRequests": false, //False: Number of rejections should be recorded on another counter
"RealIpHeader": "X-Real-IP",
"ClientIdHeader": "X-ClientId",
"IpWhitelist": [], //白名单
"EndpointWhitelist": [],
"ClientWhitelist": [],
"HttpStatusCode": 200,
"QuotaExceededResponse": {
"Content": "{{\"code\":429,\"msg\":\"访问过于频繁,请稍后重试\",\"data\":null}}",
"ContentType": "application/json",
"StatusCode": 200
},
"GeneralRules": [
{
"Endpoint": "*",
"Period": "1s",
"Limit": 5
},
{
"Endpoint": "*",
"Period": "1m",
"Limit": 50
},
{
"Endpoint": "*",
"Period": "12h",
"Limit": 500
}
]
},
"AllowedHosts": "*"
}
Binary file not shown.