Classe OOP Webservice RestSend
Exemplo de como Trabalhar com Webservice do tipo Restfull com ResSend( )
Mais um material de apoio para quem esta se aventurando e fazendo integrações além dos webservices SOAP agora exemplos REST e pode ser facilmente integrada e adaptada em seus sistemas.
Classe OOP desenvolvida com o apoio do Willian
ST_parametros_header is structure
s_nome_parametro is string
s_valor_parametro is string
END
ST_retorno_json_token is structure
access_token is string
token_type is string
expires_in is string
END
ST_retorno_json_pedidos_abertos is structure
DocNum is int
DocEntry is int
CardCode is string
CardName is string
END
ST_retorno_json_descargas_abertas is structure
DocNum is int
DocEntry is int
CardCode is string
CardName is string
END
ST_retorno_json_consulta_descargas is structure
DocNum is int
DocEntry is int
CardCode is string
CardName is string
END
ST_retorno_json_bip is structure
Lote is string
DocEntry is int
Quantidade is int
Fabricacao is string
Validade is string
END
ST_retorno_json_itens_pedido_venda is structure
ItemCode is string
Dscription is string
Total is real
Bipado is real
Falta is real
END
ST_retorno_json_itens_descarga is structure
ItemCode is string
Dscription is string
Total is real
Bipado is real
Falta is real
END
ST_retorno_json_itens_lote_pedido_venda is structure
ItemCode is string
ItemName is string
ExpDate is string
MnfDate is string
Lote is string
Quantidade is real
BaseLinNum is int
DocEntry is int
END
ST_json_lote is structure
Lote is string
END
ST_retorno_consulta_lote is structure
WhsCode is string
Posicao is string
END
ST_json_iten_bip is structure
Lote is string
DocEntry is int
Quantidade is int
ItemCode is string
END
ST_LoginSapParametros is structure
Login is string
Senha is string
FIN
ClassAPIWeb is a Class
m_arr_st_descargas_em_aberto is array of ST_retorno_json_descargas_abertas
m_arr_st_itens_descarga is array of ST_retorno_json_itens_descarga
m_arr_st_pedidos_em_aberto is array of ST_retorno_json_pedidos_abertos
m_arr_st_itens_pedido_venda is array of ST_retorno_json_itens_pedido_venda
m_arr_st_itens_lote_pedido_venda is array of ST_retorno_json_itens_lote_pedido_venda
PRIVATE
m_arr_st_consulta_lote is array of ST_retorno_consulta_lote
m_s_lote is string
m_st_token is ST_retorno_json_token
m_s_token is string
m_s_url_token is string = "/Token"
ms_s_url_loginsap is string = "/api/Generic/LoginSAP"
m_s_url_descargas is string = "/api/Generic/ConsultaDescarga/"
m_s_url_itens_descarga is string = "/api/Generic/ConsultaItensDescarga/"
m_s_url_bip is string = "/api/Generic/DescargaBIP"
m_s_url_finalizar_descarga_doca is string = "/api/Generic/FinalizaDescarga/"
m_s_url_pedidos_em_aberto is string = "/api/Generic/ConsultaPedidosEmAberto/"
m_s_url_itens_pedido_venda is string = "/api/Generic/ConsultaItensPedidoDeVenda/"
m_s_url_itens_lote_pedido_venda is string = "/api/Generic/ConsultaItensLotePedidoDeVenda/"
m_s_url_pedido_venda_bip is string = "/api/Generic/PedidoDeVendaBIP"
m_s_url_finalizar_pedido_Aberto is string = "/api/Generic/FinalizaPedidoEmAberto/"
m_s_url_ConsultaLote is string = "/api/Generic/ConsultaLote"
m_s_ultimo_erro is string
m_s_resultado_request is string
END
Procedure BipDescargaDoca(st_item is ST_retorno_json_bip)
WHEN EXCEPTION IN
tempo_ocioso = 0
url is string = gs_Urlprincipal + m_s_url_bip
arr_header is array of 2 ST_parametros_header
arr_header[1].s_nome_parametro = "Authorization"
arr_header[1].s_valor_parametro = "Bearer "+gsToken
arr_header[2].s_nome_parametro = "Content-Type"
arr_header[2].s_valor_parametro = "application/json"
s_json is string
Serialize(st_item,s_json,psdJSON)
IF not :HttpExecutaRequest(url,
s_json,
True,
arr_header,False,"application/json") THEN
RESULT False
ELSE
IF m_s_resultado_request = "" OR gbResultOK = True
RESULT True
ELSE
RESULT False
END
END
DO
m_s_ultimo_erro = ExceptionInfo(errFullDetails)
END
Procedure BipFinalizarDescargaDoca(DocEntry is string)
WHEN EXCEPTION IN
tempo_ocioso = 0
url is string = gs_Urlprincipal + m_s_url_finalizar_descarga_doca + DocEntry
arr_header is array of 2 ST_parametros_header
arr_header[1].s_nome_parametro = "Authorization"
arr_header[1].s_valor_parametro = "Bearer "+ gsToken
arr_header[2].s_nome_parametro = "Content-Type"
arr_header[2].s_valor_parametro = "application/json"
IF not :HttpExecutaRequest(url,
DocEntry,
False,
arr_header) THEN
RESULT False
ELSE
IF m_s_resultado_request = "" OR gbResultOK = True
RESULT True
ELSE
RESULT False
END
END
DO
m_s_ultimo_erro = ExceptionInfo(errFullDetails)
END
Procedure BipFinalizarPedidoEmAberto(DocEntry is string)
WHEN EXCEPTION IN
tempo_ocioso = 0
url is string = gs_Urlprincipal + m_s_url_finalizar_pedido_Aberto + DocEntry
arr_header is array of 2 ST_parametros_header
arr_header[1].s_nome_parametro = "Authorization"
arr_header[1].s_valor_parametro = "Bearer "+ gsToken
arr_header[2].s_nome_parametro = "Content-Type"
arr_header[2].s_valor_parametro = "application/json"
IF not :HttpExecutaRequest(url,
DocEntry,
False,
arr_header) THEN
RESULT False
ELSE
IF m_s_resultado_request = "" OR gbResultOK = True
RESULT True
ELSE
RESULT False
END
END
DO
m_s_ultimo_erro = ExceptionInfo(errFullDetails)
END
Procedure BipObterPosicaoLote(s_numero_lote is string)
WHEN EXCEPTION IN
tempo_ocioso = 0
url is string = gs_Urlprincipal + m_s_url_ConsultaLote
arr_header is array of 2 ST_parametros_header
arr_header[1].s_nome_parametro = "Authorization"
arr_header[1].s_valor_parametro = "Bearer "+gsToken
arr_header[2].s_nome_parametro = "Content-Type"
arr_header[2].s_valor_parametro = "application/json"
s_json is string
st_param_lote is ST_json_lote
st_param_lote.Lote = s_numero_lote
Serialize(st_param_lote,s_json,psdJSON)
IF not :HttpExecutaRequest(url,
s_json,
True,
arr_header,False,"application/json") THEN
RESULT False
ELSE
lst_json_retorno is ST_retorno_consulta_lote
Deserialize(lst_json_retorno,:m_s_resultado_request,psdJSON)
gsPosicao = lst_json_retorno.Posicao
gsWhsCode = lst_json_retorno.WhsCode
RESULT True
END
DO
m_s_ultimo_erro = ExceptionInfo(errFullDetails)
END
Procedure BipPedidoDeVenda(st_iten_bip is ST_json_iten_bip)
WHEN EXCEPTION IN
tempo_ocioso = 0
url is string = gs_Urlprincipal + m_s_url_pedido_venda_bip
arr_header is array of 2 ST_parametros_header
arr_header[1].s_nome_parametro = "Authorization"
arr_header[1].s_valor_parametro = "Bearer "+gsToken
arr_header[2].s_nome_parametro = "Content-Type"
arr_header[2].s_valor_parametro = "application/json"
s_json is string
Serialize(st_iten_bip,s_json,psdJSON)
IF not :HttpExecutaRequest(url,
s_json,
True,
arr_header,False,"application/json") THEN
RESULT False
ELSE
IF m_s_resultado_request = "" OR gbResultOK = True
RESULT True
ELSE
RESULT False
END
END
DO
m_s_ultimo_erro = ExceptionInfo(errFullDetails)
RESULT False
END
Procedure consultaDescargasAbertas(sUserCode)
WHEN EXCEPTION IN
tempo_ocioso = 0
url is string = ""
url = gs_Urlprincipal + m_s_url_descargas + sUserCode
arr_header is array of 2 ST_parametros_header
arr_header[1].s_nome_parametro = "Authorization"
arr_header[1].s_valor_parametro = "Bearer "+gsToken
arr_header[2].s_nome_parametro = "Content-Type"
arr_header[2].s_valor_parametro = "application/json"
IF not :HttpExecutaRequest(url,
sUserCode,
False,
arr_header) THEN
RESULT False
ELSE
Deserialize(m_arr_st_descargas_em_aberto, :m_s_resultado_request, psdJSON)
RESULT True
END
DO
m_s_ultimo_erro = ExceptionInfo(errFullDetails)
RESULT False
END
Procedure consultaDescargasItens(s_nro_documento is string)
WHEN EXCEPTION IN
tempo_ocioso = 0
url is string = gs_Urlprincipal + m_s_url_itens_descarga + s_nro_documento
arr_header is array of 2 ST_parametros_header
arr_header[1].s_nome_parametro = "Authorization"
arr_header[1].s_valor_parametro = "Bearer "+gsToken
arr_header[2].s_nome_parametro = "Content-Type"
arr_header[2].s_valor_parametro = "application/json"
IF not :HttpExecutaRequest(url,
s_nro_documento,
False,
arr_header) THEN
RESULT False
ELSE
Deserialize(m_arr_st_itens_descarga,:m_s_resultado_request,psdJSON)
RESULT True
END
DO
m_s_ultimo_erro = ExceptionInfo(errFullDetails)
RESULT False
END
Procedure ConsultaPedidosEmAberto(sUserCode)
WHEN EXCEPTION IN
tempo_ocioso = 0
url is string = ""
url = gs_Urlprincipal + m_s_url_pedidos_em_aberto + sUserCode
arr_header is array of 2 ST_parametros_header
arr_header[1].s_nome_parametro = "Authorization"
arr_header[1].s_valor_parametro = "Bearer "+gsToken
arr_header[2].s_nome_parametro = "Content-Type"
arr_header[2].s_valor_parametro = "application/json"
IF not :HttpExecutaRequest(url,
sUserCode,
False,
arr_header) THEN
RESULT False
ELSE
Deserialize(m_arr_st_pedidos_em_aberto,:m_s_resultado_request,psdJSON)
RESULT True
END
DO
m_s_ultimo_erro = ExceptionInfo(errFullDetails)
RESULT False
END
Procedure consultaPedidosItensVenda(s_nro_documento is string)
WHEN EXCEPTION IN
tempo_ocioso = 0
url is string = gs_Urlprincipal + m_s_url_itens_pedido_venda + s_nro_documento
arr_header is array of 2 ST_parametros_header
arr_header[1].s_nome_parametro = "Authorization"
arr_header[1].s_valor_parametro = "Bearer "+gsToken
arr_header[2].s_nome_parametro = "Content-Type"
arr_header[2].s_valor_parametro = "application/json"
IF not :HttpExecutaRequest(url,
s_nro_documento,
False,
arr_header) THEN
RESULT False
ELSE
Deserialize(m_arr_st_itens_pedido_venda,:m_s_resultado_request,psdJSON)
RESULT True
END
DO
m_s_ultimo_erro = ExceptionInfo(errFullDetails)
RESULT False
END
Procedure consultaPedidosLoteItensVenda(s_nro_documento is string)
WHEN EXCEPTION IN
tempo_ocioso = 0
url is string = gs_Urlprincipal + m_s_url_itens_lote_pedido_venda + s_nro_documento
arr_header is array of 2 ST_parametros_header
arr_header[1].s_nome_parametro = "Authorization"
arr_header[1].s_valor_parametro = "Bearer "+gsToken
arr_header[2].s_nome_parametro = "Content-Type"
arr_header[2].s_valor_parametro = "application/json"
IF not :HttpExecutaRequest(url,
s_nro_documento,
False,
arr_header) THEN
RESULT False
ELSE
Deserialize(m_arr_st_itens_lote_pedido_venda, :m_s_resultado_request, psdJSON)
RESULT True
END
DO
m_s_ultimo_erro = ExceptionInfo(errFullDetails)
RESULT False
END
Procedure getUltimoErro()
tempo_ocioso = 0
s_erro is string
s_erro = m_s_ultimo_erro
m_s_ultimo_erro = ""
RESULT s_erro
Procedure LoginObterToken(s_usuario is string, s_senha is string)
WHEN EXCEPTION IN
tempo_ocioso = 0
s_resultado is string
url is string = gs_Urlprincipal + m_s_url_token
s_parametros is string
s_parametros = "grant_type=%1&password=%2&username=%3"
s_parametros = StringBuild(s_parametros,"password",s_senha,s_usuario)
arr_header is array of ST_parametros_header
IF not :HttpExecutaRequest(url,
s_parametros,
True,
arr_header) THEN
ToastAffiche("Erro ao obter o Token")
RESULT False
ELSE
lst_json_retorno is ST_retorno_js
Deserialize(lst_json_retorno,:m_s_resultado_request,psdJSON)
gsToken = lst_json_retorno.access_token
gsTokenDataHora = lst_json_retorno.expires_in
s_resultado = lst_json_retorno.access_token
ToastAffiche("Token OK")
RESULT s_resultado
END
DO
ToastAffiche("Erro ao obter o Token")
m_s_ultimo_erro = ExceptionInfo(errFullDetails)
RESULT False
END
Procedure LoginSAP(s_usuario is string, s_senha is string)
WHEN EXCEPTION IN
tempo_ocioso = 0
url is string = gs_Urlprincipal + ms_s_url_loginsap
st_parametros_login is ST_LoginSapParametros
st_parametros_login.Login = s_usuario
st_parametros_login.Senha = s_senha
s_parametros is string
Sérialise(st_parametros_login,s_parametros,psdJSON)
arr_header is array of 2 ST_parametros_header
arr_header[1].s_nome_parametro = "Authorization"
arr_header[1].s_valor_parametro = "Bearer "+gsToken
arr_header[2].s_nome_parametro = "Content-Type"
arr_header[2].s_valor_parametro = "application/json"
IF not :HttpExecutaRequest(url,
s_parametros,
True,
arr_header,False,"application/json") THEN
ToastAffiche("Erro ao obter o Acesso")
RESULT False
ELSE
IF NoSpace(:m_s_resultado_request) = "true" THEN
ToastAffiche("Login no SAP OK")
RESULT True
END
ToastAffiche("Erro ao obter o Acesso")
RESULT False
END
DO
ToastAffiche("Erro ao obter o Acesso")
m_s_ultimo_erro = ExceptionInfo(errFullDetails)
RESULT False
END
Procedure PRIVATE HttpExecutaRequest(s_url is string,
s_parametros is string,
b_via_post is boolean,
arr_header_parametros is array of ST_parametros_header,
b_codificar_parametros is boolean = True,
s_content_type is string = "")
WHEN EXCEPTION IN
tempo_ocioso = 0
HourGlass(True)
cMyRequest is restRequest
cMyResponse is restResponse
cMyRequest..URL = s_url
IF Length(s_parametros) > 0 THEN
IF b_codificar_parametros THEN
cMyRequest..Content = URLEncode(s_parametros)
ELSE
cMyRequest..Content = s_parametros
END
END
IF s_content_type <> "" THEN
cMyRequest..ContentType = s_content_type
END
IF b_via_post = True THEN
cMyRequest..Method = httpPost
ELSE
cMyRequest..Method = httpGet
END
IF ArrayCount(arr_header_parametros) > 0 THEN
FOR EACH st_parametro OF arr_header_parametros
cMyRequest.Header[st_parametro.s_nome_parametro] = st_parametro.s_valor_parametro
END
END
gbResultOK = False
cMyResponse = RESTSend ( cMyRequest )
IF ErrorOccurred OR PositionOccurrence(cMyResponse..Content,"DOCTYPE html PUBLIC",firstRank,DepuisDébut) > 0
m_s_ultimo_erro = s_url+s_parametros +" "+ ErrorInfo(errFullDetails)
RESULT False
ELSE
:m_s_resultado_request = cMyResponse..Content
gbResultOK = HTTPRequête(gs_Urlprincipal)
HourGlass(False)
RESULT True
END
DO
HourGlass(False)
RESULT False
END
x is int = 0
gb_ocioso is boolean = False
tempo_ocioso is int = 0
gsToken is string = ""
gsTokenDataHora is string = ""
gsLote is string = ""
gsPosicao is string = ""
gsWhsCode is string = ""
gbResultOK is boolean = False
ST_retorno_js is structure
access_token is string
sToken_type is string
expires_in is string
END
st_ConsultaDescargas is structure
DocNum is int
DocEntry is int
CardCode is string
CardName is string
END
st_ItensDescarga is structure
ItemCode is string
Bipado is string
Dscription is string
Falta is int
Total is int
END
ST_retorno_pedidos_abertos is structure
DocNum is int
DocEntry is int
CardCode is string
CardName is string
END
st_ItensPedidoVenda is structure
ItemCode is string
Dscription is string
Falta is int
Total is int
Bipado is string
END
ItensLotePedidoVenda is structure
ItemCode is string
ItemName is string
BaseLinNum is string
DocEntry is string
ExpDate is string
Lote is string
MnfDate is string
Quantidade is string
END
gs_Urlprincipal is string = BuscaConfigValor("Url:Porta")
IF gs_Urlprincipal = "" THEN
gs_Urlprincipal = "http://192.168.10.200:8089"
GravaConfigValor("Url:Porta","http://192.168.10.200:8089")
ELSE
gs_Urlprincipal = NoSpace(gs_Urlprincipal)
END
Procedure BuscaConfigStatus(Descricao)
tempo_ocioso = 0
bStatus is boolean
IF Descricao <> "" THEN
HReset(t000_config)
IF HReadSeek(t000_config,t000_descricao,Descricao,hIdentical) = True THEN
IF HFound(t000_config) = True
bStatus = t000_config.t000_status
END
ELSE
t000_config.t000_descricao = Descricao
HAdd(t000_config)
END
END
RESULT(bStatus)
Procedure BuscaConfigValor(Descricao)
tempo_ocioso = 0
sValor is string
IF Descricao <> "" THEN
HReset(t000_config)
IF HReadSeek(t000_config,t000_descricao,Descricao,hIdentical) = True THEN
IF HFound(t000_config) = True
sValor = t000_config.t000_valor
END
ELSE
t000_config.t000_descricao = Descricao
HAdd(t000_config)
END
END
RESULT(sValor)
Procedure BuscaValorJson(JsonBuffer, TagIni, TagFin)
tempo_ocioso = 0
PosIni, PosFin is int = 0
Resultado is string = ""
IF JsonBuffer <> "" AND TagIni <> "" AND TagFin <> ""
PosIni = PositionOccurrence(JsonBuffer,TagIni,firstRank,IgnoreCase) + Length(TagIni)
PosFin = PositionOccurrence(JsonBuffer,TagFin,firstRank,IgnoreCase)
IF PosFin <= PosIni THEN
PosFin = PositionOccurrence(JsonBuffer,TagFin,nextRank,IgnoreCase)
END
IF (PosFin-PosIni) > 0
Resultado = Middle(JsonBuffer,PosIni,PosFin-PosIni)
END
ELSE
Resultado = ""
END
RESULT(Resultado)
Procedure ExemploLoginToken(Username string, Password string)
tempo_ocioso = 0
bufResultado is Buffer = ""
s_parametros is string
s_parametros = "grant_type=%1&password=%2&username=%3"
s_parametros = URLEncode(StringBuild(s_parametros,"password",Password,Username))
IF httpRequest(gs_Urlprincipal+"/Token","","",s_parametros) THEN
bufResultado = HTTPGetResult()
ELSE
Error(ErrorInfo())
END
ArrResultado is array of string
IF bufResultado <> "" THEN
bufResultado = Replace(bufResultado,Charact(34),"")
access_token is string = BuscaValorJson(bufResultado,"access_token:",",token_type:")
token_type is string = BuscaValorJson(bufResultado,"token_type:",",expires_in:")
expires_in is string = BuscaValorJson(bufResultado,"expires_in:",",.issued:")
issued is string = BuscaValorJson(bufResultado,".issued:",",.expires:")
expires is string = BuscaValorJson(bufResultado,".expires:","}")
Add(ArrResultado,access_token)
Add(ArrResultado,token_type)
Add(ArrResultado,expires_in)
Add(ArrResultado,issued)
Add(ArrResultado,expires)
t030_logs.t030_access_token = access_token
t030_logs.t030_datahora = token_type
t030_logs.t030_metodo = "Login"
t030_logs.t030_parametros = Username +"; "+ Password
HAdd(t030_logs)
gsToken = access_token
ELSE
gsToken = ""
END
RESULT(ArrResultado)
Procedure GravaConfigValor(Descricao, Valor)
tempo_ocioso = 0
ok is boolean
IF Descricao <> "" THEN
IF HReadSeek(t000_config,t000_descricao,Descricao,hIdentical) = True THEN
IF HFound(t000_config) = True
t000_config.t000_valor = Valor
t000_config.t000_status = True
ok = HModify(t000_config)
END
ELSE
t000_config.t000_descricao = Descricao
t000_config.t000_valor = Valor
t000_config.t000_status = True
ok = HAdd(t000_config)
END
END
RESULT(ok)
Procedure GravaConfigValorStatus(Descricao,Valor,Status boolean)
tempo_ocioso = 0
ok is boolean
IF Descricao <> "" THEN
IF HReadSeek(t000_config,t000_descricao,Descricao,hIdentical) = True THEN
IF HFound(t000_config) = True
t000_config.t000_valor = Valor
t000_config.t000_status = Status
ok = HModify(t000_config)
END
ELSE
t000_config.t000_descricao = Descricao
t000_config.t000_valor = Valor
t000_config.t000_status = True
ok = HAdd(t000_config)
END
END
RESULT(ok)
Procedure VerificaWebservice(WebserviceURL, nTimeOut)
tempo_ocioso = 0
ok is boolean = False
PosicaoOK is int = 0
HttpRetorno is string
IF WebserviceURL = ""
WebserviceURL = "http://www.google.com.br"
END
IF nTimeOut = 0 OR nTimeOut = "" THEN
nTimeOut = 3000
END
HTTPTimeOut(nTimeOut)
IF httpRequest(WebserviceURL) = True THEN
HttpRetorno = HTTPGetResult(httpHeader)
PosicaoOK = PositionOccurrence(HttpRetorno,"Connection",firstRank,IgnoreCase)
IF PosicaoOK = 0 THEN
PosicaoOK = PositionOccurrence(Upper(HttpRetorno),"200",firstRank,IgnoreCase)
IF PosicaoOK = 0 THEN
PosicaoOK = PositionOccurrence(Upper(HttpRetorno),"OK",firstRank,IgnoreCase)
END
END
IF WebserviceURL <> "" AND PosicaoOK > 0 AND HttpRetorno <> "" THEN
ok = True
ELSE
ok = False
END
ELSE
ok = False
END
RESULT(ok)
Procedure WS_X_ClasseApiDownload(sUsername is string)
HourGlass(True)
tempo_ocioso = 0
HDeleteAll(t024_ItemDescarga)
HDeleteAll(t023_ItemDescargaBIP)
HDeleteAll(t022_DescargaAberta)
ContadorA, nContadorB, ContadorC, ContadorD, nContadorE are int = 0
nContadorB = 0
ContadorD = 0
gnDocEntryDescarga, gnDocnumDescarga, gnDocEntryPedido, sGnDocnumPedido is string = ""
cl_ws is ClassAPIWeb
IF InternetConnecté() = True AND VerificaWebservice(gs_Urlprincipal,120000) = True
ToastDisplay("Aguarde... atualizando dados!...",toastLong,cvMilieu,chCentre)
tempo_ocioso = 0
ContadorA = 0
IF cl_ws.consultaDescargasAbertas(sUsername) THEN
FOR EACH st_ConsultaDescargas OF cl_ws.m_arr_st_descargas_em_aberto
ContadorA += 1
gnDocEntryDescarga = st_ConsultaDescargas.DocEntry
gnDocnumDescarga = st_ConsultaDescargas.DocNum
IF Length(st_ConsultaDescargas.DocEntry) < 3
t022_DescargaAberta.t022_DocEntry = NumToString(st_ConsultaDescargas.DocEntry,"03D")
ELSE
t022_DescargaAberta.t022_DocEntry = st_ConsultaDescargas.DocEntry
END
IF Length(st_ConsultaDescargas.DocNum) < 3
t022_DescargaAberta.t022_DocNum = NumToString(st_ConsultaDescargas.DocNum,"03D")
ELSE
t022_DescargaAberta.t022_DocNum = st_ConsultaDescargas.DocNum
END
t022_DescargaAberta.t022_CardCode = st_ConsultaDescargas.CardCode
t022_DescargaAberta.t022_CardName = Upper(st_ConsultaDescargas.CardName)
t022_DescargaAberta.t022_Status = "Aberto"
HAdd(t022_DescargaAberta)
tempo_ocioso = 0
Multitask(1)
Trace(gnDocEntryDescarga +" "+ TimeSys())
END
ELSE
ToastAffiche("Erros nas Descargas Abertas: "+cl_ws.getUltimoErro())
END
tempo_ocioso = 0
ContadorC = 0
HDeleteAll(t028_ItemLotePedidoDeVenda)
HDeleteAll(t027_ItemPedidoBIP)
HDeleteAll(t026_ItemPedidoDeVenda)
HDeleteAll(t025_PedidosAbertos)
IF cl_ws.ConsultaPedidosEmAberto(sUsername) THEN
FOR EACH st_pedidosEmAberto OF cl_ws.m_arr_st_pedidos_em_aberto
ContadorC += 1
gnDocEntryPedido = st_pedidosEmAberto.DocEntry
sGnDocnumPedido = st_pedidosEmAberto.DocNum
IF Length(st_pedidosEmAberto.DocEntry) < 3
t025_PedidosAbertos.t025_DocEntry = NumToString(st_pedidosEmAberto.DocEntry,"03D")
ELSE
t025_PedidosAbertos.t025_DocEntry = st_pedidosEmAberto.DocEntry
END
IF Length(st_pedidosEmAberto.DocNum) < 3
t025_PedidosAbertos.t025_DocNum = NumToString(st_pedidosEmAberto.DocNum,"03D")
ELSE
t025_PedidosAbertos.t025_DocNum = st_pedidosEmAberto.DocNum
END
t025_PedidosAbertos.t025_CardCode = st_pedidosEmAberto.CardCode
t025_PedidosAbertos.t025_CardNome = Upper(st_pedidosEmAberto.CardName)
t025_PedidosAbertos.t025_Status = "Aberto"
HAdd(t025_PedidosAbertos)
tempo_ocioso = 0
Multitask(1)
Trace(gnDocEntryPedido +" "+ TimeSys())
END
ELSE
HourGlass(False)
ToastAffiche("Erro Consultas em Aberto: "+cl_ws.getUltimoErro())
END
HourGlass(False)
ToastDisplay("Sucesso ao atualizar os dados!...",toastLong,cvMilieu,chCentre)
ELSE
HourGlass(False)
Error("Erro de acesso a internet ou ao webservice")
END
HourGlass(False)
ToastAffiche("Total de Descargas: "+ ContadorA +", Total de Pedidos: "+ ContadorC)
tempo_ocioso = 0
FONTE:
http://repository.windev.com/publish.awp…
http://repository.windev.com/publish.awp?file_id=281474976710676;classe-oop-webservice-restsend
Muito obrigado pelo apoio Willian Fernando Padilha
Bons Estudos a todos!
--
Adriano José Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 99949 1800
adrianoboller@gmail.com
skype: adrianoboller
http://wxinformatica.com.br/Message modifié, 11 février 2018 - 22:04