B2017-011: Complete report, sorted by setpoint id, crashes if duplicate setpoint id

B2017-011: Complete report, don’t crash if requested ro is not in database
This commit is contained in:
Kathy Ruffing 2017-01-19 17:51:45 +00:00
parent 431503a104
commit 3e5741ef75
2 changed files with 63 additions and 57 deletions

View File

@ -96,9 +96,9 @@ namespace CmpRpt
bool success; bool success;
VlnXmlElement rootXml; VlnXmlElement rootXml;
VlnXmlDocument myroXmlDoc; VlnXmlDocument myroXmlDoc;
string recid=null; string recid = null;
string tbl=null; string tbl = null;
RODB myrodb=null; RODB myrodb = null;
// the next two lists contain group headers for the reports. // the next two lists contain group headers for the reports.
ArrayList headers = new ArrayList(); ArrayList headers = new ArrayList();
ArrayList reversehdrs = new ArrayList(); ArrayList reversehdrs = new ArrayList();
@ -126,7 +126,7 @@ namespace CmpRpt
// recid = args[0].Substring(4, 8); // recid = args[0].Substring(4, 8);
// // myrodb = new RODB(Directory.GetCurrentDirectory()); // // myrodb = new RODB(Directory.GetCurrentDirectory());
//} //}
/******/ /******/
// if an RO directory path was passed in, then change the // if an RO directory path was passed in, then change the
// current working directory to it. // current working directory to it.
// this path will also be used to generate a connection string // this path will also be used to generate a connection string
@ -139,12 +139,12 @@ namespace CmpRpt
Directory.SetCurrentDirectory(path); Directory.SetCurrentDirectory(path);
} }
myrodb = new RODB(Directory.GetCurrentDirectory()); myrodb = new RODB(Directory.GetCurrentDirectory());
VlnXmlElement rptele=null; VlnXmlElement rptele = null;
// Add the root to the tree // Add the root to the tree
myroXmlDoc = myrodb.RODB_GetRoot(); myroXmlDoc = myrodb.RODB_GetRoot();
rootXml = (VlnXmlElement) myroXmlDoc.FirstChild; rootXml = (VlnXmlElement)myroXmlDoc.FirstChild;
success = myrodb.RODB_GetRootGroups(rootXml); success = myrodb.RODB_GetRootGroups(rootXml);
if (success == false) return; if (success == false) return;
@ -191,7 +191,8 @@ namespace CmpRpt
// read in this element from the table. // read in this element from the table.
rptele = myrodb.RODB_ReadRO(tbname, recid); rptele = myrodb.RODB_ReadRO(tbname, recid);
if (rptele != null)
{
VlnXmlElement parent; VlnXmlElement parent;
string parentid; string parentid;
parentid = rptele.GetAttribute("ParentID"); parentid = rptele.GetAttribute("ParentID");
@ -240,12 +241,13 @@ namespace CmpRpt
int cnt = reversehdrs.Count; int cnt = reversehdrs.Count;
for (int i = cnt - 1; i >= 0; i--) for (int i = cnt - 1; i >= 0; i--)
headers.Add(reversehdrs[i]); headers.Add(reversehdrs[i]);
}
myrodb.MyDBID = tbl; myrodb.MyDBID = tbl;
rptele.Show(myrodb, headers, showStat); rptele.Show(myrodb, headers, showStat);
Application.DoEvents(); Application.DoEvents();
headers.Clear(); headers.Clear();
reversehdrs.Clear(); reversehdrs.Clear();
}
}
}// end foreach roid }// end foreach roid
if (showStat != null) if (showStat != null)
showStat.Dispose(); showStat.Dispose();

View File

@ -187,6 +187,10 @@ namespace Volian.Controls.Library
{ {
rtnstr = rodbidPrefix + string.Format("{0}", roc.roid); rtnstr = rodbidPrefix + string.Format("{0}", roc.roid);
keystr = ((roc.appid == "") ? GetNextBlankKey() : roc.appid) + chld.roid.Substring(0, 4); keystr = ((roc.appid == "") ? GetNextBlankKey() : roc.appid) + chld.roid.Substring(0, 4);
if (AccIDROIDdic.ContainsKey(keystr)) // For duplicates, append the parent title (B2017-011) so adding to dictionary doesn't crash.
{
keystr = keystr + "|" + chld.title;
}
AccIDROIDdic.Add(keystr, rtnstr); AccIDROIDdic.Add(keystr, rtnstr);
} }
} }