private void ProcessReport(DOEgbXMLPhase2Report report, bool createTable) { //add report to report list //have to deep copy the report before put report in the list DOEgbXMLPhase2Report tmpreport = report.Copy(); ReportList.Add(tmpreport); //title int subType = -1; string title = report.testType.ToString(); if (report.subTestIndex != -1 && report.subTestIndex != null) { subType = report.subTestIndex; } title = title.Replace("_", " "); if (subType != -1) { title += " " + subType; } //message var passTest = report.TestPassedDict.Values; bool individualTestBool = true; foreach (bool testResult in passTest) { if (testResult == false) { individualTestBool = false; break; } } //description log += "Explanation of Test: " + report.testSummary + System.Environment.NewLine; if (report.passOrFail && individualTestBool) { log += "Test has Passed" + System.Environment.NewLine; } else { log += "Test has Failed" + System.Environment.NewLine; overallPassTest = false; } log += "Explanation of What Happened: " + report.longMsg + System.Environment.NewLine; //message list, print out each message in the list if there are any if (report.MessageList.Count() > 0) { foreach (KeyValuePair <string, List <string> > message in report.MessageList) { foreach (string finding in message.Value) { log += message.Key + ": " + finding + System.Environment.NewLine; } } } else if (report.TestPassedDict.Count() > 0) { foreach (KeyValuePair <string, bool> pair in report.TestPassedDict) { log += pair.Key + ": " + pair.Value + System.Environment.NewLine; } } log += System.Environment.NewLine; //create table row if (createTable) { if (report.standResult.Count == 0) { report.standResult.Add("---"); report.testResult.Add("---"); report.idList.Add(""); } //for each output for (int i = 0; i < report.standResult.Count; i++) { bool sameString = false; if (report.standResult[i] == report.testResult[i]) { sameString = true; } //check if test pass or fail if ((report.passOrFail && individualTestBool))// || sameString) { TestResultPanel.Controls.Add(new LiteralControl("<tr class='success'>")); } else { TestResultPanel.Controls.Add(new LiteralControl("<tr class='danger'>")); overallPassTest = false; } TestResultPanel.Controls.Add(new LiteralControl("<td style='text-align:left'><a href='TestDetailPage.aspx?type=" + (int)report.testType + "&subtype=" + report.subTestIndex + "' target='_blank'>" + title + " " + report.idList[i] + "</a></td>")); if ((report.passOrFail && individualTestBool))// || sameString) { TestResultPanel.Controls.Add(new LiteralControl("<td>±" + report.tolerance + " " + report.unit + "</td><td>Pass</td></tr>")); } else { TestResultPanel.Controls.Add(new LiteralControl("<td>±" + report.tolerance + " " + report.unit + "</td><td>Fail</td></tr>")); } } } }
protected void Page_Load(object sender, EventArgs e) { if (TestDetailLabelOverView != null) { if (Request.QueryString["type"] != "Error") { // List of reports List <DOEgbXMLPhase2Report> reportlist = new List <DOEgbXMLPhase2Report>(); if (Session["reportList"] == null || Request.QueryString["type"] == null) { Response.Redirect(@"~/"); } reportlist = (List <DOEgbXMLPhase2Report>)Session["reportList"]; #region Get Current Report //looking for the right report from the list int testType = 0; int subType = -1; if (Request.QueryString["type"] != null) { try { testType = (int)Convert.ToInt32(Request.QueryString["type"]); } catch { return; } } if (Request.QueryString["subtype"] != null) { try { subType = (int)Convert.ToInt32(Request.QueryString["subtype"]); } catch { return; } } DOEgbXMLPhase2Report rightReport = new DOEgbXMLPhase2Report(); foreach (DOEgbXMLPhase2Report report in reportlist) { if (report.testType == (TestType)testType) { if (report.subTestIndex == -1 || report.subTestIndex == subType) { rightReport = report; } } } #endregion Get Current Report #region Title string title = rightReport.testType.ToString(); title = title.Replace("_", " "); if (subType != -1) { title += " " + subType; } TestDetailLabelName.Text += "<h2>" + title + "</h2>"; #endregion Title #region Description TestDetailLabelOverView.Text += "<h4>Test Summary:</h4><p>" + rightReport.testSummary + "</p>"; #endregion Description #region Message Summary var passTest = rightReport.TestPassedDict.Values; bool individualTestBool = true; foreach (bool testResult in passTest) { if (testResult == false) { individualTestBool = false; break; } } string output = "<div class='panel panel-default'><div class='panel-heading'><h4 class='panel-title'>Test Results:</h4></div><div class='panel-body'>"; if (rightReport.passOrFail && individualTestBool) { output += "<p class='text-success panel-body'>" + rightReport.longMsg + "</p>"; } else { output += "<p class='text-danger panel-body'>" + rightReport.longMsg + "</p>"; } #endregion Message Summary #region Message Detail //message list, print out each message in the list if there are any if (rightReport.MessageList.Count() > 0) { output += "<div id='notaccordion'>"; foreach (KeyValuePair <string, List <string> > message in rightReport.MessageList) { bool panelError = false; string currentKeyOutput = ""; #region Panel Body string currentBodyOutput = "<div>"; foreach (string finding in message.Value) { if (finding.Substring(0, 5) == "PASS:"******"PERFECT MATCH:" || finding.Substring(0, 12) == "TEST PASSED:") { currentBodyOutput += "<p class='text-success'>" + finding + "</p>"; } else if (finding.Substring(0, 5) == "FAIL:" || finding.Substring(0, 12) == "TEST FAILED:") { currentBodyOutput += "<p class='text-danger'>" + finding + "</p>"; panelError = true; } else { currentBodyOutput += "<p class='text-info'>" + finding + "</p>"; } } currentBodyOutput += "</div>"; #endregion Panel Body #region Panel Header if (panelError) { currentKeyOutput += "<h3 style='color:Red'>" + message.Key + "</h3>"; } else { currentKeyOutput += "<h3>" + message.Key + "</h3>"; } #endregion Panel Header output += currentKeyOutput + currentBodyOutput; } output += "</div>"; } else if (rightReport.TestPassedDict.Count() > 0) { output += "<div id='notaccordion'>"; foreach (KeyValuePair <string, bool> pair in rightReport.TestPassedDict) { //output += "<p class='text-info'>" + pair.Key + ":" + pair.Value.ToString() + "</p>"; string currentKey = ""; if (currentKey == pair.Key) { output += "<p>" + pair.Value.ToString() + "</p>"; } else { output += "<h3>" + pair.Key + "</h3>"; output += "<div><p>" + pair.Value.ToString() + "</p></div>"; currentKey = pair.Key; } } output += "</div>"; } output += "</div></div>"; #endregion Message Detail TestDetailLabelResults.Text = output; } else { TestDetailImage.Visible = false; TestDetailLabelResults.Text = Session["table"].ToString(); } } }
private void ProcessValidXML(XMLParser parser, XmlReader xmlreader2) { // Phase 2 Testing XmlDocument myxml = new XmlDocument(); myxml.Load(xmlreader2); //3-get the namespace XmlNamespaceManager nsm = parser.getnsmanager(myxml); //figure out if metric or USIP (we have not found a reason to use this yet) parser.getunits(nsm, myxml); /* Begin Parsing the XML and reporting on it----------------------------------------------------------*/ //make a reporting object DOEgbXMLPhase2Report report = new DOEgbXMLPhase2Report(); /* Basic Uniqueness Constraints check-------------------------------------------------*/ //Basic requirements check // Setup the results view for the log and web. log = ""; TestResultPanel.Controls.Add(new LiteralControl("<div class='well-lg'><h3>Test Sections</h3><table class='table table-bordered'><tr class='info'><td>Test Section Name</td><td>Tolerances</td><td>Pass/Fail</td></tr>")); //first create a list of lists that is indexed identically to the drop down list the user selects TestDetail = new DOEgbXMLTestDetail(); //then populate the list of lists. All indexing is done "by hand" in InitializeTestResultStrings() TestDetail.InitializeTestResultStrings(); //Set up the Global Pass/Fail criteria for the test case file TestCriteria = new DOEgbXMLTestCriteriaObject(); TestCriteria.InitializeTestCriteriaWithTestName(TestToRun); // ("Test1"); // Reports //ensure that all names of spaces are unique--------------------------------------------------------------------------------------------------------Unique_Space_ID_Test// report.testType = TestType.Unique_Space_ID_Test; report = DOEgbXML.gbXMLSpaces.UniqueSpaceIdTest2(myxml, nsm, report); ProcessReport(report, true); report.Clear(); //ensure that all space boundary names are unique--------------------------------------------------------------------------------------------------Unique_Space_Boundary// XmlNodeList nodes = myxml.SelectNodes("/gbXMLv5:gbXML/gbXMLv5:Campus/gbXMLv5:Building/gbXMLv5:Space/gbXMLv5:SpaceBoundary", nsm); if (nodes.Count > 0) { spaceBoundsPresent = true; report.testType = TestType.Unique_Space_Boundary; report = DOEgbXML.gbXMLSpaces.UniqueSpaceBoundaryIdTest2(myxml, nsm, report); ProcessReport(report, true); report.Clear(); } else { //needs to be included so the report can be processed report.testType = TestType.Unique_Space_Boundary; report.passOrFail = true; report.longMsg = "A test is usually performed here to ensure Space Boundaries have valid naming conventions. This test was skipped (legally) because your file does not have space boundaries present. Continuing to next test."; ProcessReport(report, true); report.Clear(); } //Space Tests //make a simplified representation of the spaces List <DOEgbXML.gbXMLSpaces> spaces = DOEgbXML.gbXMLSpaces.getSimpleSpaces(myxml, nsm); //4-check for self-intersecting polygons //report = DOEgbXML.gbXMLSpaces.SpaceSurfacesSelfIntersectionTest(spaces, report); //report.Clear(); //check that all polyloops are in a counterclockwise direction-----------------------------------------------------------------------------------------Space_Surfaces_CC// report = DOEgbXML.gbXMLSpaces.SpaceSurfacesCCTest2(spaces, report); report.testType = TestType.Space_Surfaces_CC; ProcessReport(report, true); report.Clear(); //check for non-planar objects for all Spaces' polyloops-------------------------------------------------------------------------------------------Space_Surfaces_Planar// report.coordtol = DOEgbXMLBasics.Tolerances.VectorAngleTolerance; report = DOEgbXML.gbXMLSpaces.SpaceSurfacesPlanarTest(spaces, report); report.testType = TestType.Space_Surfaces_Planar; ProcessReport(report, true); report.Clear(); //valid space enclosure?---------------------------------------------------------------------------------------------------------------------------Check_Space_Enclosure// report.tolerance = 0.0001; //when we are comparing angles in this function, we are testing the angle between dot products report.vectorangletol = DOEgbXMLBasics.Tolerances.dotproducttol; report.lengthtol = DOEgbXMLBasics.Tolerances.lengthTolerance; //toler report.coordtol = DOEgbXMLBasics.Tolerances.coordToleranceIP; report = Validator.CheckSpaceEnclosureSG(spaces, report); report.testType = TestType.Check_Space_Enclosure; ProcessReport(report, true); report.Clear(); /* Surface tests----------------------------------------------------------------------------------*/ /* Basic Requirements ----------------------------------------------------------------------------*/ //Are there at least 4 surface definitions? (see the surface requirements at the campus node)-------------------------------------------------------At_Least_4_Surfaces// report.testType = TestType.At_Least_4_Surfaces; report = SurfaceDefinitions.AtLeast4Surfaces(myxml, nsm, report); ProcessReport(report, true); report.Clear(); //Does the AdjacentSpaceId not exceed the max number allowable?-----------------------------------------------------------------------------------------Two_Adj_Space_Id// //this needs to be updated! report.testType = TestType.Two_Adj_Space_Id; report = SurfaceDefinitions.AtMost2SpaceAdjId(myxml, nsm, report); ProcessReport(report, true); report.Clear(); //Are all required elements and attributes in place?---------------------------------------------------------------------------------------------Required_Surface_Fields// //report.testType = TestType.Required_Surface_Fields; //report = SurfaceDefinitions.RequiredSurfaceFields(myxml, nsm, report); //ProcessReport(report, true); //report.Clear(); //ensure that all names of surfaces are unique------------------------------------------------------------------------------------------------------Surface_ID_Uniqueness// report.testType = TestType.Surface_ID_Uniqueness; report = DOEgbXML.SurfaceDefinitions.SurfaceIDUniquenessTest(myxml, nsm, report); ProcessReport(report, true); report.Clear(); //now grab all the surfaceIds and make them available------------------------------------------------------------------------------------------------Surface_Adj_Id_Match// List <string> spaceIds = new List <string>(); foreach (gbXMLSpaces s in spaces) { spaceIds.Add(s.id); } List <SurfaceDefinitions> surfaces = DOEgbXML.XMLParser.MakeSurfaceList(myxml, nsm); //make sure the surface Adjacent space Id names match only the the space Ids gathered above. The adjacent space Ids can't have their own special values report.testType = TestType.Surface_Adj_Id_Match; report = DOEgbXML.SurfaceDefinitions.SurfaceAdjSpaceIdTest(spaceIds, surfaces, report); ProcessReport(report, true); report.Clear(); //Surface_ID_SB_Match------------------------------------------------------------------------------------------------------------------------------Surface_ID_SB_Match// if (spaceBoundsPresent) { report.tolerance = DOEgbXMLBasics.Tolerances.coordToleranceIP; report.testType = TestType.Surface_ID_SB_Match; report = SurfaceDefinitions.SurfaceMatchesSpaceBoundary(myxml, nsm, report); ProcessReport(report, true); report.Clear(); } else { report.testType = TestType.Surface_ID_SB_Match; report.passOrFail = true; report.longMsg = "A test is usually performed here to ensure Space Boundaries and Surfaces share the same ID. This test was skipped (legally) because your file does not have space boundaries present. Continuing to next test."; ProcessReport(report, true); report.Clear(); } //Does the polyloop right hand rule vector form the proper azimuth and tilt? (with and without a CADModelAzimuth)----------------------------------Surface_Tilt_Az_Check// report.tolerance = DOEgbXMLBasics.Tolerances.VectorAngleTolerance; report.vectorangletol = DOEgbXMLBasics.Tolerances.VectorAngleTolerance; report.testType = TestType.Surface_Tilt_Az_Check; report = SurfaceDefinitions.SurfaceTiltAndAzCheck(myxml, nsm, report); ProcessReport(report, true); report.Clear(); //planar surface test-------------------------------------------------------------------------------------------------------------------------------Surface_Planar_Test// report.vectorangletol = DOEgbXMLBasics.Tolerances.VectorAngleTolerance; report = SurfaceDefinitions.TestSurfacePlanarTest(surfaces, report); report.testType = TestType.Surface_Planar_Test; ProcessReport(report, true); report.Clear(); //I must take the surfaces, group them, and rearrange any interior surfaces' coordinates that should be pointed the opposite way string searchpath = "/gbXMLv5:gbXML/gbXMLv5:Campus/gbXMLv5:Building/gbXMLv5:Space"; List <string> spaceids = DOEgbXML.gbXMLSpaces.getSpaceIds(myxml, nsm, searchpath); Dictionary <string, List <SurfaceDefinitions> > enclosure = new Dictionary <string, List <SurfaceDefinitions> >(); foreach (string id in spaceids) { //find all surfaces with this adjacent space id, get their polyloops, and then match their polyloops List <SurfaceDefinitions> surflist = new List <SurfaceDefinitions>(); foreach (SurfaceDefinitions surf in surfaces) { foreach (var adj in surf.AdjSpaceId) { if (adj == id) { surflist.Add(surf); //don't want to add surfaces twice (slab on grade) break; } } } enclosure[id] = surflist; } //counter clockwise winding test-------------------------------------------------------------------------------------------------------------------------Surface_CC_Test// report.testType = TestType.Surface_CC_Test; report = SurfaceDefinitions.SurfaceCCTest(enclosure, report); ProcessReport(report, true); report.Clear(); //self intersecting polygon test //report = SurfaceDefinitions.SurfaceSelfIntersectionTest(surfaces, report); //report.Clear(); //Is the Lower Left Corner properly defined? //surface enclosure tests------------------------------------------------------------------------------------------------------------------------Check_Surface_Enclosure// report.tolerance = 0.0001; report.vectorangletol = DOEgbXMLBasics.Tolerances.dotproducttol; report.lengthtol = DOEgbXMLBasics.Tolerances.lengthTolerance; report.coordtol = .01; report.testType = TestType.Check_Surface_Enclosure; report = Validator.CheckSurfaceEnclosure(enclosure, report); ProcessReport(report, true); report.Clear(); TestResultPanel.Controls.Add(new LiteralControl("</table></div>")); CreateSummaryTable(); }