From ed718e8037f713bd33b121d90be6596b4a119018 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Wed, 20 Nov 2019 16:22:58 +0100 Subject: [PATCH] Lead import: move error logs to import logs-preview && bugfixes && refactorings && use SqlBuilder --- entity/Document_entity/Document_entity.aod | 6 + entity/LeadLog_entity/LeadLog_entity.aod | 29 ++- .../assignmentname_param/valueProcess.js | 3 + .../assignmentrowid_param/valueProcess.js | 4 + .../assignmenttable_param/valueProcess.js | 3 + .../Leadimport_entity/Leadimport_entity.aod | 9 +- .../bindata/displayValueProcess.js | 13 + .../filename/displayValueProcess.js | 10 - .../entityfields/filename/valueProcess.js | 9 - .../entityfields/load_data/onActionProcess.js | 79 +++--- .../transferdata/onActionProcess.js | 59 +++-- .../recordcontainers/db/onDBDelete.js | 37 ++- .../recordcontainers/db/onDBInsert.js | 6 +- .../recordcontainers/db/onDBUpdate.js | 13 +- neonContext/LeadLog/LeadLog.aod | 6 + .../DocumentList_view/DocumentList_view.aod | 1 + .../LeadLogPreview_view.aod | 17 ++ .../LeadimportPreview_view.aod | 4 +- process/Leadimport_lib/process.js | 242 +++++++----------- process/importLead_serverProcess/process.js | 19 +- 20 files changed, 300 insertions(+), 269 deletions(-) create mode 100644 entity/LeadLog_entity/entityfields/logdocuments/children/assignmentname_param/valueProcess.js create mode 100644 entity/LeadLog_entity/entityfields/logdocuments/children/assignmentrowid_param/valueProcess.js create mode 100644 entity/LeadLog_entity/entityfields/logdocuments/children/assignmenttable_param/valueProcess.js create mode 100644 entity/Leadimport_entity/entityfields/bindata/displayValueProcess.js delete mode 100644 entity/Leadimport_entity/entityfields/filename/displayValueProcess.js delete mode 100644 entity/Leadimport_entity/entityfields/filename/valueProcess.js create mode 100644 neonView/LeadLogPreview_view/LeadLogPreview_view.aod diff --git a/entity/Document_entity/Document_entity.aod b/entity/Document_entity/Document_entity.aod index 3d01bb47316..9ec31757dbb 100644 --- a/entity/Document_entity/Document_entity.aod +++ b/entity/Document_entity/Document_entity.aod @@ -211,6 +211,12 @@ <fieldName>DocumentC</fieldName> <isConsumer v="false" /> </entityDependency> + <entityDependency> + <name>cea7ef62-e3fb-43af-8a11-952d809e8242</name> + <entityName>LeadLog_entity</entityName> + <fieldName>LogDocuments</fieldName> + <isConsumer v="false" /> + </entityDependency> </dependencies> <children> <entityParameter> diff --git a/entity/LeadLog_entity/LeadLog_entity.aod b/entity/LeadLog_entity/LeadLog_entity.aod index e66fe580afd..2ae30e4f4ea 100644 --- a/entity/LeadLog_entity/LeadLog_entity.aod +++ b/entity/LeadLog_entity/LeadLog_entity.aod @@ -57,13 +57,28 @@ <name>IMPORTROWS</name> <title>Inserted rows</title> </entityField> - <entityActionField> - <name>resetImport</name> - <title>Reset import</title> - <onActionProcess>
 -</onActionProcess> - <isSelectionAction v="true" /> - </entityActionField> + <entityConsumer> + <name>LogDocuments</name> + <dependency> + <name>dependency</name> + <entityName>Document_entity</entityName> + <fieldName>Documents</fieldName> + </dependency> + <children> + <entityParameter> + <name>AssignmentName_param</name> + <valueProcess>%aditoprj%/entity/LeadLog_entity/entityfields/logdocuments/children/assignmentname_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>AssignmentRowId_param</name> + <valueProcess>%aditoprj%/entity/LeadLog_entity/entityfields/logdocuments/children/assignmentrowid_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>AssignmentTable_param</name> + <valueProcess>%aditoprj%/entity/LeadLog_entity/entityfields/logdocuments/children/assignmenttable_param/valueProcess.js</valueProcess> + </entityParameter> + </children> + </entityConsumer> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/LeadLog_entity/entityfields/logdocuments/children/assignmentname_param/valueProcess.js b/entity/LeadLog_entity/entityfields/logdocuments/children/assignmentname_param/valueProcess.js new file mode 100644 index 00000000000..c36f0598a02 --- /dev/null +++ b/entity/LeadLog_entity/entityfields/logdocuments/children/assignmentname_param/valueProcess.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string("ERRORLOG"); \ No newline at end of file diff --git a/entity/LeadLog_entity/entityfields/logdocuments/children/assignmentrowid_param/valueProcess.js b/entity/LeadLog_entity/entityfields/logdocuments/children/assignmentrowid_param/valueProcess.js new file mode 100644 index 00000000000..b9d761f7eaf --- /dev/null +++ b/entity/LeadLog_entity/entityfields/logdocuments/children/assignmentrowid_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$field.LEADLOGID")); \ No newline at end of file diff --git a/entity/LeadLog_entity/entityfields/logdocuments/children/assignmenttable_param/valueProcess.js b/entity/LeadLog_entity/entityfields/logdocuments/children/assignmenttable_param/valueProcess.js new file mode 100644 index 00000000000..13a61db8e5e --- /dev/null +++ b/entity/LeadLog_entity/entityfields/logdocuments/children/assignmenttable_param/valueProcess.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string("LEADLOG"); \ No newline at end of file diff --git a/entity/Leadimport_entity/Leadimport_entity.aod b/entity/Leadimport_entity/Leadimport_entity.aod index 9fadab1ad2d..f0069f155b7 100644 --- a/entity/Leadimport_entity/Leadimport_entity.aod +++ b/entity/Leadimport_entity/Leadimport_entity.aod @@ -24,6 +24,7 @@ <entityField> <name>NAME</name> <title>Import name</title> + <mandatory v="true" /> </entityField> <entityField> <name>LEADIMPORT_EMPLOYEE</name> @@ -53,7 +54,7 @@ <title>File</title> <contentType>FILE</contentType> <mandatory v="true" /> - <valueProcess></valueProcess> + <displayValueProcess>%aditoprj%/entity/Leadimport_entity/entityfields/bindata/displayValueProcess.js</displayValueProcess> </entityField> <entityField> <name>LEADIMPORTID</name> @@ -215,12 +216,6 @@ </entityParameter> </children> </entityConsumer> - <entityField> - <name>filename</name> - <linkedContext>Document</linkedContext> - <valueProcess>%aditoprj%/entity/Leadimport_entity/entityfields/filename/valueProcess.js</valueProcess> - <displayValueProcess>%aditoprj%/entity/Leadimport_entity/entityfields/filename/displayValueProcess.js</displayValueProcess> - </entityField> <entityConsumer> <name>LogHistoryC</name> <dependency> diff --git a/entity/Leadimport_entity/entityfields/bindata/displayValueProcess.js b/entity/Leadimport_entity/entityfields/bindata/displayValueProcess.js new file mode 100644 index 00000000000..83c858f348f --- /dev/null +++ b/entity/Leadimport_entity/entityfields/bindata/displayValueProcess.js @@ -0,0 +1,13 @@ +import("Sql_lib"); +import("system.result"); +import("system.vars"); +import("system.db"); + +var binMetadatas = db.getBinaryMetadata("LEADIMPORT", "IMPORTFILE", vars.get("$field.LEADIMPORTID"), false, SqlUtils.getBinariesAlias(), ""); + +if (binMetadatas.length > 0) +{ + result.string(binMetadatas[0].filename); +} else { + result.string("FILE MISSING"); +} \ No newline at end of file diff --git a/entity/Leadimport_entity/entityfields/filename/displayValueProcess.js b/entity/Leadimport_entity/entityfields/filename/displayValueProcess.js deleted file mode 100644 index e71f4bb2c7f..00000000000 --- a/entity/Leadimport_entity/entityfields/filename/displayValueProcess.js +++ /dev/null @@ -1,10 +0,0 @@ -import("system.result"); -import("Sql_lib"); -import("system.vars"); -import("system.db"); - -var data = db.cell(SqlCondition.begin(SqlUtils.getBinariesAlias()) - .andPrepare("ASYS_BINARIES.ROW_ID", vars.getString("$field.LEADIMPORTID")) - .buildSql("select FILENAME from ASYS_BINARIES"), SqlUtils.getBinariesAlias()); - -result.string(data); \ No newline at end of file diff --git a/entity/Leadimport_entity/entityfields/filename/valueProcess.js b/entity/Leadimport_entity/entityfields/filename/valueProcess.js deleted file mode 100644 index 2b308e026d5..00000000000 --- a/entity/Leadimport_entity/entityfields/filename/valueProcess.js +++ /dev/null @@ -1,9 +0,0 @@ -import("system.result"); -import("Sql_lib"); -import("system.vars"); -import("system.db"); - -var data = db.cell(SqlCondition.begin(SqlUtils.getBinariesAlias()) - .andPrepare("ASYS_BINARIES.ROW_ID", vars.getString("$field.LEADIMPORTID")) - .buildSql("select FILENAME from ASYS_BINARIES"), SqlUtils.getBinariesAlias()); -result.string(data); \ No newline at end of file diff --git a/entity/Leadimport_entity/entityfields/load_data/onActionProcess.js b/entity/Leadimport_entity/entityfields/load_data/onActionProcess.js index 5c2344a79ae..b42cd1b12af 100644 --- a/entity/Leadimport_entity/entityfields/load_data/onActionProcess.js +++ b/entity/Leadimport_entity/entityfields/load_data/onActionProcess.js @@ -14,56 +14,63 @@ var assignmentRowId = vars.get("$field.LEADIMPORTID"); var importDate = vars.get("$field.LEADIMPORT_DATE"); var importName = vars.get("$field.NAME"); -var binId = db.cell(SqlCondition.begin(SqlUtils.getBinariesAlias()) - .andPrepare("ASYS_BINARIES.ROW_ID", assignmentRowId) - .buildSql("select ID from ASYS_BINARIES", "1=2"), SqlUtils.getBinariesAlias()); -var fieldSep = KeywordUtils.getViewValue($KeywordRegistry.fieldSeparator(), vars.get("$field.FIELDSEPARATOR")); -var fieldLimit = KeywordUtils.getViewValue($KeywordRegistry.fieldLimit(), vars.get("$field.FIELDDELIMITERS")); -var recordSep = KeywordUtils.getViewValue($KeywordRegistry.recordSeparator(), vars.get("$field.SENTENCESEPARATOR")); +var binMetadatas = db.getBinaryMetadata("LEADIMPORT", "IMPORTFILE", vars.get("$field.LEADIMPORTID"), false, SqlUtils.getBinariesAlias(), ""); +if (binMetadatas.length > 0) +{ + var binId = binMetadatas[0].id; -if (recordSep == "CRLF") recordSep = '\r\n'; -if ( fieldSep == "TAB" ) fieldSep = '\t'; -else fieldSep = fieldSep.charAt(0); + var fieldSep = KeywordUtils.getViewValue($KeywordRegistry.fieldSeparator(), vars.get("$field.FIELDSEPARATOR")); + var fieldLimit = KeywordUtils.getViewValue($KeywordRegistry.fieldLimit(), vars.get("$field.FIELDDELIMITERS")); + var recordSep = KeywordUtils.getViewValue($KeywordRegistry.recordSeparator(), vars.get("$field.SENTENCESEPARATOR")); -var data = db.getBinaryContent(binId, SqlUtils.getBinariesAlias()); -data = util.decodeBase64String(data); -var table = text.parseCSV(data.replace(/(^\s+)|(\s+$)/g,""), recordSep, fieldSep, fieldLimit.charAt(0)); + if (recordSep == "CRLF") recordSep = '\r\n'; + if ( fieldSep == "TAB" ) fieldSep = '\t'; + else fieldSep = fieldSep.charAt(0); -var insertTable = "LEADTEMP"; -var insertCols = LeadImportUtils.leadTempColumns(); -var insertTypes = db.getColumnTypes(insertTable, insertCols); -var insertVals = []; + var data = db.getBinaryContent(binId, SqlUtils.getBinariesAlias()); + data = util.decodeBase64String(data); -var toInsert = []; + var table = text.parseCSV(data.replace(/(^\s+)|(\s+$)/g,""), recordSep, fieldSep, fieldLimit.charAt(0)); -db.deleteData(insertTable, "ROW_ID = '" + assignmentRowId + "'");//delete existing + var insertTable = "LEADTEMP"; + var insertCols = LeadImportUtils.leadTempColumns(); + var insertTypes = db.getColumnTypes(insertTable, insertCols); + var insertVals = []; -for (i = 0; i < table.length; i++)//and load new -{ - insertVals = []; - for (j = 0; j < 30; j++) //fill the 30 data-columns of the table + var toInsert = []; + + db.deleteData(insertTable, "ROW_ID = '" + assignmentRowId + "'");//delete existing + + for (i = 0; i < table.length; i++)//and load new { - if(table[i][j] == undefined) - table[i][j] = ""; - - insertVals.push(table[i][j]); + insertVals = []; + for (j = 0; j < 30; j++) //fill the 30 data-columns of the table + { + if(table[i][j] == undefined) + table[i][j] = ""; + + insertVals.push(table[i][j]); + } + + insertVals.push(importDate, util.getNewUUID(), importName, i.toString(), assignmentRowId);//push other necessary data for the insert + toInsert.push([insertTable, insertCols, insertTypes, insertVals]); } - insertVals.push(importDate, util.getNewUUID(), importName, i.toString(), assignmentRowId);//push other necessary data for the insert - toInsert.push([insertTable, insertCols, insertTypes, insertVals]); -} + db.inserts(toInsert); -db.inserts(toInsert); + question.showMessage("Daten wurden geladen! Zeilen: " + eMath.subInt(table.length, 1)); -question.showMessage("Daten wurden geladen! Zeilen: " + eMath.subInt(table.length, 1)); + var updTable = "LEADIMPORT"; + var updCols = ["STATUS"]; + var updTypes = db.getColumnTypes(updTable, updCols); -var updTable = "LEADIMPORT"; -var updCols = ["STATUS"]; -var updTypes = db.getColumnTypes(updTable, updCols); + db.updateData(updTable, updCols, updTypes, [$KeywordRegistry.importStatus$loaded()], newWhere([updTable, "LEADIMPORTID"], assignmentRowId)); -db.updateData(updTable, updCols, updTypes, [$KeywordRegistry.importStatus$loaded()], "LEADIMPORTID = '" + assignmentRowId + "'"); + neon.refreshAll(); -neon.refreshAll(); +} else { + question.showMessage("Error: The Importfile could not be found anymore."); +} \ No newline at end of file diff --git a/entity/Leadimport_entity/entityfields/transferdata/onActionProcess.js b/entity/Leadimport_entity/entityfields/transferdata/onActionProcess.js index ca941a0fa69..9ae7b754968 100644 --- a/entity/Leadimport_entity/entityfields/transferdata/onActionProcess.js +++ b/entity/Leadimport_entity/entityfields/transferdata/onActionProcess.js @@ -1,3 +1,4 @@ +import("system.question"); import("Employee_lib"); import("system.process"); import("KeywordRegistry_basic"); @@ -7,33 +8,39 @@ import("system.db"); import("system.vars"); import("system.neon"); +var binMetadatas = db.getBinaryMetadata("LEADIMPORT", "IMPORTFILE", vars.get("$field.LEADIMPORTID"), false, SqlUtils.getBinariesAlias(), ""); - -var assignmentRowId = vars.get("$field.LEADIMPORTID"); -var name = vars.get("$field.NAME"); -var fieldSep = KeywordUtils.getViewValue($KeywordRegistry.fieldSeparator(), vars.get("$field.FIELDSEPARATOR")); -var recordSep = KeywordUtils.getViewValue($KeywordRegistry.recordSeparator(), vars.get("$field.SENTENCESEPARATOR")); -var fieldLimit = KeywordUtils.getViewValue($KeywordRegistry.fieldLimit(), vars.get("$field.FIELDDELIMITERS")); -var user = vars.get("$sys.user"); -if (recordSep == "CRLF") recordSep = '\r\n'; -if ( fieldSep == "TAB" ) fieldSep = '\t'; -else fieldSep = fieldSep.charAt(0); - -var params = +if (binMetadatas.length > 0) { - importdefid: vars.get("$field.LEADIMPORTID"), - assignmentRowId: assignmentRowId, - binId: db.cell(SqlCondition.begin(SqlUtils.getBinariesAlias()).andPrepare("ASYS_BINARIES.ROW_ID", assignmentRowId).buildSql("select ID from ASYS_BINARIES", "1=2"), SqlUtils.getBinariesAlias()), - recordSep: recordSep, - fieldSep: fieldSep, - fieldLimit: fieldLimit, - user: user, - source: vars.getString("$field.IMPORTSOURCE"), - currDate: vars.get("$sys.date"), - userId: EmployeeUtils.getCurrentUserId(), - importName: name -} + var binId = binMetadatas[0].id; + + var assignmentRowId = vars.get("$field.LEADIMPORTID"); + var name = vars.get("$field.NAME"); + var fieldSep = KeywordUtils.getViewValue($KeywordRegistry.fieldSeparator(), vars.get("$field.FIELDSEPARATOR")); + var recordSep = KeywordUtils.getViewValue($KeywordRegistry.recordSeparator(), vars.get("$field.SENTENCESEPARATOR")); + var fieldLimit = KeywordUtils.getViewValue($KeywordRegistry.fieldLimit(), vars.get("$field.FIELDDELIMITERS")); + var user = vars.get("$sys.user"); + if (recordSep == "CRLF") recordSep = '\r\n'; + if ( fieldSep == "TAB" ) fieldSep = '\t'; + else fieldSep = fieldSep.charAt(0); -//process.execute("importLead_serverProcess", params); -process.executeAsync("importLead_serverProcess", params, false, user, process.THREADPRIORITY_LOW, process.TIMERTYPE_SERVER) + var params = + { + importdefid: vars.get("$field.LEADIMPORTID"), + assignmentRowId: assignmentRowId, + binId: binId, + recordSep: recordSep, + fieldSep: fieldSep, + fieldLimit: fieldLimit, + user: user, + source: vars.getString("$field.IMPORTSOURCE"), + currDate: vars.get("$sys.date"), + userId: EmployeeUtils.getCurrentUserId(), + importName: name + } + //process.execute("importLead_serverProcess", params); + process.executeAsync("importLead_serverProcess", params, false, user, process.THREADPRIORITY_LOW, process.TIMERTYPE_SERVER) +} else { + question.showMessage("Error: The Importfile could not be found anymore."); +} \ No newline at end of file diff --git a/entity/Leadimport_entity/recordcontainers/db/onDBDelete.js b/entity/Leadimport_entity/recordcontainers/db/onDBDelete.js index 9c79b8ecb79..541e655e366 100644 --- a/entity/Leadimport_entity/recordcontainers/db/onDBDelete.js +++ b/entity/Leadimport_entity/recordcontainers/db/onDBDelete.js @@ -3,16 +3,33 @@ import("system.vars"); import("system.db"); var leadImportId = vars.getString("$field.LEADIMPORTID"); -var binId = db.cell(SqlCondition.begin(SqlUtils.getBinariesAlias()) - .andPrepare("ASYS_BINARIES.ROW_ID", leadImportId) - .buildSql("select ID from ASYS_BINARIES", "1=2"), SqlUtils.getBinariesAlias()); + +// the import file +var binMetadata = db.getBinaryMetadata("LEADIMPORT", "IMPORTFILE", leadImportId, false, SqlUtils.getBinariesAlias(), ""); + +// additional uploaded files from Document tab +binMetadata = binMetadata.concat(db.getBinaryMetadata("LEADIMPORT", "DOCUMENT", leadImportId, false, SqlUtils.getBinariesAlias(), "")); + +// error log files +newSelect("LEADLOGID") + .from("LEADLOG") + .where("LEADLOG.LEADIMPORT_ID", leadImportId) + .arrayColumn() + .forEach(function(leadLogId) + { + binMetadata = binMetadata.concat(db.getBinaryMetadata("LEADLOG", "ERRORLOG", leadLogId, false, SqlUtils.getBinariesAlias(), "")); + }); if(leadImportId != "")//delete the connected importfields - { - db.deleteData("IMPORTFIELD", "LEADIMPORT_ID = '" + leadImportId + "'"); - db.deleteData("LEADTEMP", "ROW_ID = '" + leadImportId + "'"); - db.deleteData("LEAD", "LEADIMPORT_ID = '" + leadImportId + "'"); - } +{ + db.deleteData("IMPORTFIELD", newWhere("IMPORTFIELD.LEADIMPORT_ID", leadImportId).build()); + db.deleteData("LEADTEMP", newWhere("LEADTEMP.ROW_ID", leadImportId).build()); + db.deleteData("LEAD", newWhere("LEAD.LEADIMPORT_ID", leadImportId).build()); + db.deleteData("LEADLOG", newWhere("LEADLOG.LEADIMPORT_ID", leadImportId).build()); +} -if(binId != "")//delete the connected binData - db.deleteBinary(binId, SqlUtils.getBinariesAlias()); \ No newline at end of file +binMetadata.forEach(function(pMeta) +{ //delete the connected binData + db.deleteBinary(pMeta.id, SqlUtils.getBinariesAlias()); +}); + \ No newline at end of file diff --git a/entity/Leadimport_entity/recordcontainers/db/onDBInsert.js b/entity/Leadimport_entity/recordcontainers/db/onDBInsert.js index 9c821ae1744..05e42d88282 100644 --- a/entity/Leadimport_entity/recordcontainers/db/onDBInsert.js +++ b/entity/Leadimport_entity/recordcontainers/db/onDBInsert.js @@ -1,3 +1,4 @@ +import("Sql_lib"); import("KeywordRegistry_basic"); import("Keyword_lib"); import("Binary_lib"); @@ -18,11 +19,10 @@ var recordSep = KeywordUtils.getViewValue($KeywordRegistry.recordSeparator(), va if(bindata != '' && filename != '') { var mimeType = DocumentUtil.getMimeTypeFromUpload(vars.get("$field.bindata")); - if (mimeType == "application/vnd.ms-excel") { - SingleBinaryUtils.insertMainDocument("LEADIMPORT", "", assignmentRowId, bindata, filename, ""); - LeadImportUtils.loadImportFile(vars.get("$field.bindata"), fieldSep, fieldLimit, recordSep, assignmentRowId); + var documentId = SingleBinaryUtils.insertMainDocument("LEADIMPORT", "IMPORTFILE", assignmentRowId, bindata, filename, "", SqlUtils.getBinariesAlias()); + LeadImportUtils.loadImportFile(documentId, fieldSep, fieldLimit, recordSep, assignmentRowId); } } diff --git a/entity/Leadimport_entity/recordcontainers/db/onDBUpdate.js b/entity/Leadimport_entity/recordcontainers/db/onDBUpdate.js index cd9205f937f..3342342c82a 100644 --- a/entity/Leadimport_entity/recordcontainers/db/onDBUpdate.js +++ b/entity/Leadimport_entity/recordcontainers/db/onDBUpdate.js @@ -1,3 +1,4 @@ +import("system.neon"); import("Sql_lib"); import("KeywordRegistry_basic"); import("Keyword_lib"); @@ -21,12 +22,12 @@ if(bindata != '' && filename != '') if (mimeType == "application/vnd.ms-excel") { - var binId = db.cell(SqlCondition.begin(SqlUtils.getBinariesAlias()) - .andPrepare("ASYS_BINARIES.ROW_ID", vars.getString("$field.LEADIMPORTID")) - .buildSql("select ID from ASYS_BINARIES", "1=2"), SqlUtils.getBinariesAlias()); - - db.updateBinary(binId, "", bindata, filename, "", "MAINDOCUMENT", SqlUtils.getBinariesAlias()); - LeadImportUtils.loadImportFile(vars.get("$field.bindata"), fieldSep, fieldLimit, recordSep, assignmentRowId, true, vars.get("$param.LeadimportNewFile_param")); + var binMetadata = db.getBinaryMetadata("LEADIMPORT", "IMPORTFILE", assignmentRowId, false, SqlUtils.getBinariesAlias(), "MAINDOCUMENT"); + if (binMetadata.length > 0) { + db.updateBinary(binMetadata[0].id, "", bindata, filename, "", "MAINDOCUMENT", SqlUtils.getBinariesAlias()); + LeadImportUtils.loadImportFile(binMetadata[0].id, fieldSep, fieldLimit, recordSep, assignmentRowId, true, vars.get("$param.LeadimportNewFile_param")); + } } } +neon.refreshAll(); \ No newline at end of file diff --git a/neonContext/LeadLog/LeadLog.aod b/neonContext/LeadLog/LeadLog.aod index 1dc2c334a01..c5c5b90e883 100644 --- a/neonContext/LeadLog/LeadLog.aod +++ b/neonContext/LeadLog/LeadLog.aod @@ -2,11 +2,17 @@ <neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0"> <name>LeadLog</name> <majorModelMode>DISTRIBUTED</majorModelMode> + <filterview>LeadLogFilter_view</filterview> + <preview>LeadLogPreview_view</preview> <entity>LeadLog_entity</entity> <references> <neonViewReference> <name>dab31f69-12a0-4074-af81-f497853eca24</name> <view>LeadLogFilter_view</view> </neonViewReference> + <neonViewReference> + <name>3e5f7e73-5a5c-4004-9b08-95f495e84a06</name> + <view>LeadLogPreview_view</view> + </neonViewReference> </references> </neonContext> diff --git a/neonView/DocumentList_view/DocumentList_view.aod b/neonView/DocumentList_view/DocumentList_view.aod index 3ed5473fe3a..aaac9b0b645 100644 --- a/neonView/DocumentList_view/DocumentList_view.aod +++ b/neonView/DocumentList_view/DocumentList_view.aod @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.2"> <name>DocumentList_view</name> + <title>Errorlogs</title> <majorModelMode>DISTRIBUTED</majorModelMode> <layout> <drawerLayout> diff --git a/neonView/LeadLogPreview_view/LeadLogPreview_view.aod b/neonView/LeadLogPreview_view/LeadLogPreview_view.aod new file mode 100644 index 00000000000..983d2c3e56d --- /dev/null +++ b/neonView/LeadLogPreview_view/LeadLogPreview_view.aod @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.2"> + <name>LeadLogPreview_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <layout> + <headerFooterLayout> + <name>layout</name> + </headerFooterLayout> + </layout> + <children> + <neonViewReference> + <name>b18d95d9-c767-4dca-a5c4-1171fd436ce9</name> + <entityField>LogDocuments</entityField> + <view>DocumentList_view</view> + </neonViewReference> + </children> +</neonView> diff --git a/neonView/LeadimportPreview_view/LeadimportPreview_view.aod b/neonView/LeadimportPreview_view/LeadimportPreview_view.aod index 6518c592858..16a75018184 100644 --- a/neonView/LeadimportPreview_view/LeadimportPreview_view.aod +++ b/neonView/LeadimportPreview_view/LeadimportPreview_view.aod @@ -60,8 +60,8 @@ <entityField>#ENTITY</entityField> <fields> <entityFieldLink> - <name>1b7aaf10-ed58-4f0d-9dbc-f329e89b71e6</name> - <entityField>filename</entityField> + <name>24d3036f-be4e-418c-a13f-e21c44112edf</name> + <entityField>bindata</entityField> </entityFieldLink> </fields> </genericViewTemplate> diff --git a/process/Leadimport_lib/process.js b/process/Leadimport_lib/process.js index e4f727e01e1..92d6007427a 100644 --- a/process/Leadimport_lib/process.js +++ b/process/Leadimport_lib/process.js @@ -72,7 +72,7 @@ LeadImportUtils.leadTempColumns = function() /* * Load the data * -* @param {String} pFile req the bindata of the file +* @param {String} pBinId req the binary id for loading the binary * @param {String} pFieldSep req the fieldSeparator * @param {String} pFieldLimit req the fieldLimit * @param {String} pRecordSep req the recordSeparator @@ -82,7 +82,7 @@ LeadImportUtils.leadTempColumns = function() * * @return {integer} rows the number of rows which have been inserted */ -LeadImportUtils.loadImportFile = function(pFile, pFieldSep, pFieldLimit, pRecordSep, pLeadImportId, pUpdate, pNewFile) +LeadImportUtils.loadImportFile = function(pBinId, pFieldSep, pFieldLimit, pRecordSep, pLeadImportId, pUpdate, pNewFile) { var rows = 0; var toInsert = []; @@ -93,26 +93,23 @@ LeadImportUtils.loadImportFile = function(pFile, pFieldSep, pFieldLimit, pRecord if(pUpdate == undefined) pUpdate = false; - if (pFile != "") + if (pBinId) { if (pRecordSep == "CRLF") pRecordSep = '\r\n'; - if ( pFieldSep == "TAB" ) pFieldSep = '\t'; + if (pFieldSep == "TAB") pFieldSep = '\t'; else pFieldSep = pFieldSep.charAt(0); try - { - var binId = db.cell(SqlCondition.begin(SqlUtils.getBinariesAlias()) - .andPrepare("ASYS_BINARIES.ROW_ID", pLeadImportId) - .buildSql("select ID from ASYS_BINARIES", "1=2"), SqlUtils.getBinariesAlias()); - - var data = db.getBinaryContent(binId, SqlUtils.getBinariesAlias()); + { + var data = db.getBinaryContent(pBinId, SqlUtils.getBinariesAlias()); data = util.decodeBase64String(data, "UTF-8"); var table = text.parseCSV( data.replace(/(^\s+)|(\s+$)/g,""), pRecordSep, pFieldSep, pFieldLimit.charAt(0)); - + logging.log(JSON.stringify([table], null, "\t")) if(pNewFile != "true") { - if(pUpdate) - db.deleteData("IMPORTFIELD", "LEADIMPORT_ID = '" + pLeadImportId + "'"); + if(pUpdate) { + db.deleteData("IMPORTFIELD", newWhere("IMPORTFIELD.LEADIMPORT_ID", pLeadImportId).build()); + } //insert the importfields for (i = 0; i < table[0].length; i++) { @@ -122,10 +119,11 @@ LeadImportUtils.loadImportFile = function(pFile, pFieldSep, pFieldLimit, pRecord db.inserts(toInsert); } - db.deleteData("LEADTEMP", "ROW_ID = '" + pLeadImportId + "'");//delete existing temp data + db.deleteData("LEADTEMP", newWhere("LEADTEMP.ROW_ID", pLeadImportId).build());//delete existing temp data } catch(ex) { + logging.log(ex); question.showMessage(translate.text("Fehler beim einlesen der Datei !")); } } @@ -211,7 +209,7 @@ LeadImportUtils.importData = function(pDataFields, pDataTypes, pFieldDef, pField LeadValues["LEADIMPORT_ID"] = pImportDefID; LeadValues["ORGANISATION_ID"] = orgid; LeadValues["PERSON_ID"] = persid; - + var leadId = LeadImportUtils.insertTable(pDataFields, pDataTypes ,LeadValues, "LEAD", pUser, pDate);//inserts the LEAD dataset LeadImportUtils.insertLeadAttr(pAttrObject, orgid, persid, LeadValues["DATE_NEW"], pUser, pDate, (orgRet && orgRet.length >= 4 && orgRet[3])); @@ -319,19 +317,14 @@ LeadImportUtils.setValues = function(pFields, pFieldDef, pFieldValues) * * @return {[]} ImportFieldDef */ -LeadImportUtils.getImportFieldDef = function( pID ) +LeadImportUtils.getImportFieldDef = function(pID) { - var condition = SqlCondition.begin(); - - var ImportFieldDef = db.table(SqlBuilder.begin() - .select("distinct FIELDNUMBER, " + SqlMaskingUtils.prototype.trim("MAPPINGFIELD") + ", ''") - .from("IMPORTFIELD") - .where(condition - .andPrepare("IMPORTFIELD.LEADIMPORT_ID", pID) - .and("MAPPINGFIELD is not null")) - .orderBy("IMPORTFIELD.FIELDNUMBER asc") - .build() - ); + var ImportFieldDef = newSelect(["distinct FIELDNUMBER", SqlMaskingUtils.prototype.trim("MAPPINGFIELD"), "''"]) + .from("IMPORTFIELD") + .where("IMPORTFIELD.LEADIMPORT_ID", pID) + .and("MAPPINGFIELD is not null") + .orderBy("IMPORTFIELD.FIELDNUMBER asc") + .table(); var FieldDef = new Array(); for (let i = 0; i < ImportFieldDef.length; i++) @@ -340,13 +333,15 @@ LeadImportUtils.getImportFieldDef = function( pID ) if(ImportFieldDef[i][1].substr(0, 9) == "ATTRIBUTE")//ATTRIBUTES are defined like ATTRIBUTE_Loyalty { var attrName = ImportFieldDef[i][1].substr(10);// so cut the first 10 characters off to get the ATTRIBUTENAME "Loyalty" - var attrdata = db.array(db.ROW, SqlCondition.begin() - .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_NAME", attrName) - .buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_TYPE from AB_ATTRIBUTE", "1=2")); + var attrdata = newSelect("AB_ATTRIBUTEID, ATTRIBUTE_TYPE") + .from("AB_ATTRIBUTE") + .where("AB_ATTRIBUTE.ATTRIBUTE_NAME", attrName) + .arrayRow(); - var attrobj = db.table(SqlCondition.begin() - .andPrepare("AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID", attrdata[0]) - .buildSql("select OBJECT_TYPE, MAX_COUNT from AB_ATTRIBUTEUSAGE", "1=2")); + var attrobj = newSelect("OBJECT_TYPE, MAX_COUNT") + .from("AB_ATTRIBUTEUSAGE") + .where("AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID", attrdata[0]) + .table(); var attrobject = new Object(); for (let j = 0; j < attrobj.length; j++) @@ -400,11 +395,12 @@ LeadImportUtils.insertAttr = function(pDataFields, pDataTypes, pFieldDef, pLeadV switch(attrdata[1][1].trim())//type { case "COMBO": - value = db.cell(SqlCondition.begin() - .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", attrdata[1][0]) - .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_NAME", value) - .buildSql("select AB_ATTRIBUTEID from AB_ATTRIBUTE", "1=2")); - + value = newSelect("AB_ATTRIBUTEID") + .from("AB_ATTRIBUTE") + .where("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", attrdata[1][0]) + .and("AB_ATTRIBUTE.ATTRIBUTE_NAME", value) + .cell(); + type = "ID_VALUE"; break; //other cases can be added here @@ -637,11 +633,12 @@ LeadImportUtils.insertLeadAttr = function(pAttrObject, orgid, persid, pUser, pD if (orgid != "" && pInsertOrgAttr) { AttrValues[0] = "Organisation"; - AttrValues[7] = db.cell(SqlCondition.begin() - .andPrepare("CONTACT.ORGANISATION_ID", orgid) - .and("CONTACT.PERSON_ID is null") - .buildSql("select CONTACTID from CONTACT", "1=2")); - + AttrValues[7] = newSelect("CONTACTID") + .from("CONTACT") + .where("CONTACT.ORGANISATION_ID", orgid) + .and("CONTACT.PERSON_ID is null") + .cell(); + sqlInsertAttr(pAttrObject, AttrValues, pUser, pDate); } // Attribute für the Person @@ -649,10 +646,11 @@ LeadImportUtils.insertLeadAttr = function(pAttrObject, orgid, persid, pUser, pD { AttrValues[0] = "Person"; if (orgid == "") orgid = "0"; // Private - AttrValues[7] = db.cell(SqlCondition.begin() - .andPrepare("CONTACT.ORGANISATION_ID", orgid) - .andPrepare("CONTACT.PERSON_ID", persid) - .buildSql("select CONTACT.CONTACTID from CONTACT", "1=2")); + AttrValues[7] = newSelect("CONTACT.CONTACTID") + .from("CONTACT") + .where("CONTACT.ORGANISATION_ID", orgid) + .and("CONTACT.PERSON_ID", persid) + .cell(); sqlInsertAttr(pAttrObject, AttrValues, pUser, pDate); } @@ -687,104 +685,58 @@ LeadImportUtils.sqlInsertAttr = function(pAttrObject, pAttrValues, pUser, pDate) */ LeadImportUtils.getLeadAttr = function(pImportDefID) { - var ret = new Object(); - var condition = SqlCondition.begin(); - - ret["Fields"] = new Array("OBJECT_TYPE", "AB_ATTRIBUTE_ID", "CHAR_VALUE","DATE_VALUE","NUMBER_VALUE", "INT_VALUE", "ID_VALUE", "OBJECT_ROWID", "AB_ATTRIBUTERELATIONID", "DATE_NEW", "USER_NEW"); - ret["Types"] = db.getColumnTypes("AB_ATTRIBUTERELATION", ret["Fields"]); - ret["Values"] = db.table(SqlBuilder.begin() - .select("AB_ATTRIBUTERELATION.OBJECT_TYPE, AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID, CHAR_VALUE, DATE_VALUE, NUMBER_VALUE, INT_VALUE, ID_VALUE, -1, -1, '', ''") - .from("AB_ATTRIBUTERELATION") - .join("AB_ATTRIBUTEUSAGE", " AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID = AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID") - .where(condition - .andPrepare("AB_ATTRIBUTERELATION.OBJECT_ROWID", pImportDefID) - .and("AB_ATTRIBUTERELATION.OBJECT_TYPE = 'Leadimport'") - ).build()); - - return ret; + let fields = ["OBJECT_TYPE", "AB_ATTRIBUTE_ID", "CHAR_VALUE","DATE_VALUE","NUMBER_VALUE", "INT_VALUE", "ID_VALUE", "OBJECT_ROWID", "AB_ATTRIBUTERELATIONID", "DATE_NEW", "USER_NEW"]; + return { + Fields: fields, + Types: db.getColumnTypes("AB_ATTRIBUTERELATION", fields), + Values: newSelect("AB_ATTRIBUTERELATION.OBJECT_TYPE, AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID, CHAR_VALUE, DATE_VALUE, NUMBER_VALUE, INT_VALUE, ID_VALUE, -1, -1, '', ''") + .from("AB_ATTRIBUTERELATION") + .join("AB_ATTRIBUTEUSAGE", "AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID = AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID") + .where("AB_ATTRIBUTERELATION.OBJECT_ROWID", pImportDefID) + .and("AB_ATTRIBUTERELATION.OBJECT_TYPE = 'Leadimport'") + .table() + }; } /* -* Checks and validates the COUNTRY -* If the lenght of the COUNTRY is 2 (e. g. DE) then DE -* If the lenght of the COUNTRY is 3 (e. g. DEU) then DE -* If the lenght of the COUNTRY is more then 3 (e. g. Germany) then DE -* If there is no COUNTRY then DE -* -* @param {String} pValue req the COUNTRY +* Checks if the COUNTRY is a valid one. +* The value is checked against ISO2, ISO3 and NAME_LATIN +* +* @param {String} pCountry req the COUNTRY * -* @return {String} validated COUNTRY +* @return {String} validated COUNTRY as ISO2, Default is "DE". */ -LeadImportUtils.checkCountry = function( pValue ) +LeadImportUtils.checkCountry = function(pCountry) { - var ret = ""; - if (pValue.length == 2) - { - ret = db.cell(SqlCondition.begin() - .andPrepare("AB_COUNTRYINFO.ISO2", pValue) - .buildSql("select ISO2 from AB_COUNTRYINFO", "1=2")); - - } - else - if (pValue.length == 3) - { - ret = db.cell(SqlCondition.begin() - .andPrepare("AB_COUNTRYINFO.ISO3", pValue) - .buildSql("select ISO2 from AB_COUNTRYINFO", "1=2")); - } - else - if (pValue.length > 3) - { - ret = db.cell(SqlCondition.begin() - .andPrepare("AB_COUNTRYINFO.NAME_LATIN", pValue) - .buildSql("select ISO2 from AB_COUNTRYINFO", "1=2")); - } - - if ( ret == "") ret = "DE"; - - return ret; + var iso2 = newSelect("MAX(ISO2)") // normally there should be only one so MAX is only to be safe here... + .from("AB_COUNTRYINFO") + .where("AB_COUNTRYINFO.ISO2", pCountry) + .or("AB_COUNTRYINFO.ISO3", pCountry) + .or("AB_COUNTRYINFO.NAME_LATIN", pCountry) + .cell(); + + return iso2 ? iso2 : "DE"; } /* -* Checks and validates the LANGUAGE -* If the lenght of the LANGUAGE is 2 (e. g. de) then deu -* If the lenght of the LANGUAGE is 3 (e. g. deu) then deu -* If the lenght of the LANGUAGE is more then 3 (e. g. German) then deu -* If there is no LANGUAGE then deu +* Checks if the LANGUAGE is a valid one. +* The value is checked against ISO2, ISO3 and NAME_LATIN * -* @param {String} pValue req the LANGUAGE +* @param {String} pLanguage req the LANGUAGE * -* @return {String} validated LANGUAGE +* @return {String} validated LANGUAGE as ISO3. Default is "deu". */ -LeadImportUtils.checkISOLanguage = function(pValue) +LeadImportUtils.checkISOLanguage = function(pLanguage) { - var ret = ""; - - if (pValue.length == 2) - { - ret = db.cell(SqlCondition.begin() - .andPrepare("AB_LANGUAGE.ISO2", pValue) - .buildSql("select ISO3 from AB_LANGUAGE", "1=2")); - } - else - if (pValue.length == 3) - { - ret = db.cell(SqlCondition.begin() - .andPrepare("AB_LANGUAGE.ISO3", pValue) - .buildSql("select ISO3 from AB_LANGUAGE", "1=2")); - } - else - if (pValue.length > 3) - { - ret = db.cell(SqlCondition.begin() - .andPrepare("AB_LANGUAGE.NAME_LATIN", pValue) - .buildSql("select ISO3 from AB_LANGUAGE", "1=2")); - } - - if (ret == "") ret = "deu"; + var iso3 = newSelect("MAX(ISO3)") // normally there should be only one so MAX is only to be safe here... + .from("AB_LANGUAGE") + .where("AB_LANGUAGE.ISO2", pLanguage) + .or("AB_LANGUAGE.ISO3", pLanguage) + .or("AB_LANGUAGE.NAME_LATIN", pLanguage) + .cell(); - return ret; + return iso3 ? iso3 : "deu"; } @@ -847,8 +799,8 @@ LeadImportUtils.scanLeadDups = function(pAllContactData) var leadID = ""; var toUpdate = []; var updDupVals = []; - var persObj =[]; - var orgObj =[]; + var persObj = {}; + var orgObj = {}; for(let pLeadID in pAllContactData) { @@ -859,8 +811,7 @@ LeadImportUtils.scanLeadDups = function(pAllContactData) leadID = pLeadID; persObj = pAllContactData[pLeadID][0];//personData orgObj = pAllContactData[pLeadID][1];//organisationData - - + if(orgObj != undefined && Object.keys(orgObj).length > 0)//checks if there is an ORGANISATIONDUPLICATE { let scanResultsOrg = DuplicateScannerUtils.ScanForDuplicates("OrganisationDuplicates", "Organisation_entity", orgObj, null); @@ -889,7 +840,7 @@ LeadImportUtils.scanLeadDups = function(pAllContactData) updDupVals = [dupStatus]; - toUpdate.push([dupUpdateLeadTable, ["DUPSTATUS"], null, updDupVals, "LEADID = '" + leadID + "'"]); + toUpdate.push([dupUpdateLeadTable, ["DUPSTATUS"], null, updDupVals, newWhere([dupUpdateLeadTable, "LEADID"], leadID).build()]); } db.updates(toUpdate);//update Leads with the new status } @@ -1030,12 +981,14 @@ ContactInfoUtils.getGender = function(pLeadValues) */ ContactInfoUtils.getSalutation = function(pLeadValues, pIsoLanguage) { + // TODO: use getRows if ( pLeadValues["SALUTATION"] != undefined && pLeadValues["SALUTATION"] != "" ) { - var salutation = db.array(db.COLUMN, SqlCondition.begin() - .andPrepare("SALUTATION.ISOLANGUAGE", pIsoLanguage) - .and("SALUTATION.SALUTATION is not null") - .buildSql("select distinct SALUTATION from SALUTATION", "1=2")); + var salutation = newSelect("distinct SALUTATION") + .from("SALUTATION") + .where("SALUTATION.ISOLANGUAGE", pIsoLanguage) + .and("SALUTATION.SALUTATION is not null") + .arrayColumn(); for (let i = 0; i < salutation.length; i++) { @@ -1055,12 +1008,15 @@ ContactInfoUtils.getSalutation = function(pLeadValues, pIsoLanguage) */ ContactInfoUtils.getTitle = function(pLeadValues, pIsoLanguage) { + // TODO: use getRows if ( pLeadValues["TITLE"] != undefined && pLeadValues["TITLE"] != "" ) { - var title = db.array(db.COLUMN, SqlCondition.begin() - .andPrepare("SALUTATION.ISOLANGUAGE", pIsoLanguage) - .and("SALUTATION.TITLE is not null") - .buildSql("select distinct TITLE from SALUTATION", "1=2")); + var title = newSelect("distinct TITLE") + .from("SALUTATION") + .where("SALUTATION.ISOLANGUAGE", pIsoLanguage) + .and("SALUTATION.TITLE is not null") + .arrayColumn(); + for (let i = 0; i < title.length; i++) { if(pLeadValues["TITLE"].trim() == title[i].trim()) diff --git a/process/importLead_serverProcess/process.js b/process/importLead_serverProcess/process.js index a6807e22970..b32a49225e1 100644 --- a/process/importLead_serverProcess/process.js +++ b/process/importLead_serverProcess/process.js @@ -153,21 +153,20 @@ rows = eMath.subInt(rows, errorCount);//datasetcount - errors = inserts var updTable = "LEADIMPORT"; var updFields =["IMPORT_DATE", "DATE_EDIT", "USER_EDIT", "STATUS"]; -var updTypes = db.getColumnTypes(updTable, updFields); var updVals = [ImportDate, currDate, user, $KeywordRegistry.importStatus$transfered()]; -var insTable = "LEADLOG"; -var insFields =["LEADLOGID", "ROWSINSERTED", "IMPORTERRORS", "LEADIMPORT_ID", "IMPORTSOURCE", "USER_NEW", "DATE_NEW"]; -var insTypes = db.getColumnTypes(insTable, insFields); +var logTable = "LEADLOG"; +var logFields =["LEADLOGID", "ROWSINSERTED", "IMPORTERRORS", "LEADIMPORT_ID", "IMPORTSOURCE", "USER_NEW", "DATE_NEW"]; +var logVals = [util.getNewUUID(), rows, errorCount, importdefid, source, user, currDate]; -var insVals = [util.getNewUUID(), rows, errorCount, importdefid, source, user, currDate]; - -db.insertData(insTable, insFields, insTypes, insVals); -db.updateData(updTable, updFields, updTypes, updVals, "LEADIMPORTID = '" + importdefid + "'"); -db.deleteData("LEADTEMP", "ROW_ID = '" + importdefid + "'");//delete existing temp data +db.insertData(logTable, logFields, null, logVals); +newWhere("LEADIMPORT.LEADIMPORTID", importdefid) + .updateData(true, updTable, updFields, null, updVals); +newWhere("LEADTEMP.ROW_ID", importdefid) + .deleteData(true, "LEADTEMP");//delete existing temp data if(exeptions != "")//insert error document - db.insertBinary("LEADIMPORT", "DOCUMENT", assignmentRowId, + db.insertBinary("LEADLOG", "ERRORLOG", logVals[0], "", util.encodeBase64String(exeptions, "UTF-8"), "Error-Log " + source + " " + datetime.toDate(currDate, "dd.MM.yyyy HH:mm") , "", "", SqlUtils.getBinariesAlias()); if (userId)// if there is an user - show a notification to this user when the import is complete -- GitLab