use of org.netxms.client.ScheduledTask in project netxms by netxms.
the class UploadFileToAgent method run.
/**
* @see IActionDelegate#run(IAction)
*/
public void run(IAction action) {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
boolean canScheduleFileUpload = (session.getUserSystemRights() & UserAccessRights.SYSTEM_ACCESS_SCHEDULE_FILE_UPLOAD) > 0;
final StartServerToAgentFileUploadDialog dlg = new StartServerToAgentFileUploadDialog(shell, canScheduleFileUpload);
if (dlg.open() == Window.OK) {
final Long[] nodeIdList = nodes.toArray(new Long[nodes.size()]);
new ConsoleJob(Messages.get().UploadFileToAgent_JobTitle, viewPart, Activator.PLUGIN_ID, null) {
@Override
protected String getErrorMessage() {
return Messages.get().UploadFileToAgent_JobError;
}
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
boolean multipleFiles = dlg.getServerFiles().size() > 1;
for (ServerFile sf : dlg.getServerFiles()) {
String remoteFileName = dlg.getRemoteFileName();
if (!remoteFileName.isEmpty()) {
if (// $NON-NLS-1$ //$NON-NLS-2$
remoteFileName.endsWith("/") || remoteFileName.endsWith("\\")) {
remoteFileName += sf.getName();
} else if (multipleFiles) {
remoteFileName += "/" + sf.getName();
}
} else {
if (!dlg.isScheduled())
remoteFileName = null;
}
for (int i = 0; i < nodeIdList.length; i++) {
if (dlg.isScheduled()) {
ScheduledTask task = dlg.getScheduledTask();
// $NON-NLS-1$
String parameters = sf.getName() + "," + remoteFileName;
task.setParameters(parameters);
task.setObjectId(nodeIdList[i]);
session.addSchedule(task);
} else {
session.uploadFileToAgent(nodeIdList[i], sf.getName(), remoteFileName, dlg.isCreateJobOnHold());
}
}
}
}
}.start();
}
}
use of org.netxms.client.ScheduledTask in project netxms by netxms.
the class ScheduleMaintenance method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
ISelection selection = window.getActivePage().getSelection();
if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
return null;
final MaintanenceScheduleDialog dialog = new MaintanenceScheduleDialog(window.getShell());
if (dialog.open() != Window.OK)
return null;
final Object[] objects = ((IStructuredSelection) selection).toArray();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
new ConsoleJob(Messages.get().SetObjectManagementState_JobTitle, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object o : objects) {
if (o instanceof AbstractObject) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ScheduledTask taskStart = new ScheduledTask("Maintenance.Enter", "", "", "", dialog.getStartDate(), ScheduledTask.SYSTEM, ((AbstractObject) o).getObjectId());
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
ScheduledTask taskEnd = new ScheduledTask("Maintenance.Leave", "", "", "", dialog.getEndDate(), ScheduledTask.SYSTEM, ((AbstractObject) o).getObjectId());
session.addSchedule(taskStart);
session.addSchedule(taskEnd);
}
}
}
@Override
protected String getErrorMessage() {
return Messages.get().SetObjectManagementState_JobError;
}
}.start();
return null;
}
use of org.netxms.client.ScheduledTask in project netxms by netxms.
the class ScheduledTaskView method deleteTask.
/**
* Delete task
*/
protected void deleteTask() {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() == 0)
return;
if (!MessageDialogHelper.openQuestion(getSite().getShell(), "Confirm Task Delete", (selection.size() == 1) ? "Selected task will be deleted. Are you sure?" : "Selected tasks will be deleted. Are you sure?"))
return;
new ConsoleJob("Delete scheduled task", null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object o : selection.toList()) {
session.removeSchedule(((ScheduledTask) o).getId());
}
}
@Override
protected String getErrorMessage() {
return "Cannot delete scheduled tasks";
}
}.start();
}
use of org.netxms.client.ScheduledTask in project netxms by netxms.
the class ScheduledTaskView method setScheduledTaskEnabled.
/**
* @param enabled
*/
protected void setScheduledTaskEnabled(final boolean enabled) {
final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() < 0)
return;
new ConsoleJob("Update scheduled task", null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
for (Object o : selection.toList()) {
ScheduledTask task = (ScheduledTask) o;
task.setEnabed(enabled);
session.updateSchedule(task);
}
}
@Override
protected String getErrorMessage() {
return "Cannot update scheduled tasks";
}
}.start();
}
use of org.netxms.client.ScheduledTask in project netxms by netxms.
the class ScheduledTaskView method fillContextMenu.
/**
* Fill context menu
* @param mgr Menu manager
*/
protected void fillContextMenu(IMenuManager mgr) {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() == 1) {
mgr.add(actionEdit);
ScheduledTask origin = (ScheduledTask) selection.toList().get(0);
if (origin.getSchedule().isEmpty())
mgr.add(actionReschedule);
}
boolean containDisabled = false;
boolean containEnabled = false;
for (Object o : selection.toList()) {
if (((ScheduledTask) o).isDisbaled())
containDisabled = true;
else
containEnabled = true;
if (containDisabled && containEnabled)
break;
}
if (containDisabled)
mgr.add(actionEnable);
if (containEnabled)
mgr.add(actionDisable);
if (selection.size() > 0)
mgr.add(actionDelete);
mgr.add(new Separator());
mgr.add(actionCreate);
}
Aggregations