public ref ObservableCollection <IDListItem> GetIDList(string excelpath) { currentLuaTableData = InitLuaTableData(excelpath); currentExcelpath = excelpath; if (currentLuaTableData.tableDiffs.Count <= 0) { for (int i = 1; i < currentLuaTableData.tables.Count; i++) { currentLuaTableData.tableDiffs.Add(CompareTable(currentLuaTableData.tables[0], currentLuaTableData.tables[i])); } } if (currentLuaTableData.idList == null) { currentLuaTableData.idList = new ObservableCollection <IDListItem>(); for (int i = 0; i < currentLuaTableData.tables[0].configs.Count; i++) { currentLuaTableData.idList.Add(new IDListItem { ID = currentLuaTableData.tables[0].configs[i].key, Row = i, States = GetRowAllStatus(currentLuaTableData.tables[0].configs[i].key), IsApplys = new List <bool>() { false, false, false, false } }); } Dictionary <string, IDListItem> tmpDic = GetExcelDeletedRow(); foreach (var item in tmpDic.Values) { currentLuaTableData.idList.Add(item); } } return(ref currentLuaTableData.idList); }
private LuaTableData InitLuaTableData(string excelpath) { if (!_lTableDataDic.ContainsKey(excelpath)) { _lTableDataDic[excelpath] = new LuaTableData { tables = new List <table>(), tableDiffs = new List <tablediff>() }; } //对比md5,看是否需要重新生成LocalLuaTable llt string tablename = string.Format("Table_{0}", Path.GetFileNameWithoutExtension(excelpath)); string lltpath = Path.Combine(SourcePath, LocalTmpTablePath, tablename + ".txt"); string md5 = ExcelParserFileHelper.GetMD5HashFromFile(excelpath); LuaTableData ltd = _lTableDataDic[excelpath]; if (!File.Exists(lltpath) || md5 != ReadTableMD5(lltpath)) { ExcelParser.ReGenLuaTable(excelpath); } if (!ltd.IsInitTable(0)) { ltd.ModifiedTables(0, parse(lltpath)); } TmpTableRealPaths = GenTmpPath(tablename); for (int i = 1; i < TmpTableRealPaths.Count + 1; i++) { if (File.Exists(TmpTableRealPaths[i - 1])) { if (!ltd.IsInitTable(i)) { ltd.ModifiedTables(i, parse(TmpTableRealPaths[i - 1])); } } else { if (!ltd.IsInitTable(i)) { ltd.ModifiedTables(i, null); } } } return(ltd); }
public ObservableCollection <IDListItem> GetIDList(string excelpath) { previousLuaTableData = currentLuaTableData; currentLuaTableData = InitLuaTableData(excelpath); if (currentLuaTableData == null) { return(null); } currentExcelpath = excelpath; if (currentLuaTableData.tableDiffs.Count <= 0) { for (int i = 1; i < currentLuaTableData.tables.Length; i++) { currentLuaTableData.tableDiffs.Add(CompareTable(currentLuaTableData.tables[0], currentLuaTableData.tables[i])); } } if (currentLuaTableData.idList == null) { currentLuaTableData.idList = new ObservableCollection <IDListItem>(); for (int i = 0; i < currentLuaTableData.tables[0].configs.Count; i++) { currentLuaTableData.idList.Add(new IDListItem { ID = currentLuaTableData.tables[0].configs[i].key, IdDisplay = IDListItem.GenIdDisplay(currentLuaTableData.tables[0].configs[i]), Row = i, States = GetRowAllStatus(currentLuaTableData.tables[0].configs[i].key), }); } Dictionary <string, IDListItem> tmpDic = GetExcelDeletedRow(); foreach (var item in tmpDic.Values) { currentLuaTableData.idList.Add(item); } } return(currentLuaTableData.idList); }
private LuaTableData InitLuaTableData(string excelpath) { if (!_lTableDataDic.ContainsKey(excelpath)) { LuaTableData ltd = new LuaTableData { tableDiffs = new List <tablediff>() }; #region 对比md5,看是否需要重新生成LocalLuaTable llt string tablename = string.Format("Table_{0}", Path.GetFileNameWithoutExtension(excelpath)); string slltpath = GetLocalServerLuaPath(tablename); string clltpath = GetLocalClientLuaPath(excelpath); string md5 = ExcelParserFileHelper.GetMD5HashFromFile(excelpath); bool isServer = ExcelParserFileHelper.IsServer(excelpath); if (md5 == null) { return(null); } if (!File.Exists(slltpath) || md5 != ReadTableMD5(slltpath) || (!isServer && (!File.Exists(clltpath) || md5 != ReadTableMD5(clltpath)))) { if (!ExcelParser.ReGenLuaTable(excelpath)) { return(null); } } #endregion try { ltd.tables[0] = parse(slltpath, excelpath); } catch (LuaTableException ex) /*可能会有重复ID的错误 和 Lua table 语法错误*/ { System.Windows.Forms.MessageBoxButtons button = System.Windows.Forms.MessageBoxButtons.OK; System.Windows.Forms.DialogResult errorDr = System.Windows.Forms.MessageBox.Show(ex.Message, "错误", button); if (errorDr == System.Windows.Forms.DialogResult.OK) { return(null); } } for (int i = 1; i < BranchCount + 1; i++) { string serverLuaPath = GetBranchServerLuaPath(tablename, i - 1); if (File.Exists(serverLuaPath)) { try { ltd.tables[i] = parse(serverLuaPath, excelpath); } catch (LuaTableException ex) { System.Windows.Forms.MessageBoxButtons button = System.Windows.Forms.MessageBoxButtons.OK; System.Windows.Forms.DialogResult errorDr = System.Windows.Forms.MessageBox.Show(serverLuaPath + "\n" + ex.Message, "错误", button); if (errorDr == System.Windows.Forms.DialogResult.OK) { return(null); } } } else { string excelName = Path.GetFileNameWithoutExtension(excelpath); ltd.tables[i] = new table(ReadTableMD5(slltpath), string.Format("Table_{0}", excelName), excelpath); } } _lTableDataDic[excelpath] = ltd; } return(_lTableDataDic[excelpath]); }