|
@@ -22,7 +22,10 @@ namespace GFGEditor
|
|
|
|
|
|
private static List<string> _names = new List<string>();
|
|
|
private static List<string> _types = new List<string>();
|
|
|
+ private static List<string> _allNames = new List<string>();
|
|
|
+ private static List<string> _allTypes = new List<string>();
|
|
|
private static List<int> _indexs = new List<int>();
|
|
|
+ private static List<int> _allIndexs = new List<int>();
|
|
|
private static Dictionary<string, string> _idDic = new Dictionary<string, string>();
|
|
|
private static Dictionary<string, string> _itemTypeDicByName = new Dictionary<string, string>();
|
|
|
|
|
@@ -33,129 +36,193 @@ namespace GFGEditor
|
|
|
_assignmentBuilder.Clear();
|
|
|
_parseBuilder.Clear();
|
|
|
_names.Clear();
|
|
|
+ _allNames.Clear();
|
|
|
_types.Clear();
|
|
|
- _idDic.Clear();
|
|
|
+ _allTypes.Clear();
|
|
|
_indexs.Clear();
|
|
|
+ _allIndexs.Clear();
|
|
|
+ _idDic.Clear();
|
|
|
//_hasSameIds = false;
|
|
|
- List<string> keyNames = new List<string>();
|
|
|
- List<string> keyTypes = new List<string>();
|
|
|
- List<string> groupNames = new List<string>();
|
|
|
- List<string> groupTypes = new List<string>();
|
|
|
- bool groupOnly = false;
|
|
|
+ List<string> keyName = new List<string>();//默认用id查询单条数据
|
|
|
+ List<string> keyType = new List<string>();
|
|
|
+ Dictionary<string, List<string>> keyNames = new Dictionary<string, List<string>>();
|
|
|
+ Dictionary<string, List<string>> keyTypes = new Dictionary<string, List<string>>();
|
|
|
+ Dictionary<string, List<string>> groupNames = new Dictionary<string, List<string>>();
|
|
|
+ Dictionary<string, List<string>> groupTypes = new Dictionary<string, List<string>>();
|
|
|
+ bool groupOnly = false;//可根据id分组时,不提供根据id查询单条数据的接口
|
|
|
int len = worksheet.Dimension.End.Column;
|
|
|
if (len <= 0)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+ worksheet = HandleExcelWorksheet(worksheet);
|
|
|
for (int i = 1; i <= len; ++i)
|
|
|
{
|
|
|
ET.Log.Debug($"GenerateCode for i {i}");
|
|
|
string annotation = worksheet.Cells[1, i].Text.Trim();
|
|
|
- string type = worksheet.Cells[2, i].Text.Trim();
|
|
|
+ string typeWhole = worksheet.Cells[2, i].Text.Trim();
|
|
|
+ string type = typeWhole.Split('#')[0];
|
|
|
string nameWhole = worksheet.Cells[3, i].Text.Trim();
|
|
|
- string[] nameInfos = nameWhole.Split('#');
|
|
|
+ string[] nameInfos = nameWhole.Split('#', '&');//#和&不会同时存在,即不会将数组用作数据查询的关键字key
|
|
|
string name = nameInfos[0];
|
|
|
- if (i == 1 || nameWhole.Contains("#k"))
|
|
|
+ if (i == 1)
|
|
|
{
|
|
|
- keyNames.Add(name);
|
|
|
- keyTypes.Add(type);
|
|
|
+ keyName.Add(name);
|
|
|
+ keyType.Add(type);
|
|
|
}
|
|
|
- if (nameWhole.Contains("#g"))
|
|
|
+ for (int j = 1; j < nameInfos.Length; j++)
|
|
|
{
|
|
|
- groupNames.Add(name);
|
|
|
- groupTypes.Add(type);
|
|
|
+ if (nameInfos[j].Contains("k"))
|
|
|
+ {
|
|
|
+ if (!keyNames.ContainsKey(nameInfos[j]))
|
|
|
+ {
|
|
|
+ keyNames.Add(nameInfos[j], new List<string>());
|
|
|
+ keyTypes.Add(nameInfos[j], new List<string>());
|
|
|
+ }
|
|
|
+ keyNames[nameInfos[j]].Add(name);
|
|
|
+ keyTypes[nameInfos[j]].Add(type);
|
|
|
+ }
|
|
|
+ if (nameInfos[j].Contains("g"))
|
|
|
+ {
|
|
|
+ if (!groupNames.ContainsKey(nameInfos[j]))
|
|
|
+ {
|
|
|
+ groupNames.Add(nameInfos[j], new List<string>());
|
|
|
+ groupTypes.Add(nameInfos[j], new List<string>());
|
|
|
+ }
|
|
|
+ groupNames[nameInfos[j]].Add(name);
|
|
|
+ groupTypes[nameInfos[j]].Add(type);
|
|
|
+ }
|
|
|
}
|
|
|
- ParseDataColumn(annotation, type, name, i);
|
|
|
- }
|
|
|
- if (keyNames.Count == groupNames.Count)
|
|
|
- {
|
|
|
- bool isSame = true;
|
|
|
- for (var i = 0; i < keyNames.Count; i++)
|
|
|
+ foreach (string key in groupNames.Keys)
|
|
|
{
|
|
|
- if (keyNames[i] != groupNames[i])
|
|
|
+ if (groupNames[key].Count == 1 && groupNames[key][0] == keyName[0])
|
|
|
{
|
|
|
- isSame = false;
|
|
|
+ groupOnly = true;
|
|
|
}
|
|
|
}
|
|
|
- groupOnly = isSame;
|
|
|
+ ParseDataColumn(annotation, type, name, nameWhole, typeWhole, i);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
//创建sqlite表
|
|
|
SQLiteHelper.Instance.CreateTable(configArrayName, _names.ToArray(), _types.ToArray());
|
|
|
AddDataToSql(worksheet, configName, configArrayName);
|
|
|
|
|
|
//生成管理类代码
|
|
|
string configArrayStr = CodeTemplateFactory.ConfigArrayTemplate;
|
|
|
- string paramsStr;
|
|
|
- string colNames;
|
|
|
- string colValues;
|
|
|
- _declarationBuilder.AppendFormat("\t\t//{0}", "组合key");
|
|
|
+
|
|
|
+ _declarationBuilder.AppendFormat("\t\t//{0}", "key");
|
|
|
_declarationBuilder.AppendLine();
|
|
|
- _declarationBuilder.AppendFormat("\t\tpublic {0} {1};", "string", "combinedKey");
|
|
|
+ _declarationBuilder.AppendFormat("\t\tpublic {0} {1};", "string", "key");
|
|
|
_declarationBuilder.AppendLine();
|
|
|
- //处理查询单条数据函数
|
|
|
- if (groupOnly)
|
|
|
+
|
|
|
+ // _assignmentBuilder.AppendFormat("\t\t\t{0} = \"{1}\";", "key", keyName);
|
|
|
+ // _assignmentBuilder.AppendLine();
|
|
|
+
|
|
|
+ foreach (string key in keyNames.Keys)
|
|
|
{
|
|
|
- configArrayStr = configArrayStr.Replace("{singleFunction}", "");
|
|
|
- _assignmentBuilder.AppendFormat("\t\t\t{0} = \"{1}\";", "combinedKey", string.Join("_", groupNames));
|
|
|
- _assignmentBuilder.AppendLine();
|
|
|
+ _declarationBuilder.AppendFormat("\t\t//{0}{1}", "key_", key);
|
|
|
+ _declarationBuilder.AppendLine();
|
|
|
+ _declarationBuilder.AppendFormat("\t\tpublic {0} {1}{2};", "string", "combinedKey_", key);
|
|
|
+ _declarationBuilder.AppendLine();
|
|
|
+
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ foreach (string key in groupNames.Keys)
|
|
|
{
|
|
|
- string FunctionSingleStr = CodeTemplateFactory.FunctionSingleTemplate;
|
|
|
- CreateParamsString(keyNames, keyTypes, out paramsStr, out colNames, out colValues);
|
|
|
- FunctionSingleStr = FunctionSingleStr.Replace("{params}", paramsStr);
|
|
|
- FunctionSingleStr = FunctionSingleStr.Replace("{colNames}", colNames);
|
|
|
- FunctionSingleStr = FunctionSingleStr.Replace("{colValues}", colValues);
|
|
|
- configArrayStr = configArrayStr.Replace("{singleFunction}", FunctionSingleStr);
|
|
|
- _assignmentBuilder.AppendFormat("\t\t\t{0} = \"{1}\";", "combinedKey", string.Join("_", keyNames));
|
|
|
- _assignmentBuilder.AppendLine();
|
|
|
+ _declarationBuilder.AppendFormat("\t\t//{0}{1}", "groupKey_", key);
|
|
|
+ _declarationBuilder.AppendLine();
|
|
|
+ _declarationBuilder.AppendFormat("\t\tpublic {0} {1}{2};", "string", "groupKey_", key);
|
|
|
+ _declarationBuilder.AppendLine();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- //处理查询多条数据函数
|
|
|
- if (groupNames.Count > 0)
|
|
|
+ string strDiapose = "_allDatas = null;\n";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ string singleFunction = "";
|
|
|
+ //处理查询单条数据函数
|
|
|
+ if (!groupOnly)
|
|
|
+ {
|
|
|
+ singleFunction = HandleSingleFunction("key", keyName, keyType, "GetCfg", "_cfgsDic", configArrayStr);
|
|
|
+ strDiapose = string.Format("{0}\t\t\t{1}\n", strDiapose, "_cfgsDic.Clear();");
|
|
|
+ }
|
|
|
+ foreach (string key in keyNames.Keys)
|
|
|
{
|
|
|
- string FunctionGroupStr = CodeTemplateFactory.FunctionGroupTemplate;
|
|
|
- CreateParamsString(groupNames, groupTypes, out paramsStr, out colNames, out colValues);
|
|
|
- FunctionGroupStr = FunctionGroupStr.Replace("{params}", paramsStr);
|
|
|
- FunctionGroupStr = FunctionGroupStr.Replace("{colNames}", colNames);
|
|
|
- FunctionGroupStr = FunctionGroupStr.Replace("{colValues}", colValues);
|
|
|
+ string functionName = string.Format("GetCfgBy{0}", string.Join("And", keyNames[key]));
|
|
|
+ string cfgsDicName = string.Format("_cfgsDicBy{0}", string.Join("And", keyNames[key]));
|
|
|
|
|
|
- configArrayStr = configArrayStr.Replace("{groupFunction}", FunctionGroupStr);
|
|
|
+ singleFunction = singleFunction + HandleSingleFunction("combinedKey_" + key, keyNames[key], keyTypes[key], functionName, cfgsDicName, configArrayStr);
|
|
|
+ strDiapose = string.Format("{0}\t\t\t{1}.Clear();\n", strDiapose, cfgsDicName);
|
|
|
}
|
|
|
- else
|
|
|
+ configArrayStr = configArrayStr.Replace("{singleFunction}", singleFunction);
|
|
|
+
|
|
|
+ string groupFunction = "";
|
|
|
+
|
|
|
+ //处理查询多条数据函数
|
|
|
+ if (groupNames.Count > 0)
|
|
|
{
|
|
|
- configArrayStr = configArrayStr.Replace("{groupFunction}", "");
|
|
|
+ int index0 = 0;
|
|
|
+ foreach (string key in groupNames.Keys)
|
|
|
+ {
|
|
|
+ string functionName = groupNames.Count == 1 ? "GetCfgs" : string.Format("GetCfgsBy{0}", string.Join("And", groupNames[key]));
|
|
|
+ string cfgsGroupDicName = string.Format("_cfgsGroupDic{0}", index0);
|
|
|
+ groupFunction = groupFunction + HandleGroupFunction("groupKey_" + key, groupNames[key], groupTypes[key], functionName, cfgsGroupDicName, configArrayStr);
|
|
|
+ strDiapose = string.Format("{0}\t\t\t{1}.Clear();", strDiapose, cfgsGroupDicName);
|
|
|
+ index0++;
|
|
|
+ }
|
|
|
}
|
|
|
+ configArrayStr = configArrayStr.Replace("{groupFunction}", groupFunction);
|
|
|
+
|
|
|
+
|
|
|
//处理全部数据函数
|
|
|
string FunctionAllStr = CodeTemplateFactory.FunctionAllTemplate;
|
|
|
configArrayStr = configArrayStr.Replace("{allFunction}", FunctionAllStr);
|
|
|
- //if (needAll)
|
|
|
- //{
|
|
|
+ configArrayStr = configArrayStr.Replace("{Init}", CodeTemplateFactory.InitTemplate);
|
|
|
+ configArrayStr = configArrayStr.Replace("{Dispose}", CodeTemplateFactory.DisposeTemplate);
|
|
|
+ configArrayStr = configArrayStr.Replace("{StrDiapose}", strDiapose);
|
|
|
+
|
|
|
configArrayStr = configArrayStr.Replace("{editorConditionStart}", "");
|
|
|
configArrayStr = configArrayStr.Replace("{editorConditionEnd}", "");
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // configArrayStr = configArrayStr.Replace("{editorConditionStart}", "#if UNITY_EDITOR");
|
|
|
- // configArrayStr = configArrayStr.Replace("{editorConditionEnd}", "#endif");
|
|
|
- //}
|
|
|
- //处理回调函数内语句块
|
|
|
- if (groupOnly)
|
|
|
- {
|
|
|
- configArrayStr = configArrayStr.Replace("{FunctionAllSingleBlock}", "");
|
|
|
- }
|
|
|
- else
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<string> singleStrArry = new List<string>();
|
|
|
+ if (!groupOnly)
|
|
|
{
|
|
|
- configArrayStr = configArrayStr.Replace("{FunctionAllSingleBlock}", CodeTemplateFactory.FunctionAllSingleBlockTemplate);
|
|
|
+ string singleStr = CodeTemplateFactory.FunctionAllSingleBlockTemplate;
|
|
|
+ singleStr = singleStr.Replace("{cfgsDicName}", "_cfgsDic");
|
|
|
+ singleStr = singleStr.Replace("{combinedKey}", "cfg.key");
|
|
|
+ singleStrArry.Add(singleStr);
|
|
|
}
|
|
|
- if (groupNames.Count > 0)
|
|
|
+ foreach (string key in keyNames.Keys)
|
|
|
{
|
|
|
- configArrayStr = configArrayStr.Replace("{FunctionAllGroupBlock}", CodeTemplateFactory.FunctionAllGroupBlockTemplate);
|
|
|
+ string cfgsDicName = string.Format("_cfgsDicBy{0}", string.Join("And", keyNames[key]));
|
|
|
+ string singleStr = CodeTemplateFactory.FunctionAllSingleBlockTemplate;
|
|
|
+ singleStr = singleStr.Replace("{cfgsDicName}", cfgsDicName);
|
|
|
+ singleStr = singleStr.Replace("{combinedKey}", "cfg.combinedKey_" + key);
|
|
|
+ singleStrArry.Add(singleStr);
|
|
|
}
|
|
|
- else
|
|
|
+ string singleStrs = string.Join("\n", singleStrArry);
|
|
|
+
|
|
|
+ List<string> groupStrArry = new List<string>();
|
|
|
+ int index1 = 0;
|
|
|
+ foreach (string key in groupNames.Keys)
|
|
|
{
|
|
|
- configArrayStr = configArrayStr.Replace("{FunctionAllGroupBlock}", "");
|
|
|
+ string cfgsDicName = string.Format("_cfgsGroupDic{0}", index1);
|
|
|
+ string singleStr = CodeTemplateFactory.FunctionAllGroupBlockTemplate;
|
|
|
+ singleStr = singleStr.Replace("{cfgsGroupDicName}", cfgsDicName);
|
|
|
+ singleStr = singleStr.Replace("{groupKey}", "cfg.groupKey_" + key);
|
|
|
+ singleStr = singleStr.Replace("{list}", "list" + index1);
|
|
|
+ groupStrArry.Add(singleStr);
|
|
|
+ index1++;
|
|
|
}
|
|
|
+ string groupStrs = string.Join("\n", groupStrArry);
|
|
|
+
|
|
|
+ configArrayStr = configArrayStr.Replace("{FunctionAllBlock}", singleStrs + "\n" + groupStrs);
|
|
|
+
|
|
|
+ // foreach()
|
|
|
//名称处理
|
|
|
configArrayStr = configArrayStr.Replace("{CfgName}", configName);
|
|
|
configArrayStr = configArrayStr.Replace("{CfgArrayName}", configArrayName);
|
|
@@ -177,17 +244,51 @@ namespace GFGEditor
|
|
|
|
|
|
Debug.LogFormat("生成{0}", configName);
|
|
|
}
|
|
|
+ private static string HandleSingleFunction(string key, List<string> keyNames, List<string> keyTypes, string functionName, string cfgsDicName, string configArrayStr)
|
|
|
+ {
|
|
|
+ string FunctionSingleStr = CodeTemplateFactory.FunctionSingleTemplate;
|
|
|
+ CreateParamsString(keyNames, keyTypes, out string paramsStr, out string colNames, out string colValues);
|
|
|
+ FunctionSingleStr = FunctionSingleStr.Replace("{params}", paramsStr);
|
|
|
+ FunctionSingleStr = FunctionSingleStr.Replace("{colNames}", colNames);
|
|
|
+ FunctionSingleStr = FunctionSingleStr.Replace("{colValues}", colValues);
|
|
|
+ FunctionSingleStr = FunctionSingleStr.Replace("{FunctionName}", functionName);
|
|
|
+ FunctionSingleStr = FunctionSingleStr.Replace("{cfgsDicName}", cfgsDicName);
|
|
|
|
|
|
- private static void ParseDataColumn(string annotation, string type, string name, int index)
|
|
|
+ _assignmentBuilder.AppendFormat("\t\t\t{0} = \"{1}\";", key, string.Join("_", keyNames));
|
|
|
+ _assignmentBuilder.AppendLine();
|
|
|
+ return FunctionSingleStr;
|
|
|
+ }
|
|
|
+ private static string HandleGroupFunction(string key, List<string> groupNames, List<string> groupTypes, string functionName, string cfgsGroupDicName, string configArrayStr)
|
|
|
+ {
|
|
|
+ string FunctionGroupStr = CodeTemplateFactory.FunctionGroupTemplate;
|
|
|
+ CreateParamsString(groupNames, groupTypes, out string paramsStr, out string colNames, out string colValues);
|
|
|
+ FunctionGroupStr = FunctionGroupStr.Replace("{params}", paramsStr);
|
|
|
+ FunctionGroupStr = FunctionGroupStr.Replace("{colNames}", colNames);
|
|
|
+ FunctionGroupStr = FunctionGroupStr.Replace("{colValues}", colValues);
|
|
|
+ FunctionGroupStr = FunctionGroupStr.Replace("{FunctionName}", functionName);
|
|
|
+ FunctionGroupStr = FunctionGroupStr.Replace("{cfgsGroupDicName}", cfgsGroupDicName);
|
|
|
+
|
|
|
+ _assignmentBuilder.AppendFormat("\t\t\t{0} = \"{1}\";", key, string.Join("_", groupNames));
|
|
|
+ _assignmentBuilder.AppendLine();
|
|
|
+ return FunctionGroupStr;
|
|
|
+
|
|
|
+ }
|
|
|
+ private static void ParseDataColumn(string annotation, string type, string name, string nameWhole, string typeWhole, int index)
|
|
|
{
|
|
|
if (type.Length > 0 && name.Length > 0)
|
|
|
{
|
|
|
+
|
|
|
+ _allNames.Add(nameWhole);
|
|
|
+ _allTypes.Add(typeWhole);
|
|
|
+ _allIndexs.Add(index);
|
|
|
+
|
|
|
+ if (_names.IndexOf(SQL_PREFIX + name) >= 0) return;
|
|
|
_names.Add(SQL_PREFIX + name);
|
|
|
_types.Add("TEXT");
|
|
|
_indexs.Add(index);
|
|
|
|
|
|
//生成解析后的数据变量
|
|
|
- _declarationBuilder.AppendFormat("\t\t//{0}", annotation);
|
|
|
+ _declarationBuilder.AppendFormat("\t\t//{0}", annotation.Split('#')[0]);
|
|
|
_declarationBuilder.AppendLine();
|
|
|
if (type.Contains("[]"))
|
|
|
{
|
|
@@ -240,7 +341,10 @@ namespace GFGEditor
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ private static ExcelWorksheet HandleExcelWorksheet(ExcelWorksheet worksheet)
|
|
|
+ {
|
|
|
+ return worksheet;
|
|
|
+ }
|
|
|
|
|
|
private static void AddDataToSql(ExcelWorksheet worksheet, string configName, string configArrayName)
|
|
|
{
|
|
@@ -265,40 +369,46 @@ namespace GFGEditor
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void WriteRowDataToSqlite(ExcelRange excelRange, string configArrayName, int row)
|
|
|
+ private static void WriteRowDataToSqlite(ExcelRange worksheet, string configArrayName, int row)
|
|
|
{
|
|
|
List<string> values = new List<string>();
|
|
|
- var keyValue = excelRange[row, 1].Text.Trim();
|
|
|
+ var keyValue = worksheet[row, 1].Text.Trim();
|
|
|
foreach (var i in _indexs)
|
|
|
{
|
|
|
- var fieldName = _names[i - 1];
|
|
|
- var value = excelRange[row, i].Text.Trim();
|
|
|
- if (configArrayName == nameof(ItemTypeCfgArray))
|
|
|
+ if (configArrayName == "GiftBagCfgArray")
|
|
|
{
|
|
|
- CacheItemTypeByName(keyValue, fieldName, value);
|
|
|
+ Debug.Log("zoya");
|
|
|
}
|
|
|
- else if (configArrayName == nameof(ItemCfgArray))
|
|
|
+ var fieldName = _allNames[i - 1];
|
|
|
+ var name = fieldName.Split('#')[0];
|
|
|
+ var value = worksheet[row, i].Text.Trim();
|
|
|
+ if (configArrayName == nameof(ItemTypeCfgArray) && name == "name")
|
|
|
{
|
|
|
- HandleItemCfgField(keyValue, fieldName, ref value);
|
|
|
+ CacheItemTypeByName(keyValue, name, value);
|
|
|
+ values.Add(value);
|
|
|
+ }
|
|
|
+ else if (configArrayName == nameof(ItemCfgArray) && (name == "itemType" || name == "subType"))
|
|
|
+ {
|
|
|
+ HandleItemCfgField(keyValue, name, ref value);
|
|
|
+ values.Add(value);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string _value = GetValue(configArrayName, worksheet, name, row, i);
|
|
|
+ values.Add(_value);
|
|
|
}
|
|
|
-
|
|
|
- //value = Regex.Replace(value, ":", "/:");
|
|
|
- values.Add(value);
|
|
|
}
|
|
|
SQLiteHelper.Instance.InsertValues(configArrayName, values.ToArray());
|
|
|
}
|
|
|
|
|
|
private static void CacheItemTypeByName(string idStr, string fieldName, string value)
|
|
|
{
|
|
|
- if (fieldName == SQL_PREFIX + "name")
|
|
|
- {
|
|
|
- _itemTypeDicByName[value] = idStr;
|
|
|
- }
|
|
|
+ _itemTypeDicByName[value] = idStr;
|
|
|
}
|
|
|
|
|
|
private static void HandleItemCfgField(string idStr, string fieldName, ref string value)
|
|
|
{
|
|
|
- fieldName = fieldName.Substring(1);
|
|
|
+ // fieldName = fieldName.Substring(1);
|
|
|
ET.Log.Debug($"idStr {idStr} fieldName {fieldName} value {value}");
|
|
|
int id = int.Parse(idStr);
|
|
|
int itemType = (int)Mathf.Floor(id / GameConst.MAX_COUNT_EVERY_TYPE_ITEM);
|
|
@@ -329,11 +439,6 @@ namespace GFGEditor
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // else if (fieldName == "resLayer1" || fieldName == "resLayer2")
|
|
|
- // {
|
|
|
- // value = value.Replace('n', '1');
|
|
|
- // value = value.Replace('t', '2');
|
|
|
- // }
|
|
|
}
|
|
|
|
|
|
private static void CreateParamsString(List<string> keyNames, List<string> keyTypes, out string paramStr, out string colNames, out string colValues)
|
|
@@ -355,5 +460,80 @@ namespace GFGEditor
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private static string GetValue(string configArrayName, ExcelRange worksheet, string name, int row, int index)
|
|
|
+ {
|
|
|
+ Dictionary<string, List<string>> _twoDimensionalDic = new Dictionary<string, List<string>>();
|
|
|
+ string value = "";
|
|
|
+ // foreach (var i in _allIndexs)
|
|
|
+ // {
|
|
|
+ for (int i = index - 1; i < _allIndexs.Count; i++)
|
|
|
+ {
|
|
|
+ // int _index = i - 1;
|
|
|
+ string _name = _allNames[i];
|
|
|
+ string[] _names = _name.Split('#');
|
|
|
+ string _type = _allTypes[i];
|
|
|
+ string[] _types = _type.Split('#');
|
|
|
+ string _value = worksheet[row, i + 1].Text.Trim();
|
|
|
+ if (_names[0] != name) continue;
|
|
|
+
|
|
|
+
|
|
|
+ if (_type.Contains("[][]") && _type.Contains("#"))
|
|
|
+ {
|
|
|
+ if (!_twoDimensionalDic.ContainsKey(_types[1]) && string.IsNullOrEmpty(_value))
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(_value))
|
|
|
+ {
|
|
|
+ ET.Log.Error(configArrayName + " 第" + row + "行 " + _type + " 无数值!");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!_twoDimensionalDic.ContainsKey(_types[1]))
|
|
|
+ {
|
|
|
+ _twoDimensionalDic.Add(_types[1], new List<string>());
|
|
|
+ }
|
|
|
+ _twoDimensionalDic[_types[1]].Add(_value);
|
|
|
+ }
|
|
|
+ else if (_type.Contains("[]") && _type.Contains("#"))
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(_value)) continue;
|
|
|
+ if (string.IsNullOrEmpty(value))
|
|
|
+ {
|
|
|
+ value = _value;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ value = string.Format("{0};{1}", value, _value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ value = _value;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (_twoDimensionalDic.Count > 0)
|
|
|
+ {
|
|
|
+ List<string> _values = new List<string>();
|
|
|
+ foreach (string key in _twoDimensionalDic.Keys)
|
|
|
+ {
|
|
|
+ // if (!_twoDimensionalDic[key].ContainsKey(0)) continue;
|
|
|
+ // string _value0 = _twoDimensionalDic[key][0];
|
|
|
+ // if (!_twoDimensionalDic[key].ContainsKey(1))
|
|
|
+ // {
|
|
|
+ // _values.Add(_value0);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // string str = string.Format("{0}*{1}", _value0, _twoDimensionalDic[key][1]);
|
|
|
+ // _values.Add(str);
|
|
|
+ // }
|
|
|
+ _values.Add(string.Join("*", _twoDimensionalDic[key]));
|
|
|
+ }
|
|
|
+ value = string.Join(";", _values);
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|