コード例 #1
0
ファイル: CheckExtend.cs プロジェクト: wcsjb/XiaoGame_New
        public static CheckResult Check(this RowData row)
        {
            CheckResult result = new CheckResult(true);

            //TODO: CHECK ROW

            if (!result.isSucceed)
            {
                return(result);
            }

            foreach (var cell in row.cells)
            {
                result = cell.Check();
                if (!result.isSucceed)
                {
                    break;
                }
            }
            return(result);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: wcsjb/XiaoGame_New
        static void Main(string[] args)
        {
            try
            {
                string exePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
#if DEBUG
                exePath = TOOLS_PATH;
#endif
                IniFile        ini            = new IniFile(exePath + "config.ini");
                string         xmlDir         = exePath + ini.ReadValue("Checker", "XmlDir");
                string         languageXmlDir = exePath + ini.ReadValue("Checker", "LanguageXmlDir");
                CheckerManager mgr            = new CheckerManager();
                CheckResult    result         = mgr.CheckDirectory(xmlDir);
                if (result.isSucceed)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine(result);
                    File.Delete(exePath + ".lock");
                    if (args.Length == 0)
                    {
                        Console.ReadKey();
                    }
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(result);
                    Console.ReadKey();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + "    " + e.StackTrace);
                Console.ReadKey();
            }
        }
コード例 #3
0
ファイル: CheckExtend.cs プロジェクト: wcsjb/XiaoGame_New
        public static CheckResult Check(this TableData table)
        {
            Console.WriteLine(table.name);

            CheckResult result = new CheckResult(true);

            //raw_name, raw_type
            List <CellData> rawNames = table.sheets[0].rows[0].cells;
            List <CellData> rawTypes = table.sheets[0].rows[1].cells;

            //check repeated
            foreach (var rawName in rawNames)
            {
                var group = rawNames.FindAll(a => a.value == rawName.value);
                if (group.Count >= 2)
                {
                    result.Set(false, string.Format("Sheet({0}) 存在重复的属性名(第一行是属性名)" +
                                                    ", 属性名{1}, {2}行,{3}({4})列 与 {5}行,{6}({7})列 "
                                                    , table.sheets[0].name, rawName.value
                                                    , group[0].rowIndex + 1, group[0].columnIndex + 1, CellExtend.IntToNumberSystem26(group[0].columnIndex + 1)
                                                    , group[1].rowIndex + 1, group[1].columnIndex + 1, CellExtend.IntToNumberSystem26(group[1].columnIndex + 1)));
                    return(result);
                }
            }

            for (int i = 1; i < table.sheets.Count; i++)
            {
                for (int j = 0; j < rawNames.Count; j++)
                {
                    var rawNameCell = rawNames[j];
                    var nameCell    = table.sheets[i].rows[0].cells[j];
                    if (rawNameCell.value != nameCell.value)
                    {
                        result.Set(false, string.Format("Sheet({0}) 存在不一致的属性名(第一行是属性名)" +
                                                        ", 属性名{1}, 原始属性名{2}, {3}行,{4}({5})列 "
                                                        , table.sheets[i].name, nameCell.value, rawNameCell.value
                                                        , nameCell.rowIndex + 1, nameCell.columnIndex + 1, CellExtend.IntToNumberSystem26(nameCell.columnIndex + 1)));
                        return(result);
                    }


                    var rawTypeCell = rawTypes[j];
                    var typeCell    = table.sheets[i].rows[1].cells[j];
                    if (rawTypeCell.value != typeCell.value)
                    {
                        result.Set(false, string.Format("Sheet({0}) 存在不一致的类型(第二行是类型)" +
                                                        ", 类型{1}, 原始类型{2}, {3}行,{4}({5})列 "
                                                        , table.sheets[i].name, typeCell.value, rawTypeCell.value
                                                        , typeCell.rowIndex + 1, typeCell.columnIndex + 1, CellExtend.IntToNumberSystem26(typeCell.columnIndex + 1)));
                        return(result);
                    }
                }
            }

            HashSet <string> ids = new HashSet <string>();

            foreach (var sheet in table.sheets)
            {
                int ignoreRow = 3;
                foreach (var row in sheet.rows)
                {
                    if (row.cells.Count < 0 || ignoreRow-- > 0)
                    {
                        continue;
                    }
                    string id = row.cells[0].value;
                    if (ids.Contains(id))
                    {
                        result.Set(false,
                                   string.Format("Sheet({0}) 存在重复的ID:{1}",
                                                 sheet.name, id));
                        return(result);
                    }
                    else
                    {
                        ids.Add(id);
                    }
                }
            }


            if (!result.isSucceed)
            {
                return(result);
            }

            foreach (var sheet in table.sheets)
            {
                result = sheet.Check();
                if (!result.isSucceed)
                {
                    break;
                }
            }
            Console.WriteLine();
            return(result);
        }