MES-ETL/MesETL.App/Options/DatabaseOutputOptions.cs
2024-02-15 16:18:50 +08:00

36 lines
1.0 KiB
C#

namespace MesETL.App.Options;
public class DatabaseOutputOptions
{
public string? ConnectionString { get; set; }
public int MaxAllowedPacket { get; set; } = 32 * 1024 * 1024;
public int FlushCount { get; set; } = 10000;
public int MaxDatabaseOutputTask { get; set; } = 4;
public bool TreatJsonAsHex { get; set; } = true;
public string[] NoOutput { get; set; } = [];
public Dictionary<string, string>? ForUpdate { get; set; }
/// <summary>
/// 配置导入数据的特殊列
/// </summary>
public Dictionary<string, ColumnType> ColumnTypeConfig { get; set; } = new(); // "table.column" -> type
public ColumnType GetColumnType(string table, string column)
{
return ColumnTypeConfig.GetValueOrDefault($"{table}.{column}", ColumnType.UnDefine);
}
public bool TryGetForUpdate(string table, out string? forUpdate)
{
forUpdate = null;
if (ForUpdate is null || !ForUpdate.TryGetValue(table, out forUpdate))
return false;
return true;
}
}