From 3e5741ef757a4ec1a6c3c7234c4f1b0f5493a0d4 Mon Sep 17 00:00:00 2001 From: Kathy Date: Thu, 19 Jan 2017 17:51:45 +0000 Subject: [PATCH] =?UTF-8?q?B2017-011:=20Complete=20report,=20sorted=20by?= =?UTF-8?q?=20setpoint=20id,=20crashes=20if=20duplicate=20setpoint=20id=20?= =?UTF-8?q?B2017-011:=20Complete=20report,=20don=E2=80=99t=20crash=20if=20?= =?UTF-8?q?requested=20ro=20is=20not=20in=20database?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Exe/RefObj/CmpRpt/CmpRpt.cs | 116 +++++++++--------- .../Volian.Controls.Library/DisplayReports.cs | 4 + 2 files changed, 63 insertions(+), 57 deletions(-) diff --git a/PROMS/ReferencedObjects/Exe/RefObj/CmpRpt/CmpRpt.cs b/PROMS/ReferencedObjects/Exe/RefObj/CmpRpt/CmpRpt.cs index aff05936..a15511d1 100644 --- a/PROMS/ReferencedObjects/Exe/RefObj/CmpRpt/CmpRpt.cs +++ b/PROMS/ReferencedObjects/Exe/RefObj/CmpRpt/CmpRpt.cs @@ -90,15 +90,15 @@ namespace CmpRpt /// The main entry point for the application. /// [STAThread] - static void Main(string[] args) + static void Main(string[] args) { if (args.Length <= 0) return; // nothing to do bool success; VlnXmlElement rootXml; VlnXmlDocument myroXmlDoc; - string recid=null; - string tbl=null; - RODB myrodb=null; + string recid = null; + string tbl = null; + RODB myrodb = null; // the next two lists contain group headers for the reports. ArrayList headers = new ArrayList(); ArrayList reversehdrs = new ArrayList(); @@ -126,7 +126,7 @@ namespace CmpRpt // recid = args[0].Substring(4, 8); // // myrodb = new RODB(Directory.GetCurrentDirectory()); //} -/******/ + /******/ // if an RO directory path was passed in, then change the // current working directory to it. // this path will also be used to generate a connection string @@ -139,12 +139,12 @@ namespace CmpRpt Directory.SetCurrentDirectory(path); } myrodb = new RODB(Directory.GetCurrentDirectory()); - VlnXmlElement rptele=null; + VlnXmlElement rptele = null; // Add the root to the tree myroXmlDoc = myrodb.RODB_GetRoot(); - rootXml = (VlnXmlElement) myroXmlDoc.FirstChild; + rootXml = (VlnXmlElement)myroXmlDoc.FirstChild; success = myrodb.RODB_GetRootGroups(rootXml); if (success == false) return; @@ -171,8 +171,8 @@ namespace CmpRpt showStatBar.StatMsg = string.Format("Retrieving RO {0} of {1}", inc++, bmax); showStatBar.BarValue = inc; } - tbl = roid.Substring(0, 4); - recid = (roid.Length > 4) ? roid.Substring(4, 8) : null; + tbl = roid.Substring(0, 4); + recid = (roid.Length > 4) ? roid.Substring(4, 8) : null; // if the table & recid = all zeros, we have a request // for all ROs, otherwise it's a request for specific RO(s) @@ -191,62 +191,64 @@ namespace CmpRpt // read in this element from the table. rptele = myrodb.RODB_ReadRO(tbname, recid); - - VlnXmlElement parent; - string parentid; - parentid = rptele.GetAttribute("ParentID"); - string rpteleParentid = parentid; - - // walk up tree to get the path through the tree. - VlnXmlElement child = rptele; - while (parentid != null && parentid != "00000000") + if (rptele != null) { - parent = myrodb.RODB_ReadRO(tbname, parentid); - if (parent != null) + VlnXmlElement parent; + string parentid; + parentid = rptele.GetAttribute("ParentID"); + string rpteleParentid = parentid; + + // walk up tree to get the path through the tree. + VlnXmlElement child = rptele; + while (parentid != null && parentid != "00000000") { - parentid = parent.GetAttribute("ParentID"); - if (parentid == "00000000") + parent = myrodb.RODB_ReadRO(tbname, parentid); + if (parent != null) { - reversehdrs.Add(parent.InnerText); + parentid = parent.GetAttribute("ParentID"); + if (parentid == "00000000") + { + reversehdrs.Add(parent.InnerText); + break; + } + parent.AppendChild(child); + child = parent; + reversehdrs.Add(parent.GetAttribute("MenuTitle")); + } + else + parentid = null; + } + + // Now hook this into the top part of tree by looking at the table + // names. + VlnXmlElement group = (VlnXmlElement)rootXml.FirstChild; + while (group != null) + { + string curtbname = group.GetAttribute("Table"); + // hook it in here. + if (curtbname == tbname) + { + if (rpteleParentid != "00000000") + group.AppendChild(child); + else // if this is a top group, just reset rept ele + rptele = group; break; } - parent.AppendChild(child); - child = parent; - reversehdrs.Add(parent.GetAttribute("MenuTitle")); + group = (VlnXmlElement)group.NextSibling; } - else - parentid = null; + // Set up the headers array, it's in reverse order since we walked + // up the tree, not down. + int cnt = reversehdrs.Count; + for (int i = cnt - 1; i >= 0; i--) + headers.Add(reversehdrs[i]); + myrodb.MyDBID = tbl; + rptele.Show(myrodb, headers, showStat); + Application.DoEvents(); + headers.Clear(); + reversehdrs.Clear(); } - - // Now hook this into the top part of tree by looking at the table - // names. - VlnXmlElement group = (VlnXmlElement)rootXml.FirstChild; - while (group != null) - { - string curtbname = group.GetAttribute("Table"); - // hook it in here. - if (curtbname == tbname) - { - if (rpteleParentid != "00000000") - group.AppendChild(child); - else // if this is a top group, just reset rept ele - rptele = group; - break; - } - group = (VlnXmlElement)group.NextSibling; - } - // Set up the headers array, it's in reverse order since we walked - // up the tree, not down. - int cnt = reversehdrs.Count; - for (int i = cnt - 1; i >= 0; i--) - headers.Add(reversehdrs[i]); } - myrodb.MyDBID = tbl; - rptele.Show(myrodb, headers, showStat); - Application.DoEvents(); - headers.Clear(); - reversehdrs.Clear(); - }// end foreach roid + }// end foreach roid if (showStat != null) showStat.Dispose(); if (showStatBar != null) diff --git a/PROMS/Volian.Controls.Library/DisplayReports.cs b/PROMS/Volian.Controls.Library/DisplayReports.cs index 5572429b..652ae89f 100644 --- a/PROMS/Volian.Controls.Library/DisplayReports.cs +++ b/PROMS/Volian.Controls.Library/DisplayReports.cs @@ -187,6 +187,10 @@ namespace Volian.Controls.Library { rtnstr = rodbidPrefix + string.Format("{0}", roc.roid); 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); } }