Desculpe a demora no tópico, mas como uso MYSQL via WEB linkando diretamento com miha aplicação em xharbour há pelo mesmo 2 anos segue meu código que sincroniza DBF no desktop com base MySql em servidor remoto na WEB.
Código: Selecionar todos
****************************** INICIO DO ARQUIVO *******************************
static v_ins:={}
static oServer, cQuery, oQuery, i
#include "c:\hwgui\include\windows.ch"
#include "c:\hwgui\include\guilib.ch"
#define CRLF Chr(13) + Chr(10)
#define CR Chr(13)
#define LF Chr(10)
procedure sincronismo
private yarq_dbf1,yarq_dbf2,yarq_dbf3
private wTipo:=1,otipo
private oFrm,oBrw
if !pode_usuHWG('SUP','pode_util')
return(NIL)
endif
cod_ctoWEB="21"
desc_ctoWEB="PQU-Ampliacao"
select SINC
set order to 1
set filter to ctoweb=cod_ctoWEB
go top
SetToolTipBalloon(.t.)
// Dialog Principal
INIT DIALOG oFrm TITLE menu[linhaDoMenu,4] CLIPPER FONT retornaFonte("browse") AT 0,0 SIZE 800,600 ICON retornaIcone() STYLE WS_DLGFRAME + WS_SYSMENU + DS_CENTER
// Toolbar
//@ 0,0 TOOLBAR oToolbar1 SIZE 800,30 ID 700
// Browse
@ 05,50 BROWSE oBrw DATABASE OF oFrm SIZE 795,450 STYLE WS_VSCROLL + WS_HSCROLL;
ON CLICK {|o,key| EndDialog()}
oBrw:alias := alias()
ADD COLUMN {|| sinc->usuario } TO oBrw HEADER 'Usuario'
ADD COLUMN {|| sinc->data } TO oBrw HEADER 'Data'
ADD COLUMN {|| sinc->hora } TO oBrw HEADER 'Hora'
ADD COLUMN {|| iif(sinc->etapa1,'Sim','Nao') } TO oBrw HEADER 'Etapa1'
ADD COLUMN {|| sinc->reg_etp1 } TO oBrw HEADER 'Registros'
ADD COLUMN {|| iif(sinc->etapa2,'Sim','Nao') } TO oBrw HEADER 'Etapa2'
ADD COLUMN {|| sinc->reg_etp2 } TO oBrw HEADER 'Registros'
GET RADIOGROUP otipo VAR wtipo
@ 010,20 RADIOBUTTON oradiobutton1 CAPTION "PQU-Ampliacao" SIZE 200,22 STYLE WS_TABSTOP;
ON CLICK {|| sincronismosRealizados()}
@ 210,20 RADIOBUTTON oradiobutton2 CAPTION "PQU-Parada XVI" SIZE 200,22 STYLE WS_TABSTOP;
ON CLICK {|| sincronismosRealizados()}
@ 410,20 RADIOBUTTON oradiobutton2 CAPTION "CST-LTQ" SIZE 200,22 STYLE WS_TABSTOP;
ON CLICK {|| sincronismosRealizados()}
END RADIOGROUP otipo SELECTED wtipo
@ 010,519 BUTTONEX btnConfirma CAPTION "&Confirma" TOOLTIP "Confirma Operação" SIZE 90,32 STYLE WS_TABSTOP;
ON CLICK {|| iif(executaSincronismo(),oFrm:close(),nil)}
@ 110,519 BUTTONEX btnCancela CAPTION "C&ancela" TOOLTIP "Cancela Operação" SIZE 90,32 STYLE WS_TABSTOP;
ON CLICK {|| oFrm:close()}
ADD STATUS oStatus0 TO oFrm PARTS 600,200
oFrm:Activate()
return(nil)
function sincronismosRealizados
do case
case wtipo=1
cod_ctoWEB="21"
desc_ctoWEB="PQU-Ampliacao"
case wtipo=2
cod_ctoWEB="22"
desc_ctoWEB="PQU-Parada XVI"
case wtipo=3
cod_ctoWEB="25"
desc_ctoWEB="CST-LTQ"
endcase
select SINC
set order to 1
set filter to ctoweb=cod_ctoWEB
go top
oBrw:Refresh()
return(nil)
function executaSincronismo
if !VereficaNet()
rot_mensHWG("É preciso estar conectado à internet para realizar esta operação")
return(.f.)
endif
if !yesnoHWG("Este procedimento é executado em duas etapas:"+CRLF+CRLF+"1) Pega os dados que foram cadastrados no Gemain e os copia para o GOP."+CRLF+CRLF+"2) Pega toda a base de dados do GOP já atualizada e copia para o Gemain."+CRLF+CRLF+"Confirma Sincronismo?")
return(.f.)
endif
escreveBStatus(oFrm,"Conectando com o banco de dados")
cHostName= AQUI ENTRA IP DO SEU HOST
cUserName= AQUI ENTRA SEU USUARIO
cPassword= AQUI ENTRA SUA SENHA
oServer:=TMYSQLSERVER():NEW(cHostName,cUserName,cPassword)
if oServer:NETERR()
rot_mensHWG("Falha na conexão com o banco de dados"+CRLF+CRLF+"Erro: "+oServer:ERROR()+CRLF+CRLF+"Possíveis causas: "+CRLF+CRLF+"1) Verifique se está conectado à internet."+CRLF+CRLF+"2) Verifique se o IP de sua máquina tem acesso ao banco de dados Gemain.")
oServer:DESTROY()
return(.f.)
endif
cQuery := 'USE gopec' // base de dados de producao
oQuery := oServer:QUERY(cQuery)
if oQuery:NETERR()
rot_mensHWG("Falha na utilização do banco de dados"+CRLF+CRLF+cQuery+CRLF+ALLTRIM(STR(oQuery:ERRORNO()))+CRLF+oQuery:ERROR())
oQuery:DESTROY()
oServer:DESTROY()
return(.f.)
endif
apagaBStatus(oFrm)
if !bloqueiaContratoWEB(.t.)
oServer:DESTROY()
endif
select SINC
set order to 1
go top
mult_sinc=space(5)
do while !eof()
if cod_sinc>mult_sinc
mult_sinc=cod_sinc
endif
skip
enddo
mult_sinc=STRZERO(VAL(mult_sinc)+1,5)
adiregHWG(0)
replace ctoweb with cod_ctoWEB,;
data with date(),;
hora with time(),;
usuario with usu_inic,;
cod_sinc with mult_sinc
mreg_sinc=recno()
realizouEtapa1=.f.
if yesnoHWG("Etapa 1: Copia dados da WEB para o GOP?")
totalRegistros=0
if !puxaDadosWEB()
oServer:DESTROY()
return(.f.)
endif
realizouEtapa1=.t.
select SINC
go mreg_sinc
replace etapa1 with .t.,;
reg_etp1 with totalRegistros
endif
realizouEtapa2=.f.
if yesnoHWG("Etapa 2: Copia dados do GOP para a WEB?")
totalRegistros=0
if !gravaDadosWEB()
oServer:DESTROY()
return(.f.)
endif
realizouEtapa2=.t.
select SINC
go mreg_sinc
replace etapa2 with .t.,;
reg_etp2 with totalRegistros
endif
if !bloqueiaContratoWEB(.f.)
oServer:DESTROY()
endif
oServer:DESTROY()
avi_repHWG("Sincronismo Finalizado, o histórico abaixo foi gravado para futura consulta."+CRLF+CRLF+iif(realizouEtapa1,"Etapa 1: Realizada com Sucesso","Etapa 1: Não Realizada")+CRLF+CRLF+iif(realizouEtapa2,"Etapa 2: Realizada com Sucesso","Etapa 2: Não Realizada"))
return(.t.)
function bloqueiaContratoWEB
para bloqueia
if bloqueia
escreveBStatus(oFrm,"Bloqueando projeto "+desc_ctoWEB+" no Gemain")
cQuery="update g_contratos set sincronizando='S' where cod_cto="+cod_ctoWEB
else
escreveBStatus(oFrm,"Desbloqueando projeto "+desc_ctoWEB+" no Gemain")
cQuery="update g_contratos set sincronizando='N' where cod_cto="+cod_ctoWEB
endif
oQuery := oServer:QUERY(cQuery)
if oQuery:NETERR()
rot_mensHWG("Falha na gravação da tabela"+CRLF+cQuery+CRLF+ALLTRIM(STR(oQuery:ERRORNO()))+CRLF+oQuery:ERROR())
oQuery:DESTROY()
return(.f.)
endif
apagaBStatus(oFrm)
return(.t.)
function puxaDadosWEB
local temRelatorio:=.f.
escreveBStatus(oFrm,"Recebendo dados de PEDIDOS do Gemain")
cQuery="select cod_obra,cod_pc,dat_web,hor_web,usu_web,cod_sinc from pedidos"+cod_ctoWEB+" where usu_web <> 0"
oQuery := oServer:QUERY(cQuery)
if oQuery:NETERR()
rot_mensHWG("Falha na leitura da tabela"+CRLF+cQuery+CRLF+ALLTRIM(STR(oQuery:ERRORNO()))+CRLF+oQuery:ERROR())
oQuery:DESTROY()
return(.f.)
endif
totalRegistros=oQuery:LASTREC
for i := 1 TO oQuery:LASTREC
mcod_obra = tiraMascara(oQuery:GETROW(i):FIELDGET(1),10)
mcod_af = tiraMascara(oQuery:GETROW(i):FIELDGET(2),10)
mdat_web = oQuery:GETROW(i):FIELDGET(3)
mhor_web = oQuery:GETROW(i):FIELDGET(4)
musu_web = oQuery:GETROW(i):FIELDGET(5)
mcod_sinc = oQuery:GETROW(i):FIELDGET(6)
if empty(mcod_sinc) // coloca 00000 em todos os pedidos que já estavam no Gemain antes do controle de envio do sincronismo
mcod_sinc="00000"
endif
select AF
set order to 1
seek mcod_obra+mcod_af
if !eof()
bloqregHWG(0)
replace dat_web with mdat_web,;
hor_web with mhor_web,;
usu_web with musu_web,;
cod_sinc with mcod_sinc
unlock
endif
GTprocessmessages()
WriteStatus( oFrm,2,transf(i,mascaraNumerica("99999"))+"/"+transf(totalRegistros,mascaraNumerica("99999")))
next i
oQuery:DESTROY()
apagaBStatus(oFrm)
escreveBStatus(oFrm,"Recebendo dados de INSUMOS do Gemain")
cQuery="select cod_obra,cod_pc,insumo,item,cronograma,diligencia,data1,data2,data3,data4,data5,data6,obs1,obs2,obs3,obs4,obs5,status,forma_ent from insumos"+cod_ctoWEB+" where usuweb <> 0"
oQuery := oServer:QUERY(cQuery)
if oQuery:NETERR()
rot_mensHWG("Falha na leitura da tabela"+CRLF+cQuery+CRLF+ALLTRIM(STR(oQuery:ERRORNO()))+CRLF+oQuery:ERROR())
oQuery:DESTROY()
return(.f.)
endif
totalRegistros=oQuery:LASTREC
for i := 1 TO oQuery:LASTREC
mcod_obra = tiraMascara(oQuery:GETROW(i):FIELDGET(1),10)
mcod_af = tiraMascara(oQuery:GETROW(i):FIELDGET(2),10)
mcod_ins = tiraMascara(oQuery:GETROW(i):FIELDGET(3),7)
mitem = tiraMascara(oQuery:GETROW(i):FIELDGET(4),18)
mdat_cron = oQuery:GETROW(i):FIELDGET(5)
mdat_dili = oQuery:GETROW(i):FIELDGET(6)
mdata1 = oQuery:GETROW(i):FIELDGET(7)
mdata2 = oQuery:GETROW(i):FIELDGET(8)
mdata3 = oQuery:GETROW(i):FIELDGET(9)
mdata4 = oQuery:GETROW(i):FIELDGET(10)
mdata5 = oQuery:GETROW(i):FIELDGET(11)
mdata6 = oQuery:GETROW(i):FIELDGET(12)
mobs1 = oQuery:GETROW(i):FIELDGET(13)
mobs2 = oQuery:GETROW(i):FIELDGET(14)
mobs3 = oQuery:GETROW(i):FIELDGET(15)
mobs4 = oQuery:GETROW(i):FIELDGET(16)
mobs5 = oQuery:GETROW(i):FIELDGET(17)
mstatus = oQuery:GETROW(i):FIELDGET(18)
mforma_ent= oQuery:GETROW(i):FIELDGET(19)
select INS_AF
set order to 1
seek mcod_obra+mcod_af+mcod_ins+mitem
if !eof()
bloqregHWG(0)
replace status with mstatus,;
forma_ent with mforma_ent,;
dat_cron with mdat_cron,;
dat_dili with mdat_dili,;
data1 with mdata1,;
data2 with mdata2,;
data3 with mdata3,;
data4 with mdata4,;
data5 with mdata5,;
data6 with mdata6
unlock
select OBSSUP
set order to 1
seek mcod_obra+mcod_af+mcod_ins+mitem
if !eof()
bloqregHWG(0)
else
adiregHWG(0)
replace cod_obra with mcod_obra,;
cod_af with mcod_af,;
cod_ins with mcod_ins,;
item with mitem
endif
replace obs1 with mobs1,;
obs2 with mobs2,;
obs3 with mobs3,;
obs4 with mobs4,;
obs5 with mobs5
unlock
else
if !temRelatorio
temRelatorio=.t.
utimp(2,'SINCRONISMO GEMAIN')
sai = .f.
pag = 0
mlin=1
endif
if mlin=1
Cab(92,"Sincronimo Gemain - "+desc_ctoWEB)
@ mlin,000 say "Budget"
@ mlin,021 say "PC"
@ mlin,042 say "Insumo"
@ mlin,053 say "Item"
@ mlin,074 say "Ocorrencia"
endif
@ mlin,000 say oQuery:GETROW(i):FIELDGET(1)
@ mlin,021 say oQuery:GETROW(i):FIELDGET(2)
@ mlin,042 say oQuery:GETROW(i):FIELDGET(3)
@ mlin,053 say oQuery:GETROW(i):FIELDGET(4)
@ mlin,074 say "Inexistente no GOP"
mlin++
if mlin>i_mlin
mlin=1
endif
endif
GTprocessmessages()
WriteStatus( oFrm,2,transf(i,mascaraNumerica("99999"))+"/"+transf(totalRegistros,mascaraNumerica("99999")))
next i
oQuery:DESTROY()
apagaBStatus(oFrm)
if temRelatorio
sailist()
endif
return(.t.)
function tiraMascara
para codigo,tamanho
codigo=strtran(codigo,'.','')
codigo=strtran(codigo,'-','')
codigo=strtran(codigo,'/','')
codigo=strtran(codigo,' ','')
codigo=alltrim(codigo)
codigo=codigo+space(tamanho-len(codigo))
return(codigo)
procedure geraDBFWEB
escreveBStatus(oFrm,"Gerando Arquivos Locais")
select select('TMP')
use
v_est:={}
aadd(v_est,{'COD_OBRA','C',20,0})
aadd(v_est,{'COD_PC','C',20,0})
aadd(v_est,{'PEDIDO','C',12,0})
aadd(v_est,{'INSUMO','C',10,0})
aadd(v_est,{'DESC1','C',60,0})
aadd(v_est,{'DESC2','C',60,0})
aadd(v_est,{'ITEM','C',30,0})
aadd(v_est,{'UNID','C',4,0})
aadd(v_est,{'QTDE','N',19,2})
aadd(v_est,{'SALDO','N',19,2})
aadd(v_est,{'STATUS','C',15,0})
aadd(v_est,{'FORMA_ENT','C',1,0})
aadd(v_est,{'PREVISTA','D',8,0})
aadd(v_est,{'ENTREGA','D',8,0})
aadd(v_est,{'CRONOGRAMA','D',8,0})
aadd(v_est,{'DILIGENCIA','D',8,0})
aadd(v_est,{'DATA1','D',8,0})
aadd(v_est,{'DATA2','D',8,0})
aadd(v_est,{'DATA3','D',8,0})
aadd(v_est,{'DATA4','D',8,0})
aadd(v_est,{'DATA5','D',8,0})
aadd(v_est,{'DATA6','D',8,0})
aadd(v_est,{'OBS1','C',72,0})
aadd(v_est,{'OBS2','C',72,0})
aadd(v_est,{'OBS3','C',72,0})
aadd(v_est,{'OBS4','C',72,0})
aadd(v_est,{'OBS5','C',72,0})
aadd(v_est,{'USUWEB','N',5,0}) // para gravar no gemain quem alterou o material
yarq_dbf1=diz_dbf()
cria_dbf(yarq_dbf1)
select select('TMP')
use (yarq_dbf1) via "dbfcdx" exclusive new alias tmp
select select('TMP2')
use
v_est:={}
aadd(v_est,{'COD_OBRA','C',20,0})
aadd(v_est,{'COD_PC','C',20,0})
aadd(v_est,{'COD_FOR','C',5,0})
aadd(v_est,{'NOME_FOR','C',40,0})
aadd(v_est,{'PEDIDO','C',12,0})
aadd(v_est,{'DAT_WEB','D',8,0}) // data que o pedido foi alterado na WEB
aadd(v_est,{'HOR_WEB','C',8,0}) // hora que o pedido foi alterado na WEB
aadd(v_est,{'USU_WEB','N',5,0}) // quem alterou o pedido na WEB = USUWEB de pedidos
aadd(v_est,{'CAB_DATA1','C',10,0})
aadd(v_est,{'CAB_DATA2','C',10,0})
aadd(v_est,{'CAB_DATA3','C',10,0})
aadd(v_est,{'CAB_DATA4','C',10,0})
aadd(v_est,{'CAB_DATA5','C',10,0})
aadd(v_est,{'CAB_DATA6','C',10,0})
aadd(v_est,{'COD_SINC','C',5,0})
yarq_dbf2=diz_dbf()
cria_dbf(yarq_dbf2)
select select('TMP2')
use (yarq_dbf2) via "dbfcdx" exclusive new alias tmp2
mconta=0
select AF
set order to 1
go top
do while !eof()
o_orig=cod_obra
select OBRAS
set order to 1
seek o_orig
if !eof() .and. model_af="I"
mask_item="@R "+strtran(alltrim(OBRAS->masc_item),'.',' ')
select AF
mcod_af = cod_af
mnum_ped=num_ped
mcod_for=cod_for
mitem = item
mdat_web=dat_web
mhor_web=hor_web
musu_web=usu_web
mcod_sinc=cod_sinc
if empty(mcod_sinc)
mcod_sinc=mult_sinc
endif
select FORNECED
set order to 1
seek mcod_for
mnome_for=nome
select AF
v_cabUso:=cabecalhoDatas(o_orig,mcod_af)
v_ins:={}
select INS_AF
set order to 1
seek o_orig+mcod_af
do while !eof() .and. cod_obra+cod_af=o_orig+mcod_af
mcod_ins=cod_ins
mitem=item
mqual_uni=qual_uni
mqtd =qtd
mstatus=status
mforma_ent=forma_ent
if substr(mcod_ins,1,1)='D'
munidade=space(4)
mdesc1 ='Despesas Gerais Relativas ao Item '+transf(mitem,mask_item)
mdesc2 =space(1)
else
select INSUMOS
set order to 1
seek mcod_ins
munidade=iif(mqual_uni='1',unidade,unidade2)
mdesc1=desc1
mdesc2=desc2
endif
mentregue=0
mdat_ent=ctod("")
v_dat:={}
select INS_AP
set order to 2
seek o_orig+mcod_af+mcod_ins+mitem
do while !eof() .and. cod_obra+cod_af+cod_ins+item=o_orig+mcod_af+mcod_ins+mitem
mentregue+=qtd
aadd(v_dat,{INS_AP->dat_ent})
skip
enddo
if len(v_dat) # 0
asort(v_dat,,,{|elem1,elem2| elem1[1]<elem2[1]})
mdat_ent=v_dat[len(v_dat),1]
endif
msaldo=mqtd-mentregue
if trunca2(msaldo,2) # 0
aadd(v_ins,{mcod_ins,mitem,mdesc1,mdesc2,mqtd,munidade,msaldo,mstatus,mforma_ent,INS_AF->dat_prev,mdat_ent,INS_AF->dat_cron,INS_AF->dat_dili,INS_AF->data1,INS_AF->data2,INS_AF->data3,INS_AF->data4,INS_AF->data5,INS_AF->data6})
endif
select INS_AF
skip
enddo
if len(v_ins) # 0
select TMP2
append blank
replace cod_obra with transf(o_orig,mask_obr),;
cod_pc with transf(mcod_af,mask_pc),;
cod_for with mcod_for,;
nome_for with mnome_for,;
pedido with mnum_ped,;
dat_web with mdat_web,;
hor_web with mhor_web,;
usu_web with musu_web,;
cod_sinc with mcod_sinc
for x=1 to len(v_cabUSO)
ad1=alltrim(str(v_cabUSO[x,2]))
replace cab_data&ad1 with v_cabUSO[x,1]
next
for x=1 to len(v_ins)
v_cabUso:=cabecalhoDatas(o_orig,mcod_af)
v_obs:={}
select OBSSUP
set order to 1
seek o_orig+mcod_af+v_ins[x,1]+v_ins[x,2]
if !eof()
for y=1 to 5
ad1=alltrim(str(y))
aadd(v_obs,{obs&ad1})
next
endif
select TMP
append blank
mconta++
replace cod_obra with transf(o_orig,mask_obr),;
cod_pc with transf(mcod_af,mask_pc),;
pedido with mnum_ped,;
insumo with transf(v_ins[x,1],masc_ins),;
item with transf(v_ins[x,2],mask_item),;
desc1 with v_ins[x,3],;
desc2 with v_ins[x,4],;
unid with v_ins[x,6],;
qtde with v_ins[x,5],;
saldo with v_ins[x,7],;
status with v_ins[x,8],;
forma_ent with v_ins[x,9],;
prevista with v_ins[x,10],;
entrega with v_ins[x,11],;
cronograma with v_ins[x,12],;
diligencia with v_ins[x,13],;
data1 with v_ins[x,14],;
data2 with v_ins[x,15],;
data3 with v_ins[x,16],;
data4 with v_ins[x,17],;
data5 with v_ins[x,18],;
data6 with v_ins[x,19]
for y=1 to len(v_obs)
ad1=alltrim(str(y))
replace obs&ad1 with v_obs[y,1]
next
next
endif
endif
select AF
skip
enddo
apagaBStatus(oFrm)
return
function gravaDadosWEB
geraDBFWEB()
escreveBStatus(oFrm,"Enviando dados de SINCRONISMO para o Gemain")
select SINC
set order to 1
set filter to ctoWEB=cod_ctoWEB .and. !empty(cod_sinc)
if !dbf2Mysql("sinc"+cod_ctoWEB,.t.)
return(.f.)
endif
select SINC
set filter to
apagaBStatus(oFrm)
escreveBStatus(oFrm,"Enviando dados de PEDIDOS para o Gemain")
select TMP2
if !dbf2Mysql("pedidos"+cod_ctoWEB,.t.)
return(.f.)
endif
apagaBStatus(oFrm)
escreveBStatus(oFrm,"Enviando dados de INSUMOS para o Gemain")
select TMP
if !dbf2Mysql("insumos"+cod_ctoWEB,.t.)
return(.f.)
endif
apagaBStatus(oFrm)
return(.t.)
function dbf2Mysql
parameters cTable,lCreateTable
local cTok, nTok := 1
local aDbfStruct, i
local oTable, oRecord
aDbfStruct := dbStruct()
if lCreateTable
if Ascan(oServer:ListTables(), cTable) > 0
oServer:DeleteTable(cTable)
if oServer:NetErr()
rot_mensHWG(oServer:Error())
return(.f.)
endif
endif
oServer:CreateTable(cTable, aDbfStruct)
if oServer:NetErr()
rot_mensHWG(oServer:Error())
return(.f.)
endif
endif
oTable := oServer:Query("SELECT * FROM " + cTable + " LIMIT 1")
if oTable:NetErr()
rot_mensHWG(oTable:Error())
return(.f.)
endif
totalRegistros=reccount()
go top
registrosIncluidos=0
do while !eof()
oRecord := oTable:GetBlankRow()
for i := 1 to FCount()
oRecord:FieldPut(i, FieldGet(i))
next
oTable:Append(oRecord)
if oTable:NetErr()
rot_mensHWG(oTable:Error())
return(.f.)
endif
dbSkip()
registrosIncluidos++
WriteStatus( oFrm,2,transf(registrosIncluidos,mascaraNumerica("99999"))+"/"+transf(totalRegistros,mascaraNumerica("99999")))
GTprocessmessages()
#ifdef DESENV
if registrosIncluidos>20
exit
endif
#endif
enddo
oTable:Destroy()
return(.t.)
Function VereficaNet( cAddress )
LOCAL aHosts
LOCAL cName
InetInit()
IF cAddress == NIL
cAddress := "www.google.com.br"
ENDIF
aHosts := InetGetHosts( cAddress )
IF aHosts == NIL .or. len(aHosts)=0
InetCleanup()
RETURN .f.
endif
InetCleanup()
RETURN .t.
function cabecalhoDatas
para cBudget,cPC
local y,v_cabBudget:={},v_cabPC:={},v_cabUso:={},usaBudget
select OBRAS
set order to 1
seek cBudget
aadd(v_cabBudget,{OBRAS->cab_data1})
aadd(v_cabBudget,{OBRAS->cab_data2})
aadd(v_cabBudget,{OBRAS->cab_data3})
aadd(v_cabBudget,{OBRAS->cab_data4})
aadd(v_cabBudget,{OBRAS->cab_data5})
aadd(v_cabBudget,{OBRAS->cab_data6})
seek cPc
aadd(v_cabPC,{OBRAS->cab_data1})
aadd(v_cabPC,{OBRAS->cab_data2})
aadd(v_cabPC,{OBRAS->cab_data3})
aadd(v_cabPC,{OBRAS->cab_data4})
aadd(v_cabPC,{OBRAS->cab_data5})
aadd(v_cabPC,{OBRAS->cab_data6})
usaBudget=.t.
for y=1 to len(v_cabPC)
if !empty(v_cabPC[y,1])
usaBudget=.f.
exit
endif
next
if usaBudget
for y=1 to len(v_cabBudget)
if !empty(v_cabBudget[y,1])
aadd(v_cabUSO,{v_cabBudget[y,1],y})
endif
next
else
for y=1 to len(v_cabPC)
if !empty(v_cabPC[y,1])
aadd(v_cabUSO,{v_cabPC[y,1],y})
endif
next
endif
return(v_cabUSO)
****************************** FIM DO ARQUIVO *********************************