Skip to content

Commit

Permalink
Merge pull request #64 from beginor/smartcode_master
Browse files Browse the repository at this point in the history
dotnet 6.0.0
  • Loading branch information
Ahoo-Wang authored Jan 11, 2022
2 parents 81c7c0c + 256cfb6 commit 2233bd7
Show file tree
Hide file tree
Showing 35 changed files with 234 additions and 459 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

Expand Down Expand Up @@ -317,7 +317,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/

# MSBuild Binary and Structured Log
Expand All @@ -326,7 +326,8 @@ ASALocalRun/
# NVidia Nsight GPU debugger configuration file
*.nvuser

# MFractors (Xamarin productivity tool) working folder
# MFractors (Xamarin productivity tool) working folder
.mfractor/
/.vscode/tasks.json
/.vscode/launch.json
.DS_Store
4 changes: 2 additions & 2 deletions README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Build:
| Author | Author |
| DataSource | Data Source |
| Language | Language: CSharp/Java/.... |
| TemplateEngine | Template Engine: Currently Built: Razor/Handlebars |
| TemplateEngine | Template Engine: Currently Built: Razor |
| Output | Output |
| Build | Task Build |

Expand Down Expand Up @@ -358,4 +358,4 @@ Build:
,{Column: Deleted,Mapping: deleted}]
PreCommand:
PostCommand:
```
```
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Build:
| Author | 作者 |
| DataSource | 数据源 |
| Language | 语言:CSharp/Java/.... |
| TemplateEngine | 模板引擎:目前内置:Razor/Handlebars |
| TemplateEngine | 模板引擎:目前内置:Razor |
| Output | 输出 |
| Build | 任务构建s |

Expand Down Expand Up @@ -368,4 +368,4 @@ Build:
,{Column: Deleted,Mapping: deleted}]
PreCommand:
PostCommand:
```
```
1 change: 1 addition & 0 deletions doc/SmartCode-TypeScript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Build:
Type: Table
Module: Data
TemplateEngine:
Name: RazorCore
Path: Model.cshtml
Output:
Path: '{{Items.CurrentTable.Name}}/services'
Expand Down
8 changes: 2 additions & 6 deletions doc/SmartCode.ETL-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ I believe that many students who have already landed the microservices architect
},
{
"Type": "SmartCode.TemplateEngine.ITemplateEngine,SmartCode.TemplateEngine",
"ImplType": "SmartCode.TemplateEngine.Impl.HandlebarsTemplateEngine,SmartCode.TemplateEngine"
},
{
"Type": "SmartCode.TemplateEngine.ITemplateEngine,SmartCode.TemplateEngine",
"ImplType": "SmartCode.TemplateEngine.Impl.OfficialRazorTemplateEngine,SmartCode.TemplateEngine"
"ImplType": "SmartCode.TemplateEngine.Impl.RazorCoreTemplateEngine,SmartCode.TemplateEngine"
},
{
"Type": "SmartCode.Generator.IDbTypeConverter,SmartCode.Generator",
Expand Down Expand Up @@ -274,4 +270,4 @@ The following is the data loading performance, the amount of bulk insert data is
At present, SmartCode.ETL has been put into our production environment (2018-11-01 went online, as of 2018-11-16 16:50 executed 65520 synchronization tasks, no error log was thrown
)

> PS: Although SmartCode.ETL only took two days to complete the expansion on the weekend, it can already meet at least 90% of our application scenarios. This is enough to see how amazing the SmartCode expansion capabilities are. Of course, other capabilities of SmartCode have to be followed up and explored! ! !
> PS: Although SmartCode.ETL only took two days to complete the expansion on the weekend, it can already meet at least 90% of our application scenarios. This is enough to see how amazing the SmartCode expansion capabilities are. Of course, other capabilities of SmartCode have to be followed up and explored! ! !
8 changes: 2 additions & 6 deletions doc/SmartCode.ETL.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@
},
{
"Type": "SmartCode.TemplateEngine.ITemplateEngine,SmartCode.TemplateEngine",
"ImplType": "SmartCode.TemplateEngine.Impl.HandlebarsTemplateEngine,SmartCode.TemplateEngine"
},
{
"Type": "SmartCode.TemplateEngine.ITemplateEngine,SmartCode.TemplateEngine",
"ImplType": "SmartCode.TemplateEngine.Impl.OfficialRazorTemplateEngine,SmartCode.TemplateEngine"
"ImplType": "SmartCode.TemplateEngine.Impl.RazorCoreTemplateEngine,SmartCode.TemplateEngine"
},
{
"Type": "SmartCode.Generator.IDbTypeConverter,SmartCode.Generator",
Expand Down Expand Up @@ -274,4 +270,4 @@ LastMaxModifyTime 即上一次抽取的数据最大ModifyTime值(第一次抽取

目前 SmartCode.ETL 已经落地到我们的生产环境了(11-01上线截至 2018-11-16 16:50 执行了 65520 次同步任务,暂无error日志抛出)

> PS: 虽然 SmartCode.ETL 只花了周末俩天时间完成扩展,但已经可以满足我们至少90%的应用场景。这足以见得 SmartCode 扩展能力是多么令人意外了。当然SmartCode的其他能力还得后续等各位一起发掘!!!
> PS: 虽然 SmartCode.ETL 只花了周末俩天时间完成扩展,但已经可以满足我们至少90%的应用场景。这足以见得 SmartCode 扩展能力是多么令人意外了。当然SmartCode的其他能力还得后续等各位一起发掘!!!
10 changes: 3 additions & 7 deletions doc/common-problem.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ SmartCode 插件机制拥有非常灵活的扩展能力,SmartCode 中一切都
},
{
"Type": "SmartCode.TemplateEngine.ITemplateEngine,SmartCode.TemplateEngine",
"ImplType": "SmartCode.TemplateEngine.Impl.HandlebarsTemplateEngine,SmartCode.TemplateEngine"
},
{
"Type": "SmartCode.TemplateEngine.ITemplateEngine,SmartCode.TemplateEngine",
"ImplType": "SmartCode.TemplateEngine.Impl.OfficialRazorTemplateEngine,SmartCode.TemplateEngine"
"ImplType": "SmartCode.TemplateEngine.Impl.RazorCoreTemplateEngine,SmartCode.TemplateEngine"
},
{
"Type": "SmartCode.Generator.IDbTypeConverter,SmartCode.Generator",
Expand Down Expand Up @@ -111,9 +107,9 @@ SmartCode 插件机制拥有非常灵活的扩展能力,SmartCode 中一切都

## 如何自定义模板

目前SmartCode支持俩种模板引擎 **Razor** & **Handlebars**
目前SmartCode支持模板引擎 **Razor**
Razor 模板引擎使用的是官方版本,这一点上.NETer同学可以很轻松的自定义SmartCode模板,需要注意的是Razor模板的Model为BuildContext,具体方法可以参考源代码中的模板。编写完成之后放到RazorTemplates,构建时指定好即可。

## 代码生成器支持多少种数据库

SmartCode获取数据源结构使用的是[SmartSql](https://github.com/Ahoo-Wang/SmartSql),所以SmartCode支持所有ADO.NET驱动相关的数据库:MySql/PostgreSql/SqlServer/Oracle/SQLite 等
SmartCode获取数据源结构使用的是[SmartSql](https://github.com/Ahoo-Wang/SmartSql),所以SmartCode支持所有ADO.NET驱动相关的数据库:MySql/PostgreSql/SqlServer/Oracle/SQLite 等
6 changes: 3 additions & 3 deletions src/SmartCode.App/SmartCode.App.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Handlebars.Net" Version="1.10.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Handlebars.Net" Version="2.0.9" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SmartCode.ETL\SmartCode.ETL.csproj" />
Expand Down
23 changes: 22 additions & 1 deletion src/SmartCode.App/SmartCodeApp.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand All @@ -7,6 +8,7 @@
using System.IO;
using SmartCode.Configuration.ConfigBuilders;
using System.Reflection;
using System.Text;
using HandlebarsDotNet;
using SmartCode.ETL;
using SmartCode.Generator;
Expand Down Expand Up @@ -136,6 +138,25 @@ public string Encode(string value)
{
return value;
}

public void Encode(StringBuilder text, TextWriter target)
{
target.Write(text.ToString());
}

public void Encode(string text, TextWriter target)
{
target.Write(text);
}

public void Encode<T>(T text, TextWriter target) where T : IEnumerator<char>
{
while (text.MoveNext())
{
target.Write(text.Current);
}
}

}
}
}
}
12 changes: 6 additions & 6 deletions src/SmartCode.CLI/SmartCode.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<PackAsTool>true</PackAsTool>
<ToolCommandName>SmartCode</ToolCommandName>
Expand All @@ -14,11 +14,11 @@
</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.6.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 2 additions & 6 deletions src/SmartCode.CLI/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@
},
{
"Type": "SmartCode.TemplateEngine.ITemplateEngine,SmartCode.TemplateEngine",
"ImplType": "SmartCode.TemplateEngine.Impl.HandlebarsTemplateEngine,SmartCode.TemplateEngine"
},
{
"Type": "SmartCode.TemplateEngine.ITemplateEngine,SmartCode.TemplateEngine",
"ImplType": "SmartCode.TemplateEngine.Impl.OfficialRazorTemplateEngine,SmartCode.TemplateEngine"
"ImplType": "SmartCode.TemplateEngine.Impl.RazorCoreTemplateEngine,SmartCode.TemplateEngine"
},
{
"Type": "SmartCode.Generator.IDbTypeConverter,SmartCode.Generator",
Expand Down Expand Up @@ -100,7 +96,7 @@
"Type": "SmartCode.ETL.IETLTaskRepository,SmartCode.ETL",
"ImplType": "SmartCode.ETL.SQLite.SQLiteETLTaskRepository,SmartCode.ETL.SQLite",
"Parameters": {
//"ConnectionString": "Data Source=YOUR_DB_DIR\smartcode-etl.db;Version=3;"
// "ConnectionString": "Data Source=YOUR_DB_DIR\smartcode-etl.db;Version=3;"
}
}
]
Expand Down
18 changes: 9 additions & 9 deletions src/SmartCode.Db/SmartCode.Db.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SmartSql.Options" Version="4.1.50" />
<PackageReference Include="SmartSql.TypeHandler" Version="4.1.50" />
<PackageReference Include="SmartSql.TypeHandler.PostgreSql" Version="4.1.50" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
<PackageReference Include="System.Data.SQLite" Version="1.0.112" />
<PackageReference Include="MySql.Data" Version="8.0.19" />
<PackageReference Include="Npgsql" Version="4.1.3.1" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.19.60" />
<PackageReference Include="SmartSql.Options" Version="4.1.57" />
<PackageReference Include="SmartSql.TypeHandler" Version="4.1.57" />
<PackageReference Include="SmartSql.TypeHandler.PostgreSql" Version="4.1.57" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<PackageReference Include="System.Data.SQLite" Version="1.0.115.5" />
<PackageReference Include="MySql.Data" Version="8.0.27" />
<PackageReference Include="Npgsql" Version="6.0.0" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.4" />
</ItemGroup>

<ItemGroup>
Expand Down
17 changes: 8 additions & 9 deletions src/SmartCode.ETL.LoadToES/LoadToESBuildTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public async Task Build(BuildContext context)
if (colMapping.TryGetValue(itemKey, out string mapping))
{
itemKey = mapping;
}
}
}
newItem.Add(itemKey,item.Value);
}
Expand All @@ -90,16 +90,15 @@ public async Task Build(BuildContext context)
#endregion
#region BatchInsert
var esClient = GetElasticClient(esOptions);
var indexExResp = await esClient.IndexExistsAsync(esOptions.Index);
var indexExResp = await esClient.Indices.ExistsAsync(esOptions.Index);
if (!indexExResp.Exists)
{
var createIndexResp = await esClient.CreateIndexAsync(esOptions.Index);
var createIndexResp = await esClient.Indices.CreateAsync(esOptions.Index);
}
var esSyncResp = await esClient.BulkAsync((bulkRequest) =>
{
var bulkReqDesc = bulkRequest
.Index(esOptions.Index)
.Type(esOptions.TypeName);
var esSyncResp = await esClient.BulkAsync((bulkRequest) => {
var bulkReqDesc = bulkRequest
.Index(esOptions.Index);
// .Type(esOptions.TypeName);
if (context.Build.Parameters.Value(ID_MAPPING, out string es_id))
{
return bulkReqDesc.IndexMany(dataSource.TransformData, (bulkIdxDesc, item) =>
Expand Down Expand Up @@ -150,7 +149,7 @@ private IElasticClient GetElasticClient(ESOptions esOptions)
Uri node = new Uri(esOptions.Host);
ConnectionSettings settings = new ConnectionSettings(node);
settings.DefaultIndex(esOptions.Index);
settings.DefaultTypeName(esOptions.TypeName);
// settings.DefaultTypeName(esOptions.TypeName);
#region Auth
if (!String.IsNullOrEmpty(esOptions.UserName))
{
Expand Down
4 changes: 2 additions & 2 deletions src/SmartCode.ETL.LoadToES/SmartCode.ETL.LoadToES.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NEST" Version="6.4.1" />
<PackageReference Include="NEST" Version="7.15.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/SmartCode.ETL.SQLite/SmartCode.ETL.SQLite.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Data.SQLite" Version="1.0.112" />
<PackageReference Include="System.Data.SQLite" Version="1.0.115.5" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/SmartCode.ETL/SmartCode.ETL.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SmartSql.Bulk.MySql" Version="4.1.52" />
<PackageReference Include="SmartSql.Bulk.PostgreSql" Version="4.1.52" />
<PackageReference Include="SmartSql.Bulk.SqlServer" Version="4.1.52" />
<PackageReference Include="SmartSql.Bulk.MySql" Version="4.1.57" />
<PackageReference Include="SmartSql.Bulk.PostgreSql" Version="4.1.57" />
<PackageReference Include="SmartSql.Bulk.SqlServer" Version="4.1.57" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 2233bd7

Please sign in to comment.