饭太稀
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using Fantasy.Serialize;
|
||||
|
||||
#pragma warning disable CS8603 // Possible null reference return.
|
||||
|
||||
namespace Fantasy;
|
||||
|
||||
public static class ConfigTableHelper
|
||||
{
|
||||
public static T Load<T>() where T : ASerialize
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
using System.Reflection;
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Serialize;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using ProtoBuf;
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
|
||||
namespace Exporter.Excel;
|
||||
|
||||
/// <summary>
|
||||
/// 动态程序集类,用于加载动态生成的程序集并获取动态信息。
|
||||
/// </summary>
|
||||
public static class DynamicAssembly
|
||||
{
|
||||
private static void MetadataReference(out string assemblyName, out List<MetadataReference> metadataReferenceList)
|
||||
{
|
||||
AssemblyMetadata assemblyMetadata;
|
||||
MetadataReference metadataReference;
|
||||
var currentDomain = AppDomain.CurrentDomain;
|
||||
assemblyName = Path.GetRandomFileName();
|
||||
var assemblyArray = currentDomain.GetAssemblies();
|
||||
metadataReferenceList = new List<MetadataReference>();
|
||||
|
||||
// 注册引用
|
||||
|
||||
foreach (var domainAssembly in assemblyArray)
|
||||
{
|
||||
if (string.IsNullOrEmpty(domainAssembly.Location))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
assemblyMetadata = AssemblyMetadata.CreateFromFile(domainAssembly.Location);
|
||||
metadataReference = assemblyMetadata.GetReference();
|
||||
metadataReferenceList.Add(metadataReference);
|
||||
}
|
||||
|
||||
// 添加Proto支持
|
||||
|
||||
assemblyMetadata = AssemblyMetadata.CreateFromFile(typeof(ProtoMemberAttribute).Assembly.Location);
|
||||
metadataReference = assemblyMetadata.GetReference();
|
||||
metadataReferenceList.Add(metadataReference);
|
||||
|
||||
// 添加Fantasy支持
|
||||
|
||||
assemblyMetadata = AssemblyMetadata.CreateFromFile(typeof(ASerialize).Assembly.Location);
|
||||
metadataReference = assemblyMetadata.GetReference();
|
||||
metadataReferenceList.Add(metadataReference);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载指定路径下的动态程序集。
|
||||
/// </summary>
|
||||
/// <param name="path">程序集文件路径。</param>
|
||||
/// <returns>加载的动态程序集。</returns>
|
||||
public static Assembly Load(string path)
|
||||
{
|
||||
var fileList = new List<string>();
|
||||
|
||||
// 找到所有需要加载的CS文件
|
||||
|
||||
foreach (string file in Directory.GetFiles(path))
|
||||
{
|
||||
if (Path.GetExtension(file) != ".cs")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
fileList.Add(file);
|
||||
}
|
||||
|
||||
var syntaxTreeList = new List<SyntaxTree>();
|
||||
|
||||
foreach (var file in fileList)
|
||||
{
|
||||
using var fileStream = new StreamReader(file);
|
||||
var cSharp = CSharpSyntaxTree.ParseText(fileStream.ReadToEnd());
|
||||
syntaxTreeList.Add(cSharp);
|
||||
}
|
||||
|
||||
// 注册程序集
|
||||
MetadataReference(out var assemblyName, out var metadataReferenceList);
|
||||
var compilation = CSharpCompilation.Create(assemblyName, syntaxTreeList, metadataReferenceList, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
|
||||
using var ms = new MemoryStream();
|
||||
var result = compilation.Emit(ms);
|
||||
if (!result.Success)
|
||||
{
|
||||
foreach (var resultDiagnostic in result.Diagnostics)
|
||||
{
|
||||
Log.Error(resultDiagnostic.GetMessage());
|
||||
}
|
||||
|
||||
throw new Exception("failures");
|
||||
}
|
||||
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
return Assembly.Load(ms.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取动态程序集中指定表格的动态信息。
|
||||
/// </summary>
|
||||
/// <param name="dynamicAssembly">动态程序集。</param>
|
||||
/// <param name="tableName">表格名称。</param>
|
||||
/// <returns>动态信息对象。</returns>
|
||||
public static DynamicConfigDataType GetDynamicInfo(Assembly dynamicAssembly, string tableName)
|
||||
{
|
||||
var dynamicConfigDataType = new DynamicConfigDataType
|
||||
{
|
||||
ConfigDataType = GetConfigType(dynamicAssembly, $"{tableName}Data"),
|
||||
ConfigType = GetConfigType(dynamicAssembly, $"{tableName}")
|
||||
};
|
||||
|
||||
dynamicConfigDataType.ConfigData = CreateInstance(dynamicConfigDataType.ConfigDataType);
|
||||
|
||||
var listPropertyType = dynamicConfigDataType.ConfigDataType.GetProperty("List");
|
||||
|
||||
if (listPropertyType == null)
|
||||
{
|
||||
throw new Exception("No Property named Add was found");
|
||||
}
|
||||
|
||||
dynamicConfigDataType.Obj = listPropertyType.GetValue(dynamicConfigDataType.ConfigData);
|
||||
dynamicConfigDataType.Method = listPropertyType.PropertyType.GetMethod("Add");
|
||||
|
||||
if (dynamicConfigDataType.Method == null)
|
||||
{
|
||||
throw new Exception("No method named Add was found");
|
||||
}
|
||||
|
||||
return dynamicConfigDataType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据类型名称获取动态类型。
|
||||
/// </summary>
|
||||
/// <param name="dynamicAssembly">动态程序集。</param>
|
||||
/// <param name="typeName">类型名称。</param>
|
||||
/// <returns>动态类型。</returns>
|
||||
private static Type GetConfigType(Assembly dynamicAssembly, string typeName)
|
||||
{
|
||||
var configType = dynamicAssembly.GetType($"Fantasy.{typeName}");
|
||||
|
||||
if (configType == null)
|
||||
{
|
||||
throw new FileNotFoundException($"Fantasy.{typeName} not found");
|
||||
}
|
||||
|
||||
return configType;
|
||||
// return dynamicAssembly.GetType($"Fantasy.{typeName}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建动态实例。
|
||||
/// </summary>
|
||||
/// <param name="configType">动态类型。</param>
|
||||
/// <returns>动态实例。</returns>
|
||||
public static object CreateInstance(Type configType)
|
||||
{
|
||||
var config = Activator.CreateInstance(configType);
|
||||
|
||||
if (config == null)
|
||||
{
|
||||
throw new Exception($"{configType.Name} is Activator.CreateInstance error");
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
|
||||
namespace Exporter.Excel;
|
||||
|
||||
/// <summary>
|
||||
/// 动态配置数据类型类,用于存储动态配置数据的相关信息。
|
||||
/// </summary>
|
||||
public class DynamicConfigDataType
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置数据对象,继承自 AProto 基类。
|
||||
/// </summary>
|
||||
public object ConfigData;
|
||||
/// <summary>
|
||||
/// 配置数据类型。
|
||||
/// </summary>
|
||||
public Type ConfigDataType;
|
||||
/// <summary>
|
||||
/// 配置类型。
|
||||
/// </summary>
|
||||
public Type ConfigType;
|
||||
/// <summary>
|
||||
/// 反射方法信息,用于调用特定方法。
|
||||
/// </summary>
|
||||
public MethodInfo Method;
|
||||
/// <summary>
|
||||
/// 配置数据对象实例。
|
||||
/// </summary>
|
||||
public object Obj;
|
||||
/// <summary>
|
||||
/// 用于生成 JSON 格式数据的字符串构建器。
|
||||
/// </summary>
|
||||
public StringBuilder Json = new StringBuilder();
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Reflection;
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Serialize;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using ProtoBuf;
|
||||
|
||||
namespace Exporter.Excel;
|
||||
|
||||
public class OneDynamicAssembly
|
||||
{
|
||||
private readonly List<SyntaxTree> _syntaxTreeList = new List<SyntaxTree>();
|
||||
|
||||
public void Load(string file)
|
||||
{
|
||||
using var fileStream = new StreamReader(file);
|
||||
var cSharp = CSharpSyntaxTree.ParseText(fileStream.ReadToEnd());
|
||||
_syntaxTreeList.Add(cSharp);
|
||||
}
|
||||
|
||||
public Assembly Assembly
|
||||
{
|
||||
get
|
||||
{
|
||||
AssemblyMetadata assemblyMetadata;
|
||||
MetadataReference metadataReference;
|
||||
var currentDomain = AppDomain.CurrentDomain;
|
||||
var assemblyName = Path.GetRandomFileName();
|
||||
var assemblyArray = currentDomain.GetAssemblies();
|
||||
var metadataReferenceList = new List<MetadataReference>();
|
||||
// 注册引用
|
||||
foreach (var domainAssembly in assemblyArray)
|
||||
{
|
||||
if (string.IsNullOrEmpty(domainAssembly.Location))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
assemblyMetadata = AssemblyMetadata.CreateFromFile(domainAssembly.Location);
|
||||
metadataReference = assemblyMetadata.GetReference();
|
||||
metadataReferenceList.Add(metadataReference);
|
||||
}
|
||||
// 添加ProtoEntity支持
|
||||
assemblyMetadata = AssemblyMetadata.CreateFromFile(typeof(ASerialize).Assembly.Location);
|
||||
metadataReference = assemblyMetadata.GetReference();
|
||||
metadataReferenceList.Add(metadataReference);
|
||||
// 添加MessagePack支持
|
||||
assemblyMetadata = AssemblyMetadata.CreateFromFile(typeof(ProtoMemberAttribute).Assembly.Location);
|
||||
metadataReference = assemblyMetadata.GetReference();
|
||||
metadataReferenceList.Add(metadataReference);
|
||||
CSharpCompilation compilation = CSharpCompilation.Create(assemblyName, _syntaxTreeList, metadataReferenceList, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
|
||||
|
||||
using var ms = new MemoryStream();
|
||||
var result = compilation.Emit(ms);
|
||||
|
||||
if (!result.Success)
|
||||
{
|
||||
foreach (var resultDiagnostic in result.Diagnostics)
|
||||
{
|
||||
Log.Error(resultDiagnostic.GetMessage());
|
||||
}
|
||||
|
||||
throw new Exception("failures");
|
||||
}
|
||||
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
return Assembly.Load(ms.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
1054
Tools/SourceCode/Fantasy.Tools.ConfigTable/Exporter/ExcelExporter.cs
Normal file
1054
Tools/SourceCode/Fantasy.Tools.ConfigTable/Exporter/ExcelExporter.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,47 @@
|
||||
using OfficeOpenXml;
|
||||
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
/// <summary>
|
||||
/// 提供操作 Excel 文件的辅助方法。
|
||||
/// </summary>
|
||||
public static class ExcelHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载 Excel 文件并返回 ExcelPackage 实例。
|
||||
/// </summary>
|
||||
/// <param name="name">Excel 文件的路径。</param>
|
||||
/// <returns>ExcelPackage 实例。</returns>
|
||||
public static ExcelPackage LoadExcel(string name)
|
||||
{
|
||||
return new ExcelPackage(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定工作表中指定行列位置的单元格值。
|
||||
/// </summary>
|
||||
/// <param name="sheet">Excel 工作表。</param>
|
||||
/// <param name="row">行索引。</param>
|
||||
/// <param name="column">列索引。</param>
|
||||
/// <returns>单元格值。</returns>
|
||||
public static string GetCellValue(this ExcelWorksheet sheet, int row, int column)
|
||||
{
|
||||
ExcelRange cell = sheet.Cells[row, column];
|
||||
|
||||
try
|
||||
{
|
||||
if (cell.Value == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
string s = cell.GetValue<string>();
|
||||
|
||||
return s.Trim();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception($"Rows {row} Columns {column} Content {cell.Text} {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
/// <summary>
|
||||
/// Excel表格类,用于存储表格的名称和列信息。
|
||||
/// </summary>
|
||||
public sealed class ExcelTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 表格的名称。
|
||||
/// </summary>
|
||||
public readonly string Name;
|
||||
/// <summary>
|
||||
/// 客户端列信息,使用排序字典存储列名和列索引列表。
|
||||
/// </summary>
|
||||
public readonly SortedDictionary<string, List<int>> ClientColInfos = new();
|
||||
/// <summary>
|
||||
/// 服务器端列信息,使用排序字典存储列名和列索引列表。
|
||||
/// </summary>
|
||||
public readonly SortedDictionary<string, List<int>> ServerColInfos = new();
|
||||
/// <summary>
|
||||
/// 构造函数,初始化Excel表格对象并设置表格名称。
|
||||
/// </summary>
|
||||
/// <param name="name">表格名称。</param>
|
||||
public ExcelTable(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
public static class ExcelTemplate
|
||||
{
|
||||
public static readonly string Template = """
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using Fantasy;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using Fantasy.ConfigTable;
|
||||
using Fantasy.Serialize;
|
||||
// ReSharper disable CollectionNeverUpdated.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
#pragma warning disable CS0169
|
||||
#pragma warning disable CS8618
|
||||
#pragma warning disable CS8625
|
||||
#pragma warning disable CS8603
|
||||
|
||||
namespace (namespace)
|
||||
{
|
||||
[ProtoContract]
|
||||
public sealed partial class (ConfigName)Data : ASerialize, IConfigTable, IProto
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<(ConfigName)> List { get; set; } = new List<(ConfigName)>();
|
||||
#if FANTASY_NET
|
||||
[ProtoIgnore]
|
||||
private readonly ConcurrentDictionary<uint, (ConfigName)> _configs = new ConcurrentDictionary<uint, (ConfigName)>();
|
||||
#else
|
||||
[ProtoIgnore]
|
||||
private readonly Dictionary<uint, (ConfigName)> _configs = new Dictionary<uint, (ConfigName)>();
|
||||
#endif
|
||||
private static (ConfigName)Data _instance = null;
|
||||
|
||||
public static (ConfigName)Data Instance
|
||||
{
|
||||
get { return _instance ??= ConfigTableHelper.Load<(ConfigName)Data>(); }
|
||||
private set => _instance = value;
|
||||
}
|
||||
|
||||
public (ConfigName) Get(uint id, bool check = true)
|
||||
{
|
||||
if (_configs.ContainsKey(id))
|
||||
{
|
||||
return _configs[id];
|
||||
}
|
||||
|
||||
if (check)
|
||||
{
|
||||
throw new Exception($"(ConfigName) not find {id} Id");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public bool TryGet(uint id, out (ConfigName) config)
|
||||
{
|
||||
config = null;
|
||||
|
||||
if (!_configs.ContainsKey(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
config = _configs[id];
|
||||
return true;
|
||||
}
|
||||
public override void AfterDeserialization()
|
||||
{
|
||||
foreach (var config in List)
|
||||
{
|
||||
#if FANTASY_NET
|
||||
_configs.TryAdd(config.Id, config);
|
||||
#else
|
||||
_configs.Add(config.Id, config);
|
||||
#endif
|
||||
config.AfterDeserialization();
|
||||
}
|
||||
|
||||
EndInit();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoContract]
|
||||
public sealed partial class (ConfigName) : ASerialize, IProto
|
||||
{(Fields)
|
||||
}
|
||||
}
|
||||
""";
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Helper;
|
||||
using OfficeOpenXml;
|
||||
#pragma warning disable CS8601 // Possible null reference assignment.
|
||||
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
public sealed class ExcelWorksheets(ExcelExporter excelExporter)
|
||||
{
|
||||
public bool TryGetValue(string worksheetName, out ExcelWorksheet excelWorksheet)
|
||||
{
|
||||
if (excelExporter.Worksheets.TryGetValue(worksheetName, out excelWorksheet))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var computeHash64 = HashCodeHelper.ComputeHash64(worksheetName);
|
||||
if (!excelExporter.VersionInfo.WorksheetNames.Contains(computeHash64))
|
||||
{
|
||||
Log.Info($"{worksheetName} is not exist!");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
/// <summary>
|
||||
/// 导出信息类,用于存储导出操作的名称和文件信息。
|
||||
/// </summary>
|
||||
public class ExportInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 导出操作的名称。
|
||||
/// </summary>
|
||||
public string Name;
|
||||
/// <summary>
|
||||
/// 导出操作生成的文件信息。
|
||||
/// </summary>
|
||||
public FileInfo FileInfo;
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Helper;
|
||||
// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义导出接口
|
||||
/// </summary>
|
||||
public interface ICustomExport
|
||||
{
|
||||
/// <summary>
|
||||
/// 执行导出操作
|
||||
/// </summary>
|
||||
void Run();
|
||||
/// <summary>
|
||||
/// 内部操作用于初始化、不明白原理不要修改这里和调用这个方法
|
||||
/// </summary>
|
||||
/// <param name="excelExporter"></param>
|
||||
/// <param name="worksheets"></param>
|
||||
void Init(ExcelExporter excelExporter, ExcelWorksheets worksheets);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 抽象自定义导出基类
|
||||
/// </summary>
|
||||
public abstract class ACustomExport : ICustomExport
|
||||
{
|
||||
protected ExcelExporter ExcelExporter;
|
||||
protected ExcelWorksheets Worksheets;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义导出类型枚举:客户端、服务器
|
||||
/// </summary>
|
||||
protected enum CustomExportType
|
||||
{
|
||||
/// <summary>
|
||||
/// 客户端
|
||||
/// </summary>
|
||||
Client,
|
||||
/// <summary>
|
||||
/// 服务器
|
||||
/// </summary>
|
||||
Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内部操作用于初始化、不明白原理不要修改这里
|
||||
/// </summary>
|
||||
/// <param name="excelExporter"></param>
|
||||
/// <param name="worksheets"></param>
|
||||
public void Init(ExcelExporter excelExporter, ExcelWorksheets worksheets)
|
||||
{
|
||||
ExcelExporter = excelExporter;
|
||||
Worksheets = worksheets;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行导出操作的抽象方法
|
||||
/// </summary>
|
||||
public abstract void Run();
|
||||
|
||||
/// <summary>
|
||||
/// 写入文件内容到指定位置
|
||||
/// </summary>
|
||||
/// <param name="fileName">文件名</param>
|
||||
/// <param name="fileContent">文件内容</param>
|
||||
/// <param name="filePath">相对的导出的目录</param>
|
||||
/// <param name="customExportType">自定义导出类型</param>
|
||||
protected void Write(string fileName, string fileContent, string filePath, CustomExportType customExportType)
|
||||
{
|
||||
if (filePath == null)
|
||||
{
|
||||
Log.Error($" {nameof(filePath)} is null");
|
||||
return;
|
||||
}
|
||||
|
||||
filePath = FileHelper.GetFullPath(filePath);
|
||||
|
||||
if (!Directory.Exists(filePath))
|
||||
{
|
||||
FileHelper.CreateDirectory(filePath);
|
||||
}
|
||||
|
||||
var combine = Path.Combine(filePath, fileName);
|
||||
File.WriteAllText(combine, fileContent);
|
||||
|
||||
switch (customExportType)
|
||||
{
|
||||
case CustomExportType.Client:
|
||||
{
|
||||
Log.Info($"导出客户端自定义文件:{filePath}/{fileName}");
|
||||
return;
|
||||
}
|
||||
case CustomExportType.Server:
|
||||
{
|
||||
Log.Info($"导出服务器自定义文件:{filePath}/{fileName}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入文件内容到指定位置
|
||||
/// </summary>
|
||||
/// <param name="fileName">文件名</param>
|
||||
/// <param name="fileContent">文件内容</param>
|
||||
/// <param name="customExportType">自定义导出类型</param>
|
||||
protected void Write(string fileName, string fileContent, CustomExportType customExportType)
|
||||
{
|
||||
switch (customExportType)
|
||||
{
|
||||
case CustomExportType.Client:
|
||||
{
|
||||
if (string.IsNullOrEmpty(ExcelExporter.ClientCustomExportDirectory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(ExcelExporter.ClientCustomExportDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(ExcelExporter.ClientCustomExportDirectory);
|
||||
}
|
||||
|
||||
File.WriteAllText($"{ExcelExporter.ClientCustomExportDirectory}/{fileName}", fileContent);
|
||||
Log.Info($"导出客户端自定义文件:{ExcelExporter.ClientCustomExportDirectory}/{fileName}");
|
||||
return;
|
||||
}
|
||||
case CustomExportType.Server:
|
||||
{
|
||||
if (string.IsNullOrEmpty(ExcelExporter.ServerCustomExportDirectory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Directory.Exists(ExcelExporter.ServerCustomExportDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(ExcelExporter.ServerCustomExportDirectory);
|
||||
}
|
||||
|
||||
File.WriteAllText($"{ExcelExporter.ServerCustomExportDirectory}/{fileName}", fileContent);
|
||||
Log.Info($"导出服务器自定义文件:{ExcelExporter.ServerCustomExportDirectory}/{fileName}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Fantasy.Tools.ConfigTable;
|
||||
|
||||
public class VersionInfo
|
||||
{
|
||||
public SortedSet<long> WorksheetNames = [];
|
||||
public SortedDictionary<long, long> Tables = new();
|
||||
}
|
||||
Reference in New Issue
Block a user