private void RecipientKeyChanged(Int64 APartnerKey, String APartnerShortName, bool AValidSelection) { if ((APartnerKey > 0) && AValidSelection) { // get recipeint's current Gift Destination Int64 RecipientLedgerNumber = TRemote.MFinance.Gift.WebConnectors.GetRecipientFundNumber(APartnerKey, DateTime.Today); TVerificationResultCollection VerificationResults; // if recipient ledger number belongs to a different ledger then check that it is set up for inter-ledger transfers if (((int)RecipientLedgerNumber / 1000000 != FLedgerNumber) && !TRemote.MFinance.Gift.WebConnectors.IsRecipientLedgerNumberSetupForILT( FLedgerNumber, APartnerKey, RecipientLedgerNumber, out VerificationResults)) { MessageBox.Show(VerificationResults.BuildVerificationResultString(), Catalog.GetString("Invalid Data Entered"), MessageBoxButtons.OK, MessageBoxIcon.Error); // use a thread because the textbox text has not actually been set yet if using the partner find screen Thread NewThread = new Thread(() => ResetReceipientKey(APartnerKey)); NewThread.Start(); return; } txtCurrentField.Text = RecipientLedgerNumber.ToString(); } else { txtCurrentField.Text = "0"; } }
private void WriteResults(VerificationResults resultSet) { Console.WriteLine("Succcess : " + resultSet.Success); Console.WriteLine("Iterations : " + resultSet.IterationsCompleted); Console.WriteLine("ExecutionMS : " + resultSet.ExecutionTimeMS); foreach (var result in resultSet.Results) { Console.WriteLine($"Key: {result.Key}"); Console.WriteLine($" - Success: {result.Success}"); Console.WriteLine($" - Expected: {result.Expected}"); Console.WriteLine($" - Actual: {result.Actual}"); Console.WriteLine(" "); } foreach (var err in resultSet.ErrorMessages) { Console.WriteLine(err); } }
private static VerificationResults PerformValidationFromXml(string xml, VerificationParameters validationParameters) { var document = new XmlDocument { PreserveWhitespace = true }; document.LoadXml(xml); var newsignedXml = new ExtendedSignedXml(document); if (document.DocumentElement == null) { throw new InvalidDocumentException("Document has no root element"); } var signatureNode = XmlDsigNodesHelper.GetSignatureNode(document); newsignedXml.LoadXml(signatureNode); var verificationCertificate = GetVerificationCertificate(newsignedXml, validationParameters); if (verificationCertificate == null) { throw new Exception("Signer public key could not be found"); } if (!newsignedXml.CheckSignature(verificationCertificate, !validationParameters.VerifyCertificate)) { throw new InvalidOperationException("Signature is invalid."); } var results = new VerificationResults { Timestamp = GetTimeStampFromSignature(document), OriginalDocument = GetDocumentFromSignature(document), SigningCertificate = GetCertificateFromSignature(document) }; return(results); }
/// <summary> /// Verifies the state machine's accuracy. /// </summary> /// <remarks> /// Evaluates the computed data against the ideal data. /// </remarks> /// <param name="verificationData">The verification data bundle.</param> /// <returns>The verification results.</returns> public VerificationResults Verify(VectorBundle verificationData) { VerificationResults verificationResults = new VerificationResults(Config.ReadoutLayerCfg); for (int sampleIdx = 0; sampleIdx < verificationData.InputVectorCollection.Count; sampleIdx++) { double[] predictors; if (NP == null) { //Neural preprocessor is bypassed predictors = verificationData.InputVectorCollection[sampleIdx]; } else { //Neural preprocessing predictors = NP.Preprocess(verificationData.InputVectorCollection[sampleIdx]); } double[] outputVector = RL.Compute(predictors, out ReadoutLayer.ReadoutData readoutData); verificationResults.Update(predictors, readoutData, verificationData.OutputVectorCollection[sampleIdx]); VerificationProgressChanged?.Invoke(verificationData.InputVectorCollection.Count, sampleIdx + 1); } return(verificationResults); }
private Boolean CheckAccountCodeValueChanged() { String strNewDetailAccountCode = txtDetailAccountCode.Text; String strAccountShortDescr = txtDetailEngAccountCodeShortDesc.Text; bool changeAccepted = false; if (strNewDetailAccountCode != FRecentlyUpdatedDetailAccountCode) { if (strNewDetailAccountCode != strOldDetailAccountCode) { if (strOldDetailAccountCode.IndexOf(FNameForNewAccounts) < 0) // If they're just changing this from the initial value, don't show warning. { if (MessageBox.Show(String.Format(Catalog.GetString( "You have changed the Account Code from '{0}' to '{1}'.\r\n\r\n" + "Please confirm that you want to rename this account by choosing 'OK'.\r\n\r\n" + "(Renaming will take a few moments, then the form will be re-loaded.)"), strOldDetailAccountCode, strNewDetailAccountCode), Catalog.GetString("Rename Account: Confirmation"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { txtDetailAccountCode.Text = strOldDetailAccountCode; return(false); } } this.Cursor = Cursors.WaitCursor; this.Refresh(); // Just to get the Wait Cursor to display... FRecentlyUpdatedDetailAccountCode = strNewDetailAccountCode; changeAccepted = ProtectedChangeOfPrimaryKey(FCurrentAccount); if (changeAccepted) { ucoAccountsTree.SetNodeLabel(strNewDetailAccountCode, strAccountShortDescr); if (FCurrentAccount.IsNew) { // This is the code for changes in "un-committed" nodes: // there are no references to this new row yet, apart from children nodes, so I can just change them here and carry on! ucoAccountsTree.FixupChildrenAfterAccountNameChange(); strOldDetailAccountCode = strNewDetailAccountCode; FPetraUtilsObject.HasChanges = true; ucoAccountAnalysisAttributes.AccountCode = strNewDetailAccountCode; } else { ShowStatus(Catalog.GetString("Updating Account Code change - please wait.")); TVerificationResultCollection VerificationResults; // If this code was previously in the DB, I need to assume that there may be transactions posted to it. // There's a server call I need to use, and after the call I need to re-load this page. // (No other changes will be lost, because the txtDetailAccountCode_TextChanged would // have disallowed the change if there were already changes.) bool Success = TRemote.MFinance.Setup.WebConnectors.RenameAccountCode(strOldDetailAccountCode, strNewDetailAccountCode, FLedgerNumber, out VerificationResults); // This call takes ages.. if (Success) { FIAmUpdating++; FMainDS.Clear(); FMainDS.Merge(TRemote.MFinance.Setup.WebConnectors.LoadAccountHierarchies(FLedgerNumber)); // and this also takes a while! strOldDetailAccountCode = ""; FPetraUtilsObject.SuppressChangeDetection = true; ucoAccountsTree.PopulateTreeView(FMainDS, FLedgerNumber, FSelectedHierarchy); ucoAccountsList.PopulateListView(FMainDS, FLedgerNumber, FSelectedHierarchy); ShowDetailsManual(null); ClearStatus(); FIAmUpdating--; FPetraUtilsObject.SuppressChangeDetection = false; ucoAccountsTree.SelectNodeByName(FRecentlyUpdatedDetailAccountCode); ShowStatus(String.Format(Catalog.GetString("Account Code changed to '{0}'."), strNewDetailAccountCode)); TDataCache.TMFinance.RefreshCacheableFinanceTable(Shared.TCacheableFinanceTablesEnum.AccountList, FLedgerNumber); } else { MessageBox.Show(VerificationResults.BuildVerificationResultString(), Catalog.GetString("Rename Account")); } changeAccepted = false; // Actually the change was accepted, but processed here, so there's nothing left to do. FPetraUtilsObject.HasChanges = false; } btnRename.Visible = false; } // if changeAccepted this.Cursor = Cursors.Default; } // if changed } // if not handling the same change as before (prevents this method running several times for a single change!) return(changeAccepted); }
public async Task <VerificationResults> VerifyAsync(VerificationRequest <DeviceMessageDefinition> request, EntityHeader org, EntityHeader user) { var sw = new Stopwatch(); var verifier = request.Verifier as Verifier; var result = new VerificationResults(new EntityHeader() { Text = request.Configuration.Name, Id = request.Configuration.Id }, VerifierTypes.MessageParser); if (String.IsNullOrEmpty(verifier.Input) && String.IsNullOrEmpty(verifier.Topic) && String.IsNullOrEmpty(verifier.PathAndQueryString) && verifier.Headers.Count == 0) { result.ErrorMessages.Add(VerifierResources.Verifier_MissingInput); result.Success = false; await _resultRepo.AddResultAsync(result); return(result); } if (verifier.ExpectedOutputs == null || verifier.ExpectedOutputs.Count == 0) { result.ErrorMessages.Add(VerifierResources.Verifier_MissingInput); result.Success = false; await _resultRepo.AddResultAsync(result); return(result); } if (EntityHeader.IsNullOrEmpty(verifier.InputType)) { result.ErrorMessages.Add(VerifierResources.Verifier_MissingInputType); result.Success = false; await _resultRepo.AddResultAsync(result); return(result); } if (request.Iterations == 0) { result.ErrorMessages.Add(VerifierResources.Verifier_IterationCountZero); result.Success = false; await _resultRepo.AddResultAsync(result); return(result); } var start = DateTime.Now; result.DateStamp = start.ToJSONString(); result.Success = true; result.RequestedBy = user; /* TODO: Need to think this through we are using the same parser we are for instances, do we care about logging this? */ var logger = new VerifierLogger(null, null, null, null); foreach (var fld in request.Configuration.Fields) { if (fld.StorageType.Value == DeviceAdmin.Models.ParameterTypes.State) { fld.StateSet.Value = await _deviceAdminManager.GetStateSetAsync(fld.StateSet.Id, org, user); } else if (fld.StorageType.Value == DeviceAdmin.Models.ParameterTypes.ValueWithUnit) { fld.UnitSet.Value = await _deviceAdminManager.GetAttributeUnitSetAsync(fld.UnitSet.Id, org, user); } } var parser = _parserManager.GetMessageParser(request.Configuration, logger); sw.Start(); for (var idx = 0; idx < request.Iterations; ++idx) { var pem = new IoT.Runtime.Core.Models.PEM.PipelineExecutionMessage(); pem.PayloadType = verifier.InputType.Value == InputTypes.Text ? IoT.Runtime.Core.Models.PEM.MessagePayloadTypes.Text : IoT.Runtime.Core.Models.PEM.MessagePayloadTypes.Binary; if (pem.PayloadType == IoT.Runtime.Core.Models.PEM.MessagePayloadTypes.Binary) { pem.BinaryPayload = verifier.GetBinaryPayload(); if (pem.BinaryPayload == null || pem.BinaryPayload.Length == 0) { result.ErrorMessages.Add(VerifierResources.Verifier_MissingInput); result.Success = false; await _resultRepo.AddResultAsync(result); return(result); } } else { pem.TextPayload = verifier.Input; } foreach (var header in verifier.Headers) { pem.Envelope.Headers.Add(header.Name, header.Value); } pem.Envelope.Path = verifier.PathAndQueryString; pem.Envelope.Topic = verifier.Topic; var parseResult = parser.Parse(pem, request.Configuration); if (parseResult.Successful) { foreach (var item in verifier.ExpectedOutputs) { var expectedValue = item.Value; if (pem.Envelope.Values.ContainsKey(item.Key)) { var actualValue = pem.Envelope.Values[item.Key].Value; if (expectedValue == actualValue) { result.Results.Add(new VerificationResult() { Key = item.Key, Expected = item.Value, Actual = String.IsNullOrEmpty(actualValue) ? "-empty-" : actualValue, Success = true, }); } else { var verificationResult = new VerificationResult() { Key = item.Key, Expected = item.Value, Actual = String.IsNullOrEmpty(actualValue) ? "-empty-" : actualValue, Success = false, }; result.Results.Add(verificationResult); result.ErrorMessages.Add($"{VerifierResources.Verifier_Expected_NotMatch_Actual}. {VerifierResources.Verifier_Field}: {item.Key}, {VerifierResources.Verifier_Expected}={verificationResult.Expected}, {VerifierResources.Verifier_Actual}={verificationResult.Actual} "); result.Success = false; } } else { result.ErrorMessages.Add($"{VerifierResources.Verifier_ResultDoesNotContainKey}, {item.Key}"); result.Success = false; } } } else { result.Success = false; result.ErrorMessages.AddRange(parseResult.Errors.Select(err => err.Message + " " + err.Details)); } result.IterationsCompleted++; if (!result.Success) { idx = request.Iterations; result.ErrorMessages.Add($"{VerifierResources.Verifier_Aborted}; {VerifierResources.Verifier_IterationsCompleted} ({result.IterationsCompleted})"); } } sw.Stop(); result.ExecutionTimeMS = Math.Round(sw.Elapsed.TotalMilliseconds, 3); await _resultRepo.AddResultAsync(result); return(result); }
public override int GetHashCode() { int hashCode = 1465447186; if (Status != null) { hashCode += Status.GetHashCode(); } if (Card != null) { hashCode += Card.GetHashCode(); } if (EntryMethod != null) { hashCode += EntryMethod.GetHashCode(); } if (CvvStatus != null) { hashCode += CvvStatus.GetHashCode(); } if (AvsStatus != null) { hashCode += AvsStatus.GetHashCode(); } if (AuthResultCode != null) { hashCode += AuthResultCode.GetHashCode(); } if (ApplicationIdentifier != null) { hashCode += ApplicationIdentifier.GetHashCode(); } if (ApplicationName != null) { hashCode += ApplicationName.GetHashCode(); } if (ApplicationCryptogram != null) { hashCode += ApplicationCryptogram.GetHashCode(); } if (VerificationMethod != null) { hashCode += VerificationMethod.GetHashCode(); } if (VerificationResults != null) { hashCode += VerificationResults.GetHashCode(); } if (StatementDescription != null) { hashCode += StatementDescription.GetHashCode(); } if (DeviceDetails != null) { hashCode += DeviceDetails.GetHashCode(); } if (CardPaymentTimeline != null) { hashCode += CardPaymentTimeline.GetHashCode(); } if (RefundRequiresCardPresence != null) { hashCode += RefundRequiresCardPresence.GetHashCode(); } if (Errors != null) { hashCode += Errors.GetHashCode(); } return(hashCode); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is CardPaymentDetails other && ((Status == null && other.Status == null) || (Status?.Equals(other.Status) == true)) && ((Card == null && other.Card == null) || (Card?.Equals(other.Card) == true)) && ((EntryMethod == null && other.EntryMethod == null) || (EntryMethod?.Equals(other.EntryMethod) == true)) && ((CvvStatus == null && other.CvvStatus == null) || (CvvStatus?.Equals(other.CvvStatus) == true)) && ((AvsStatus == null && other.AvsStatus == null) || (AvsStatus?.Equals(other.AvsStatus) == true)) && ((AuthResultCode == null && other.AuthResultCode == null) || (AuthResultCode?.Equals(other.AuthResultCode) == true)) && ((ApplicationIdentifier == null && other.ApplicationIdentifier == null) || (ApplicationIdentifier?.Equals(other.ApplicationIdentifier) == true)) && ((ApplicationName == null && other.ApplicationName == null) || (ApplicationName?.Equals(other.ApplicationName) == true)) && ((ApplicationCryptogram == null && other.ApplicationCryptogram == null) || (ApplicationCryptogram?.Equals(other.ApplicationCryptogram) == true)) && ((VerificationMethod == null && other.VerificationMethod == null) || (VerificationMethod?.Equals(other.VerificationMethod) == true)) && ((VerificationResults == null && other.VerificationResults == null) || (VerificationResults?.Equals(other.VerificationResults) == true)) && ((StatementDescription == null && other.StatementDescription == null) || (StatementDescription?.Equals(other.StatementDescription) == true)) && ((DeviceDetails == null && other.DeviceDetails == null) || (DeviceDetails?.Equals(other.DeviceDetails) == true)) && ((CardPaymentTimeline == null && other.CardPaymentTimeline == null) || (CardPaymentTimeline?.Equals(other.CardPaymentTimeline) == true)) && ((RefundRequiresCardPresence == null && other.RefundRequiresCardPresence == null) || (RefundRequiresCardPresence?.Equals(other.RefundRequiresCardPresence) == true)) && ((Errors == null && other.Errors == null) || (Errors?.Equals(other.Errors) == true))); }
/// <summary> /// Change CostCentre Value /// /// The Cost Centre code is a foreign key in loads of tables, /// so renaming a Cost Centre code is a major work on the server. /// From the client's perspective it's easy - we just need to ask the server to do it! /// /// </summary> private bool CheckCostCentreValueChanged() { if ((FIAmUpdating > 0) || (strOldDetailCostCentreCode == null)) { return false; } String strNewDetailCostCentreCode = txtDetailCostCentreCode.Text; bool changeAccepted = false; if (strNewDetailCostCentreCode != FRecentlyUpdatedDetailCostCentreCode) { if (strNewDetailCostCentreCode != strOldDetailCostCentreCode) { if (strOldDetailCostCentreCode.IndexOf(FnameForNewCostCentre) < 0) // If they're just changing this from the initial value, don't show warning. { if (MessageBox.Show(String.Format(Catalog.GetString( "You have changed the Cost Centre Code from '{0}' to '{1}'.\r\n\r\n" + "Please confirm that you want to rename this Cost Centre Code by choosing 'OK'.\r\n\r\n" + "(Renaming will take a few moments, then the form will be re-loaded.)"), strOldDetailCostCentreCode, strNewDetailCostCentreCode), Catalog.GetString("Rename Cost Centre Code: Confirmation"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) != DialogResult.OK) { txtDetailCostCentreCode.Text = strOldDetailCostCentreCode; btnRename.Visible = false; return false; } } this.UseWaitCursor = true; this.Refresh(); FRecentlyUpdatedDetailCostCentreCode = strNewDetailCostCentreCode; changeAccepted = ProtectedChangeOfPrimaryKey(FCurrentCostCentre); if (changeAccepted) { ucoCostCentreTree.SetNodeLabel(FCurrentCostCentre.CostCentreRow); if (FCurrentCostCentre.IsNew) { // This is the code for changes in "un-committed" nodes: // there are no references to this new row yet, apart from children nodes, so I can just change them here and carry on! // fixup children nodes ucoCostCentreTree.FixupChildrenAfterCostCentreNameChange(); strOldDetailCostCentreCode = strNewDetailCostCentreCode; FPetraUtilsObject.HasChanges = true; } else { ShowStatus(Catalog.GetString("Updating Cost Centre Code change - please wait.\r\n")); TVerificationResultCollection VerificationResults; // If this code was previously in the DB, I need to assume that there may be transactions posted against it. // There's a server call I need to use, and after the call I need to re-load this page. // (No other changes will be lost, because the change would not have been allowed if there were already changes.) this.Cursor = Cursors.WaitCursor; bool Success = TRemote.MFinance.Setup.WebConnectors.RenameCostCentreCode(strOldDetailCostCentreCode, strNewDetailCostCentreCode, FLedgerNumber, out VerificationResults); this.Cursor = Cursors.Default; if (Success) { TDataCache.TMFinance.RefreshCacheableFinanceTable(Shared.TCacheableFinanceTablesEnum.CostCentreList, FLedgerNumber); FMainDS = TRemote.MFinance.Setup.WebConnectors.LoadCostCentreHierarchy(FLedgerNumber); strOldDetailCostCentreCode = ""; FIAmUpdating++; FPetraUtilsObject.SuppressChangeDetection = false; txtDetailCostCentreCode.Text = ""; FPetraUtilsObject.SuppressChangeDetection = false; FCurrentCostCentre = null; ucoCostCentreTree.PopulateTreeView(FMainDS); ucoCostCentreList.PopulateListView(FMainDS, FLedgerNumber); FIAmUpdating--; ucoCostCentreTree.SelectNodeByName(FRecentlyUpdatedDetailCostCentreCode); ClearStatus(); changeAccepted = true; ShowStatus(String.Format("Cost Centre Code changed to '{0}'.\r\n", strNewDetailCostCentreCode)); } else { MessageBox.Show(VerificationResults.BuildVerificationResultString(), Catalog.GetString("Rename Cost Centre Code")); } } } // if changeAccepted this.UseWaitCursor = false; } // if changed } return changeAccepted; }