FoxPro and .NET Interop
Retrieve data via dot net bridge
Gravatar is a globally recognized avatar based on your email address. Retrieve data via dot net bridge
  Mark Stratton
  All
  May 28, 2018 @ 07:39pm

Hi is it possible to retrieve a value from a .net assembly via dot net bridge? The following code is to perform this task in .Net

/// <summary>
/// Shows simple use of POS Controlled printing.
/// </summary>
static void PurchaseWithPOSControlledPrinting()
{
// Create a vault session
using (VaultSession session=new VaultSession("CHECKOUT1",OnPrint))
{
// After creating a session always check for uncompleted transactions
// <insert code here>
// Create a transaction object
PurchaseTransaction purchaseTx=new PurchaseTransaction("#1",19.95m);
TransactionResult result=session.ExecuteTransaction(purchaseTx);
// Determine the success of the transaction
if (result==TransactionResult.Success)
{
Console.WriteLine("Transaction succeeded");
Console.WriteLine("Truncated PAN = {0}",purchaseTx.CardInfo.PAN);
Console.WriteLine(
"Duplicate Receipt = \n{0}",
purchaseTx.TxInfo.DuplicateReceiptImage);
}
else
{
Console.WriteLine("Transaction failed - <enter> to continue");
Console.ReadLine();
}
}
}
/// <summary>
/// Receipt Print Handler
/// </summary>
/// <param name="text">The text to be printed.</param>
/// <param name="printType">The type of print job.</param>
/// <returns>Returns true if the receipt was printed OK.</returns>
static bool OnPrint(string text,PrintType printType)
{
bool printedOk=true;
// Send receipt to printer here...
Console.WriteLine("--- Print Job ---\n{0}\n-----------------\n",text);
return printedOk;
}

Looking particularly at getting DuplicateReceiptImage

I have been trying the following

lcRef=Sys(1)+Sys(2)
purchaseTx=loBridge.CreateInstance('Verifone.Vault.POSInterface.PurchaseTransaction',lcRef, Cast(15.22 As Currency))
EftResult=objVaultEft.ExecuteTransaction(purchaseTx)
lcRcpTxt=lobridge.getstaticproperty('purchaseTx.TxInfo','DuplicateReceiptImage')

lcRcpTxt above is set to .null.

Thanks

Gravatar is a globally recognized avatar based on your email address. re: Retrieve data via dot net bridge
  Rick Strahl
  Mark Stratton
  May 28, 2018 @ 10:08pm

The value you are trying to retrieve is not a static value. It's a property on an object instance.

lcRef=Sys(1)+Sys(2)

purchaseTx=loBridge.CreateInstance('Verifone.Vault.POSInterface.PurchaseTransaction',lcRef, Cast(15.22 As Currency))
EftResult=objVaultEft.ExecuteTransaction(purchaseTx)

* this might work too although I can't tell what type that is
* purchaseTx.TxInfo.DuplicationReceiptImage
lcRcpTxt=lobridge.GetProperty(purchaseTx,'TxInfo.DuplicateReceiptImage')
Gravatar is a globally recognized avatar based on your email address. re: Retrieve data via dot net bridge
  Mark Stratton
  Rick Strahl
  May 29, 2018 @ 01:44am

Hmm that returns .t. not a string as I thought it would

Gravatar is a globally recognized avatar based on your email address. re: Retrieve data via dot net bridge
  Rick Strahl
  Mark Stratton
  May 29, 2018 @ 11:11am

Check for an error message...

If something fails you should get an exception. However if you have an error handler or try/catch hooked up it might eat the exception. Sounds to me like that's what's happening in your case.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Retrieve data via dot net bridge
  Mark Stratton
  Mark Stratton
  Jun 10, 2018 @ 07:52pm

Thanks for the good responses. I am wondering does the bridge support callbacks (delegates), I am wondering if this is my issue

Gravatar is a globally recognized avatar based on your email address. re: Retrieve data via dot net bridge
  Rick Strahl
  Mark Stratton
  Jun 11, 2018 @ 11:41am

Event support was just added to wwDotnetBridge. It's in the OSS version and will be in the next releases for Web Connection and West Wind Client Tools. This feature was landed by an external contributor (yay!...)

Docs here:

+++ Rick ---

© 1996-2024