use of org.netxms.client.reporting.ReportingJob in project netxms by netxms.
the class ReportExecutionForm method addSchedule.
/**
* Add schedule
*/
protected void addSchedule() {
final Map<String, String> execParameters = new HashMap<String, String>();
if (parameters != null) {
for (int i = 0; i < parameters.size(); i++) execParameters.put(parameters.get(i).getName(), fields.get(i).getValue());
}
final ReportingJob job = new ReportingJob(report);
final PropertyDialog dialog = PropertyDialog.createDialogOn(workbenchPart.getSite().getShell(), General.ID, job);
dialog.getShell().setText("Report Execution Schedule");
if (dialog.open() != Window.OK)
return;
new ConsoleJob("Adding report schedule", workbenchPart, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.scheduleReport(job, execParameters);
}
@Override
protected String getErrorMessage() {
return String.format("Cannot schedule report %s", report.getName());
}
}.start();
}
use of org.netxms.client.reporting.ReportingJob in project netxms by netxms.
the class ScheduleLabelProvider method getColumnText.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
@Override
public String getColumnText(Object element, int columnIndex) {
final ReportingJob job = (ReportingJob) element;
switch(columnIndex) {
case ReportExecutionForm.SCHEDULE_START_TIME:
// $NON-NLS-1$
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
String HHmm = timeFormat.format(job.getStartTime().getTime() / 1000);
switch(job.getType()) {
case ReportingJob.TYPE_ONCE:
return RegionalSettings.getDateTimeFormat().format(job.getStartTime().getTime() / 1000);
case ReportingJob.TYPE_DAILY:
return HHmm;
case ReportingJob.TYPE_MONTHLY:
// $NON-NLS-1$
String result = "";
for (int i = 0; i < 31; i++) {
if (((job.getDaysOfMonth() >> i) & 0x01) != 0)
// $NON-NLS-1$ //$NON-NLS-2$
result = String.valueOf(31 - i) + (result.length() > 0 ? "," : "") + result;
}
// $NON-NLS-1$
return HHmm + " - " + result;
case ReportingJob.TYPE_WEEKLY:
// $NON-NLS-1$
String result1 = "";
for (int i = 0; i < 7; i++) {
if (((job.getDaysOfWeek() >> i) & 0x01) != 0)
// $NON-NLS-1$ //$NON-NLS-2$
result1 = dayOfWeek[7 - (i + 1)] + (result1.length() > 0 ? "," : "") + result1;
}
// $NON-NLS-1$
return HHmm + " - " + result1;
default:
return Messages.get().ScheduleLabelProvider_Error;
}
case ReportExecutionForm.SCHEDULE_TYPE:
switch(job.getType()) {
case ReportingJob.TYPE_ONCE:
return Messages.get().ScheduleLabelProvider_Once;
case ReportingJob.TYPE_DAILY:
return Messages.get().ScheduleLabelProvider_Daily;
case ReportingJob.TYPE_MONTHLY:
return Messages.get().ScheduleLabelProvider_Monthly;
case ReportingJob.TYPE_WEEKLY:
return Messages.get().ScheduleLabelProvider_Weekly;
default:
return Messages.get().ScheduleLabelProvider_Error;
}
case ReportExecutionForm.SCHEDULE_OWNER:
AbstractUserObject user = ((NXCSession) ConsoleSharedData.getSession()).findUserDBObjectById(job.getUserId());
// $NON-NLS-1$ //$NON-NLS-2$
return (user != null) ? user.getName() : ("[" + job.getUserId() + "]");
case ReportExecutionForm.SCHEDULE_COMMENTS:
return job.getComments();
}
// $NON-NLS-1$
return "<INTERNAL ERROR>";
}
use of org.netxms.client.reporting.ReportingJob in project netxms by netxms.
the class NXCSession method listScheduledJobs.
/**
* List scheduled jobs
*
* @param reportId The report UUID
* @return List of ReportingJob objects
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public List<ReportingJob> listScheduledJobs(UUID reportId) throws NXCException, IOException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_RS_LIST_SCHEDULES);
msg.setField(NXCPCodes.VID_REPORT_DEFINITION, reportId);
sendMessage(msg);
NXCPMessage response = waitForRCC(msg.getMessageId());
List<ReportingJob> result = new ArrayList<ReportingJob>();
long varId = NXCPCodes.VID_ROW_DATA_BASE;
int num = response.getFieldAsInt32(NXCPCodes.VID_NUM_ITEMS);
for (int i = 0; i < num; i++) {
result.add(new ReportingJob(response, varId));
varId += 20;
}
return result;
}
Aggregations