Пример #1
0
        //仅修改逻辑缓存中的值,不直接修改配置文件
        public void ApplyRow(int branchIdx, IDListItem item)
        {
            //if(currentTablediffs.Count > branchIdx && currentTables.Count > branchIdx + 1 &&
            //    currentTablediffs[branchIdx] != null && currentTables[branchIdx + 1] != null &&
            //    item != null && item.States.Count > branchIdx)
            //{
            //}
            table     lt  = currentLuaTableData.tables[0];             //local table
            table     bt  = currentLuaTableData.tables[branchIdx + 1]; //branch table
            tablediff btd = currentLuaTableData.tableDiffs[branchIdx]; //branch tablediff

            if (bt == null)
            {
                bt = new table(lt);
                currentLuaTableData.tables[branchIdx + 1] = bt;
            }

            string status = item.States[branchIdx];

            btd.Apply(status, item.ID, bt, lt);
            if (currentLuaTableData.applyedRows == null)
            {
                currentLuaTableData.applyedRows = new Dictionary <string, Dictionary <int, string> >();
            }
            if (!currentLuaTableData.applyedRows.ContainsKey(item.ID))
            {
                currentLuaTableData.applyedRows[item.ID] = new Dictionary <int, string>();
            }
            currentLuaTableData.applyedRows[item.ID][branchIdx] = item.States[branchIdx];
            int index = currentLuaTableData.idList.IndexOf(item);

            _lTableDataDic[currentExcelpath].idList[index].SetStates(STATUS_NONE, branchIdx);
        }
Пример #2
0
        //根据目前选择的操作,修改配置文件
        public void ExcuteModified(int branchIdx)
        {
            table     bt         = currentLuaTableData.tables[branchIdx + 1]; //branch table
            tablediff btd        = currentLuaTableData.tableDiffs[branchIdx]; //branch tablediff
            string    tmp        = bt.GenString(null, btd);
            string    aimTmpPath = TmpTableRealPaths[branchIdx];

            FileUtil.WriteTextFile(tmp, aimTmpPath);
        }
Пример #3
0
        public void CancelRow(int branchIdx, IDListItem item)
        {
            Dictionary <string, Dictionary <int, string> > applyedRows = currentLuaTableData.applyedRows;
            table     bt  = currentLuaTableData.tables[branchIdx + 1]; //branch table
            tablediff btd = currentLuaTableData.tableDiffs[branchIdx]; //branch tablediff

            if (bt == null)
            {
                return;
            }
            btd.Cancel(item.ID, bt);
            int index = currentLuaTableData.idList.IndexOf(item);

            _lTableDataDic[currentExcelpath].idList[index].SetStates(applyedRows[item.ID][branchIdx], branchIdx);
            applyedRows[item.ID][branchIdx] = "";
        }
Пример #4
0
            public string GenString(Func <string> callback = null, tablediff filter = null)
            {
                StringBuilder sb = new StringBuilder();

                sb.Append("--" + md5 + "\n");
                sb.Append(name + " = {\n");
                int rows = 0;

                for (int i = 0; i < configs.Count; i++)
                {
                    if (filter != null && filter.addedrows.ContainsKey(configs[i].key))
                    {
                        continue;
                    }
                    if (filter != null && filter.modifiedrows.ContainsKey(configs[i].key))
                    {
                        AppendConfig(ref sb, configs[i], filter.modifiedrows[configs[i].key]);
                    }
                    else
                    {
                        AppendConfig(ref sb, configs[i]);
                    }
                    rows++;
                }
                //if (filter != null && filter.deletedrows.Count > 0)//是否需要追加若干行配置
                //{
                //    AppendExcelDelRows(filter.deletedrows, ref sb);
                //    rows++;
                //}
                if (rows > 0)
                {
                    sb.Remove(sb.Length - 2, 1);//删除最后一行的逗号 ','
                }
                sb.Append("}\n");
                if (callback != null)
                {
                    sb.Append(callback());
                }
                sb.Append("return " + name);
                return(sb.ToString());
            }