private void _btnSaveOnClick(object sender, EventArgs e) { if (_task == null) { _task = new DiagnosticsTaskInfo(); } if (_task.TaskId.IsEmpty) { _task.TaskId = BplIdentity.Get(Guid.NewGuid().ToString()); if (textName.Text == "") { MessageBox.Show("Enter task name", "Task name is empty", MessageBoxButtons.OK, MessageBoxIcon.Error); textName.Focus(); return; } _task.TaskName = textName.Text; if (((DiagnosticsTaskType)cmbType.SelectedItem) == DiagnosticsTaskType.None) { MessageBox.Show("Enter correct task type", "Incorrect task type", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbType.Focus(); return; } _task.TaskType = (DiagnosticsTaskType)cmbType.SelectedItem; } try { _task.TaskSchedule = TimeSpan.Parse(textSchedule.Text); } catch (Exception ex) { MessageBox.Show("Enter schedule in correct format", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); textSchedule.Focus(); return; } if (textData.Text != "") { _task.TaskData = System.Text.Encoding.Unicode.GetBytes(textData.Text); } var req = new SaveDiagnosticsTask(); req.Task = _task.Clone(); SendRequest(req); }
private void _listTasksOnSelectedIndexChanged(object sender, EventArgs e) { if (listTasks.SelectedItems.Count == 0) { return; } var taskItem = (TaskListItem)listTasks.SelectedItems[0]; _selectedTask = taskItem.Task; _listDevicesRefresh(); }
public TaskListItem(DiagnosticsTaskInfo task) { _task = task; Text = _task.TaskName; SubItems.Add(_task.TaskType.ToString()); SubItems.Add(_task.TaskSchedule.ToString()); SubItems.Add(_task.TaskId.LocalId.ToString()); }
private void _listTasksRefresh() { _selectedTask = null; listTasks.Items.Clear(); _selectedDevice = null; listDevices.Items.Clear(); var req = new GetAllDiagnosticsTasks(); SendRequest(req); }