我正在嘗試爲日曆活動實施通知。我已按照爲Alfresco網站日曆活動發送電子郵件通知
Email Notifications on Calendar Events in Alfresco
信的討論,但仍無法得到它的工作。我想在日曆活動發生前兩天根據日曆活動發送通知。它應該只發送給站點成員(值得注意的是,站點成員&所有用戶通常都是從ldap服務器中選取的)。
我的計劃行動服務-context.xml中看起來如下:
<!--
Define the model factory used to generate object models suitable for use with freemarker templates.
-->
<bean id="templateActionModelFactory" class="org.alfresco.repo.action.scheduled.FreeMarkerWithLuceneExtensionsModelFactory">
<property name="serviceRegistry">
<ref bean="ServiceRegistry"/>
</property>
</bean>
<!--
Execute the script /Company Home/Record Management/testscript.js
-->
<bean id="runScriptAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
<property name="actionName">
<value>script</value>
</property>
<property name="parameterTemplates">
<map>
<entry>
<key>
<value>script-ref</value>
</key>
<!-- Note that as of Alfresco 4.0, due to a Spring upgrade, the FreeMarker ${foo} entries must be escaped -->
<value>\$\{selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/app:dictionary/app:scripts/cm:calendar_notify.js"')\}</value>
</entry>
</map>
</property>
<property name="templateActionModelFactory">
<ref bean="templateActionModelFactory"/>
</property>
<property name="dictionaryService">
<ref bean="DictionaryService"/>
</property>
<property name="actionService">
<ref bean="ActionService"/>
</property>
<property name="templateService">
<ref bean="TemplateService"/>
</property>
</bean>
<!--
Run the script every minute - select the single node company home that is not used ...
-->
<bean id="runScript" class="org.alfresco.repo.action.scheduled.CronScheduledQueryBasedTemplateActionDefinition">
<property name="transactionMode">
<value>UNTIL_FIRST_FAILURE</value>
</property>
<property name="compensatingActionMode">
<value>IGNORE</value>
</property>
<property name="searchService">
<ref bean="SearchService"/>
</property>
<property name="templateService">
<ref bean="TemplateService"/>
</property>
<property name="queryLanguage">
<value>lucene</value>
</property>
<property name="stores">
<list>
<value>workspace://SpacesStore</value>
</list>
</property>
<property name="queryTemplate">
<!--<value>[email protected]\:fromDate:\$\{luceneDateRange(now, \"P10D\")\} AND +PATH:"/app:company_home/st:sites/cm:prova/cm:calendar//*"</value>-->
<value>+PATH:"/app:company_home/st:sites//*/cm:calendar//*" AND [email protected]\:fromDate:[NOW TO MAX]</value>
</property>
<property name="cronExpression">
<value>0 0/10 * * * ?</value>
</property>
<property name="jobName">
<value>jobD</value>
</property>
<property name="jobGroup">
<value>jobGroup</value>
</property>
<property name="triggerName">
<value>triggerD</value>
</property>
<property name="triggerGroup">
<value>triggerGroup</value>
</property>
<property name="scheduler">
<ref bean="schedulerFactory"/>
</property>
<property name="actionService">
<ref bean="ActionService"/>
</property>
<property name="templateActionModelFactory">
<ref bean="templateActionModelFactory"/>
</property>
<property name="templateActionDefinition">
<ref bean="runScriptAction"/> <!-- This is name of the action (bean) that gets run -->
</property>
<property name="transactionService">
<ref bean="TransactionService"/>
</property>
<property name="runAsUser">
<value>System</value>
</property>
</bean>
我的電子郵件模板中的位置發現
公司首頁>數據字典>電子郵件模板>通知郵件模板
和模板如下:
<html>
<head>
<style type="text/css"><!--
body
{
font-family: Arial, sans-serif;
font-size: 14px;
color: #4c4c4c;
}
a, a:visited
{
color: #0072cf;
}
.activity a
{
text-decoration: none;
}
.activity a:hover
{
text-decoration: underline;
}
--></style>
</head>
<body bgcolor="#dddddd">
<#assign displayPaths=document.displayPath?split("/")>
<#assign site=displayPaths[3]>
<#assign contenuto=document.content>
<table width="100%" cellpadding="20" cellspacing="0" border="0" bgcolor="#dddddd">
<tr>
<td width="100%" align="center">
<table width="70%" cellpadding="0" cellspacing="0" bgcolor="white" style="background-color: white; border: 1px solid #aaaaaa;">
<tr>
<td width="100%">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding: 20px 30px 0px;">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<div style="font-size: 22px; padding-bottom: 4px;">
Clinical Information Network reminds you that tomorrow ...
</div>
<div style="font-size: 14px; margin: 18px 0px 24px 0px; padding-top: 18px; border-top: 1px solid #aaaaaa;">
<div class="activity">
title: ${document.properties["{http://www.alfresco.org/model/calendar}whatEvent"]}
<br></br>
<br></br>
description: ${document.properties["{http://www.alfresco.org/model/calendar}descriptionEvent"]}
<br></br>
<br></br>
date: ${document.properties["{http://www.alfresco.org/model/calendar}fromDate"]?date}
<br></br>
<br></br>
from: ${document.properties["{http://www.alfresco.org/model/calendar}fromDate"]?time}
<br></br>
<br></br>
where: ${document.properties["{http://www.alfresco.org/model/calendar}whereEvent"]}
</div>
<div style="font-size: 11px; padding: 4px 0px 12px 0px;">
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<div style="border-top: 1px solid #aaaaaa;"> </div>
</td>
</tr>
<tr>
<td style="padding: 0px 30px; font-size: 13px;">
Please do not reply to this mail, the complete calendar is at:
http://host:8080/share/page/site/${site}/calendar
</td>
</tr>
<tr>
<td>
<div style="border-bottom: 1px solid #aaaaaa;"> </div>
</td>
</tr>
<tr>
<td style="padding: 10px 30px;">
<img src="${shareUrl}/themes/default/images/logo.png" alt="" width="117" height="48" border="0" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
和在
Company_Home > Data Dictionary > Scripts
發現calendar_notify.js的javascript如下所示:
var titoloEvento = document.properties["{http://www.alfresco.org/model/calendar}whatEvent"];
var fromDate = document.properties["{http://www.alfresco.org/model/calendar}fromDate"];
var today = new Date();
fromDate.setHours(0,0,0);
today.setHours(0,0,0);
var milli_fromDate = fromDate.getTime();
var milli_today = today.getTime();
var diff = fromDate - today;
var num_days =Math.round(diff/(86400000));
var person;
var email;
if (num_days == 1) {
var displayPaths=document.displayPath.split("/");
var siteName = displayPaths[3];
var site=siteService.getSite(siteName);
var siteMembers = site.listMembers(null,null,0);
if(siteMembers !=null){
for (userName in siteMembers){
person = people.getPerson(userName);
email = person.properties["cm:email"];
var mail = actions.create("mail");
mail.parameters.html = "html";
mail.parameters.to = email;
mail.parameters.template = search.findNode("workspace://SpacesStore/f98619dc-7b09-40c6-8057-2867728c45a0"); //please set the correct node reference for the email template
mail.parameters.subject = "Share reminder: "+titoloEvento;
mail.parameters.from = "[email protected]";
// execute action against a document
mail.execute(document);
}
}
}
什麼可能導致它失敗?我試圖找出最後48小時,我仍然不明白爲什麼它沒有執行。
您的-context無效,您有一個重複的bean id =「runScript&一個非關閉的bean-tag – alfrescian
對不起,我錯誤地粘貼了代碼,因爲我一直在複製段。反映它的實際情況,對不起,你能看看並告訴我可能是什麼問題嗎? –