#include "FiveWin.Ch"
#include "xbrowse.ch"
#include "adodef.ch" // IMPORTANT
function mysqlimages()
local oCn, oRs, cSql, a
local cPath := "c:\fwh\bitmaps\pngs\"
local cPassWord := <yourpasswordhere>
oCn := FW_OpenAdoConnection( { "MYSQL", "localhost", "FWH", "root", cPassWord } )
if FW_AdoTableExists( "IMAGETEST", oCn )
oCn:Execute( "DROP TABLE IMAGETEST" )
endif
FWAdoCreateTable( "IMAGETEST", ;
{ { "IMGNAME", 'C', 20, 0 }, ;
{ "IMAGE", 'm', 10, 0 } }, ; // small 'm' indicates binary data
oCn )
for each a in Directory( cPath + "*.png" )
cSql := SQL ; // SQL is FWH command
INSERT INTO IMAGETEST ( IMGNAME, IMAGE ) ;
VALUES ( a[ 1 ], MemoRead( cPath + a[ 1 ] ) )
oCn:Execute( cSql )
next
oRs := FW_OpenRecordSet( oCn, "IMAGETEST" )
XBROWSER oRs TITLE "IMAGES IN MYSQL" SETUP ( ;
oBrw:nEditTypes := EDIT_GET, ;
oBrw:lCanPaste := .t. )
oRs:Close()
oCn:Close()
return nil
cArch := cPAth+"\tmp\temporal1.jpg"
IF file(cArch)
nHANDLE := FOpen( cArch )
nBYTES := FSEEK( nHANDLE, 0,2 )
cBUFFER := SPACE(nBYTES+1)
FSeek( nHANDLE, 0, 0 )
nBytesRead := FRead( nHANDLE, @cBuffer, nBytes )
FClose( nHANDLE )
if nBytesRead != nBytes
SAYING := "nBytesRead = "+str(nBYTESREAD)+CHR(10)
SAYING += "nBytes = "+str(nBYTES)+CHR(10)
SAYING += "Error Reading Data"+chr(10)
MsgInfo( saying )
else
oRsBoleta:Fields("temporal1"):AppendChunk( VTArrayWrapper():New( 17, cBUFFER ) )
endif
endif
cBuffer := ""
nBytes := nBytesRead := 0
cArch := cPAth+"\tmp\temporal2.jpg"
IF file(cArch)
nHANDLE := FOpen( cArch )
nBYTES := FSEEK( nHANDLE, 0,2 )
cBUFFER := SPACE(nBYTES+1)
FSeek( nHANDLE, 0, 0 )
nBytesRead := FRead( nHANDLE, @cBuffer, nBytes )
FClose( nHANDLE )
if nBytesRead != nBytes
SAYING := "nBytesRead = "+str(nBYTESREAD)+CHR(10)
SAYING += "nBytes = "+str(nBYTES)+CHR(10)
SAYING += "Error Reading Data"+chr(10)
MsgInfo( saying )
else
oRsBoleta:Fields("temporal2"):AppendChunk( VTArrayWrapper():New( 17, cBUFFER ) )
endif
endif
cBuffer := ""
nBytes := nBytesRead := 0
cArch := cPAth+"\tmp\temporal3.jpg"
IF file(cArch)
nHANDLE := FOpen( cArch )
nBYTES := FSEEK( nHANDLE, 0,2 )
cBUFFER := SPACE(nBYTES+1)
FSeek( nHANDLE, 0, 0 )
nBytesRead := FRead( nHANDLE, @cBuffer, nBytes )
FClose( nHANDLE )
if nBytesRead != nBytes
SAYING := "nBytesRead = "+str(nBYTESREAD)+CHR(10)
SAYING += "nBytes = "+str(nBYTES)+CHR(10)
SAYING += "Error Reading Data"+chr(10)
MsgInfo( saying )
else
oRsBoleta:Fields("temporal3"):AppendChunk( VTArrayWrapper():New( 17, cBUFFER ) )
endif
endif
oRsBoleta:Fields("temporal1"):Value := STRTOHEX( MemoRead( cPAth+"\tmp\temporal1.jpg" ) )
oRsBoleta:Fields("temporal2"):Value := STRTOHEX( MemoRead( cPAth+"\tmp\temporal3.jpg" ) )
PROCEDURE Concesiones_ViewDoc()
LOCAL oWnd, oOcx
LOCAL cFileName, cExtension
IF COND->( Eof() )
MsgAlert( TC( IDS_CONC_EOF_VIEWDOC ) )
RETURN
ENDIF
WaitOn( TC( IDS_VIEW_PREPAREFILE ) )
CursorWait()
cFileName := GetFolderMyTemp() + "\" + RTrim ( COND->NOMBRE )
cExtension := Upper( cFileExt( cFileName ) )
COND->( AdsBlob2File( cFileName , "DOCUMENTO" ) )
WaitOff()
CursorArrow()
//IF !Empty( cExtension ) .and. cExtension $ "PDF_XLS_DOC_XLSX_DOCX_PPT_PPTX_JPG_PNG_BMP"
// ShellExecute( oDlgE:hWnd, "open", cFileName )
//ELSE
IF !IsActiveX( "oixctrl.oixctrl.2" )
MsgStop( TC( IDS_VIEW_NOINSTALLOCX ) )
RETURN
ENDIF
DEFINE WINDOW oWnd TITLE TC( IDS_VIEW_TITLE ) ICON GetIcon()
DEFINE BUTTONBAR OF oWnd 3D SIZE 60, 60 2010
DEFINE BUTTON NAME "TB_SALIR" OF oWnd:oBar ACTION oWnd:END() PROMPT TC( IDS_VIEW_TB1 )
oOcx := TActiveX():New( oWnd, "oixctrl.oixctrl.2" )
oWnd:oClient := oOcx
oWnd:SetSize( 800, 600 )
oOcx:ViewFile( FALSE, cFileName )
ACTIVATE WINDOW oWnd ON INIT oWnd:MAXIMIZE() VALID ( oOcx:Close(), oOcx := NIL, FileDelete( cFileName ), TRUE )
//ENDIF
RETURN
Function cargapdf()
local cFile, xuData, xx
xx:=0
oQry := TDolphinQry():New( "SELECT * FROM polizario order by archivo" )
oQry:GOTOP()
DO WHILE !oQry:EOF()
cFile := oQry:archivo
xuData = D_ReadFile( cFile )
oServer:Insert( "pdf", { "archivo", "documento" }, { GetOnlyName2( cFile ), xuData } )
xx:=xx+1
oQry:skip()
loop
oQry:skip()
ENDDO
Return
FUNCTION GetOnlyName2( cFile )
LOCAL nRat
IF ! Empty( cFile )
nRat = RAt( "\", cFile )
cFile = SubStr( cFile, nRat + 1 )
ENDIF
RETURN cFile
#ifndef __XHARBOUR__
#include "hbcompat.ch"
#endif
FUNCTION CargaPDF()
LOCAL cFile, xuData
oQry := TDolphinQry():New( "SELECT * FROM polizario order by archivo" )
oQry:GOTOP()
DO WHILE !oQry:EOF()
cFile := oQry:archivo
xuData := FileStr( cFile )
oServer:Insert( "pdf", { "archivo", "documento" }, { cFileName( cFile ), HB_Base64Encode( xuData, len( xuData ) ) } )
xuData := NIL
oQry:skip()
IF mod( oQry:Recno(), 10 )==0 //aca modificar el 10 segun tamaño de archivos, la idea es que cada 2 segundos se realize el sysrefresh
SysRefresh()
ENDIF
ENDDO
oQry:end()
RETURN
cFile := HB_Base64Decode( oQry:documento )
StrFile( cFile, oQry:archivo )
C:\Harbour\harb20131007\bin>hbmk2 -find HB_STRTOHEX
Harbour core (installed):
hb_StrToHex()
C:\Harbour\harb20131007\bin>hbmk2 -find HB_BASE64ENCODE
Harbour core (installed):
hb_base64Encode()
//-------------------------------------------------------------------------------//
static function conectar()
local xFile, xuData
LOCAL oErr, lRet := .f.
LOCAL hIni := HB_ReadIni( "conecxion.ini" ) // PARA LEER ARCHIVOS .ini
*LOCAL oServer := NIL
LOCAL cServer := hIni["mysql"]["host"] ,; // NOMBRE DEL HOST (localhost)
cUser := hIni["mysql"]["user"] ,; // NOMBRE DEL USUARIO (root)
cPassword := hIni["mysql"]["psw"] ,; // CLAVE DEL USUARIO (vacio por ahora)
nPort := val(hIni["mysql"]["port"]) ,; // PUERTO DE CONEXION (3306)
cDBName := hIni["mysql"]["dbname"] ,; // NOMBRE DE LA BASE DE DATOS (sisprocom)
nFlags := val(hIni["mysql"]["flags"]) // NUMERO DE FLAG (0)
TRY
oServer = TDolphinSrv():New( cServer, cUser, cPassword, nPort, nFlags, cDBName )
* ?oServer
CATCH oErr
MSGALERT( "ERROR FATAL: No hubo Conexión con el SERVIDOR" + CRLF + CRLF + ;
oErr:Description(), " SISPROCOM - MYSQL" )
oServer:Execute("set session wait_timeout=86400") // 28880
IF oServer:lError
MsgStop('Error al intentar establecer wait_timeout','Error')
oServer:end()
return .f.
ENDIF
oServer:Execute("set session interactive_timeout=28880")
if oServer:lError
MsgStop('Error al intentar establecer interactive_timeout','Error')
oServer:end()
return .f.
ENDIF
oServer:Execute("set session sql_big_selects=1")
if oServer:lError
MsgStop('Error al intentar establecer sql_big_selects=1','Error')
oServer:end()
return .f.
ENDIF
oServer:Execute("set @lower_case_table_names=1")
if oServer:lError
MsgStop('Error al intentar establecer set @lower_case_table_names=1','Error')
oServer:end()
return .f.
ENDIF
oServer:Execute("SET lc_time_names = 'es_ES'")
if oServer:lError
MsgStop("Error al intentar establecer SET lc_time_names = 'es_ES'",'Error')
oServer:end()
return .f.
ENDIF
oServer:Execute("set session max_allowed_packet=16G")
if oServer:lError
MsgStop('Error al intentar establecermax_allowed_packet=16M','Error')
oServer:end()
return .f.
ENDIF
RETURN( lRet )
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 61 guests