修改导出
This commit is contained in:
parent
de141de3bd
commit
d2697baf37
@ -1,18 +1,13 @@
|
||||
using MySqlConnector;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Dapper;
|
||||
using CliFx;
|
||||
using CliFx.Infrastructure;
|
||||
using CliFx.Attributes;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using Chenfeng.MES.Archiver.Core;
|
||||
using Chenfeng.MES.Archiver.Core;
|
||||
using Chenfeng.MES.Archiver.Data;
|
||||
using CliFx;
|
||||
using CliFx.Attributes;
|
||||
using CliFx.Infrastructure;
|
||||
using Dapper;
|
||||
using MySqlConnector;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace Chenfeng.MES.Archiver.Commands
|
||||
{
|
||||
@ -89,7 +84,7 @@ namespace Chenfeng.MES.Archiver.Commands
|
||||
{
|
||||
Db?.Close();
|
||||
}
|
||||
console.Output.WriteLine("执行耗时:" + (DateTime.Now - startTime).TotalMilliseconds+"ms");
|
||||
console.Output.WriteLine("执行耗时:" + (DateTime.Now - startTime).TotalMilliseconds + "ms");
|
||||
return default;
|
||||
}
|
||||
|
||||
@ -159,12 +154,12 @@ namespace Chenfeng.MES.Archiver.Commands
|
||||
|
||||
using (var reader = cmd.ExecuteReader())
|
||||
{
|
||||
if (columnString.Length ==0)
|
||||
if (columnString.Length == 0)
|
||||
{
|
||||
for (int i = 0; i < reader.FieldCount; i++)
|
||||
{
|
||||
//columns.Add(reader.GetName(i));
|
||||
columnString.Append($"`reader.GetName(i)`,");
|
||||
columnString.Append($"`{reader.GetName(i)}`,");
|
||||
}
|
||||
columnString.Length--;
|
||||
}
|
||||
@ -175,13 +170,17 @@ namespace Chenfeng.MES.Archiver.Commands
|
||||
for (int i = 0; i < reader.FieldCount; i++)
|
||||
{
|
||||
var val = reader.GetValue(i);
|
||||
|
||||
switch (val)
|
||||
{
|
||||
case bool b:
|
||||
row.Add(b ? 1 : 0);
|
||||
break;
|
||||
case string s:
|
||||
row.Add($"'{s}'");
|
||||
break;
|
||||
case DateTime dt:
|
||||
row.Add(dt.ToString("'yyyy-MM-dd HH:mm:ss'"));
|
||||
row.Add('\'' + dt.ToString("yyyy-MM-dd HH:mm:ss") + '\'');
|
||||
break;
|
||||
case byte[] byteList:
|
||||
row.Add("0x" + string.Concat(byteList.Select(i => i.ToString("X2"))));
|
||||
@ -237,7 +236,7 @@ namespace Chenfeng.MES.Archiver.Commands
|
||||
}
|
||||
|
||||
watch.Stop();
|
||||
Print("导出完成,耗时" + watch.ElapsedMilliseconds+"ms");
|
||||
Print("导出完成,耗时" + watch.ElapsedMilliseconds + "ms");
|
||||
}
|
||||
|
||||
public void Step(Action<string> action, params string[] tables)
|
||||
|
Loading…
Reference in New Issue
Block a user