Help to transform Byte[] value to something 4gl friendly

Posted by OctavioOlguin on 16-Feb-2017 19:50

Greetings to all...

I have reduced the fingerprint code to the following piece of code, that does all the needed stuff.

Just have one caveat... I'm transformiing this to a class that will be callled from .net as 4gl code aswell, but now i'm in the last step, want to pop out the value I got from scanner to be managed out side of the scanner realm...

METHOD PRIVATE VOID btnStart_Click( INPUT sender AS System.Object, INPUT e AS System.EventArgs ):
        DEFINE VARIABLE ufs_res           AS UFS_STATUS NO-UNDO.
        DEFINE VARIABLE Scanner           AS UFScanner  NO-UNDO.              
        DEFINE VARIABLE EnrollQuality     AS INTEGER    NO-UNDO.
              
        
        //ufs_res = scannerManager:Init() .     it was initie'd in other place.
        Scanner = scannerManager:Scanners[0].
        
        IF Scanner <> ? THEN
        DO:
            ASSIGN            
                Scanner:nTemplateType = 2003.            
            
            Scanner:ClearCaptureImageBuffer().
            ufs_res = Scanner:CaptureSingleImage().
            
            IF STRING(ufs_res) <> STRING(UFS_STATUS:OK) THEN 
            DO:
                ASSIGN 
                    Resultado = "No se pudo leer ".
                ufs_res = scannerManager:Uninit() .
                RETURN.
            END.
            
            Template = NEW "System.Byte[]" (max_template_size).
            ufs_res = Scanner:Extract(Template,TemplateSize, EnrollQuality).
            
            IF  STRING(UFS_STATUS:OK) <> "OK" THEN 
                ASSIGN 
                    resultado = "Lectura incorrecta".
                        
            IF EnrollQuality < 40 THEN 
                ASSIGN 
                    resultado = "Repita la lectura de la huella".
        END. 
        ELSE
            ASSIGN 
                resultado = msgError(ufs_res:value__).
                
        MESSAGE STRING(template)
            VIEW-AS ALERT-BOX.
            
        ufs_res = scannerManager:Uninit() .
        
        RETURN.

    END METHOD.

My problem is the:  

MESSAGE STRING(template)
VIEW-AS ALERT-BOX.

I put that to see what type of data is sending the scanner, so I can handle properly, and do the matching of persons on my payroll database...  How could it be transformd to a native datatype?

My intention is to eliminate all visual of this class... and pop the identifier of the person out, so wil be handled outside the class...

All Replies

Posted by Mike Fechner on 17-Feb-2017 00:38

Which kind of data is stored in the Byte[]?
 
 
For binary data use something like this. And you can use ABL methods to deal with MEMPTR or COPY-LOB it to a BLOB field.
 
 
    /**
     * Purpose: Converts a .NET Byte[] to an ABL MEMPTR
     * Notes:
     * @param poBytes The System.Byte[] to convert to a MEMPTR
     * @return The new MEMPTR with the data from the Byte[]
     */
    METHOD PUBLIC STATIC MEMPTR ByteArrayToMemptr (poBytes AS "System.Byte[]":U):
 
        DEFINE VARIABLE memptr      AS MEMPTR        NO-UNDO .
        DEFINE VARIABLE oIntPointer AS System.IntPtr NO-UNDO .
 
        SET-SIZE (memptr) = poBytes:Length .
 
        oIntPointer = NEW System.IntPtr (GET-POINTER-VALUE (memptr)).
 
        System.Runtime.InteropServices.Marshal:Copy (poBytes, 0, oIntPointer, poBytes:Length).
 
        RETURN memptr .
 
        FINALLY:
            DELETE OBJECT oIntPointer.
        END FINALLY.
 
    END METHOD .
 
 

Posted by OctavioOlguin on 17-Feb-2017 08:34

Thanks a ton!!!!

As allways, deep insight....

This thread is closed