|
@@ -15,44 +15,59 @@ namespace GFGEditor
|
|
|
{
|
|
|
string[] files = Directory.GetFiles(ExcelConfig.excelsFolderPath);
|
|
|
int totalCount = files.Length;
|
|
|
+ string strCfgArrayDispose = "";
|
|
|
for (int i = 0; i < totalCount; i++)
|
|
|
{
|
|
|
string filePath = files[i];
|
|
|
string fileName = Path.GetFileNameWithoutExtension(filePath);
|
|
|
- if(!fileName.Contains("~"))
|
|
|
+ if (!fileName.Contains("~"))
|
|
|
{
|
|
|
ET.Log.Debug($"fileName {fileName}");
|
|
|
Stream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
|
|
ExcelPackage excelPackage = new ExcelPackage(stream);
|
|
|
//IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
|
|
|
//DataSet result = excelReader.AsDataSet();
|
|
|
-
|
|
|
- HandleTableCollection(excelPackage.Workbook.Worksheets, rowCollectionHandler);
|
|
|
+
|
|
|
+ HandleTableCollection(excelPackage.Workbook.Worksheets, rowCollectionHandler, out string dispose);
|
|
|
+ strCfgArrayDispose = strCfgArrayDispose + dispose;
|
|
|
}
|
|
|
}
|
|
|
+ string functionDispose = CodeTemplateFactory.FunctionDisposeTemplate;
|
|
|
+ functionDispose = functionDispose.Replace("{StrCfgArrayDispose}", strCfgArrayDispose);
|
|
|
+ string disposeAllCfgsCache = CodeTemplateFactory.DisposeAllCfgsCacheTemplate;
|
|
|
+ disposeAllCfgsCache = disposeAllCfgsCache.Replace("{FunctionDispose}", functionDispose);
|
|
|
+ //创建管理类代码
|
|
|
+ using (StreamWriter sw = new StreamWriter(ExcelConfig.configDataDisposePath + "DisposeAllCfgsCache.cs"))
|
|
|
+ {
|
|
|
+ sw.Write(disposeAllCfgsCache);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- private static void HandleTableCollection(ExcelWorksheets Worksheets, RowCollectionHandler rowCollectionHandler)
|
|
|
+ private static void HandleTableCollection(ExcelWorksheets Worksheets, RowCollectionHandler rowCollectionHandler, out string strCfgArrayDispose)
|
|
|
{
|
|
|
+ strCfgArrayDispose = "";
|
|
|
for (int i = 1; i <= Worksheets.Count; i++)
|
|
|
{
|
|
|
ExcelWorksheet worksheet = Worksheets[i];
|
|
|
- HandleTable(worksheet, rowCollectionHandler);
|
|
|
+ string configArrayName = HandleTable(worksheet, rowCollectionHandler);
|
|
|
+ if (string.IsNullOrEmpty(configArrayName)) continue;
|
|
|
+ string dispose = CodeTemplateFactory.StrCfgArrayDisposeTemplate.Replace("{configArrayName}", configArrayName);
|
|
|
+ strCfgArrayDispose = strCfgArrayDispose + "\n" + dispose;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void HandleTable(ExcelWorksheet worksheet, RowCollectionHandler rowCollectionHandler)
|
|
|
+ private static string HandleTable(ExcelWorksheet worksheet, RowCollectionHandler rowCollectionHandler)
|
|
|
{
|
|
|
string[] names = worksheet.Name.Split('_');
|
|
|
if (names.Length < 2)
|
|
|
{
|
|
|
//未正确命名的表格
|
|
|
- return;
|
|
|
+ return "";
|
|
|
}
|
|
|
if (worksheet.Name.Contains("#"))
|
|
|
{
|
|
|
//被注释的表格
|
|
|
- return;
|
|
|
+ return "";
|
|
|
}
|
|
|
string configItemName = names[1];
|
|
|
string managerTag = "";
|
|
@@ -62,9 +77,10 @@ namespace GFGEditor
|
|
|
}
|
|
|
//文件名及管理器名
|
|
|
string configManagerName = string.Format(ExcelConfig.CONFIG_ARRAY_TEMPLATE, configItemName, managerTag);
|
|
|
-
|
|
|
|
|
|
rowCollectionHandler(worksheet, configItemName, configManagerName);
|
|
|
+
|
|
|
+ return configManagerName;
|
|
|
}
|
|
|
|
|
|
}
|