PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Is there any way to create this VB structure in Windev?
Is there any way to create this VB structure in Windev?
Iniciado por guest, 28,ago. 2017 21:43 - 11 respuestas
Publicado el 28,agosto 2017 - 21:43
public struct CARD_DATA
{
public byte CardOperationStatus;
public byte CardOperationStatus;
public byte CardStatus;
public byte CardType;
public byte DataType;
public byte EncMPLength;
public byte EncMPStatus;
public byte EncTrack1Length;
public byte EncTrack1Status;
public byte EncTrack2Length;
public byte EncTrack2Status;
public byte EncTrack3Length;
public byte EncTrack3Status;
public byte MSStatus;
public uint reserved;
public byte Track1Length;
public byte Track1Status;
public byte Track2Length;
public byte Track2Status;
public byte Track3Length;
public byte Track3Status;
public string CBCMAC { get; }
public string EncMP { get; }
public string EncTrack1 { get; }
public string EncTrack2 { get; }
public string EncTrack3 { get; }
public string KSN { get; }
public string MPSTS { get; }
public string Track1 { get; }
public string Track2 { get; }
public string Track3 { get; }
public void alloc(int size);
public void clear();
public void free();
public string getExpDate();
public string getFirstName();
public string getLastName();
public string getMiddleName();
public string getPAN();
public string ToSeparatedString(string separator);
public override string ToString();
}


Thanks!
Publicado el 29,agosto 2017 - 08:40
Hi Steve,


The DotNetDelegate() function should make this possible for you.
See http://doc.windev.com/en-US/…

Cheers,

Peter
Publicado el 29,agosto 2017 - 16:11
Quote
Peter Holemans

Hi Steve,





The DotNetDelegate() function should make this possible for you.

See http://doc.windev.com/en-US/…



Cheers,



Peter

I've seen the documentation. The issue is that, at least from my perspective, it's not terribly clear. The examples seem to bounce back and force between procedural and object methods and I'm having a hard time following. Especially as I do no Object based coding.
Publicado el 30,agosto 2017 - 07:36
Hi Steve
I usually wrap .Net assemblies in their own class and do all my calls through it but essentially what you'll need is something like the following
CardRequestCompleted is OnCardRequestCompleteEvent dynamic CardRequestCompleted = DotNetDelegate(MyRequestCompleted,"OnCardRequestCompleteEvent")
You will then need a procedure MyRequestCompleted(CardResult is string) where you can code whatever you need for the result

HTH

David
Publicado el 30,agosto 2017 - 17:05
Quote
David Egan

Hi Steve

I usually wrap .Net assemblies in their own class and do all my calls through it but essentially what you'll need is something like the following


CardRequestCompleted is OnCardRequestCompleteEvent dynamic
CardRequestCompleted = DotNetDelegate(MyRequestCompleted,"OnCardRequestCompleteEvent")


You will then need a procedure MyRequestCompleted(CardResult is string) where you can code whatever you need for the result



HTH



David

Hi David,

Thanks so much. That got me quite a bit further. However, I'm now getting this error on execution.

Error at line 21 of Click BTN_Open_Device process.
DotNetDelegate function called.
Unable to create object (<> assembly)
Unable to open assembly
Error returned by .NET Framework:
Could not load file or assembly 'file:///C:\My Projects20\Tourcube\Exe\Tourcube\' or one of its dependencies. The system cannot find the file specified.

Ideas?

Steve
Publicado el 30,agosto 2017 - 21:11
Hi Steve,

most probably the MagTek dll cannot be found from the path. Maybe you have to copy it into your project exe directory. You may very well need to copy more than one dll. You can Google for ".net dependency analyzer" and find numerous tools which show you the 2nd, 3rd and other required dll's it needs.
Publicado el 30,agosto 2017 - 21:20
Hi Steve
It can't find the assembly at runtime so apart from the obvious (typos etc), it could be where the assembly is located. As Peter mentioned in another thread it seems rather 'flaky' in where it searches for the assembly. If it's not in your executable directory try copying it in there, we've found that's the most reliable.

David
Publicado el 30,agosto 2017 - 22:36
The problem was that I had to install the .NET framework and now the code completes without error.

CardRequestCompleted is OnCardRequestCompleteEvent dynamic
CardRequestCompleted = DotNetDelegate(GP_MyRequestCompleted,"OnCardRequestCompleteEvent")

However, the "GP_MyRequestCompleted" procedure doe not seem to ever get called when I trigger event from device.
Publicado el 31,agosto 2017 - 17:13
Not getting errors but still having issues getting a response back.

Here is what my code looks like. (It is loaded in a button on a form)


// declare object

clMagtek is object MTPPSCRA

// declare delegate

CardRequestCompleted is OnCardRequestCompleteEvent dynamic
CardRequestCompleted = DotNetDelegate(GP_MyRequestCompleted,"OnCardRequestCompleteEvent")

//register delegate

clMagtek.add_onCardRequestComplete(OnCardRequestCompleteEvent)

//open device

sDevice is UNICODE string
nOpen is int=clMagtek.openDevice(sDevice)

// request manual card entry
nStatus is int

clMagtek.requestManualCardData(60,1,31010003,nStatus)

// user enters CC # into device and presses OK button. This should trigger OnCardRequestCompleteEvent


Below is the Procedure that I want the callback to trigger.

PROCEDURE GP_MyRequestCompleted(sString is UNICODE string)

WINTest_Magtek.EDT_NoName1=sString

Any ideas what I'm doing wrong?

Thanks!
Publicado el 31,agosto 2017 - 21:39
Hi Steve,
when I compare your code to the example in the help:
clOwn is OwnEvent
clOwn:add_MyEvent(DotNetDelegate("MyHandler", "EventHandler"))
clOwn:Trigger("Hello")

I see that the dotnetdelegate object resurling from DotNetDelegate function is supposed to be registered on the .net aside (in the example, by the add_myevent method)

in your code, it seems you try to register a class (OnCardRequestCompleteEvent)) instead of the object returned by the function (CardRequestCompleted ):
clMagtek.add_onCardRequestComplete(OnCardRequestCompleteEvent)

I'm NOT a specialist in those things, but that doesn't look right

Best regards
Publicado el 31,agosto 2017 - 21:47
Steve,

shouldn't this line
clMagtek.add_onCardRequestComplete(OnCardRequestCompleteEvent)

be as this
clMagtek.add_onCardRequestComplete(CardRequestCompleted)

So use the created object instead of an event-description (don'nt know a better word atm) ?
Publicado el 31,agosto 2017 - 22:59
Arie and Fabrice,

Bingo! that did it.

Thanks so much!

steve