?? reportscheduleaction.java
字號:
/*
* Copyright (C) 2002 Erik Swenson - eswenson@opensourcesoft.net
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if
* not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
package org.efs.openreports.actions;
import java.util.Date;
import java.util.Map;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
import org.apache.log4j.Logger;
import org.efs.openreports.ORStatics;
import org.efs.openreports.objects.Report;
import org.efs.openreports.objects.ReportSchedule;
import org.efs.openreports.objects.ReportUser;
import org.efs.openreports.providers.*;
public class ReportScheduleAction
extends ActionSupport
implements SchedulerProviderAware, DateProviderAware
{
protected static Logger log = Logger.getLogger(ReportScheduleAction.class);
private String submitType;
private Report report;
private int scheduleType;
private String startDate;
private String startHour;
private String startMinute;
private String startAmPm;
private String recipients;
private SchedulerProvider schedulerProvider;
private DateProvider dateProvider;
public String execute()
{
ReportUser user =
(ReportUser) ActionContext.getContext().getSession().get(ORStatics.REPORT_USER);
report = (Report) ActionContext.getContext().getSession().get(ORStatics.REPORT);
if (user.getEmail() == null || user.getEmail().length() < 1)
{
addActionError("You must update your email address before scheduling reports!");
return INPUT;
}
if (recipients == null || recipients.length() < 1)
{
recipients = user.getEmail();
}
if (submitType != null && submitType.equals("Schedule"))
{
if (startDate == null
|| startDate.length() < 1
|| startHour == null
|| startHour.length() < 1
|| startMinute == null
|| startMinute.length() < 1
|| startAmPm == null
|| startAmPm.length() < 1)
{
addActionError("Start Date and Time required to schedule report.");
return INPUT;
}
try
{
Map reportParameters =
(Map) ActionContext.getContext().getSession().get(ORStatics.REPORT_PARAMETERS);
int exportType =
Integer.parseInt(
(String) ActionContext.getContext().getSession().get(ORStatics.EXPORT_TYPE));
ReportSchedule reportSchedule = new ReportSchedule();
reportSchedule.setReport(report);
reportSchedule.setUser(user);
reportSchedule.setReportParameters(reportParameters);
reportSchedule.setScheduleType(scheduleType);
reportSchedule.setStartDate(dateProvider.parseDate(startDate));
reportSchedule.setStartHour(startHour);
reportSchedule.setStartMinute(startMinute);
reportSchedule.setStartAmPm(startAmPm);
reportSchedule.setRecipients(recipients);
reportSchedule.setExportType(exportType);
reportSchedule.setScheduleName(report.getId() + "|" + new Date().getTime());
schedulerProvider.scheduleReport(reportSchedule);
}
catch (Exception e)
{
addActionError(e.getMessage());
return INPUT;
}
addActionError("Report scheduled successfully...");
}
return INPUT;
}
public Report getReport()
{
return report;
}
public void setReport(Report report)
{
this.report = report;
}
public void setSchedulerProvider(SchedulerProvider schedulerProvider)
{
this.schedulerProvider = schedulerProvider;
}
public String getSubmitType()
{
return submitType;
}
public void setSubmitType(String submitType)
{
this.submitType = submitType;
}
public int getScheduleType()
{
return scheduleType;
}
public void setScheduleType(int scheduleType)
{
this.scheduleType = scheduleType;
}
public String getStartAmPm()
{
return startAmPm;
}
public void setStartAmPm(String startAmPm)
{
this.startAmPm = startAmPm;
}
public String getStartDate()
{
return startDate;
}
public void setStartDate(String startDate)
{
this.startDate = startDate;
}
public String getStartHour()
{
return startHour;
}
public void setStartHour(String startHour)
{
this.startHour = startHour;
}
public String getStartMinute()
{
return startMinute;
}
public void setStartMinute(String startMinute)
{
this.startMinute = startMinute;
}
public void setDateProvider(DateProvider dateProvider)
{
this.dateProvider = dateProvider;
}
public String getRecipients()
{
return recipients;
}
public void setRecipients(String recipients)
{
this.recipients = recipients;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -