private async void delayFunc() { await Task.Delay(1000); switch (getCBoxDB2Text()) { case "itemdisplayinfo": db2.ListeItemDisplayInfo(db2CustomPath, getCBoxDB2Text() + "_custom.csv"); break; case "itemdisplayinfomaterialres": db2.ListeItemDisplayInfoMaterialRes(db2CustomPath, getCBoxDB2Text() + "_custom.csv"); break; case "modelfiledata": db2.ListeModelFileData(db2CustomPath, getCBoxDB2Text() + "_custom.csv"); break; case "texturefiledata": db2.ListeTextureFileData(db2CustomPath, getCBoxDB2Text() + "_custom.csv"); break; default: break; } }
private void modelFiledata() { sb.Clear(); sb.AppendLine("\"LodCount\",\"FileDataID\",\"ModelResourcesID\",\"RelationshipData\""); string header = sb.ToString(); sb.Clear(); string pathCSVGen = Path.Combine(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "modelfiledata.csv"); if (File.Exists(pathCSVGen)) { File.Delete(pathCSVGen); } File.AppendAllText(pathCSVGen, header); if (File.Exists(Path.Combine(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "modelfiledataGen.csv"))) { File.Delete(Path.Combine(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "modelfiledataGen.csv")); } db2.ListeModelFileData(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "modelfiledataGen.csv"); int maxMaterialID = 0; string pathDB2Read = Path.Combine(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "modelfiledataGen.csv"); if (File.Exists(pathDB2Read)) { string[] temp = File.ReadAllLines(pathDB2Read); sb.Clear(); for (int i = 0; i < temp.Length; i++) { sb.AppendLine(temp[i].Split(',')[2]); } File.WriteAllText(pathDB2Read, sb.ToString()); sb.Clear(); maxMaterialID = File.ReadAllLines(pathDB2Read).Select(int.Parse).Max() + 1; string file1 = File.ReadAllText(pathDB2Read); if (dataGridView1.DataSource != null) { for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) { if (!file1.Contains(dataGridView1.Rows[i].Cells[1].Value.ToString()) && dataGridView1.Rows[i].Cells[0].Value.ToString().Contains(".m2")) { sb.AppendLine("\"0\",\"" + dataGridView1.Rows[i].Cells[1].Value + "\",\"" + maxMaterialID + "\",\"" + maxMaterialID + "\""); maxMaterialID++; } } } File.AppendAllText(pathCSVGen, sb.ToString()); sb.Clear(); } else { db2.ListeModelFileDataLastOffi(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "modelfiledataLastOffi.csv"); string PathCSV = Path.Combine(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "modelfiledataLastOffi.csv"); string temp = File.ReadAllText(PathCSV); maxMaterialID = int.Parse(temp.Split(',')[2]) + 1; if (maxMaterialID < 50000) { maxMaterialID = 50000; } if (dataGridView1.DataSource != null) { for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) { if (dataGridView1.Rows[i].Cells[0].Value.ToString().Contains(".m2")) { sb.AppendLine("\"0\",\"" + dataGridView1.Rows[i].Cells[1].Value + "\",\"" + maxMaterialID + "\",\"" + maxMaterialID + "\""); maxMaterialID++; } } } File.AppendAllText(pathCSVGen, sb.ToString()); sb.Clear(); } }