#include "Xailer.ch" FUNCTION DemoApiDisenador() LOCAL cPlantillaOrigen := "faccli_#02. Facturas a Clientes (DOMINUS).lst" LOCAL cPlantillaDestino := "faccli_00_editada.lbl" LOCAL cPlantillaContenido LOCAL cDir := "faccli" LOCAL hVariables := {=>} LOCAL hJob := {=>} LOCAL hDatosConector := {=>} LOCAL aDetalle := {} LOCAL oEngine LOCAL oConector LOCAL oApi LOCAL lGuardado := .F. IF ! File( cPlantillaOrigen ) MsgStop( "No existe la plantilla: " + cPlantillaOrigen, "LL-Dominus" ) RETURN NIL ENDIF cPlantillaContenido := hb_MemoRead( cPlantillaOrigen ) IF ! HB_ISSTRING( cPlantillaContenido ) .OR. Empty( cPlantillaContenido ) MsgStop( "No se ha podido leer la plantilla.", "LL-Dominus" ) RETURN NIL ENDIF WITH OBJECT oEngine := TLLEngine():New():Create() // Los oMem de Dominus entregan nombres y valores Windows-1252. :SetEncodingWIN() :SetPlantillaContent( cPlantillaContenido ) :OpenJob() IF ! LoadDatosEjemploDominus( cDir, oEngine ) :CloseJob() :End() MsgStop( "No se han podido cargar los datos de ejemplo: " + cDir, "LL-Dominus" ) RETURN NIL ENDIF hJob := :CloseJob() :End() END IF ! HB_ISHASH( hJob ) MsgStop( "El motor no ha devuelto los datos del trabajo.", "LL-Dominus" ) RETURN NIL ENDIF IF hb_HHasKey( hJob, "aRegLine" ) .AND. ; HB_ISARRAY( hJob[ "aRegLine" ] ) .AND. ; Len( hJob[ "aRegLine" ] ) > 0 AAdd( aDetalle, hJob[ "aRegLine" ][ 1 ] ) ENDIF WITH OBJECT oConector := TConectorDatosReg():New():Create() :SendDataVar( hJob[ "aStructVar" ], hJob[ "aRegVar" ] ) :SendDataLine( hJob[ "aStructLine" ], aDetalle ) hDatosConector := :GetData() hVariables := { ; "DataVar" => hb_HClone( hDatosConector[ "DataVar" ] ), ; "DetalleVar" => hb_HClone( hDatosConector[ "DetalleVar" ] ) ; } :End() END WITH OBJECT oApi := TApiDisenadorLLDominus():New( ; "servidorcvs.duckdns.org", ; "/LL-Dominus/public/apiLLDominus.php", ; .T., ; "" ; ):Create() // CloseJob() devuelve estructuras y valores internos UTF-8. :SetEncodingUTF8() IF ! :CrearSesion( cPlantillaContenido, hVariables, cPlantillaOrigen ) MsgStop( :cLastError, "LL-Dominus" ) :End() RETURN NIL ENDIF IF ! :AbrirDisenador() MsgStop( :cLastError, "LL-Dominus" ) :CerrarSesion() :End() RETURN NIL ENDIF DO WHILE ! lGuardado MsgInfo( ; "Edite la plantilla en el navegador y pulse Guardar." + hb_eol() + ; "Despues cierre este mensaje para recuperar el resultado.", ; "LL-Dominus" ; ) lGuardado := :GuardarResultado( cPlantillaDestino ) IF ! lGuardado .AND. ! MsgYesNo( ; :cLastError + hb_eol() + hb_eol() + "Desea volver a intentarlo?", ; "LL-Dominus" ; ) EXIT ENDIF ENDDO IF lGuardado MsgInfo( "Plantilla recibida: " + cPlantillaDestino, "LL-Dominus" ) ENDIF :CerrarSesion() :End() END RETURN NIL