From 4f6f383cef1303614b436f98899e60ada0b0719e Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 8 May 2020 20:40:49 +0000 Subject: [PATCH] case 3759 --- .../GZTW.AyaNova.BLL/UIUserGridLastView.cs | 102 ++++++++++++------ 1 file changed, 70 insertions(+), 32 deletions(-) diff --git a/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/UIUserGridLastView.cs b/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/UIUserGridLastView.cs index 3afe215..355df6e 100644 --- a/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/UIUserGridLastView.cs +++ b/source/bizobjects/AyaLib/GZTW.AyaNova.BLL/UIUserGridLastView.cs @@ -88,7 +88,7 @@ namespace GZTW.AyaNova.BLL } } - + /// /// @@ -141,7 +141,7 @@ namespace GZTW.AyaNova.BLL //mViewDS.Clear(); //System.IO.StringReader sr = new System.IO.StringReader(mViewXML); //mViewDS.ReadXml(sr); - + } } } @@ -162,8 +162,18 @@ namespace GZTW.AyaNova.BLL //bugbug - not removing old filters before adding new filter case 770 set { - if (!value.Contains("SubstituteCriteria: Error value must contain open and closing WHEREITEMGROUP tags"); + //wait, this could be an issue, below it seems to anticipate this would be a normal condition + //I'm going to leave this out for now, prior attempt didn't actually "throw" it so it would have been benign + //if (!value.Contains("SubstituteCriteria: Error unexpected view xml (missing WHEREITEMGROUP tags)\r\n" + + // "ViewXML:\r\n"+ + // mViewXML+ + // "Substitute XML:\r\n"+ + // value + + // "\r\nGridKey:"+this.GridKey + ", UserId: " + this.UserID + + // "\r\n---------eot-----" + // );//case 3759 int nStart = -1; int nEnd = -1; @@ -180,8 +190,17 @@ namespace GZTW.AyaNova.BLL nEnd = nEnd + 17;//length of } - if (nStart==-1 || nEnd==-1) - new System.ApplicationException("UIUserGridLastView->SubstituteCriteria: Error could not determine placement of inserted WHEREITEMGROUP tag in view xml:\r\n" + mViewXML); + //case 3759 + if (nStart == -1 || nEnd == -1) + // throw new System.ApplicationException("UIUserGridLastView->SubstituteCriteria: Error could not determine placement of inserted WHEREITEMGROUP tag in view xml:\r\n" + mViewXML); + throw new System.ApplicationException("UIUserGridLastView->SubstituteCriteria: Error unexpected view xml\r\n" + + "ViewXML:\r\n" + + mViewXML + + "Substitute XML:\r\n" + + value + + "\r\nGridKey:" + this.GridKey + ", UserId: " + this.UserID + + "\r\n---------eot-----" + ); //BUGBUG: this line is throwing an exception for some users (adam tecnica uk) //It needs to be wrapped in a try catch block or tested for sanity @@ -246,19 +265,38 @@ Parameter name: length at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) */ - mViewXML = mViewXML.Substring(0, nStart) + value + mViewXML.Substring(nEnd, mViewXML.Length-nEnd); + //case 3759 for above + int StartViewXMLLength = nStart; + int EndViewXMLLength = mViewXML.Length - nEnd; + + + if (StartViewXMLLength < 0 || EndViewXMLLength < 0) + throw new System.ApplicationException("UIUserGridLastView->SubstituteCriteria: Error bad view xml\r\n" + + "ViewXML:\r\n" + + mViewXML + + "Substitute XML:\r\n" + + value + + "\r\n=-=-=-=-=-+\r\nStartViewXMLLength:" + StartViewXMLLength.ToString() + + ", EndViewXMLLength:" + EndViewXMLLength.ToString() + + "\r\nGridKey:" + this.GridKey + ", UserId: " + this.UserID + + "\r\n---------eot-----" + ); + + //originally before this case + //mViewXML = mViewXML.Substring(0, nStart) + value + mViewXML.Substring(nEnd, mViewXML.Length-nEnd); + mViewXML = mViewXML.Substring(0, StartViewXMLLength) + value + mViewXML.Substring(nEnd, EndViewXMLLength); //reset MarkDirty(); //flag as unsaved custom filter FilterID = GridFilter.NoFilterID; - + } } - + /// /// Guid of saved filter that was last being used /// by the user when they closed AyaNova @@ -284,7 +322,7 @@ Parameter name: length } - + /// /// Returns the order by portion of the xml /// as a datatable @@ -295,10 +333,10 @@ Parameter name: length { if (ViewDS.Tables.Contains("COLUMNITEM")) return ViewDS.Tables["COLUMNITEM"]; - else + else return new DataTable(); - + } } @@ -356,14 +394,14 @@ Parameter name: length if (string.IsNullOrEmpty(mViewXML)) return new DataSet(); string s = AyaBizUtils.EscapeXml(mViewXML);//case 1724 System.IO.StringReader sr = new System.IO.StringReader(s); - DataSet ds = new DataSet(); + DataSet ds = new DataSet(); ds.ReadXml(sr); return ds; } } #endregion - + #region System.Object overrides public override string ToString() @@ -420,19 +458,19 @@ Parameter name: length internal static string ScrubOutContactFieldsFromViewXML(string sxml, string gridkey) { //short circuit if none of the offending fields are there - if (sxml.IndexOf("aContact",StringComparison.InvariantCultureIgnoreCase) ==-1 && - sxml.IndexOf("aContactPhone.",StringComparison.InvariantCultureIgnoreCase)==-1) + if (sxml.IndexOf("aContact", StringComparison.InvariantCultureIgnoreCase) == -1 && + sxml.IndexOf("aContactPhone.", StringComparison.InvariantCultureIgnoreCase) == -1) return sxml; - string sRootObject=gridkey.Replace("List",""); - bool bUnknownObject=false; + string sRootObject = gridkey.Replace("List", ""); + bool bUnknownObject = false; if (sRootObject != "Vendor" && sRootObject != "Client" && sRootObject != "HeadOffice") bUnknownObject = true; DataSet ds = new DataSet(); System.IO.StringReader sr = new System.IO.StringReader(AyaBizUtils.EscapeXml(sxml)); - ds.ReadXml(sr,XmlReadMode.InferSchema); + ds.ReadXml(sr, XmlReadMode.InferSchema); DataTable dtCM = ds.Tables[0]; DataTable dtGroup = new DataTable(); @@ -444,13 +482,13 @@ Parameter name: length if (ds.Tables.Count > 2) dtWhere = ds.Tables[2]; - int nCMRowCount=dtCM.Rows.Count; + int nCMRowCount = dtCM.Rows.Count; int nGroupCount = dtGroup.Rows.Count; - - #region ColumnItems - for (int x = 0; x