Added code to replace the repetitive message box popups when an orphaned records are identified during the creation of a rofst with a single message box at the end of creating a rofst directing the user to a file that contains all of the orphaned records

This commit is contained in:
Rich 2015-02-05 03:47:04 +00:00
parent ef9e32b9d6
commit 3f945b04c5
2 changed files with 22 additions and 6 deletions

View File

@ -101,6 +101,7 @@ using System.Runtime.InteropServices;
using VlnStatus; using VlnStatus;
using System.Collections.Specialized; using System.Collections.Specialized;
using ROFST_FILE; using ROFST_FILE;
using Volian.Base.Library;
//using VlnProfiler; //don't forget to add VlnProfiler to the reference list //using VlnProfiler; //don't forget to add VlnProfiler to the reference list
@ -261,6 +262,14 @@ namespace ROEditor
} }
File.Copy(FstNew,FstPath,true); // save ROFST.NEW as RO.fST File.Copy(FstNew,FstPath,true); // save ROFST.NEW as RO.fST
File.Delete(FstNew); // remove ROFST.NEW File.Delete(FstNew); // remove ROFST.NEW
if (OrphanedRecords.Length > 0)
{
StreamWriter sw = new StreamWriter(VlnSettings.TemporaryFolder + @"\Orphaned RO Records.txt");
sw.Write(OrphanedRecords.ToString());
sw.Close();
MessageBox.Show("The file Orphaned RO Records.txt has been created", "Warning - Orphan RO Record");
}
MessageBox.Show("New RO.FST file created successfully.","Create RO.FST file",System.Windows.Forms.MessageBoxButtons.OK); MessageBox.Show("New RO.FST file created successfully.","Create RO.FST file",System.Windows.Forms.MessageBoxButtons.OK);
} }
// MessageBox.Show(Profiler.ToString("000.00%"),"Timings"); // MessageBox.Show(Profiler.ToString("000.00%"),"Timings");
@ -531,7 +540,7 @@ namespace ROEditor
// Profiler.End("Finish"); // Profiler.End("Finish");
return RtnVal; return RtnVal;
} }
StringBuilder OrphanedRecords = new StringBuilder();
private uint SaveFstGroup(XmlNode GroupNode, uint parentID,ref ushort typ,ArrayList AvailList,string AccPageIDTplate) private uint SaveFstGroup(XmlNode GroupNode, uint parentID,ref ushort typ,ArrayList AvailList,string AccPageIDTplate)
{ {
uint RtnVal; uint RtnVal;
@ -568,7 +577,7 @@ namespace ROEditor
{ {
// Profiler.Start("GetChildData"); // Profiler.Start("GetChildData");
// ROdatabase.RODB_GetChildData(elem,true); // ROdatabase.RODB_GetChildData(elem,true);
ROdatabase.RODB_GetGroupAndSubgroups(elem); ROdatabase.RODB_GetGroupAndSubgroups(elem, OrphanedRecords);
// Profiler.End("GetChildData"); // Profiler.End("GetChildData");
} }

View File

@ -1203,7 +1203,7 @@ namespace RODBInterface
// Note that this function is designed to be call for the // Note that this function is designed to be call for the
// root node (i.e. it gets all of group and RO data for a given // root node (i.e. it gets all of group and RO data for a given
// database table) // database table)
public bool RODB_GetGroupAndSubgroups(VlnXmlElement node) public bool RODB_GetGroupAndSubgroups(VlnXmlElement node, StringBuilder sb)
{ {
VlnStatusBar StatBar = new VlnStatusBar("Reading from the Database"); VlnStatusBar StatBar = new VlnStatusBar("Reading from the Database");
string tablename = node.GetAttribute("Table"); string tablename = node.GetAttribute("Table");
@ -1236,8 +1236,15 @@ namespace RODBInterface
{ {
if (!dicGroups.Contains(ParID)) if (!dicGroups.Contains(ParID))
{ {
string strMBText = "The following record is being skipped. The parent for this RO is missing:\n\n RecID: " + RecID + "\n\n Table: " + tablename +"\n"; if (sb.Length == 0)
MessageBox.Show(strMBText, "Warning - Orphan RO Record"); {
sb.AppendLine("The following records were skipped.");
sb.AppendLine("The parent for these RO's was missing.");
sb.AppendLine();
}
string strMBText = "RecID: " + RecID + "\n\n Table: " + tablename +"\n";
sb.AppendLine(strMBText);
// MessageBox.Show(strMBText, "Warning - Orphan RO Record");
continue; // skip - no parent for this node continue; // skip - no parent for this node
} }
node = (VlnXmlElement)dicGroups[ParID]; node = (VlnXmlElement)dicGroups[ParID];
@ -1636,7 +1643,7 @@ namespace RODBInterface
{ {
DBE.Command(readstr); DBE.Command(readstr);
DBE.Reader(); DBE.Reader();
if (recid == null) if (recid == null)
DBE.Read(); // skip the first parentID record of 00000000 DBE.Read(); // skip the first parentID record of 00000000