public void StartTest(XmlReader xmldoc, string testToRun, ref gbXMLReport gbr, string username = "******") { log4net.Config.XmlConfigurator.Configure(); TestToRun = testToRun; globalMatchObject = new gbXMLMatches(); globalMatchObject.Init(); //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(); //create report list reportlist will store all the test result ReportList = new List<DOEgbXMLReportingObj>(); //Load an XML File for the test at hand gbXMLTestFile = new XmlDocument(); gbXMLTestFile.Load(xmldoc); gbXMLStandardFile = new XmlDocument(); gbXMLStandardFile.Load(filepaths[TestToRun]); if (!TestFileIsAvailable()) { //TODO: update browser json with something to indicate there is a problem return; } //Define the namespace XmlNamespaceManager gbXMLns1 = new XmlNamespaceManager(gbXMLTestFile.NameTable); gbXMLns1.AddNamespace("gbXMLv5", "http://www.gbxml.org/schema"); XmlNamespaceManager gbXMLns2 = new XmlNamespaceManager(gbXMLStandardFile.NameTable); gbXMLns2.AddNamespace("gbXMLv5", "http://www.gbxml.org/schema"); List<XmlDocument> gbXMLdocs = new List<XmlDocument>(); gbXMLdocs.Add(gbXMLTestFile); gbXMLdocs.Add(gbXMLStandardFile); List<XmlNamespaceManager> gbXMLnsm = new List<XmlNamespaceManager>(); gbXMLnsm.Add(gbXMLns1); gbXMLnsm.Add(gbXMLns2); //standardizing all tests on US-IP Conversions c = new Conversions(); Conversions.volumeUnitEnum testVol = Conversions.volumeUnitEnum.CubicFeet; Conversions.volumeUnitEnum validatorVol = Conversions.volumeUnitEnum.CubicFeet; Conversions.areaUnitEnum testArea = Conversions.areaUnitEnum.SquareFeet; Conversions.areaUnitEnum validatorArea = Conversions.areaUnitEnum.SquareFeet; Conversions.lengthUnitEnum testLength = Conversions.lengthUnitEnum.Feet; Conversions.lengthUnitEnum validatorLength = Conversions.lengthUnitEnum.Feet; Conversions.lengthUnitEnum standardLength = Conversions.lengthUnitEnum.Feet; Conversions.areaUnitEnum standardArea = Conversions.areaUnitEnum.SquareFeet; Conversions.volumeUnitEnum standardVol = Conversions.volumeUnitEnum.CubicFeet; //standardize all units to feet, square feet, and cubic feet double testlengthConversion = 1; double testareaConversion = 1; double testvolumeConversion = 1; double standardlengthConversion = 1; double standardareaConversion = 1; double standardvolConversion = 1; bool mustBePlanar = false; for(int ns=0; ns< gbXMLnsm.Count; ns++) { if (ns == 0) { XmlNodeList nodes = gbXMLdocs[ns].SelectNodes("/gbXMLv5:gbXML", gbXMLnsm[ns]); StandardizeToUSIP(nodes, c, ref testlengthConversion, ref testareaConversion, ref testvolumeConversion, ref testLength, ref testArea, ref testVol); } else { XmlNodeList nodes = gbXMLdocs[ns].SelectNodes("/gbXMLv5:gbXML", gbXMLnsm[ns]); StandardizeToUSIP(nodes, c, ref standardlengthConversion, ref standardareaConversion, ref standardvolConversion, ref standardLength, ref standardArea, ref standardVol); } } //TODO: Add a summary of the Unit of Measures stuff above to the final result //Create a Log file that logs the success or failure of each test. //Eventually maybe I want to create a little HTML factory output = ""; log = ""; table += "<div class='container'>" + "<h3>" + "Test Sections" + "</h3>"; table += "<table class='table table-bordered'>"; table += "<tr class='info'>" + "<td>" + "Test Section Name" + "</td>" + "<td>" + "Standard Result" + "</td>" + "<td>" + "Test File Result" + "</td>" + "<td>" + "Tolerances" + "</td>" + "<td>" + "Pass/Fail" + "</td>" + "</tr>"; string units; DOEgbXMLReportingObj report = new DOEgbXMLReportingObj(); CampusReport camprep = new CampusReport(); //this string I can manipulate to produce the final test output string menujson = JsonConvert.SerializeXmlNode(gbXMLStandardFile); //prepare json for view menujson = MakeViewJson(menujson); gbr.menu = menujson; gbr.CampusReport = camprep; report.standResult = new List<string>(); report.testResult = new List<string>(); report.idList = new List<string>(); report.MessageList = new List<string>(); report.TestPassedDict = new Dictionary<string, bool>(); //Set up the Global Pass/Fail criteria for the test case file TestCriteria = new DOEgbXMLTestCriteriaObject(); TestCriteria.InitializeTestCriteriaWithTestName(testToRun); //needed specially for area and volume tests DOEgbXMLTestDetail afile = TestDetail.TestDetailList.Find(x => x.testName == TestToRun); BuildingSummary bs = new BuildingSummary(); bs.FileType = "Standard"; camprep.BuildingSummary.Add(bs); BuildingSummary bst = new BuildingSummary(); bst.FileType = "Test"; camprep.BuildingSummary.Add(bst); //Test 2 execute //report.tolerance = DOEgbXMLBasics.Tolerances.AreaTolerance; //report.testType = TestType.Building_Area; //units = DOEgbXMLBasics.MeasurementUnits.sqft.ToString(); //report = GetBuildingArea(gbXMLdocs, gbXMLnsm, report, validatorArea, testArea, testareaConversion, standardareaConversion); logger.Info("START: BUILDING AREA TEST"); var baresult = GetBuildingArea(gbXMLdocs, gbXMLnsm, ref camprep, validatorArea, testArea, testareaConversion, standardareaConversion, DOEgbXMLBasics.Tolerances.AreaPercentageTolerance, afile ); if(!baresult) { camprep.BuildingSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; } logger.Info("END: BUILDING AREA TEST"); //GetBuildingArea(gbXMLdocs,gbXMLnsm,) //AddToOutPut("Building Area Test Passed: ", report, true); //Test 3 execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.SpaceCountTolerance; //report.testType = TestType.Space_Count; //units = DOEgbXMLBasics.MeasurementUnits.spaces.ToString(); //report = GetBuildingSpaceCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: BUILDING SPACE COUNT TEST"); SpacesSummary ssm = new SpacesSummary(); ssm.FileType = "Standard"; camprep.SpacesSummary.Add(ssm); SpacesSummary ssmt = new SpacesSummary(); ssmt.FileType = "Test"; camprep.SpacesSummary.Add(ssmt); var spctResult = GetBuildingSpaceCount(gbXMLdocs, gbXMLnsm, "", DOEgbXMLBasics.Tolerances.SpaceCountTolerance, ref camprep); if(!spctResult) { camprep.BuildingSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; camprep.SpacesSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; } logger.Info("END: BUILDING SPACE COUNT TEST"); //AddToOutPut("Building Space Quantity Count Test Passed: ", report, true); // Building Stories Tests.... ////Test 4 execute //report.Clear(); report.tolerance = DOEgbXMLBasics.Tolerances.LevelCountTolerance; //report.testType = TestType.Building_Story_Count; //units = DOEgbXMLBasics.MeasurementUnits.levels.ToString(); //report = GetBuildingStoryCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: Building Storey Count Test"); var blstctresult = GetBuildingStoryCount(gbXMLdocs, gbXMLnsm, ref camprep, DOEgbXMLBasics.Tolerances.LevelCountTolerance); if(!blstctresult) { camprep.BuildingSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; //TODO: Need a Building Story Summary Field } logger.Info("END: Building Storey Count Test"); //AddToOutPut("Building Story Count Test Passed: ", report, true); //Test 5 execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.LevelHeightTolerance; //report.testType = TestType.Building_Story_Z_Height; //units = DOEgbXMLBasics.MeasurementUnits.ft.ToString(); report = GetStoryHeights(gbXMLdocs, gbXMLnsm, report, validatorLength, testLength, testlengthConversion, standardlengthConversion); logger.Info("START: Building Storey Height Test"); var storyHeightsres = GetStoryHeights(gbXMLdocs, gbXMLnsm, ref camprep, validatorLength, testLength, testlengthConversion, standardlengthConversion, DOEgbXMLBasics.Tolerances.LevelHeightTolerance); if (!storyHeightsres) { camprep.BuildingSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; //TODO: Need a Building Story Summary Field } logger.Info("END: Building Storey Height Test"); //AddToOutPut("Building Story Z-Height Test: ", report, true); //Test 6 execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.VectorAngleTolerance; //report.testType = TestType.Building_Story_PolyLoop_RHR; //units = "degrees"; //report = TestBuildingStoryRHR(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: Building Story Right Hand Rule Test."); var blstRHResult = TestBuildingStoryRHR(gbXMLdocs, gbXMLnsm, ref camprep); if(!blstRHResult) { //this method has no bearing on the overall pass or fail tests. //camprep.BuildingSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; //TODO: Need a Building Story Summary Field } logger.Info("END: Building Story Right Hand Rule Test."); //AddToOutPut("Building Story PolyLoop Right Hand Rule Test Result:", report, true); //String spShellGeometrySurfaceNum = TestShellGeomSurfaceNum(gbXMLTestFile, gbXMLns); //Space Tests ............................................................. //Test 7 execute //only needs to test the test file //report.Clear(); //report.testType = TestType.SpaceId_Match_Test; logger.Info("START: UNIQUE SPACE ID TEST"); var spaceIDresults = UniqueSpaceIdTest(gbXMLdocs, gbXMLnsm, ref camprep); if(!spaceIDresults) { camprep.SpacesSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; } logger.Info("END: UNIQUE SPACE ID TEST"); //AddToOutPut("SpaceId Match Test: ", report, true); //Test 8 execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.SpaceAreaTolerance; //report.testType = TestType.Space_Area; //units = DOEgbXMLBasics.MeasurementUnits.sqft.ToString(); logger.Info("START: SPACE AREAS TEST"); //report = TestSpaceAreas(gbXMLdocs, gbXMLnsm, report, validatorArea, testArea, testareaConversion,standardareaConversion,afile); var result = TestSpaceAreas(gbXMLdocs, gbXMLnsm, ref camprep, validatorArea, testArea, testareaConversion, standardareaConversion, afile, DOEgbXMLBasics.Tolerances.SpaceAreaTolerance); if(!result) { camprep.SpacesSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; //gbxml detailed compliance results? } logger.Info("END: SPACE AREAS TEST"); //AddToOutPut("Space Areas Test: ", report, true); //Test 9 execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.VolumeTolerance; //report.testType = TestType.Space_Volume; //units = DOEgbXMLBasics.MeasurementUnits.cubicft.ToString(); logger.Info("START: SPACE VOLUMES TEST"); //report = TestSpaceVolumes(gbXMLdocs, gbXMLnsm, report, validatorVol, testVol, testvolumeConversion,standardvolConversion,afile); var volresult = TestSpaceVolumes(gbXMLdocs, gbXMLnsm, ref camprep, validatorVol, testVol, testvolumeConversion, standardvolConversion, afile, DOEgbXMLBasics.Tolerances.VolumePercentageTolerance); logger.Info("END: SPACE VOLUMES TEST"); if (!volresult) { camprep.SpacesSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; //gbxml detailed compliance results? } //AddToOutPut("Space Volumes Test: ", report, true); //Test 10 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.VectorAngleTolerance; //report.testType = TestType.Shell_Geom_RHR; //units = "degrees"; //report = TestShellGeomPLRHR(gbXMLdocs, gbXMLnsm, report, units); //AddToOutPut("Shell Geometry RHR Test: ",report); //Surface Element tests //deprecating all counts tests as criteria for passing and failing. Use this now only to indicate counts in the surfaces summary ////Test 11 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.SurfaceCountTolerance; //report.testType = TestType.Total_Surface_Count; //units = ""; //report = GetSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); //AddToOutPut("Surface Count Test Result: ", report, true); ////Surface Element tests ////Test 12 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.ExteriorWallCountTolerance; //report.testType = TestType.Exterior_Wall_Surface_Count; //units = ""; SurfaceSummary ss = new SurfaceSummary(); ss.FileType = "Standard"; camprep.SurfacesSummary.Add(ss); SurfaceSummary sst = new SurfaceSummary(); sst.FileType = "Test"; camprep.SurfacesSummary.Add(sst); //initialization of summaries complete logger.Info("START: EXTERIOR WALL COUNT"); //report = GetEWSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); var ewctresult = GetEWSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); logger.Info("END: EXTERIOR WALL COUNT"); if (!ewctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } //AddToOutPut("Exterior Wall Surface Count Test Result: ", report, true); //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.SurfaceCountTolerance; //report.testType = TestType.Underground_Surface_Count; //units = ""; //report = GetUGSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: UNDERGROUND WALL COUNT"); var ugwctresult = GetUGSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!ugwctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } logger.Info("END: UNDERGROUND WALL COUNT"); //AddToOutPut("Underground Wall Count Test Result: ", report, true); logger.Info("START: SLABONGRADE COUNT"); var sogctresult = GetSOGSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!sogctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } logger.Info("END: SLABONGRADE WALL COUNT"); ////Surface Element tests ////Test 13 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.InteriorWallCountTolerance; //report.testType = TestType.Interior_Wall_Surface_Count; //units = ""; logger.Info("START: INTERIOR WALL COUNT"); //report = GetIWSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); var iwctresult = GetIWSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!iwctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } logger.Info("END: INTERIOR WALL COUNT"); //AddToOutPut("Interior Wall Surface Count Test Result: ", report, true); ////Surface Element tests ////Test 13 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.InteriorFloorCountTolerance; //report.testType = TestType.Interior_Floor_Surface_Count; //units = ""; //report = GetIFSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: INTERIOR FLOOR/CEILING COUNT"); var ifctresult = GetIFSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!ifctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } logger.Info("END: INTERIOR FLOOR/CEILING COUNT"); //AddToOutPut("Interior Floor Surface Count Test Result: ", report, true); ////Surface Element tests ////Test 14 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.InteriorWallCountTolerance; //report.testType = TestType.Roof_Surface_Count; //units = ""; //report = GetRoofSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: ROOF COUNT"); var irctresult = GetRoofSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!irctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } logger.Info("END: ROOF COUNT"); //AddToOutPut("Roof Surface Count Test Result: ", report, true); ////Surface Element tests ////Test 15 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.InteriorWallCountTolerance; //report.testType = TestType.Shading_Surface_Count; //units = ""; //report = GetShadeSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: SHADING DEVICE COUNT"); var shadectresult = GetShadeSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!shadectresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } //AddToOutPut("Shading Surface Count Test Result: ", report, true); logger.Info("END: SHADING DEVICE COUNT"); ////Test 16 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.AirWallCountTolerance; //report.testType = TestType.Air_Surface_Count; //units = ""; //report = GetAirSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: AIR SURFACE COUNT"); var asctresult = GetAirSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!asctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } logger.Info("END: AIR SURFACE COUNT"); //AddToOutPut("Air Surface Count Test Result: ", report, true); #region surface detailed test //Jan 31-2012: We may not want to perform these if the surface counts fail, but for now, we will include these tests //Detailed Surface Checks //Store Surface Element Information List<SurfaceDefinitions> TestSurfaces = new List<SurfaceDefinitions>(); XmlDocument TestFile = gbXMLdocs[0]; XmlNamespaceManager TestNSM = gbXMLnsm[0]; List<SurfaceDefinitions> StandardSurfaces = new List<SurfaceDefinitions>(); XmlDocument StandardFile = gbXMLdocs[1]; XmlNamespaceManager StandardNSM = gbXMLnsm[1]; TestSurfaces = GetFileSurfaceDefs(TestFile, TestNSM); StandardSurfaces = GetFileSurfaceDefs(StandardFile, StandardNSM); string TestSurfaceTable = " <div class='container'><table class='table table-bordered'>"; TestSurfaceTable += "<tr class='info'>" + "<td>" + "Test Section Name" + "</td>" + "<td>" + "Stand Surface ID" + "</td>" + "<td>" + "Test Surface ID" + "</td>" + "<td>" + "Stand Surface Tilt" + "</td>" + "<td>" + "Test Surface Tilt" + "</td>" + "<td>" + "Stand Surface Azimuth" + "</td>" + "<td>" + "Test Surface Azimuth" + "</td>" + "<td>" + "Stand Surface Height" + "</td>" + "<td>" + "Test Surface Height" + "</td>" + "<td>" + "Stand Surface Width" + "</td>" + "<td>" + "Test Surface Width" + "</td>" + "<td>" + "Pass/Fail" + "</td>" + "</tr>"; //Test Surfaces Planar Test //all polyloops must be such that the surface defined by the coordinates is planar //report.Clear(); //report.testType = TestType.Surface_Planar_Test; logger.Info("START: SURFACE PLANARITY TEST"); //report = TestSurfacePlanarTest(TestSurfaces, report); var planarityResult = TestSurfacePlanarTest(TestSurfaces,ref camprep); if (!planarityResult) { camprep.SurfacesSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; //gbxml detailed compliance results? } logger.Info("END: SURFACE PLANARITY TEST"); //if (!report.passOrFail && mustBePlanar) //{ // AddToOutPut("Test File Planar Surface Check: ", report, true); // report.Clear(); //} //only run detailed surface checks if the surfaces are planar if(planarityResult) { //<For each surface in the Standard File, try to find a match for this surface in the test file> //Written Jan 31, 2013 by Chien Si Harriman, Senior Product Manager, Carmel Software Corporation //Execute Tests // globalMatchObject.MatchedSurfaceIds = new Dictionary<string, List<string>>(); int i = 1; foreach (SurfaceDefinitions surface in StandardSurfaces) { report.Clear(); DetailedSurfaceSummary ssSummary = new DetailedSurfaceSummary(); //multiple tolerances used report.testType = TestType.Detailed_Surface_Checks; report.subTestIndex = i; if (surface.SurfaceId == "su-zone_5_Srf_7" || surface.SurfaceId == "su-zone_0_Srf_0") { var d = 1; } logger.Info("START: DETAILED SURFACE TEST"); GetSurfaceMatches(surface, TestSurfaces, ref ssSummary, validatorLength, testLength, testlengthConversion, standardlengthConversion, validatorArea, testArea, testareaConversion, standardareaConversion); logger.Info("END: DETAILED SURFACE TEST"); camprep.SurfacesReport.Add(ssSummary); } #endregion #region opending detailed test //openings detailed tests List<OpeningDefinitions> TestOpenings = new List<OpeningDefinitions>(); XmlDocument testFile = gbXMLdocs[0]; XmlNamespaceManager testNSM = gbXMLnsm[0]; List<OpeningDefinitions> StandardOpenings = new List<OpeningDefinitions>(); XmlDocument standardFile = gbXMLdocs[1]; XmlNamespaceManager standardNSM = gbXMLnsm[1]; TestOpenings = GetFileOpeningDefs(TestFile, TestNSM); StandardOpenings = GetFileOpeningDefs(StandardFile, StandardNSM); string TestOpeningTable = ""; report.Clear(); report.testType = TestType.Opening_Planar_Test; report = TestOpeningPlanarTest(TestOpenings, report); if (!report.passOrFail) { AddToOutPut("Test File Planar Opening Check: ", report, true); report.Clear(); } //only run detailed opening checks if the opening are planar else { TestOpeningTable = "<div class='container'><table class='table table-bordered'>"; TestOpeningTable += "<tr class='info'>" + "<td>" + "Test Section Name" + "</td>" + "<td>" + "Standard Opening Id" + "</td>" + "<td>" + "Test Opening Id" + "</td>" + "<td>" + "Standard Parent Surface Id" + "</td>" + "<td>" + "Test Parent Surface Id" + "</td>" + "<td>" + "Standard Parent Azimuth" + "</td>" + "<td>" + "Test Parent Azimuth" + "</td>" + "<td>" + "Standard Parent Tilt" + "</td>" + "<td>" + "Test Parent Tilt" + "</td>" + "<td>" + "Standard Surface Area" + "</td>" + "<td>" + "Test Surface Area" + "</td>" + "<td>" + "Pass/Fail" + "</td>" + "</tr>"; globalMatchObject.MatchedOpeningIds = new Dictionary<string, List<string>>(); int j = 1; //if no openings remove the table. if (StandardOpenings.Count < 1) TestOpeningTable = ""; //compare the openings foreach (OpeningDefinitions opening in StandardOpenings) { report.Clear(); report.testType = TestType.Detailed_Opening_Checks; report.subTestIndex = j; report = GetPossibleOpeningMatches(opening, TestOpenings, report); AddToOutPut("Test 17 for Opening number " + j + " Result: ", report, false); foreach (OpeningDefinitions to in TestOpenings) { if (globalMatchObject.MatchedOpeningIds.ContainsKey(opening.OpeningId)) { foreach (string id in globalMatchObject.MatchedOpeningIds[opening.OpeningId]) { if (to.OpeningId == id) { if (report.passOrFail) TestOpeningTable += "<tr class='success'>" + "<td>" + "<a href='TestDetailPage.aspx?type=" + (int)report.testType + "&subtype=" + report.subTestIndex + "' target='_blank'>" + "Detailed Opening Checks " + report.subTestIndex + "</a>" + "</td>" + "<td>" + opening.OpeningId + "</td>" + "<td>" + to.OpeningId + "</td>" + "<td>" + opening.ParentSurfaceId + "</td>" + "<td>" + to.ParentSurfaceId + "</td>" + "<td>" + String.Format("{0:#,0.00}", opening.ParentAzimuth) + "</td>" + "<td>" + String.Format("{0:#,0.00}", to.ParentAzimuth) + "</td>" + "<td>" + String.Format("{0:#,0.00}", opening.ParentTilt) + "</td>" + "<td>" + String.Format("{0:#,0.00}", to.ParentTilt) + "</td>" + "<td>" + String.Format("{0:#,0.00}", opening.surfaceArea) + "</td>" + "<td>" + String.Format("{0:#,0.00}", to.surfaceArea) + "</td>" + "<td>" + "Pass" + "</td>" + "</tr>"; } } } } //if didn't find match means it failed the test if (!report.passOrFail) TestOpeningTable += "<tr class='error'>" + "<td>" + "<a href='TestDetailPage.aspx?type=" + (int)report.testType + "&subtype=" + report.subTestIndex + "' target='_blank'>" + "Detailed Opening Checks " + report.subTestIndex + "</a>" + "</td>" + "<td>" + opening.OpeningId + "</td>" + "<td>" + "---" + "</td>" + "<td>" + opening.ParentSurfaceId + "</td>" + "<td>" + "---" + "</td>" + "<td>" + String.Format("{0:#,0.00}", opening.ParentAzimuth) + "</td>" + "<td>" + "---" + "</td>" + "<td>" + String.Format("{0:#,0.00}", opening.ParentTilt) + "</td>" + "<td>" + "---" + "</td>" + "<td>" + String.Format("{0:#,0.00}", opening.surfaceArea) + "</td>" + "<td>" + "---" + "</td>" + "<td>" + "Fail" + "</td>" + "</tr>"; j += 1; } } TestOpeningTable += "</table></div><br/>"; #endregion //close table table += "</table></div><br/>"; //add TestSurfaceTable table += TestSurfaceTable + TestOpeningTable; } //CreateSummaryTable(); ((FileAppender)LogManager.GetCurrentLoggers()[0].Logger.Repository.GetAppenders()[0]).Close(); }
public void ProcessRequest(HttpContext context) { var formdata = context.Request.Form; string testcaseName = formdata["testcase"].Replace('+',' '); string schemaversion = formdata["schema"]; gbXMLReport gbr = new gbXMLReport(); gbr.gbxml_testcase = testcaseName; gbr.gbxml_version = schemaversion; logger.Info("Received XML file from user at UTC time " + DateTime.UtcNow); var file = context.Request.Files[0]; if (file.ContentType == "text/xml") { logger.Info("File has extension XML."); DOEgbXMLValidator val = new DOEgbXMLValidator(schemaversion); XMLParser parser = new XMLParser(); //if there is a file //valadate it by pass in input stream as xmlreader Stream responseStream = file.InputStream; XmlReader xmlreader = XmlReader.Create(responseStream); //if it is not valid if (!val.IsValidXmlEx(xmlreader) || val.nErrors > 0 || val.nWarnings > 0) { //if (PrintFriendlyButton != null) // PrintFriendlyButton.Visible = false; //if (DownloadLogButton != null) // DownloadLogButton.Visible = false; //setup errorlog if (val.nErrors > 0 || val.nWarnings > 0) { gbr.XMLSchemaErrors = val.nErrors.ToString(); gbr.XMLSchemaWarnings = val.nWarnings.ToString(); logger.Info("Found " + val.nErrors + " Errors and " + val.nWarnings + " Warnings " + val.Errors); gbr.message = val.Errors; gbr.schema_compliance_results = "FAIL"; gbr.detailed_compliance_results = "DID NOT ATTEMPT DUE TO SCHEMA FAILURE"; } else { gbr.XMLSchemaWarnings = "Infinity"; gbr.XMLSchemaErrors = "Infinity"; logger.Info("Your XML File is severely deficient structurally. It may be missing element tags or is not valid XML. The test has failed. " + val.BigError); gbr.message = "Your XML File is severely deficient structurally."; gbr.schema_compliance_results = "FAIL"; gbr.detailed_compliance_results = "DID NOT ATTEMPT DUE TO SCHEMA FAILURE"; } } else{ //the xml itself is totally valid gbr.schema_compliance_results = "PASS"; gbr.message = "The XML uploaded is validated against schema " + gbr.gbxml_version; gbr.XMLSchemaErrors = val.nErrors.ToString(); gbr.XMLSchemaWarnings = val.nWarnings.ToString(); //run test responseStream.Position = 0; XmlReader xmlreader2 = XmlReader.Create(responseStream); //start test parser.StartTest(xmlreader2, testcaseName, ref gbr); //see if any of the PassOverall are failed var campusProps = gbr.CampusReport; var surffailures = campusProps.SurfacesReport.FindAll(x => x.FoundMatch == false); if (surffailures.Count > 0) gbr.detailed_compliance_results = "FAIL"; var spacefailures = campusProps.SpacesReport.FindAll(x => x.FoundMatch == false); if (spacefailures.Count > 0) gbr.detailed_compliance_results = "FAIL"; var surfsummaryfail = campusProps.SurfacesSummary.FindAll(x => x.PassedAllTests == false); if (surfsummaryfail.Count > 0) gbr.detailed_compliance_results = "FAIL"; var spacesummaryfail = campusProps.SpacesSummary.FindAll(x => x.PassedAllTests == false); if (spacesummaryfail.Count > 0) gbr.detailed_compliance_results = "FAIL"; //TODO: building summary, stories summary } } else{ //the stuff is not even xml logger.Info("Your file does not end in .xml"); gbr.message = "The file does not end in .xml"; gbr.schema_compliance_results = "FAIL"; } context.Response.ContentType = "application/json"; context.Response.Write(JsonConvert.SerializeObject(gbr)); }