/// <summary> /// Save a validation exception that happened before parsing of the xml was completed. /// As there is no Testee information, those values will be set to default values. /// </summary> /// <param name="validationType"></param> /// <param name="message"></param> /// <param name="fileLocation"></param> public void SaveResultExceptions(string validationType, string message, long fileID) { try { int count = TDSQC.QC_RECORDEXCEPTION(-1, string.Empty, -1, "-1", validationType, string.Empty, message, string.Empty, DateTime.Now, fileID, (int)Severity.Fatal, ConfigurationManager.ConnectionStrings["TDSQC"].ConnectionString); if (count == 0) { throw new Exception("No records saved in archive database."); } /*using (DbCommand cmd = _db.GetStoredProcCommand("QC_RECORDEXCEPTION")) * { * cmd.Parameters.Clear(); * _db.AddInParameter(cmd, "@TesteeEntityKey", DbType.Int64, -1); * _db.AddInParameter(cmd, "@TestName", DbType.String, string.Empty); * _db.AddInParameter(cmd, "@Opportunity", DbType.Int32, -1); * _db.AddInParameter(cmd, "@OpportunityID", DbType.String, -1); * _db.AddInParameter(cmd, "@ValidationType", DbType.String, validationType); * _db.AddInParameter(cmd, "@XPath", DbType.String,string.Empty ); * _db.AddInParameter(cmd, "@Message", DbType.String, message); * _db.AddInParameter(cmd, "@RuleID", DbType.String, string.Empty); * _db.AddInParameter(cmd, "@DateEntered", DbType.DateTime, DateTime.Now); * _db.AddInParameter(cmd, "@FileName", DbType.Int64, fileID); * _db.AddInParameter(cmd, "@Severity", DbType.Int32, (int)Severity.Fatal); * int count = _db.ExecuteNonQuery(cmd); * if (count == 0) * { * throw new Exception("No records saved in archive database."); * } * }*/ } catch (Exception ex) { throw ex; } }
public void SaveResultExceptions(TestResult tr, string validationType, string message, long fileID) { try { long? entityKey = null; string testname = null; int? opportunity = null; string opportunityid = null; if (tr != null) { if (tr.Testee != null) { entityKey = tr.Testee.EntityKey; } else { entityKey = -1; } testname = tr.Name; if (tr.Opportunity != null) { opportunity = tr.Opportunity.OpportunityNumber; opportunityid = tr.Opportunity.OpportunityID; } else { opportunity = -1; opportunityid = "-1"; } } int count = TDSQC.QC_RECORDEXCEPTION(entityKey, testname, opportunity, opportunityid, validationType, string.Empty, message, string.Empty, DateTime.Now, fileID, (int)Severity.Fatal, ConfigurationManager.ConnectionStrings["TDSQC"].ConnectionString); if (count == 0) { throw new Exception("No records saved in archive database."); } /*using (DbCommand cmd = _db.GetStoredProcCommand("QC_RECORDEXCEPTION")) * { * cmd.Parameters.Clear(); * if (tr != null) * { * if (tr.Testee != null) * _db.AddInParameter(cmd, "@TesteeEntityKey", DbType.Int64, tr.Testee.EntityKey); * else * _db.AddInParameter(cmd, "@TesteeEntityKey", DbType.Int64, -1); * * _db.AddInParameter(cmd, "@TestName", DbType.String, tr.Name); * if (tr.Opportunity != null) * { * _db.AddInParameter(cmd, "@Opportunity", DbType.Int32, tr.Opportunity.OpportunityNumber); * _db.AddInParameter(cmd, "@OpportunityID", DbType.String, tr.Opportunity.OpportunityID); * } * else * { * _db.AddInParameter(cmd, "@Opportunity", DbType.Int32, -1); * _db.AddInParameter(cmd, "@OpportunityID", DbType.String, -1); * } * } * _db.AddInParameter(cmd, "@ValidationType", DbType.String, validationType); * _db.AddInParameter(cmd, "@XPath", DbType.String, string.Empty); * _db.AddInParameter(cmd, "@Message", DbType.String, message); * _db.AddInParameter(cmd, "@RuleID", DbType.String, string.Empty); * _db.AddInParameter(cmd, "@DateEntered", DbType.DateTime, DateTime.Now); * _db.AddInParameter(cmd, "@FileID", DbType.Int64, fileID); * _db.AddInParameter(cmd, "@Severity", DbType.Int32, (int)Severity.Fatal); * int count = _db.ExecuteNonQuery(cmd); * if (count == 0) * { * throw new Exception("No records saved in archive database."); * } * }*/ } catch (Exception ex) { throw ex; } }
public void SaveResultExceptions(TestResult tr, List <ValidationRecord> vrs, long fileID) { try { foreach (ValidationRecord vr in vrs) { long entityKey = -1; string testname = ""; int opportuntiyNumber = -1; string opportunityID = ""; if (tr != null) { if (tr.Testee != null) { entityKey = tr.Testee.EntityKey; } testname = tr.Name; if (tr.Opportunity != null) { opportuntiyNumber = tr.Opportunity.OpportunityNumber; opportunityID = tr.Opportunity.OpportunityID; } } int count = TDSQC.QC_RECORDEXCEPTION(entityKey, testname, opportuntiyNumber, opportunityID, vr.Type.ToString(), vr.XPath, vr.Message, vr.RuleID, DateTime.Now, fileID, (int)vr.ResultSeverity, ConfigurationManager.ConnectionStrings["TDSQC"].ConnectionString); if (count == 0) { throw new Exception("No records saved in archive database."); } } /* * using (DbCommand cmd = _db.GetStoredProcCommand("QC_RECORDEXCEPTION")) * { * foreach (ValidationRecord vr in vrs) * { * cmd.Parameters.Clear(); * if (tr != null) * { * if(tr.Testee != null) * _db.AddInParameter(cmd, "@TesteeEntityKey", DbType.Int64, tr.Testee.EntityKey); * else * _db.AddInParameter(cmd, "@TesteeEntityKey", DbType.Int64, -1); * * _db.AddInParameter(cmd, "@TestName", DbType.String, tr.Name); * if (tr.Opportunity != null) * { * _db.AddInParameter(cmd, "@Opportunity", DbType.Int32, tr.Opportunity.OpportunityNumber); * _db.AddInParameter(cmd, "@OpportunityID", DbType.String, tr.Opportunity.OpportunityID); * } * else * { * _db.AddInParameter(cmd, "@Opportunity", DbType.Int32, -1); * _db.AddInParameter(cmd, "@OpportunityID", DbType.String, ""); * } * } * else * { * _db.AddInParameter(cmd, "@TesteeEntityKey", DbType.Int64, -1); * _db.AddInParameter(cmd, "@TestName", DbType.String, ""); * _db.AddInParameter(cmd, "@Opportunity", DbType.Int32, -1); * _db.AddInParameter(cmd, "@OpportunityID", DbType.String, ""); * } * _db.AddInParameter(cmd, "@ValidationType", DbType.String, vr.Type.ToString()); * _db.AddInParameter(cmd, "@XPath", DbType.String, vr.XPath); * _db.AddInParameter(cmd, "@Message", DbType.String, vr.Message); * _db.AddInParameter(cmd, "@RuleID", DbType.String, vr.RuleID); * _db.AddInParameter(cmd, "@DateEntered", DbType.DateTime, DateTime.Now); * _db.AddInParameter(cmd, "@FileID", DbType.Int64, fileID); * _db.AddInParameter(cmd, "@Severity", DbType.Int32, (int)vr.ResultSeverity); * * int count = _db.ExecuteNonQuery(cmd); * if (count == 0) * { * throw new Exception("No records saved in archive database."); * } * } * }*/ } catch (Exception ex) { throw ex; } }