Hello Guys
I am working with DojoUploader on an RUI.
I need to work with this plugin, in the background .. that is, the idea is to pass the uploadUrl, and automatically it uploads the files from this folder and I capture it in FileInfo.
Has anyone done this? to run DojoUploader in the background?
myFileInfo FileInfo [] = [];
uploader1 DojoUploader {
showInput = Dojolib.INPUT_NONE
, layoutData = new GridLayoutData {row = 2, column = 1, horizontalSpan = 1}
, text = "Upload Multiple Files"
, uploadOnSelect = true
//, multiple = true
//, uploadUrl = "/ updserver / spldesd1 / trash / XML3 /"
, onComplete :: = uploader1Complete
, onError :: = upError
, onBegin :: = uploader1Begin
, onProgress :: = uploader1Progress
};
------------------------------
Osvaldo Jose de Oliveira Menezes
Analista
RellegusTI
Orlândia
+55 11 96565-6368
------------------------------
____________________________________________________________________________________________________________________________________________
Hello colleagues, experts !!! ..
Based on the tip from our colleague Nick, I solved the challenge as follows:
1) I created a class in native java (see code1)
a) This code only searches the file-system for a list of files and puts it in memory, returning the method signature;
2) I have a dedicated service (see code2), which communicates with my RUI web app
a) I used the external type to access the native java.
b) I trigger the native java method to fetch the list of files
c) Process this list of files as needed
3) WEB App - RUI
a) I stopped using DojoUploader
b) I used the JOB Scheduler to trigger the dedicated service from time to time
c) Returning from the service I update my DataGrid.
Thank you very much Nick
code1
package br.com.morlan.rui.common.db.external;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
public class geraListaArquivos {
private static final String MY_CLASS_CONST = "geraListaArquivos_v01.00";
static int LogLevel = 0;
static int LogWrite = 0; //1 - alterado em 06/09/2019
static String codRetorno = "0";
static String myMensagem = "";
public static ArrayList<String> visualizaListaArquivos(final String aDiretorio,
int aLogLevel
) {
LogLevel = aLogLevel;
final String MY_METODO = ".visualizaListaArquivos";
DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 1, " BEGIN ");
DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 9, " ARGs "
+ " aFileArg=" + aDiretorio
+ " aLogLevel=" + aLogLevel
);
ArrayList<String> retornoFuncao = new ArrayList<String>();
try {
File file = new File(aDiretorio);
File afile[] = file.listFiles();
int i = 0;
DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 9, " qtde arquivos "
+ afile.length
);
for (int j = afile.length; i < j; i++) {
File arquivos = afile[i];
retornoFuncao.add(arquivos.getName());
// DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 9, " files "
// + arquivos.getName() + "\n" );
}
// DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 9, " DESCARREGANDO A retornoFuncao ");
// for (int i = 0; i < retornoFuncao.size(); i++) {
// DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 9, " retornoFuncao(i) =" + i + " = " + retornoFuncao.get(i) );
// }
} catch (Exception e) {
myMensagem = (" 1036 - visualizaListaArquivos exception " + e.toString());
DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 2, myMensagem);
return montaRetorno("1036",((MY_CLASS_CONST + MY_METODO + myMensagem)),"" );
}
DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 1, " END ");
return retornoFuncao; // montaRetorno("0","","");
}
private static String getCurrentTimeStamp() {
final String MY_METODO = ".getCurrentTimeStamp ";
DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 1, " BEGIN ");
/*
* Returns a string with the current date and time yyyy-MM-dd_HH-mm-ss
* suitable to compose a fileid
*/
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
Date now = new Date();
String strDate = sdfDate.format(now);
DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 1, " END ");
return strDate;
}
//@BEGIN montaRetorno
static private ArrayList<String> montaRetorno(String aCodigoError, String aMensagem, String aResult) {
final String MY_METODO = ".montaRetorno ";
DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 1, " BEGIN ");
ArrayList<String> result = new ArrayList<String>();
result.add("#01CodigoError:"+aCodigoError);
result.add("#02Mensagem:"+aMensagem);
result.add("#03Resultado:"+aResult);
// DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 9, " aCodigoError" + aCodigoError
// + " aMensagem=" + aMensagem
// + " aResult=" + aResult
// );
DisplayLog(MY_CLASS_CONST, MY_METODO, LogLevel, 1, " END ");
return result;
}
//@END montaRetorno
/*
* -- @DisplayLog - exibir erro de log nos metodos
* -- Niveis de Log: 0-sem log / 1-apenas log da classe-app / 2-apenas log error fatal -abend / 9-todas mensagens
* --
* -- aLogLevel = Nivel de log recebido pelo usuario, o qual deseja ver
* -- aLogLevelMsg = Nivel de log classificado pela mensagem
*/
static private void DisplayLog(String aClasse, String aMetodo, Integer aLogLevel, Integer aLogLevelMsg, String aMsg) {
String aMsgError = "";
if (aLogLevelMsg == 2) // error fatal
{
aMsgError = (aClasse + aMetodo + ".##FATAL_ERROR " + aMsg);
}
if (aLogLevel > 0) {
if (aLogLevelMsg <= aLogLevel) {
aMsgError = (aClasse + aMetodo + aMsg);
}
}
if (LogWrite > 0) {
try {
WriteFileLog(aMsgError);
} catch (IOException e) {
System.out.printf(e.toString());
e.printStackTrace();
}
}
else {
if (aMsgError != "") {
System.out.printf(aMsgError );
}
}
}
static private void WriteFileLog(String aMsg) throws IOException {
// logFS.write(aMsg.getBytes());
System.out.printf(aMsg);
}
}
code2
service ConverterXmlNfeToEgl
const SERVICE_CONST string = "ConverterXmlNfeToEgl";
const VERSAO string = ".v05.37";
myLogLevel int =0;
/*
**
**
**
**
**
/*
function LerCms(aFileNameArg string[] in, aPathFiles string in, aWI_DEBUG_LEVEL int? in) returns(NfeToEglRec[])
const aFunction string = ".LerCms";
/*
**
**
**
**
*/
mygeraListaArquivosExt geraListaArquivosExt = new geraListaArquivosExt{};
myFiles = mygeraListaArquivosExt.visualizaListaArquivos(aPathFiles, aWI_DEBUG_LEVEL);
LogMensagem(aFunction, ".DADOS JAVANATIVO - QTDE ARQUIVOS " :: myFiles.getsize() :: " - ":: currenttimestamp());
for (wi int from 1 to myFiles.getsize() by 1)
LogMensagem(aFunction, ".DADOS JAVANATIVO - ARQUIVOS =[" :: wi :: "] " :: myFiles[wi] );
end
LogMensagem(aFunction, ".END JAVANATIVO - busca lista de arquivos " :: currenttimestamp());
/*
**
**
**
**
*/
end
externalType geraListaArquivosExt type JavaObject{JavaName = "geraListaArquivos", PackageName = "br.com.morlan.rui.common.db.external"}
function visualizaListaArquivos(aDiretorio String in, aLogLevel int in ) returns (string[]);
end
------------------------------
Osvaldo Jose de Oliveira Menezes
Analista
RellegusTI
Orlândia
+55 11 96565-6368
------------------------------