Skip to content

Commit d39374c

Browse files
committed
fix build
1 parent 10b9787 commit d39374c

5 files changed

Lines changed: 39 additions & 21 deletions

File tree

‎src/SmartCode.App/SmartCodeApp.cs‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Diagnostics;
34
using Microsoft.Extensions.DependencyInjection;
45
using Microsoft.Extensions.Logging;
@@ -7,6 +8,7 @@
78
using System.IO;
89
using SmartCode.Configuration.ConfigBuilders;
910
using System.Reflection;
11+
using System.Text;
1012
using HandlebarsDotNet;
1113
using SmartCode.ETL;
1214
using SmartCode.Generator;
@@ -136,6 +138,25 @@ public string Encode(string value)
136138
{
137139
return value;
138140
}
141+
142+
public void Encode(StringBuilder text, TextWriter target)
143+
{
144+
target.Write(text.ToString());
145+
}
146+
147+
public void Encode(string text, TextWriter target)
148+
{
149+
target.Write(text);
150+
}
151+
152+
public void Encode<T>(T text, TextWriter target) where T : IEnumerator<char>
153+
{
154+
while (text.MoveNext())
155+
{
156+
target.Write(text.Current);
157+
}
158+
}
159+
139160
}
140161
}
141-
}
162+
}

‎src/SmartCode.ETL.LoadToES/LoadToESBuildTask.cs‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public async Task Build(BuildContext context)
8080
if (colMapping.TryGetValue(itemKey, out string mapping))
8181
{
8282
itemKey = mapping;
83-
}
83+
}
8484
}
8585
newItem.Add(itemKey,item.Value);
8686
}
@@ -90,16 +90,15 @@ public async Task Build(BuildContext context)
9090
#endregion
9191
#region BatchInsert
9292
var esClient = GetElasticClient(esOptions);
93-
var indexExResp = await esClient.IndexExistsAsync(esOptions.Index);
93+
var indexExResp = await esClient.Indices.ExistsAsync(esOptions.Index);
9494
if (!indexExResp.Exists)
9595
{
96-
var createIndexResp = await esClient.CreateIndexAsync(esOptions.Index);
96+
var createIndexResp = await esClient.Indices.CreateAsync(esOptions.Index);
9797
}
98-
var esSyncResp = await esClient.BulkAsync((bulkRequest) =>
99-
{
100-
var bulkReqDesc = bulkRequest
101-
.Index(esOptions.Index)
102-
.Type(esOptions.TypeName);
98+
var esSyncResp = await esClient.BulkAsync((bulkRequest) => {
99+
var bulkReqDesc = bulkRequest
100+
.Index(esOptions.Index);
101+
// .Type(esOptions.TypeName);
103102
if (context.Build.Parameters.Value(ID_MAPPING, out string es_id))
104103
{
105104
return bulkReqDesc.IndexMany(dataSource.TransformData, (bulkIdxDesc, item) =>
@@ -150,7 +149,7 @@ private IElasticClient GetElasticClient(ESOptions esOptions)
150149
Uri node = new Uri(esOptions.Host);
151150
ConnectionSettings settings = new ConnectionSettings(node);
152151
settings.DefaultIndex(esOptions.Index);
153-
settings.DefaultTypeName(esOptions.TypeName);
152+
// settings.DefaultTypeName(esOptions.TypeName);
154153
#region Auth
155154
if (!String.IsNullOrEmpty(esOptions.UserName))
156155
{

‎src/SmartCode.Generator/RazorTemplates/Sql/DbToMySql.cshtml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@using SmartCode
2-
@model BuildContext
2+
@inherits SmartCode.TemplateEngine.Impl.RazorCoreTemplate<BuildContext>
33
@{
44
var all_table = Model.GetCurrentAllTable();
55
}
@@ -32,14 +32,14 @@
3232
@for (var colIndex = 0; colIndex < table.Columns.Count(); colIndex++)
3333
{
3434
var col = table.Columns.ElementAt(colIndex);
35-
@col.ConvertedName @Html.PadLeft(4) @GetPGSqlType(col) @Html.PadLeft(4) @(col.IsNullable ? "null" : "not null") @(col.IsPrimaryKey?" primary key":"") @(col.AutoIncrement?" AUTO_INCREMENT":"") @if (!String.IsNullOrEmpty(col.Description))
35+
@col.ConvertedName @PadLeft(4) @GetPGSqlType(col) @PadLeft(4) @(col.IsNullable ? "null" : "not null") @(col.IsPrimaryKey?" primary key":"") @(col.AutoIncrement?" AUTO_INCREMENT":"") @if (!String.IsNullOrEmpty(col.Description))
3636
{
3737
<text> comment '@col.Description'</text>
3838
} if (colIndex < table.Columns.Count() - 1)
3939
{@(",")}
40-
@Html.NewLine()
40+
@NewLine()
4141
}
4242
);
43-
43+
4444
</text>
4545
}

‎src/SmartCode.Generator/RazorTemplates/Sql/DbToPGSql.cshtml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@using SmartCode
2-
@model BuildContext
2+
@inherits SmartCode.TemplateEngine.Impl.RazorCoreTemplate<BuildContext>
33
@{
44
var all_table = Model.GetCurrentAllTable();
55
}
@@ -31,8 +31,8 @@
3131

3232
@foreach (var col in table.Columns)
3333
{
34-
@col.ConvertedName @Html.PadLeft(4) @GetPGSqlType(col) @Html.PadLeft(4) @(col.IsNullable ? "null" : "not null") @(",")
35-
@Html.NewLine()
34+
@col.ConvertedName @PadLeft(4) @GetPGSqlType(col) @PadLeft(4) @(col.IsNullable ? "null" : "not null") @(",")
35+
@NewLine()
3636
}
3737
@if (table.PKColumn != null)
3838
{
@@ -44,14 +44,14 @@
4444
{
4545
<text>comment on table @table.ConvertedName is '@table.Description';</text>
4646
}
47-
@Html.NewLine()
47+
@NewLine()
4848
@foreach (var col in table.Columns)
4949
{
5050
@if (!String.IsNullOrEmpty(col.Description))
5151
{
5252
<text>comment on column @($"{table.ConvertedName}.{col.ConvertedName}") is '@col.Description';</text>
5353
}
54-
@Html.NewLine()
54+
@NewLine()
5555
}
5656
</text>
5757
}

‎src/SmartCode.TemplateEngine/SmartCode.TemplateEngine.csproj‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageReference Include="Handlebars.Net" Version="2.0.1" />
8-
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
9-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
108
<PackageReference Include="RazorEngineCore" Version="2020.10.1" />
119
</ItemGroup>
1210
<ItemGroup>

0 commit comments

Comments
 (0)