/// <summary> /// Get all conformance rules from TestResult table. /// </summary> /// <param name="guid">The job id of conformance rules.</param> public static void GetAllConformanceLevelRules(Guid guid) { try { allRulesResult.Clear(); using (var ctx = SuiteEntitiesUtility.GetODataValidationSuiteEntities()) { var testResults = (from j in ctx.TestResults where guid == j.ValidationJobID orderby j.ID descending select j); if (testResults != null) { foreach (TestResult result in testResults) { allRulesResult.Add(result); } pendingRulesResult = (from j in allRulesResult where j.Classification == "pending" select j).ToList(); } } } catch (System.Data.OptimisticConcurrencyException) { // error occurred while trying to mark operation as complete. This is not a terminal error for this system and // this is on a threadpool thread so swallow the exception } }
/// <summary> /// Write conformance test result to database. /// </summary> /// <param name="testResultID">The updated rule's test result ID.</param> /// <param name="result">The result info.</param> /// <param name="errorMessage">The error message.</param> private static void WriteToTestResult(int testResultID, string result, string errorMessage) { try { var testResult = (from j in allRulesResult where j.ID == testResultID select j).FirstOrDefault(); if (testResult != null) { using (var ctx = SuiteEntitiesUtility.GetODataValidationSuiteEntities()) { var resultInTable = (from j in ctx.TestResults where j.ID == testResultID && j.ValidationJobID == testResult.ValidationJobID select j).FirstOrDefault(); if (resultInTable != null) { resultInTable.Classification = result; resultInTable.ErrorMessage = errorMessage; ctx.SaveChanges(); var detailInTable = (from j in ctx.ResultDetails where j.TestResultID == testResultID select j); if (detailInTable != null && detailInTable.Count() > 0) { detailInTable.FirstOrDefault().ErrorMessage = errorMessage; } else { ResultDetail resultDetailInDB = new ResultDetail(); resultDetailInDB.TestResultID = resultInTable.ID; resultDetailInDB.RuleName = resultInTable.RuleName; resultDetailInDB.URI = ""; resultDetailInDB.HTTPMethod = ""; resultDetailInDB.RequestHeaders = ""; resultDetailInDB.RequestData = ""; resultDetailInDB.ResponseStatusCode = ""; resultDetailInDB.ResponseHeaders = ""; resultDetailInDB.ResponsePayload = ""; resultDetailInDB.ErrorMessage = errorMessage; ctx.AddToResultDetails(resultDetailInDB); } ctx.SaveChanges(); } } } } catch (System.Data.OptimisticConcurrencyException) { // error occurred while trying to mark operation as complete. This is not a terminal error for this system and // this is on a thread-pool thread so swallow the exception } }