Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
514 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#Include "Protheus.ch" | ||
#Include "TopConn.ch" | ||
|
||
#DEFINE MAXMENLIN 080 // Máximo de caracteres por linha de dados adicionais - deixar igual o do fonte danfeii.prw | ||
|
||
//1 - Criar uma Fórmula (SM4), com u_zComplMsg() | ||
//2 - Colocar o código dessa fórmula no campo C5_MENPAD | ||
|
||
User Function zComplMsg() | ||
Local aArea := GetArea() | ||
Local aAreaSD2 := SD2->(GetArea()) | ||
Local aAreaSF2 := SF2->(GetArea()) | ||
Local aAreaSC5 := SC5->(GetArea()) | ||
Local aAreaSC6 := SC6->(GetArea()) | ||
Local aAreaSA1 := SA1->(GetArea()) | ||
Local aAreaSB1 := SB1->(GetArea()) | ||
Local aAreaSA3 := SA3->(GetArea()) | ||
Local aAreaSF4 := SF4->(GetArea()) | ||
Local cMens := "" | ||
Local cAux := "" | ||
|
||
cAux := "Beluguinha, Belugão... Acesse Terminal de Informação (https://terminaldeinformacao.com)" | ||
cMens += fLinhaDanfe(cAux) | ||
|
||
RestArea(aAreaSD2) | ||
RestArea(aAreaSF2) | ||
RestArea(aAreaSC5) | ||
RestArea(aAreaSC6) | ||
RestArea(aAreaSA1) | ||
RestArea(aAreaSB1) | ||
RestArea(aAreaSA3) | ||
RestArea(aAreaSF4) | ||
RestArea(aArea) | ||
Return cMens | ||
|
||
Static Function fLinhaDanfe(cLinhaTexto) | ||
Local cLinhaTrans:="" | ||
|
||
//Se houver texto | ||
If !Empty(cLinhaTexto) | ||
//Enquanto o tamnho for maior que o máximo da linha, vai quebrando | ||
While Len(cLinhaTexto) > MAXMENLIN | ||
cLinhaTrans += Substr(cLinhaTexto, 1, MAXMENLIN) | ||
cLinhaTexto := Substr(cLinhaTexto, MAXMENLIN + 1, Len(cLinhaTexto) - MAXMENLIN) | ||
EndDo | ||
|
||
//Se restou texto, incrementa | ||
If cLinhaText != "" | ||
cLinhaTrans += PadR(cLinhaTexto, MAXMENLIN) | ||
EndIf | ||
EndIf | ||
|
||
Return cLinhaTrans |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//Bibliotecas | ||
#Include "Protheus.ch" | ||
|
||
/*/{Protheus.doc} zGeraB9 | ||
Função que gera saldo inicial | ||
@author Daniel Atilio | ||
@since 16/02/2015 | ||
@version 1.0 | ||
@param cCodProd, Caracter, Código do Produto | ||
@param cArmazem, Caracter, Código do Armazém | ||
@param nQuant, Numérico, Quantidade do saldo inicial | ||
@example | ||
u_zGeraB9("00000001", "01", 3000) | ||
/*/ | ||
User Function zGeraB9(cCodProd, cArmazem, nQuant) | ||
Local aArea := GetArea() | ||
DbSelectArea("SB9") | ||
DbSetOrder(1) //B9_FILIAL+B9_COD+B9_LOCAL+DTOS(B9_DATA) | ||
//Setando valores da rotina automática | ||
lMsErroAuto := .F. | ||
aVetor :={; | ||
{"B9_FILIAL" ,cFilAnt ,Nil},; | ||
{"B9_COD" ,cCodProd ,Nil},; | ||
{"B9_LOCAL" ,cArmazem ,Nil},; | ||
{"B9_DATA" ,dDataBase ,Nil},; | ||
{"B9_QINI" ,nQuant ,Nil}} | ||
//Iniciando transação e executando saldos iniciais | ||
Begin Transaction | ||
MSExecAuto({|x,y| Mata220(x,y)}, aVetor) | ||
//Se houve erro, mostra mensagem | ||
If lMsErroAuto | ||
lHouveErro := .T. | ||
MostraErro() | ||
DisarmTransaction() | ||
EndIf | ||
End Transaction | ||
RestArea(aArea) | ||
Return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
//Bibliotecas | ||
#Include "Protheus.ch" | ||
|
||
/*/{Protheus.doc} zLog2Excel | ||
Função que converte um arquivo gerado com IXBLOG em uma planilha para análise | ||
@author Atilio | ||
@since 29/08/2018 | ||
@version 1.0 | ||
@param cArquivo, characters, Caminho do arquivo a ser analisado | ||
@type function | ||
@sample u_zLog2Excel("C:\spool\administrador_461090.txt") | ||
/*/ | ||
User Function zLog2Excel(cArquivo) | ||
Local aArea := GetArea() | ||
Default cArquivo := "" | ||
//Se tiver conteúdo e o arquivo existir, chama o processamento | ||
If ! Empty(cArquivo) .And. File(cArquivo) | ||
Processa({|| fProcessa(cArquivo)}, "Processando") | ||
EndIf | ||
RestArea(aArea) | ||
Return | ||
/*---------------------------------------------------------------------* | ||
| Func: fProcessa | | ||
| Desc: Função que processa o arquivo e gera um arquivo do Excel | | ||
*---------------------------------------------------------------------*/ | ||
Static Function fProcessa(cArquivo) | ||
Local aArea := GetArea() | ||
Local oFile | ||
Local aLinhas := {} | ||
Local nAtual := 0 | ||
Local cLinAtu := "" | ||
Local aExport := {} | ||
Local nPosSeq := 1 //Sequencia | ||
Local nPosDe := 2 //From | ||
Local nPosExe := 3 //ExecBlock | ||
Local nPosIn := 4 //Time In | ||
Local nPosOut := 5 //Time Out | ||
Local nPosDif := 6 //Diferença de Tempo | ||
Local oFWMsExcel | ||
Local oExcel | ||
Local cArqExport := GetTempPath()+'zLog2Excel_'+dToS(Date())+'_'+StrTran(Time(), ':', '-')+'.xml' | ||
Local cWorkSheet := "Log" | ||
Local cTable := "" | ||
//Definindo o arquivo a ser lido | ||
oFile := FWFileReader():New(cArquivo) | ||
//Se o arquivo pode ser aberto | ||
If (oFile:Open()) | ||
//Se não for fim do arquivo | ||
If ! (oFile:EoF()) | ||
//Definindo o tamanho da régua | ||
aLinhas := oFile:GetAllLines() | ||
ProcRegua(Len(aLinhas)) | ||
//Método GoTop não funciona, deve fechar e abrir novamente o arquivo | ||
oFile:Close() | ||
oFile := FWFileReader():New(cArquivo) | ||
oFile:Open() | ||
//Enquanto houver linhas a serem lidas | ||
While (oFile:HasLine()) | ||
//Incrementando a régua | ||
nAtual++ | ||
IncProc("Analisando linha " + cValToChar(nAtual) + " de " + cValToChar(Len(aLinhas)) + "...") | ||
//Buscando o texto da linha atual | ||
cLinAtu := oFile:GetLine() | ||
//Se o trecho contém IXBLOG TYPE, é uma nova linha | ||
If Upper("IXBLOG Type") $ Upper(cLinAtu) | ||
aAdd(aExport, {; | ||
0,; //Sequencia | ||
"",; //From | ||
"",; //ExecBlock | ||
"",; //Time In | ||
"",; //Time Out | ||
""; //Diferença de Tempo | ||
}) | ||
//Define o tamanho da linha | ||
aExport[Len(aExport)][nPosSeq] := Len(aExport) | ||
//Atualiza tempo de entrada | ||
ElseIf Upper("Time In") $ Upper(cLinAtu) | ||
aExport[Len(aExport)][nPosIn] := Alltrim(SubStr(cLinAtu, At(':', cLinAtu) + 1, Len(cLinAtu))) | ||
//Atualiza tempo de saída | ||
ElseIf Upper("Time Out") $ Upper(cLinAtu) | ||
aExport[Len(aExport)][nPosOut] := Alltrim(SubStr(cLinAtu, At(':', cLinAtu) + 1, Len(cLinAtu))) | ||
//Atualiza a função chamadora | ||
ElseIf Upper("ExecBlock") $ Upper(cLinAtu) | ||
aExport[Len(aExport)][nPosExe] := Alltrim(SubStr(cLinAtu, At(':', cLinAtu) + 1, Len(cLinAtu))) | ||
//Atualiza a origem | ||
ElseIf Upper("From") $ Upper(cLinAtu) | ||
aExport[Len(aExport)][nPosDe] := Alltrim(SubStr(cLinAtu, At(':', cLinAtu) + 1, Len(cLinAtu))) | ||
EndIf | ||
EndDo | ||
//Se tiver dados a serem gerados | ||
If Len(aExport) > 0 | ||
//Agora percorre os dados, e atualiza a diferença de tempo | ||
ProcRegua(Len(aExport)) | ||
For nAtual := 1 To Len(aExport) | ||
IncProc("Atualizando totais - " + cValToChar(nAtual) + " de " + cValToChar(Len(aLinhas)) + "...") | ||
aExport[nAtual][nPosDif] := ElapTime(aExport[nAtual][nPosIn], aExport[nAtual][nPosOut]) | ||
Next | ||
ProcRegua(0) | ||
IncProc("Gerando o arquivo...") | ||
//Cria a planilha do excel | ||
oFWMsExcel := FWMSExcel():New() | ||
oFWMsExcel:AddworkSheet(cWorkSheet) | ||
oFWMsExcel:AddTable(cWorkSheet, cTable) | ||
//Adiciona as colunas | ||
oFWMsExcel:AddColumn(cWorkSheet, cTable, "Sequência", 1, 1) | ||
oFWMsExcel:AddColumn(cWorkSheet, cTable, "Origem (From)", 1, 1) | ||
oFWMsExcel:AddColumn(cWorkSheet, cTable, "Função (ExecBlock)", 1, 1) | ||
oFWMsExcel:AddColumn(cWorkSheet, cTable, "Tempo Inicial", 1, 1) | ||
oFWMsExcel:AddColumn(cWorkSheet, cTable, "Tempo Final", 1, 1) | ||
oFWMsExcel:AddColumn(cWorkSheet, cTable, "Diferença de Tempo", 1, 1) | ||
//Adiciona todas as linhas no arquivo | ||
For nAtual := 1 To Len(aExport) | ||
oFWMsExcel:AddRow(cWorkSheet, cTable, aExport[nAtual]) | ||
Next | ||
//Ativando o arquivo e gerando o xml | ||
oFWMsExcel:Activate() | ||
oFWMsExcel:GetXMLFile(cArqExport) | ||
//Abrindo o excel e abrindo o arquivo xml | ||
oExcel := MsExcel():New() | ||
oExcel:WorkBooks:Open(cArqExport) | ||
oExcel:SetVisible(.T.) | ||
oExcel:Destroy() | ||
EndIf | ||
EndIf | ||
//Fecha o arquivo e finaliza o processamento | ||
oFile:Close() | ||
EndIf | ||
RestArea(aArea) | ||
Return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//Bibliotecas | ||
#Include "Protheus.ch" | ||
|
||
/*/{Protheus.doc} zNameFile | ||
Função que serve para retirar caracteres especiais para nome de arquivos | ||
@author Atilio | ||
@since 10/08/2018 | ||
@version 1.0 | ||
@param cString, characters, Nome do arquivo que será recomposto | ||
@type function | ||
@example //... | ||
cCaminho := "C:\spool\" | ||
cArquivo := SA1->A1_NREDUZ + ".txt" //Teste | Cliente: 01.txt | ||
cCamFull := cCaminho + u_zNameFile(cArquivo) //Resultado será: C:\spool\Teste Cliente 01.txt | ||
//... | ||
@obs A função foi baseada no Windows, onde ao renomear um arquivo, não pode ser usado \ / : * ? " < > | | ||
/*/ | ||
User Function zNameFile(cString) | ||
Local aArea := GetArea() | ||
Local cStringNov := "" | ||
Local aSubstit := {} | ||
Local nAtual := 0 | ||
Default cString := "" | ||
//Se houver dados | ||
If ! Empty(cString) | ||
//Adiciona caracteres que serão retirados | ||
aAdd(aSubstit, '\') | ||
aAdd(aSubstit, '/') | ||
aAdd(aSubstit, ':') | ||
aAdd(aSubstit, '*') | ||
aAdd(aSubstit, '?') | ||
aAdd(aSubstit, '"') | ||
aAdd(aSubstit, '<') | ||
aAdd(aSubstit, '>') | ||
aAdd(aSubstit, '|') | ||
//Pega o conteúdo original e joga na nova variável | ||
cStringNov := cString | ||
//Percorre os dados | ||
For nAtual := 1 To Len(aSubstit) | ||
cStringNov := StrTran(cStringNov, aSubstit[nAtual], "") | ||
Next | ||
EndIf | ||
RestArea(aArea) | ||
Return cStringNov |
Oops, something went wrong.