/// cascading count private static int CountByPrimaryKey(Int64 AConferenceKey, TDBTransaction ATransaction, bool AWithCascCount, out TVerificationResultCollection AVerificationResults, int ANestingDepth = 0, TResultSeverity AResultSeverity = TResultSeverity.Resv_Critical) { int ReturnValue; List <TRowReferenceInfo> References; Dictionary <string, object> PKInfo = null; ReturnValue = CountByPrimaryKey(AConferenceKey, ATransaction, AWithCascCount, out References, ANestingDepth); if (ReturnValue > 0) { PKInfo = new Dictionary <string, object>(1); PKInfo.Add("Partner Key", AConferenceKey); AVerificationResults = TTypedDataAccess.BuildVerificationResultCollectionFromRefTables("PcConference", "Conference", PKInfo, References, AResultSeverity); } else { AVerificationResults = null; } return(ReturnValue); }
private void AddVerificationResult(String AResultText, TResultSeverity ASeverity) { if (ASeverity != TResultSeverity.Resv_Status) { TLogging.Log(AResultText); } FResultList.Add(new TVerificationResult(ImportContext, AResultText, ASeverity)); }
private static void AddVerificationResult(String AResultText, TResultSeverity ASeverity) { if (ASeverity != TResultSeverity.Resv_Status) { TLogging.Log(AResultText); } ResultsCol.Add(new TVerificationResult(ResultsContext, AResultText, ASeverity)); }
private void AddVerificationResultMessage( string AResultContext, string AResultText, string ALocalCode, TResultSeverity AResultSeverity) { FVerificationCollection.Add(new TVerificationResult( AResultContext, AResultText, "REVAL", "REVAL:" + ALocalCode, AResultSeverity)); if (AResultSeverity == TResultSeverity.Resv_Critical) { F_resultSeverity = TResultSeverity.Resv_Critical; } }
/// <summary> /// Constructor to initialize a variable set. /// </summary> public CLSRevaluation(int ALedgerNum, string[] AForeignAccount, decimal[] ANewExchangeRate, String ACostCentre) { F_LedgerNum = ALedgerNum; F_ForeignAccount = AForeignAccount; F_ExchangeRate = ANewExchangeRate; F_CostCentre = ACostCentre; FVerificationCollection = new TVerificationResultCollection(); F_resultSeverity = TResultSeverity.Resv_Noncritical; }
/// cascading count private static int CountByPrimaryKey(object[] APrimaryKeyValues, TDBTransaction ATransaction, bool AWithCascCount, out TVerificationResultCollection AVerificationResults, int ANestingDepth = 0, TResultSeverity AResultSeverity = TResultSeverity.Resv_Critical) { if ((APrimaryKeyValues == null) || (APrimaryKeyValues.Length == 0)) { throw new ArgumentException("APrimaryKeyValues must not be null and must contain at least one element"); } return(CountByPrimaryKey((Int64)APrimaryKeyValues[0], ATransaction, AWithCascCount, out AVerificationResults, ANestingDepth)); }
/// <summary> /// Constructor /// </summary> /// <param name="AResultContext">context where this verification happens (e.g. DB field name)</param> /// <param name="AResultText">Verification failure explanation</param> /// <param name="AResultTextCaption">caption for message box</param> /// <param name="AResultCode">a result code to identify error messages</param> /// <param name="AResultSeverity">is this an error or just a warning</param> /// <param name="ADataValidationRunID">A Data Validation Run ID that this instance should be associated with. Default: a new System.Guid instance.</param> public TVerificationResult(String AResultContext, String AResultText, String AResultTextCaption, String AResultCode, TResultSeverity AResultSeverity, System.Guid ADataValidationRunID = new System.Guid()) { FResultContext = AResultContext; FResultText = AResultText; FResultTextCaption = AResultTextCaption; FResultCode = AResultCode; FResultSeverity = AResultSeverity; FDataValidationRunID = ADataValidationRunID; }
/// <summary> /// Constructor /// </summary> /// <param name="AResultContext">context where this verification happens (e.g. DB field name)</param> /// <param name="AResultText">Verification failure explanation</param> /// <param name="AResultSeverity">is this an error or just a warning</param> /// <param name="ADataValidationRunID">A Data Validation Run ID that this instance should be associated with. Default: a new System.Guid instance.</param> public TVerificationResult(object AResultContext, String AResultText, TResultSeverity AResultSeverity, System.Guid ADataValidationRunID = new System.Guid()) { FResultContext = AResultContext; FResultText = AResultText; FResultSeverity = AResultSeverity; FDataValidationRunID = ADataValidationRunID; }
/// <summary> /// Constructor /// </summary> /// <param name="AResultContext">context where this verification happens (e.g. DB field name)</param> /// <param name="AErrorCodeInfo">An <see cref="ErrCodeInfo" /> that contains data which is used for populating the Verification Result's Properites.</param> /// <param name="ADataValidationRunID">A Data Validation Run ID that this instance should be associated with. Default: a new System.Guid instance.</param> public TVerificationResult(object AResultContext, ErrCodeInfo AErrorCodeInfo, System.Guid ADataValidationRunID = new System.Guid()) { FResultContext = AResultContext; FResultCode = AErrorCodeInfo.ErrorCode; if (AErrorCodeInfo.ErrorMessageText == String.Empty) { FResultText = AErrorCodeInfo.ShortDescription; } else { FResultText = AErrorCodeInfo.ErrorMessageText; } if (AErrorCodeInfo.ErrorMessageTitle != String.Empty) { FResultTextCaption = AErrorCodeInfo.ErrorMessageTitle; } if ((AErrorCodeInfo.Category == ErrCodeCategory.Error) || (AErrorCodeInfo.Category == ErrCodeCategory.Validation)) { FResultSeverity = TResultSeverity.Resv_Critical; } else if (AErrorCodeInfo.Category == ErrCodeCategory.NonCriticalError) { FResultSeverity = TResultSeverity.Resv_Noncritical; } FControlValueUndoRequested = AErrorCodeInfo.ControlValueUndoRequested; FDataValidationRunID = ADataValidationRunID; }
private static void AddVerificationResult(ref TVerificationResultCollection ReferenceResults, String AResultText, TResultSeverity Severity) { if (Severity != TResultSeverity.Resv_Status) { TLogging.Log(AResultText); } ReferenceResults.Add(new TVerificationResult(FImportContext, AResultText, Severity)); }
/// cascading count private static int CountByPrimaryKey(object[] APrimaryKeyValues, TDBTransaction ATransaction, bool AWithCascCount, out TVerificationResultCollection AVerificationResults, int ANestingDepth = 0, TResultSeverity AResultSeverity = TResultSeverity.Resv_Critical) { if ((APrimaryKeyValues == null) || (APrimaryKeyValues.Length == 0)) { throw new ArgumentException("APrimaryKeyValues must not be null and must contain at least one element"); } return CountByPrimaryKey((Int64)APrimaryKeyValues[0], ATransaction, AWithCascCount, out AVerificationResults, ANestingDepth); }
/// cascading count private static int CountByPrimaryKey(Int64 AConferenceKey, TDBTransaction ATransaction, bool AWithCascCount, out TVerificationResultCollection AVerificationResults, int ANestingDepth = 0, TResultSeverity AResultSeverity = TResultSeverity.Resv_Critical) { int ReturnValue; List <TRowReferenceInfo>References; Dictionary <string, object>PKInfo = null; ReturnValue = CountByPrimaryKey(AConferenceKey, ATransaction, AWithCascCount, out References, ANestingDepth); if (ReturnValue > 0) { PKInfo = new Dictionary <string, object>(1); PKInfo.Add("Partner Key", AConferenceKey); AVerificationResults = TTypedDataAccess.BuildVerificationResultCollectionFromRefTables("PcConference", "Conference", PKInfo, References, AResultSeverity); } else { AVerificationResults = null; } return ReturnValue; }
/// <summary> /// Constructor /// </summary> /// <remarks>'Downgrades' a <see cref="TScreenVerificationResult" /> to a <see cref="TVerificationResult" />.</remarks> /// <param name="AScreenVerificationResult">A <see cref="TScreenVerificationResult" />.</param> public TVerificationResult(TScreenVerificationResult AScreenVerificationResult) { FResultContext = AScreenVerificationResult.ResultContext; FResultText = AScreenVerificationResult.ResultText; FResultTextCaption = AScreenVerificationResult.ResultTextCaption; FResultCode = AScreenVerificationResult.ResultCode; FResultSeverity = AScreenVerificationResult.ResultSeverity; FDataValidationRunID = AScreenVerificationResult.DataValidationRunID; }
/// <summary> /// Constructor /// </summary> /// <param name="AResultContext">context of verification</param> /// <param name="AResultColumn">which column failed</param> /// <param name="AResultText">description and error message for the user</param> /// <param name="AResultCaption">caption for error message box</param> /// <param name="AResultCode">error code to identify the error message</param> /// <param name="AResultControl">which control is involved</param> /// <param name="AResultSeverity">is this serious, or just a warning</param> /// <param name="ADataValidationRunID">A Data Validation Run ID that this instance should be associated with. Default: a new System.Guid instance.</param> public TScreenVerificationResult(object AResultContext, DataColumn AResultColumn, String AResultText, String AResultCaption, String AResultCode, Control AResultControl, TResultSeverity AResultSeverity, System.Guid ADataValidationRunID = new System.Guid()) { FResultContext = AResultContext; FResultColumn = AResultColumn; FResultText = AResultText; FResultTextCaption = AResultCaption; FResultCode = AResultCode; FResultControl = AResultControl; FResultSeverity = AResultSeverity; FDataValidationRunID = ADataValidationRunID; }
/// <summary> /// Builds a <see cref="TVerificationResultCollection" /> from DB Table references created by a cascading count Method. /// It will contain only a single <see cref="TVerificationResult" />. /// </summary> /// <returns><see cref="TVerificationResultCollection" /> from DB Table references created by a cascading count Method. /// In case <paramref name="AReferences" /> does not contain elements a <see cref="TVerificationResultCollection" /> /// containing no elements will be returned.</returns> /// <param name="AThisTable">Name of the DB Table (as in the DB) that the references point to.</param> /// <param name="AThisTableLabel">Label (='friendly name' for the user) of the DB Table that the references point to.</param> /// <param name="APKInfo"><see cref="Dictionary{T, T}" /> consisting of a string-object pair for each Primary Key Column. /// The string (Key) is the Label ('friendly name' for the user) of the PK Column and the object (Value) holds the actual data /// of the PK Column.</param> /// <param name="AReferences">A <see cref="List{T}" /> of <see cref="TRowReferenceInfo" /> objects that contain information about /// the DB Table references created by a cascading count Method.</param> /// <param name="AResultSeverity">Allows the specification of a <see cref="TResultSeverity" /> for the <see cref="TVerificationResult" /> /// that gets added to the return value. (Default=<see cref="TResultSeverity.Resv_Critical" />.)</param> /// <returns>A <see cref="TVerificationResultCollection" /> containing a single <see cref="TVerificationResult" /> that contains information /// about DB Table references created by a cascading count Method.</returns> public static TVerificationResultCollection BuildVerificationResultCollectionFromRefTables(string AThisTable, string AThisTableLabel, Dictionary <string, object>APKInfo, List <TRowReferenceInfo>AReferences, TResultSeverity AResultSeverity = TResultSeverity.Resv_Critical) { const string STR_BULLET = "* "; Guid VerificationRunGuid = Guid.NewGuid(); TVerificationResultCollection ReturnValue = new TVerificationResultCollection(VerificationRunGuid); string MessageHeaderPart1 = Catalog.GetString(String.Format("The '{0}' record", AThisTableLabel)); string MessageHeaderPart2 = Catalog.GetString("{0}\r\n cannot be deleted because\r\n"); string MessageFooter = Catalog.GetString("\r\n {0} from the '{1}' Table:\r\n{2}"); string[] MessageDetails = null; string CompleteMessageDetails = String.Empty; string MessageContinuation = Catalog.GetString(" and\r\n"); string KeysAndValueInformation = String.Empty; List <KeyValuePair <string, TRowReferenceInfo>>ConsolidatedReferences = new List <KeyValuePair <string, TRowReferenceInfo>>(); TRowReferenceInfo FirstReferenceInCascade; if (AReferences.Count == 0) { return null; } // Iterate through References backwards because the insertion order in AReference is backwards for (int Counter = AReferences.Count - 1; Counter >= 0; Counter--) { AddOrUpdateConsolidatedReferences(AReferences[Counter], ConsolidatedReferences); } // See if we finished early because we reached our max reference count limit bool bEndedEarly = false; for (int Counter = 0; Counter < ConsolidatedReferences.Count; Counter++) { if (ConsolidatedReferences[Counter].Value.CascadingCountEndedEarly) { bEndedEarly = true; break; } } MessageDetails = new string[ConsolidatedReferences.Count]; for (int Counter = 0; Counter < ConsolidatedReferences.Count; Counter++) { MessageDetails[Counter] = Catalog.GetPluralString( String.Format(STR_INDENTATION + new string(' ', ConsolidatedReferences[Counter].Value.NestingDepth - 1) + STR_BULLET + "a '{0}' record is {1} referencing it", ConsolidatedReferences[Counter].Value.ThisTableLabel, ConsolidatedReferences[Counter].Value.NestingDepth > 1 ? Catalog.GetString("indirectly") : Catalog.GetString("still")), String.Format(STR_INDENTATION + new string(' ', ConsolidatedReferences[Counter].Value.NestingDepth - 1) + STR_BULLET + "{0} '{1}' records are {2} referencing it", ConsolidatedReferences[Counter].Value.ReferenceCount, ConsolidatedReferences[Counter].Value.ThisTableLabel, ConsolidatedReferences[Counter].Value.NestingDepth > 1 ? Catalog.GetString("indirectly") : Catalog.GetString("still")), ConsolidatedReferences[Counter].Value.ReferenceCount); } if (MessageDetails.Length > 1) { for (int Counter = 0; Counter < MessageDetails.Length; Counter++) { if (Counter != MessageDetails.Length - 1) { MessageDetails[Counter] += MessageContinuation; } CompleteMessageDetails += MessageDetails[Counter]; } } else { // Strip off leading STR_BULLET as we don't need one if there is only one MessageDetail CompleteMessageDetails = STR_INDENTATION + MessageDetails[0].Substring(MessageDetails[0].IndexOf(STR_BULLET) + 2); } CompleteMessageDetails += "."; if (bEndedEarly) { CompleteMessageDetails += Environment.NewLine; CompleteMessageDetails += String.Format(Catalog.GetString("{0}{1} More references may exist, but the count was terminated after the first {2}!"), STR_INDENTATION, STR_BULLET, AReferences.Count); } // Build Keys and values for 'this table' foreach (var element in APKInfo) { KeysAndValueInformation += STR_INDENTATION + STR_INDENTATION + element.Key + ": " + element.Value.ToString() + Environment.NewLine; } // Strip off trailing Environment.NewLine KeysAndValueInformation = KeysAndValueInformation.Substring(0, KeysAndValueInformation.Length - Environment.NewLine.Length); MessageHeaderPart2 = String.Format(MessageHeaderPart2, "\r\n" + STR_INDENTATION + " " + AThisTableLabel + Catalog.GetString(" code:\r\n") + KeysAndValueInformation); // Build Keys and values for 'first referencing table in the cascade' KeysAndValueInformation = String.Empty; FirstReferenceInCascade = ConsolidatedReferences[0].Value; foreach (var element in FirstReferenceInCascade.PKInfo) { KeysAndValueInformation += STR_INDENTATION + STR_INDENTATION + element.Key + ": " + element.Value.ToString() + Environment.NewLine; } // Strip off trailing Environment.NewLine //KeysAndValueInformation = KeysAndValueInformation.Substring(0, KeysAndValueInformation.Length - Environment.NewLine.Length); MessageFooter = String.Format(MessageFooter, FirstReferenceInCascade.ReferenceCount == 1 ? Catalog.GetString("Referencing record") : Catalog.GetString("One of the referencing records"), FirstReferenceInCascade.ThisTableLabel, STR_INDENTATION + " " + FirstReferenceInCascade.ThisTableLabel + Catalog.GetString(" code:\r\n") + KeysAndValueInformation); ReturnValue.Add(new TVerificationResult(new TRowReferenceInfo(AThisTable, AThisTableLabel, APKInfo, ConsolidatedReferences), MessageHeaderPart1 + MessageHeaderPart2 + CompleteMessageDetails + MessageFooter, CommonErrorCodes.ERR_RECORD_DELETION_NOT_POSSIBLE_REFERENCED, AResultSeverity, VerificationRunGuid)); return ReturnValue; }