Hey guys,
Problem statement: Let user upload excel file through the form.
What I want: The file to be uploaded and then handled in a background thread so that users can freely switch pages or even close the browser, while the file is being handled and inserted into the database. Once finished the callback function update the infolog, so when the user returns, he is informed that the file was uploaded.
What have I done: Implemented a form with a FileUpload button, whilst overriding its onUploadCompleted() method to handle post operation. As well as implemented an Excel file handler class (which is working file when the file is uploaded synchronously).
Where am I struggling: I have found FormRun.runAsync() method can be used to execute the logic in the background. The parameter definition is as:
public System.Threading.Tasks.Task runAsync(int runAsClassId, str runAsStaticMethodName,
[container params], [System.Threading.CancellationToken], [str callbackFormMethodName],
and some more that I don't have use of);
The problem occurs when I call the function as:
public void onUploadCompleted()
{
super();
container con = conNull();
// con = conIns(con, 1, this); // This gives error
// ExcelImport::fileUpload = this // runAsync treats this as null
element.runAsync(classNum(ExcelImport), staticMethodStr(ExcelImport, handleImportedFile), con,
System.Threading.CancellationToken::None, formMethodStr(ImportForm, importCallback));
}
According to my knowledge, setting the static fileUpload field should have worked, but is treated as a nullObject when I debug the code, so the other way to handle this was to pass the FileUpload instance in the container as a parameter, but FileUpload being an object is rejected by the container, as they can't hold objects. How do I solve this problem?
Note: The ExcelImport::handleImportedFile() works perfectly if performed synchronously.