此脚本可用于通过电子邮件将活动报表发送给收件人列表。然后可以调度此脚本每天运行,以获取每日活动报表。此脚本执行以下功能:
如果密码中包含特殊字符,请参阅“处理特殊字符”。此外,还要确保替换这些参数值以适应您的环境:
Table 4-2 要更改的参数
| 参数 | 说明 |
|---|---|
| user | 要登录环境的服务管理员的用户 ID。 |
| password | 服务管理员的密码。 |
| url | 云 EPM 环境的 URL,将从该环境通过电子邮件发送活动报表。 |
| emailaddresses | 活动报表要发送到的电子邮件地址的分号分隔列表。 |
有关使用 Groovy 规则的详细信息,请参阅《管理 Planning》中的“使用 Groovy 规则”。
/*RTPS: {user} {password} {url} {emailaddresses}*/
import java.text.SimpleDateFormat
String user = 'service_administrator'
String password = 'examplePWD'
String url = 'example_EPM_URL'
String emailaddresses = 'service_administrator@oracle.com'
EpmAutomate automate = getEpmAutomate()
def LogMessage(String message) {
def date = new Date()
def sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
println('[' + sdf.format(date) + '][GROOVY] ' + message);
}
def LogOperationStatus(EpmAutomateStatus opstatus) {
def returncode = opstatus.getStatus()
LogMessage(opstatus.getOutput())
LogMessage('return code: ' + returncode)
}
LogMessage('Starting mail activity report processing')
// encrypt
LogMessage("Operation: encrypt " + password + " oracleKey password.epw")
EpmAutomateStatus status = automate.execute('encrypt',password,"oracleKey","password.epw")
LogOperationStatus(status)
// login
LogMessage("Operation: login " + user + " password.epw " + url)
status = automate.execute('login',user,"password.epw",url)
LogOperationStatus(status)
// listfiles
LogMessage('Operation: listfiles')
status = automate.execute('listfiles')
LogOperationStatus(status)
String filelist = status.getItemsList()
String[] str = filelist.split(',');
String reportfile = ''
for( String svalues : str ) {
String[] ftr = svalues.split('/')
for( String fvalues : ftr ) {
if (fvalues.startsWith('2') && fvalues.endsWith('html')) {
reportfile = fvalues
}
}
}
def reportdir = reportfile.tokenize(".")[0]
String reportpath = 'apr/' + reportdir + '/' + reportfile
// sendMail
LogMessage('Operation: sendMail ' + emailaddresses + ' Daily Activity Report Body=Daily Activity Report Attachments=' + reportpath)
status = automate.execute('sendmail',emailaddresses,'Daily Activity Report','Body=Daily Activity Report',"Attachments=${reportpath}")
LogOperationStatus(status)
// logout
LogMessage('Operation: logout')
status = automate.execute('logout')
LogOperationStatus(status)