更新表格模块提高查询效率

This commit is contained in:
dingxiaowei
2024-07-20 13:32:53 +08:00
parent 121e59732d
commit 821a1d481c
17 changed files with 50 additions and 45 deletions
Binary file not shown.
+13 -7
View File
@@ -29,7 +29,7 @@ namespace ExcelTool
var excelName = fileInfo.Name.Remove(fileInfo.Name.IndexOf(".xlsx"));
StringBuilder sb = new StringBuilder();
sb.Append($"/*\n * auto generated by tools(注意:千万不要手动修改本文件)\n * {excelName}\n */\n");
sb.Append("using System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Text;\nusing System.Linq;\n\n");
sb.Append("using System;\nusing System.IO;\nusing System.Collections.Generic;\nusing System.Text;\n\n");
sb.Append("[Serializable]\n");
sb.Append($"public partial class {excelName} : IBinarySerializable\n");
sb.Append("{\n");
@@ -475,7 +475,8 @@ namespace ExcelTool
sb.Append("[Serializable]\n");
sb.Append($"public partial class {excelName}Config : IBinarySerializable\n");
sb.Append("{\n");
sb.Append($"\tpublic List<{excelName}> {excelName}Infos = new List<{excelName}>();\n");
// sb.Append($"\tpublic List<{excelName}> {excelName}Infos = new List<{excelName}>();\n");
sb.Append($"\tDictionary<int,{excelName}> {excelName}Infos = new Dictionary<int,{excelName}>();\n");
sb.Append($"\tpublic void DeSerialize(BinaryReader reader)\n");
sb.Append("\t{\n");
sb.Append($"\t\tint count = reader.ReadInt32();\n");
@@ -483,7 +484,8 @@ namespace ExcelTool
sb.Append("\t\t{\n");
sb.Append($"\t\t\t{excelName} tempData = new {excelName}();\n");
sb.Append($"\t\t\ttempData.DeSerialize(reader);\n");
sb.Append($"\t\t\t{excelName}Infos.Add(tempData);\n");
// sb.Append($"\t\t\t{excelName}Infos.Add(tempData);\n");
sb.Append($"\t\t\t{excelName}Infos.Add(tempData.Id, tempData);\n");
sb.Append("\t\t}\n");
sb.Append("\t}\n");
sb.Append("\n");
@@ -497,10 +499,14 @@ namespace ExcelTool
sb.Append("\t}\n\n");
sb.Append($"\tpublic {excelName} QueryById(int id)\n");
sb.Append("\t{\n");
sb.Append($"\t\tvar datas = from d in {excelName}Infos\n");
sb.Append($"\t\t\t\t\twhere d.Id == id\n");
sb.Append($"\t\t\t\t\tselect d;\n");
sb.Append("\t\treturn datas.First();\n");
// sb.Append($"\t\tvar datas = from d in {excelName}Infos\n");
// sb.Append($"\t\t\t\t\twhere d.Id == id\n");
// sb.Append($"\t\t\t\t\tselect d;\n");
// sb.Append("\t\treturn datas.First();\n");
sb.Append($"\t\tif ({excelName}Infos.ContainsKey(id))\n");
sb.Append($"\t\t\treturn {excelName}Infos[id];\n");
sb.Append($"\t\telse\n");
sb.Append($"\t\t\treturn null;\n");
sb.Append("\t}\n");
sb.Append("}\n");
FileManager.WriteToFile(Path.Combine(outputDir, $"{excelName}.cs"), sb.ToString());
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6 -7
View File
@@ -6,7 +6,6 @@ using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Linq;
[Serializable]
public partial class avatarguideTest : IBinarySerializable
@@ -116,7 +115,7 @@ public partial class avatarguideTest : IBinarySerializable
[Serializable]
public partial class avatarguideTestConfig : IBinarySerializable
{
public List<avatarguideTest> avatarguideTestInfos = new List<avatarguideTest>();
Dictionary<int,avatarguideTest> avatarguideTestInfos = new Dictionary<int,avatarguideTest>();
public void DeSerialize(BinaryReader reader)
{
int count = reader.ReadInt32();
@@ -124,7 +123,7 @@ public partial class avatarguideTestConfig : IBinarySerializable
{
avatarguideTest tempData = new avatarguideTest();
tempData.DeSerialize(reader);
avatarguideTestInfos.Add(tempData);
avatarguideTestInfos.Add(tempData.Id, tempData);
}
}
@@ -139,9 +138,9 @@ public partial class avatarguideTestConfig : IBinarySerializable
public avatarguideTest QueryById(int id)
{
var datas = from d in avatarguideTestInfos
where d.Id == id
select d;
return datas.FirstOrDefault();
if (avatarguideTestInfos.ContainsKey(id))
return avatarguideTestInfos[id];
else
return null;
}
}
+6 -7
View File
@@ -6,7 +6,6 @@ using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Linq;
[Serializable]
public partial class battleScene : IBinarySerializable
@@ -145,7 +144,7 @@ public partial class battleScene : IBinarySerializable
[Serializable]
public partial class battleSceneConfig : IBinarySerializable
{
public List<battleScene> battleSceneInfos = new List<battleScene>();
Dictionary<int,battleScene> battleSceneInfos = new Dictionary<int,battleScene>();
public void DeSerialize(BinaryReader reader)
{
int count = reader.ReadInt32();
@@ -153,7 +152,7 @@ public partial class battleSceneConfig : IBinarySerializable
{
battleScene tempData = new battleScene();
tempData.DeSerialize(reader);
battleSceneInfos.Add(tempData);
battleSceneInfos.Add(tempData.Id, tempData);
}
}
@@ -168,9 +167,9 @@ public partial class battleSceneConfig : IBinarySerializable
public battleScene QueryById(int id)
{
var datas = from d in battleSceneInfos
where d.Id == id
select d;
return datas.FirstOrDefault();
if (battleSceneInfos.ContainsKey(id))
return battleSceneInfos[id];
else
return null;
}
}
+6 -7
View File
@@ -6,7 +6,6 @@ using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Linq;
[Serializable]
public partial class official_room : IBinarySerializable
@@ -218,7 +217,7 @@ public partial class official_room : IBinarySerializable
[Serializable]
public partial class official_roomConfig : IBinarySerializable
{
public List<official_room> official_roomInfos = new List<official_room>();
Dictionary<int,official_room> official_roomInfos = new Dictionary<int,official_room>();
public void DeSerialize(BinaryReader reader)
{
int count = reader.ReadInt32();
@@ -226,7 +225,7 @@ public partial class official_roomConfig : IBinarySerializable
{
official_room tempData = new official_room();
tempData.DeSerialize(reader);
official_roomInfos.Add(tempData);
official_roomInfos.Add(tempData.Id, tempData);
}
}
@@ -241,9 +240,9 @@ public partial class official_roomConfig : IBinarySerializable
public official_room QueryById(int id)
{
var datas = from d in official_roomInfos
where d.Id == id
select d;
return datas.FirstOrDefault();
if (official_roomInfos.ContainsKey(id))
return official_roomInfos[id];
else
return null;
}
}
@@ -34,20 +34,22 @@ D:\Work\CodeHubG\ExcelTool\ExcelTool\obj\Debug\ExcelTool.csproj.CoreCompileInput
D:\Work\CodeHubG\ExcelTool\ExcelTool\obj\Debug\ExcelTool.csproj.CopyComplete
D:\Work\CodeHubG\ExcelTool\ExcelTool\obj\Debug\ExcelTool.exe
D:\Work\CodeHubG\ExcelTool\ExcelTool\obj\Debug\ExcelTool.pdb
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\ExcelTool.exe.config
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\ExcelTool.exe
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\ExcelTool.pdb
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\ICSharpCode.SharpZipLib.dll
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\NPOI.dll
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\NPOI.OOXML.dll
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\NPOI.OpenXml4Net.dll
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\NPOI.OpenXmlFormats.dll
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\Spire.Pdf.dll
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\Spire.XLS.dll
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\Microsoft.mshtml.dll
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\Spire.Pdf.xml
D:\Study\github\ExcelTool\ExcelTool\bin\Debug\Spire.XLS.xml
D:\Study\github\ExcelTool\ExcelTool\obj\Debug\ExcelTool.csproj.CopyComplete
D:\Study\github\ExcelTool\ExcelTool\obj\Debug\ExcelTool.exe
D:\Study\github\ExcelTool\ExcelTool\obj\Debug\ExcelTool.pdb
D:\Study\GitHub\ExcelTool\ExcelTool\obj\Debug\ExcelTool.csproj.CoreCompileInputs.cache
D:\study\github\ExcelTool\ExcelTool\bin\Debug\ExcelTool.exe.config
D:\study\github\ExcelTool\ExcelTool\bin\Debug\ExcelTool.exe
D:\study\github\ExcelTool\ExcelTool\bin\Debug\ExcelTool.pdb
D:\study\github\ExcelTool\ExcelTool\bin\Debug\ICSharpCode.SharpZipLib.dll
D:\study\github\ExcelTool\ExcelTool\bin\Debug\NPOI.dll
D:\study\github\ExcelTool\ExcelTool\bin\Debug\NPOI.OOXML.dll
D:\study\github\ExcelTool\ExcelTool\bin\Debug\NPOI.OpenXml4Net.dll
D:\study\github\ExcelTool\ExcelTool\bin\Debug\NPOI.OpenXmlFormats.dll
D:\study\github\ExcelTool\ExcelTool\bin\Debug\Spire.Pdf.dll
D:\study\github\ExcelTool\ExcelTool\bin\Debug\Spire.XLS.dll
D:\study\github\ExcelTool\ExcelTool\bin\Debug\Microsoft.mshtml.dll
D:\study\github\ExcelTool\ExcelTool\bin\Debug\Spire.Pdf.xml
D:\study\github\ExcelTool\ExcelTool\bin\Debug\Spire.XLS.xml
D:\study\github\ExcelTool\ExcelTool\obj\Debug\ExcelTool.csproj.AssemblyReference.cache
D:\study\github\ExcelTool\ExcelTool\obj\Debug\ExcelTool.csproj.SuggestedBindingRedirects.cache
D:\study\github\ExcelTool\ExcelTool\obj\Debug\ExcelTool.csproj.CoreCompileInputs.cache
D:\study\github\ExcelTool\ExcelTool\obj\Debug\ExcelTool.csproj.CopyComplete
D:\study\github\ExcelTool\ExcelTool\obj\Debug\ExcelTool.exe
D:\study\github\ExcelTool\ExcelTool\obj\Debug\ExcelTool.pdb
Binary file not shown.
Binary file not shown.