MES-ETL/ConsoleApp2/Services/JsvSource.cs

41 lines
1.1 KiB
C#
Raw Normal View History

2024-01-04 09:00:44 +08:00
using ConsoleApp2.Helpers;
2024-01-12 16:50:37 +08:00
using ConsoleApp2.HostedServices.Abstractions;
2023-12-28 15:18:03 +08:00
using Microsoft.Extensions.Logging;
using ServiceStack.Text;
2023-12-29 16:16:05 +08:00
namespace ConsoleApp2.Services;
2023-12-28 15:18:03 +08:00
2024-01-04 09:00:44 +08:00
/// <summary>
/// 读取Jsv格式文件
/// </summary>
[Obsolete]
2024-01-12 16:50:37 +08:00
public class JsvSource:IDataSource
2023-12-28 15:18:03 +08:00
{
2024-01-12 16:50:37 +08:00
private readonly string _inputDir;
2023-12-28 15:18:03 +08:00
private readonly JsvStringSerializer _jsv;
private readonly StreamReader _reader;
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
private readonly ILogger? _logger;
private readonly string _tableName;
public DataRecord Current { get; protected set; } = null!;
public string[]? Headers { get; }
public bool EndOfSource => _reader.EndOfStream;
2024-01-12 16:50:37 +08:00
public JsvSource(string inputDir,string tableName, ILogger? logger = null)
2023-12-28 15:18:03 +08:00
{
2024-01-12 16:50:37 +08:00
_inputDir = inputDir;
_tableName = tableName;
2023-12-28 15:18:03 +08:00
_jsv = new JsvStringSerializer();
_logger = logger;
}
2024-01-22 15:44:37 +08:00
public Task DoEnqueue(Action<DataRecord> action)
2023-12-28 15:18:03 +08:00
{
2024-01-22 15:44:37 +08:00
return Task.CompletedTask;
2023-12-28 15:18:03 +08:00
}
2024-01-12 16:50:37 +08:00
public void Dispose()
2023-12-28 15:18:03 +08:00
{
_reader.Dispose();
}
}