void parseCheckDic() { checkHelper = new CheckerHelper(); TextAsset data = Resources.Load("TestJson_define/def-Character_Character", typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject Character = new JSONObject(strSrc); checkHelper.tableName = Character ["tablename"].str; Debug.Log(" table check : " + checkHelper.tableName); List <JSONObject> jsonList = Character ["tablefields"].list; for (int i = 0; i < jsonList.Count; i++) { CharacterInfoChecker checker = new CharacterInfoChecker(); checker.name = jsonList[i]["name"].str; checker.datatype = jsonList[i]["datatype"].str; checker.isunique = jsonList[i]["isunique"].b; if (jsonList[i].HasField("ref_tables")) { List <JSONObject> refTableList = jsonList[i]["ref_tables"].list; for (int j = 0; j < refTableList.Count; j++) { CharacterInfoChecker.ReferenceTable refTable = new CharacterInfoChecker.ReferenceTable(); refTable.name = refTableList[j]["tableName"].str; refTable.field = refTableList[j]["tableField"].str; checker.referenceTable.Add(j, refTable); } } checkHelper.checkerInfoDic.Add(checker.name, checker); } }
public void LoadLowDataForTableCheck() { parseCheckDic(); TextAsset data = Resources.Load("TestJson/" + checkHelper.tableName, typeof(TextAsset)) as TextAsset; StringReader sr = new StringReader(data.text); string strSrc = sr.ReadToEnd(); JSONObject Character = new JSONObject(strSrc); for (int i = 0; i < Character.list.Count; i++) { //CharacterInfo tmpInfo = new CharacterInfo (); foreach (string s in checkHelper.checkerInfoDic.Keys) { if (Character[i].HasField(s)) { // 자료형에 따른 데이터 유효성체크이나 별 의미가 없어서 주석처리 //int 형이라고 지정되어 있다고해도 int가 들어오는지 아닌지 알수가 없다. /* * if (checkerInfoDic[s].datatype == "unsigned int"){ * if (!Character[i][s].IsNumber){ * Debug.LogError("["+i+"],"+ s + " is not number"); * } * } * else if (checkerInfoDic[s].datatype == "byte"){ * if (!Character[i][s].IsNumber){ * Debug.LogError("["+i+"],"+ s + " is not number"); * } * } * else if (checkerInfoDic[s].datatype == "string"){ * if (Character[i][s].IsNull){ * Debug.LogError("["+i+"],"+ s + " is null"); * } * } * else if (checkerInfoDic[s].datatype == "float"){ * if (Character[i][s].IsNull){ * Debug.LogError("["+i+"],"+ s + " is null"); * } * } * else{ * Debug.Log(" checkerInfoDic[s].datatype :"+checkerInfoDic[s].datatype); * } */ //Debug.Log("check field : "+s); // 상호참조하는 ID 체크 for (int k = 0; k < checkHelper.checkerInfoDic[s].referenceTable.Count; k++) { // 이 테이블에서의 ID uint checkID1 = (uint)Character[i][s].n; CharacterInfoChecker.ReferenceTable refTable = checkHelper.checkerInfoDic[s].referenceTable[k]; //Debug.Log("check field > "+s+" : "+checkID1+" || ref table: "+refTable.name+" ["+refTable.field+"]"); // //check field > NameId_ui : 1 || ref table: Local_StringUnit [StringId_ui] JSONObject StringUnitSub = _LowDataMgr.instance.getJsonObj(refTable.name); // find id int idCnt = 0; for (int m = 0; m < StringUnitSub.list.Count; m++) { if (StringUnitSub[m].HasField(refTable.field)) { uint checkID2 = (uint)StringUnitSub[m][refTable.field].n; if (checkID1 == checkID2) { idCnt++; //Debug.Log(refTable.name+"["+refTable.field+"] has "+checkID2+", OK"); // Local_StringUnit[StringId_ui] has 1, OK } } else { // 참조해야할 테이블에서 해당 필드가 없다. error Debug.LogError(refTable.name + " dont have " + refTable.field + " field"); } } if (idCnt == 0) { Debug.LogError(" reference table error, table:" + refTable.name + ", field:" + refTable.field + ", not found id:" + checkID1); } } } } } // ////// ref table check // for (int i=0; i<checkerInfoDic.Count; i++) { // // checkerInfoDic[i].name // for(int j=0; j < checkerInfoDic[i].referenceTable.Count;j++){ // // string refTableField = checkerInfoDic[i].referenceTable[j].field; // string refTableName = checkerInfoDic[i].referenceTable[j].name; // // TextAsset data2 = Resources.Load("TestJson/"+refTableName, typeof(TextAsset)) as TextAsset; // StringReader sr2 = new StringReader(data2.text); // string strSrc2 = sr2.ReadToEnd(); // JSONObject StringUnit2 = new JSONObject(strSrc2); // // for (int k = 0; k < StringUnit2.list.Count; k++) // { // if (StringUnit2[k].HasField(refTableField)){ // StringUnit2[k][refTableField].n // } // tmpInfo.StringId = (uint)StringUnit2[k]["StringId_ui"].n; // } // // // } // } Debug.Log(checkHelper.tableName + " check finish"); /* * TextAsset data = Resources.Load("TestJson/Local_StringUnit", typeof(TextAsset)) as TextAsset; * StringReader sr = new StringReader(data.text); * string strSrc = sr.ReadToEnd(); * JSONObject StringUnit = new JSONObject(strSrc); * * for (int i = 0; i < StringUnit.list.Count; i++) * { * StringUnitInfo tmpInfo = new StringUnitInfo(); * tmpInfo.StringId = (uint)StringUnit[i]["StringId_ui"].n; */ }