#include "fivewin.ch"
#include "Gif.ch"
Function GifDlgFromRes()
local aAlias := {"MCONTAB","MCONMOV"}
local aIndices := {"INDICE1","INDICE2","INDICE3","INDICE4","INDICE5","INDICE6","INDICE7"}
local n
For n:=1 to len(aAlias)
DBUSEAREA(.T.,, aAlias[n], aAlias[n], .F. )
Next
ReIndx(aAlias, aIndices)
Return nil
//---------------------------------------------------------------------
Function ReIndx(aAlias, aIndices)
local oDlg, oAnimate, oMeter1, oMeter2, oSay1, oSay2, oSay3
local lEnd:=.f.
local n:=0, nMonto1:=0, nMonto2:=0
local nProg,nProg2
DEFINE DIALOG oDlg RESOURCE "CopyFiles" TRANSPARENT COLOR CLR_BLACK, CLR_WHITE ;
TITLE "Creando ficheros indices (Reindexando)"
REDEFINE SAY oSay1 ID 110 OF oDlg
REDEFINE SAY oSay2 ID 120 OF oDlg
REDEFINE SAY oSay3 ID 140 OF oDlg
REDEFINE METEREX oMeter1 VAR nProg ID 130 TOTAL 50 ROUND ; // ROUNDSIZE 6 //;
GRADIENT TRACK { { 1/2, nRGB( 198, 203, 213 ), nRGB( 219, 224, 233 ) },; //fondo
{ 1/2, nRGB( 224, 238, 237 ), nRGB( 224, 238, 237 ) } } ;
LINECOLORS nRGB( 110, 151,204 ), CLR_WHITE //Borde
REDEFINE METEREX oMeter2 VAR nProg2 ID 150 TOTAL 50 ;
GRADIENT CHUNK { { 1/2, nRGB( 255, 251, 229 ), nRGB( 250, 223, 143 ) } , ;
{ 1/2, nRGB( 244, 194, 51 ), nRGB( 252, 235, 173 ) } } ;
GRADIENT TRACK { { 1/2, nRGB( 198, 203, 213 ), nRGB( 219, 224, 233 ) },; //fondo
{ 1/2, nRGB( 224, 238, 237 ), nRGB( 224, 238, 237 ) } } ;
LINECOLORS nRGB( 110, 151,204 ), CLR_WHITE //borde
oMeter2:nTotal = LEN(aIndices)
nTotAvance:=0
nFactorAv:= 100/len(aIndices)
oDlg:bStart := { || oAnimate:=TGif():New( oDlg, ".\avion7.gif", 14,20,64,64,,.t.),;
Reindexa( aAlias, oSay1, oSay2, oSay3, oMeter1, oMeter2, @lEnd, oDlg, oAnimate ) }
ACTIVATE DIALOG oDlg CENTERED
for n:=1 to len(aAlias)
(aAlias[n])->(DBCloseArea())
next
for n:=1 to len(aIndices) // Borramos porque solo es un ejemplo
Ferase( ".\" + aIndices[n] + ".ntx" )
next
SysRefresh()
Return NIL
//---------------------------------------------------------------------------
Function Reindexa( aAlias, oSay1, oSay2, oSay3, oMeter1, oMeter2, lEnd, oDlg, oAnimate )
local n:=0
local nInicia:=Seconds(),nFinaliza:=0
oMeter2:Set( 0 )
For n := 1 to Len( aAlias )
IF ! File( aAlias[ n ]+".dbf" )
MsgInfo( "Fichero no encontrado: " + aAlias[ n ], "Advertencia" )
loop
ELSE
DBSELECTAREA( aAlias[n] )
oSay1:SetText( "Base de Datos Actual: " + upper(aAlias[n]) )
If UPPER( aAlias[n] )="MCONTAB"
IntegIndx( oSay2,oMeter1,oMeter2,oSay3,"mcontab->codicont","INDICE1" )
IntegIndx( oSay2,oMeter1,oMeter2,oSay3,"mcontab->nombre","INDICE2" )
ElseIf UPPER( aAlias[n] )="MCONMOV"
IntegIndx( oSay2,oMeter1,oMeter2,oSay3,"MCONMOV->NUMDOC","INDICE3" )
IntegIndx( oSay2,oMeter1,oMeter2,oSay3,"MCONMOV->CODICONT","INDICE4" )
IntegIndx( oSay2,oMeter1,oMeter2,oSay3,"MCONMOV->FECHEMIS","INDICE5" )
IntegIndx( oSay2,oMeter1,oMeter2,oSay3,"MCONMOV->TD+STR(NUMDOC)","INDICE6" )
IntegIndx( oSay2,oMeter1,oMeter2,oSay3,"MCONMOV->NOMBRE","INDICE7" )
Endif
ENDIF
Next
nFinaliza:= (Seconds()-nInicia)/60
SysRefresh()
oAnimate:Stop()
MsgInfo("Reindexación completada." + " Tiempo (Minutos): "+alltrim(str(nFinaliza)),,2)
oDlg:End()
RETURN NIL
//----------------------------------------------------------------
Function IntegIndx( oSay2,oMeter1,oMeter2,oSay3,Campos,cNombIndice )
local nVar, nStep, nTotal
oSay2:SetText( "Integrando Indice " + cNombIndice )
nTotal := LastRec()
nStep := 1 // Max( Int( nTotal * .02 ), 1 ) // actualizar el meter cada 2% del progreso es mas rapido que por cada registro
nVar := 0
oMeter1:nTotal = nTotal
oMeter1:Set( 0 )
nTotAvance+=1
INDEX ON &(Campos) TO &(cNombIndice);
EVAL {|| oMeter1:Set( nVar += nStep ) , SysRefresh(), .t. } EVERY nStep
oMeter1:Set( nTotal )
oMeter2:Set( nTotAvance )
oSay3:SetText( "Indices creados: "+Transform(nTotAvance,"99,999,999") )
Return nil