merged and change insert flow
This commit is contained in:
commit
8417a9ed62
38
.gitignore
vendored
38
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
# ---> VisualStudio
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
@ -91,6 +92,7 @@ StyleCopReport.xml
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
@ -294,6 +296,17 @@ node_modules/
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
*.ncb
|
||||
*.aps
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
@ -350,6 +363,9 @@ ASALocalRun/
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
@ -361,5 +377,27 @@ MigrationBackup/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
||||
/Backend/wwwroot/upload/floor_map.zip
|
||||
*.nwd
|
||||
|
@ -27,6 +27,7 @@ namespace Backend.Controllers
|
||||
private Stopwatch stopwatch = new Stopwatch();
|
||||
private Stopwatch stopwatchSection = new Stopwatch();
|
||||
private Stopwatch syncStopWatch = new Stopwatch();
|
||||
private static long syncWatchTime = 0;
|
||||
|
||||
public NiagaraDataSynchronizeController(IBackendRepository backendRepository, INiagaraDataSynchronizeRepository niagaraDataSynchronizeRepository,IBackEndConfigHelper backEndConfig)
|
||||
{
|
||||
@ -103,7 +104,9 @@ namespace Backend.Controllers
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<bool>> CompareData([FromBody] List<Device_value> ds)
|
||||
{
|
||||
syncStopWatch = new Stopwatch();
|
||||
syncStopWatch.Start();
|
||||
syncWatchTime = 0;
|
||||
stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
bool result = false;
|
||||
@ -199,6 +202,10 @@ namespace Backend.Controllers
|
||||
|
||||
stopwatch.Stop();
|
||||
await niagaraDataSynchronizeRepository.KeepTimeLog("CompareData", stopwatch.ElapsedMilliseconds);
|
||||
|
||||
syncStopWatch.Stop();
|
||||
syncWatchTime += syncStopWatch.ElapsedMilliseconds;
|
||||
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
@ -209,6 +216,8 @@ namespace Backend.Controllers
|
||||
[HttpPost]
|
||||
public Task<ApiResult<List<ImpNiaItem>>> RawDataDevItemList([FromBody] Device_value building)
|
||||
{
|
||||
syncStopWatch = new Stopwatch();
|
||||
syncStopWatch.Start();
|
||||
ApiResult<List<ImpNiaItem>> apiResult = new ApiResult<List<ImpNiaItem>>();
|
||||
stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
@ -260,6 +269,9 @@ namespace Backend.Controllers
|
||||
//return apiResult;
|
||||
stopwatch.Stop();
|
||||
niagaraDataSynchronizeRepository.KeepTimeLog("RawDataDevItemList", stopwatch.ElapsedMilliseconds);
|
||||
|
||||
syncStopWatch.Stop();
|
||||
syncWatchTime += syncStopWatch.ElapsedMilliseconds;
|
||||
return Task.FromResult(apiResult);
|
||||
}
|
||||
|
||||
@ -270,6 +282,8 @@ namespace Backend.Controllers
|
||||
[HttpPost]
|
||||
public async Task<ApiResult<bool>> DevIteComData([FromBody] List<ImpNiaItem> ds)
|
||||
{
|
||||
syncStopWatch = new Stopwatch();
|
||||
syncStopWatch.Start();
|
||||
stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
bool result = false;
|
||||
@ -366,7 +380,8 @@ namespace Backend.Controllers
|
||||
await niagaraDataSynchronizeRepository.KeepTimeLog("DevIteComData", stopwatch.ElapsedMilliseconds);
|
||||
|
||||
syncStopWatch.Stop();
|
||||
await niagaraDataSynchronizeRepository.KeepTimeLog("Full sync usage record", syncStopWatch.ElapsedMilliseconds);
|
||||
syncWatchTime += syncStopWatch.ElapsedMilliseconds;
|
||||
await niagaraDataSynchronizeRepository.KeepTimeLog("Full sync usage record", syncWatchTime);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
|
@ -1574,11 +1574,16 @@ SET FOREIGN_KEY_CHECKS = 1;";
|
||||
#region 放入import_niagara_item資料表
|
||||
stopwatchSection = new Stopwatch();
|
||||
stopwatchSection.Start();
|
||||
string ss = string.Empty;
|
||||
foreach (var row in ds)
|
||||
{
|
||||
string ss = $@" insert import_niagara_item_history(device_area_tag, device_building_tag, device_system_tag, device_name_tag,
|
||||
device_floor_tag, device_master_tag, device_last_name_tag, device_serial_tag, device_point_name, parent_path, full_name, is_history, created_at)
|
||||
values('" +
|
||||
if (count == 0)
|
||||
{
|
||||
ss = @"insert import_niagara_item_history(device_area_tag, device_building_tag, device_system_tag, device_name_tag, device_floor_tag, device_master_tag,
|
||||
device_last_name_tag, device_serial_tag, device_point_name, parent_path, full_name, is_history, created_at) values";
|
||||
}
|
||||
|
||||
ss += $@" ('" +
|
||||
row.device_area_tag + "', '" +
|
||||
row.device_building_tag + "', '" +
|
||||
row.device_system_tag + "', '" +
|
||||
@ -1591,21 +1596,32 @@ device_floor_tag, device_master_tag, device_last_name_tag, device_serial_tag, d
|
||||
row.parent_path + "', '" +
|
||||
row.full_name + "'," +
|
||||
row.isHistory + ", now() " +
|
||||
");";
|
||||
sb.Append(ss);
|
||||
")";
|
||||
|
||||
count++;
|
||||
if (count == 100)
|
||||
{
|
||||
ss += ";";
|
||||
sb.Append(ss);
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
sb.Clear();
|
||||
ss = string.Empty;
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
ss += ",";
|
||||
}
|
||||
|
||||
sb.Append(ss);
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
sb.Clear();
|
||||
ss = ss.Remove(ss.Length - 1);
|
||||
ss += ";";
|
||||
sb.Append(ss);
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
@ -1717,23 +1733,37 @@ device_floor_tag, device_master_tag, device_last_name_tag, device_serial_tag, d
|
||||
stopwatchSection.Start();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int count = 0;
|
||||
sql = string.Empty;
|
||||
foreach (var data in dcp)
|
||||
{
|
||||
sql = $@" insert into import_niagara_device_control_point(name, displayName, device_area_tag, device_building_tag, device_system_tag, device_name_tag, device_floor_tag,
|
||||
device_number, device_point_name)
|
||||
values ('{data.name}', '{data.displayName}', '{data.device_area_tag}', '{data.device_building_tag}', '{data.device_system_tag}', '{data.device_name_tag}',
|
||||
'{data.device_floor_tag}', '{data.device_number}', '{data.device_point_name}');";
|
||||
sb.Append(sql);
|
||||
if (count == 0)
|
||||
{
|
||||
sql = @"insert into import_niagara_device_control_point(name, displayName, device_area_tag, device_building_tag, device_system_tag, device_name_tag, device_floor_tag,
|
||||
device_number, device_point_name) values";
|
||||
}
|
||||
sql += $@" ('{data.name}', '{data.displayName}', '{data.device_area_tag}', '{data.device_building_tag}', '{data.device_system_tag}', '{data.device_name_tag}',
|
||||
'{data.device_floor_tag}', '{data.device_number}', '{data.device_point_name}')";
|
||||
count++;
|
||||
if (count.Equals(100))
|
||||
{
|
||||
sql += ";";
|
||||
sb.Append(sql);
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
sb.Clear();
|
||||
sql = string.Empty;
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
sql += ",";
|
||||
}
|
||||
|
||||
sb.Append(sql);
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
sb.Clear();
|
||||
sql = sql.Remove(sql.Length - 1);
|
||||
sql += ";";
|
||||
sb.Append(sql);
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
sb.Clear();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user