From 23853b339f7628c429ab719caa9fef23e0c3a9f6 Mon Sep 17 00:00:00 2001 From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local> Date: Wed, 31 Jul 2019 12:48:37 +0200 Subject: [PATCH] Bulkmail --- entity/BulkMail_entity/BulkMail_entity.aod | 6 ++++++ .../entityfields/testmail/onActionProcess.js | 4 ++++ process/Bulkmail_lib/process.js | 7 +++++-- process/sendBulkMail_serverProcess/process.js | 3 ++- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 entity/BulkMail_entity/entityfields/testmail/onActionProcess.js diff --git a/entity/BulkMail_entity/BulkMail_entity.aod b/entity/BulkMail_entity/BulkMail_entity.aod index 5d149ff585..74c3e84fb8 100644 --- a/entity/BulkMail_entity/BulkMail_entity.aod +++ b/entity/BulkMail_entity/BulkMail_entity.aod @@ -180,6 +180,12 @@ </entityParameter> </children> </entityConsumer> + <entityActionField> + <name>testMail</name> + <title>Test email</title> + <onActionProcess>%aditoprj%/entity/BulkMail_entity/entityfields/testmail/onActionProcess.js</onActionProcess> + <iconId>VAADIN:CLIPBOARD_CHECK</iconId> + </entityActionField> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/BulkMail_entity/entityfields/testmail/onActionProcess.js b/entity/BulkMail_entity/entityfields/testmail/onActionProcess.js new file mode 100644 index 0000000000..9dcf990316 --- /dev/null +++ b/entity/BulkMail_entity/entityfields/testmail/onActionProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("Bulkmail_lib"); + +BulkMailUtils.sendBulkMailOnServer(vars.get("$field.BULKMAILID")); \ No newline at end of file diff --git a/process/Bulkmail_lib/process.js b/process/Bulkmail_lib/process.js index f262b0fc0c..d143652488 100644 --- a/process/Bulkmail_lib/process.js +++ b/process/Bulkmail_lib/process.js @@ -22,16 +22,18 @@ function BulkMailUtils () {} * Executes a process to send bulk mails on the server and creates a notification when finished. * * @param {String} pBulkMailId id of the bulk mail + * @param {Array} [pRecipients=bulkMailRecipients] overwrite the recipients (e.g. for testing) * @param {String} [pUser=currentUser] User that will get the notification, if null (not undefined!), no notification * will be created. */ -BulkMailUtils.sendBulkMailOnServer = function (pBulkMailId, pUser) +BulkMailUtils.sendBulkMailOnServer = function (pBulkMailId, pRecipients, pUser) { if (pUser === undefined) pUser = EmployeeUtils.getCurrentUserId(); process.execute("sendBulkMail_serverProcess", { bulkMailId : pBulkMailId, + recipients : JSON.stringify(pRecipients), user : pUser || "" } ); @@ -42,10 +44,11 @@ BulkMailUtils.sendBulkMailOnServer = function (pBulkMailId, pUser) * can take some time to execute, use BulkMailUtils.sendBulkMailOnServer instead. * * @param {String} pBulkMailId id of the bulk mail + * @param {Array} [pRecipients=bulkMailRecipients] overwrite the recipients (e.g. for testing) * * @return {Object} count of sucessful and failed mails */ -BulkMailUtils.sendBulkMail = function (pBulkMailId) +BulkMailUtils.sendBulkMail = function (pBulkMailId, pRecipients) { var [templateId, subject, emailSender] = db.array(db.ROW, SqlCondition.begin() .andPrepare("BULKMAIL.BULKMAILID", pBulkMailId) diff --git a/process/sendBulkMail_serverProcess/process.js b/process/sendBulkMail_serverProcess/process.js index 68c0371b37..89c76bc289 100644 --- a/process/sendBulkMail_serverProcess/process.js +++ b/process/sendBulkMail_serverProcess/process.js @@ -10,7 +10,8 @@ import("system.notification"); var startTime = datetime.date(); var bulkMailId = vars.get("$local.bulkMailId"); var user = vars.get("$local.user"); -var res = BulkMailUtils.sendBulkMail(bulkMailId); +var recipients = JSON.parse(vars.get("$local.recipients")); +var res = BulkMailUtils.sendBulkMail(bulkMailId, recipients); if (user) { -- GitLab