bool ParseClasses(string iFileName) { int num1 = 0; StreamReader iStream; try { iStream = new StreamReader(iFileName); } catch (Exception ex) { ProjectData.SetProjectError(ex); Interaction.MsgBox(ex.Message, MsgBoxStyle.Critical, "IO CSV Not Opened"); ProjectData.ClearProjectError(); return(false); } int num3 = 0; int num4 = 0; int num5 = 0; try { string iLine; do { iLine = FileIO.ReadLineUnlimited(iStream, char.MinValue); if (iLine != null) { if (!iLine.StartsWith("#")) { ++num5; if (num5 >= 9) { this.BusyMsg(Strings.Format(num3, "###,##0") + " records parsed."); num5 = 0; } string[] array = CSV.ToArray(iLine); string uidEntity = ""; if (array.Length > 1) { int index = -2; if (array[0].StartsWith("Pets.")) { uidEntity = "Pets_" + array[1]; index = DatabaseAPI.NidFromUidEntity(uidEntity); } else if (array[0].StartsWith("Villain_Pets.")) { uidEntity = "Pets_" + array[1]; index = DatabaseAPI.NidFromUidEntity(uidEntity); } if (index > -2) { SummonedEntity.Parse(index, array[0], array[2], uidEntity); ++num1; } else { ++num4; } } } ++num3; } }while (iLine != null); } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception exception = ex; iStream.Close(); Interaction.MsgBox(exception.Message, MsgBoxStyle.Critical, "Entity CSV Parse Error"); ProjectData.ClearProjectError(); return(false); } iStream.Close(); var serializer = My.MyApplication.GetSerializer(); DatabaseAPI.SaveMainDatabase(serializer); this.DisplayInfo(); Interaction.MsgBox(("Parse Completed!\r\nTotal Records: " + Conversions.ToString(num3) + "\r\nGood: " + Conversions.ToString(num1) + "\r\nRejected: " + Conversions.ToString(num4)), MsgBoxStyle.Information, "File Parsed"); return(true); }
private bool ParseClasses(string iFileName) { var num1 = 0; StreamReader iStream; try { iStream = new StreamReader(iFileName); } catch (Exception ex) { MessageBox.Show(ex.Message, "IO CSV Not Opened", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } var num3 = 0; var num4 = 0; var num5 = 0; try { string iLine; do { iLine = FileIO.ReadLineUnlimited(iStream, char.MinValue); if (iLine == null) { continue; } if (!iLine.StartsWith("#")) { ++num5; if (num5 >= 9) { BusyMsg(Strings.Format(num3, "###,##0") + " records parsed."); num5 = 0; } var array = CSV.ToArray(iLine); var uidEntity = ""; if (array.Length > 1) { var index = -2; if (array[0].StartsWith("Pets.")) { uidEntity = "Pets_" + array[1]; index = DatabaseAPI.NidFromUidEntity(uidEntity); } else if (array[0].StartsWith("Villain_Pets.")) { uidEntity = "Pets_" + array[1]; index = DatabaseAPI.NidFromUidEntity(uidEntity); } if (index > -2) { SummonedEntity.Parse(index, array[0], array[2], uidEntity); ++num1; } else { ++num4; } } } ++num3; } while (iLine != null); } catch (Exception ex) { iStream.Close(); MessageBox.Show(ex.Message, "Entity CSV Parse Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } iStream.Close(); var serializer = MyApplication.GetSerializer(); DatabaseAPI.SaveMainDatabase(serializer); DisplayInfo(); MessageBox.Show($"Parse Completed!\r\nTotal Records: {num3}\r\nGood: {num1}\r\nRejected: {num4}", "File Parsed", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); }