private void TasksForm_Load(object sender, EventArgs e) { DataContext.tasks = new List <Task>(); DataContext.profiles = new List <Profile>(); using (FileStream fs = new FileStream("tasks.xml", FileMode.OpenOrCreate)) { try { DataContext.tasks = (List <Task>)DataContext.taskFormatter.Deserialize(fs); foreach (var task in DataContext.tasks) { TaskListItem item = new TaskListItem(task, this); TasksLayoutPanel.Controls.Add(item); } } catch { StatusLabel.Text = "..."; } } using (FileStream fs = new FileStream("profiles.xml", FileMode.OpenOrCreate)) { try { DataContext.profiles = (List <Profile>)DataContext.profileFormatter.Deserialize(fs); } catch { StatusLabel.Text = "Добавьте профили."; } } }
public void CreateTaskListItem(TaskListItem taskListItem) { ToDoContext dbContext = new ToDoContext(); int id = taskListItem.TaskList.Id; var actualTasklist = dbContext.TaskLists.Where(u => u.Id == id).SingleOrDefault(); TaskListItem tListItem = new TaskListItem { Id = taskListItem.Id, Text = taskListItem.Text, IsCompleted = taskListItem.IsCompleted, TaskList = actualTasklist }; if (tListItem.TaskList.User.Id == _securityManager.GetLoggedUserId()) { dbContext.TaskListItems.Add(tListItem); try { dbContext.SaveChanges(); } catch (Exception) { _logManager.Error("Task List Item cannot be created. Information: " + taskListItem.Id + taskListItem.Text + taskListItem.TaskList.Name); throw new TaskListItemException("Task List Item cannot be created"); } } else { throw new TaskListItemException("Task List Item cannot be created. Current user doesn't have such a a Task"); } }
public void UpdateTaskListItem(TaskListItem taskListItem) { ToDoContext dbContext = new ToDoContext(); int id = taskListItem.Id; TaskListItem itemToUpdate = dbContext.TaskListItems.Include("TaskList").Where(i => i.Id == id).SingleOrDefault(); int taskListId = taskListItem.TaskList.Id; List <TaskListItem> taskListItems = dbContext.TaskListItems.Where(n => n.TaskList.Id == taskListId).ToList(); if (taskListItems.Contains(itemToUpdate)) { try { itemToUpdate.Text = taskListItem.Text; itemToUpdate.IsCompleted = taskListItem.IsCompleted; dbContext.SaveChanges(); } catch (Exception) { _logManager.Error("Error updating database with given Task"); throw new TaskListItemException("Task List Item cannot be updated"); } } else { _logManager.Error("Current User doesnt have a Task he wants to update"); _logManager.Debug("User info: " + _securityManager.GetLoggedUser().Id + " Task List info: " + taskListItem.Id + " TaskList appropriate User " + _securityManager.GetLoggedUser().Id); throw new TaskListItemNotFoundException("Task List Item cannot be updated. There is no provided item in this Task List"); } }
private static Exception GetSourceException(TaskListItem <IMessagePublisher> taskItem) { // Get the aggregate inner exception. var taskException = taskItem.Task.Exception; return(taskException?.InnerException); }
public void UpdateTaskListItem(int id) { TextBox nameBox = Application.OpenForms["frmMain"].Controls["ItemNewName"] as TextBox; CheckBox checkBox = Application.OpenForms["frmMain"].Controls["ItemIsCompletedUpdate"] as CheckBox; ListBox taskListBox = Application.OpenForms["frmMain"].Controls["taskList"] as ListBox; DataGridView itemsGridView = Application.OpenForms["frmMain"].Controls["ItemsGridView"] as DataGridView; TaskListItem currentObject = (TaskListItem)itemsGridView.CurrentRow.DataBoundItem; if (nameBox.Text != "") { int TaskListId = int.Parse(taskListBox.SelectedValue.ToString()); TaskList taskList = _taskListManager.GetTaskList(TaskListId); int ItemId = currentObject.Id; TaskListItem taskListItem = new TaskListItem { Id = ItemId, Text = nameBox.Text, IsCompleted = checkBox.Checked, TaskList = taskList }; try { _taskListManager.UpdateTaskListItem(taskListItem); } catch (TaskListItemException e) { MessageBox.Show(e.Message); } catch { MessageBox.Show("There is nothing selected to update"); } } else { MessageBox.Show("Don't add a blank Item"); } }
public static List <TaskListItem> GetTaskListItems() { List <TaskListItem> Items = new List <TaskListItem>(); for (int i = 1; i < 20; i++) { TaskListItem Item = new TaskListItem(); Item.Id = i; Item.TaskTitle = "Title of Item " + i.ToString(); Item.TaskDescription = "This is a thing I need done."; if (i % 2 == 0) { Item.Status = ItemStatus.CheckedOut; Item.Category = ItemCategory.PhysicalLabor; Item.DatePosted = new DateTime(2020, 11, i); } else if (i % 3 == 0) { Item.Status = ItemStatus.Done; Item.Category = ItemCategory.LearningSkill; Item.DatePosted = new DateTime(2020, 10, i); } else { Item.Status = ItemStatus.Open; Item.Category = ItemCategory.HomeCare; Item.DatePosted = new DateTime(2020, 12, i); } Items.Add(Item); } return(Items); }
void _worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { try { if (e.Result is TaskRunResult) { TaskRunResult _result = e.Result as TaskRunResult; TaskListItem _task = TaskList.Tasks[_result.TaskName]; _task.TaskRunResult = _result; _task.LastResult = 0; _task.LastFinishedTime = DateTime.Now; _task.State = 0; application.WriteMessage(string.Format("任务[{0}]执行完毕!{1}", _task.TaskName, _result.ResultMsg), EventLogEntryType.Information); } else if (e.Result is string) { string _ex = e.Result as string; application.WriteMessage("任务执行失败!" + _ex, EventLogEntryType.Error); } else { application.WriteMessage("任务执行失败!返回信息为null!", EventLogEntryType.Error); } } catch (Exception ex) { application.WriteMessage("未知错误!", EventLogEntryType.Error); } }
private void AddTaskBtn_Click(object sender, EventArgs e) { StatusLabel.Text = "Добавление таска..."; AddingTaskForm form = new AddingTaskForm(); DialogResult result = form.ShowDialog(this); if (result == DialogResult.Cancel) { StatusLabel.Text = "..."; return; } Task task = new Task() { Profile = DataContext.profiles.Find(profile => profile.ID == form.comboBox1.SelectedIndex), Size = form.comboBox2.Text, Proxy = form.proxyCheck.Checked, Url = form.textBox1.Text }; DataContext.tasks.Add(task); using (FileStream fs = new FileStream("tasks.xml", FileMode.Open)) { DataContext.taskFormatter.Serialize(fs, DataContext.tasks); StatusLabel.Text = "Таск сохранен!"; } TaskListItem item = new TaskListItem(task, this); TasksLayoutPanel.Controls.Add(item); }
public void UpdateTaskListItem() { Console.WriteLine("Write an ID of Task Item you want to update"); int id = Int32.Parse(Console.ReadLine()); Console.WriteLine("Write a new text for your Task List"); string text = Console.ReadLine(); Console.WriteLine("Is it Completed? Write yes or no"); string textCompleted = Console.ReadLine(); bool Completed = textCompleted.Equals("yes") ? true : false; TaskList taskList = _taskListManager.GetTaskList(ACTUAL_TASK_LIST_ID); TaskListItem taskListItem = new TaskListItem { Id = id, Text = text, IsCompleted = Completed, TaskList = taskList }; try { _taskListManager.UpdateTaskListItem(taskListItem); Console.WriteLine("Done"); } catch { Console.WriteLine("There is no such a Task List Item"); } System.Threading.Thread.Sleep(1000); ListTaskListItems(); }
public void DeleteTaskListItem(TaskListItem taskListItem) { ToDoContext dbContext = new ToDoContext(); int id = taskListItem.Id; TaskListItem itemToDelete = dbContext.TaskListItems.Include("TaskList").Where(i => i.Id == id).SingleOrDefault(); int taskListId = taskListItem.TaskList.Id; List <TaskListItem> taskListItems = dbContext.TaskListItems.Where(n => n.TaskList.Id == taskListId).ToList(); if (taskListItems.Contains(itemToDelete)) { try { dbContext.TaskListItems.Remove(itemToDelete); dbContext.SaveChanges(); _logManager.Info("Task List Item from this Task List deleted" + itemToDelete.Id); } catch (Exception) { _logManager.Debug("Error task list info: " + itemToDelete.Id + " " + itemToDelete.Text + " " + itemToDelete.TaskList.Id); throw new TaskListItemException("Task List Item cannot be deleted"); } } else { _logManager.Error("Current User doesnt have a Task he wants to delete"); throw new TaskListItemNotFoundException("Task List Item cannot be deleted. Current user doesnt have specified Task"); } }
public void DeleteTaskListItem(int id) { ListBox taskListBox = Application.OpenForms["frmMain"].Controls["taskList"] as ListBox; DataGridView itemsGridView = Application.OpenForms["frmMain"].Controls["ItemsGridView"] as DataGridView; TaskListItem currentItemObject = (TaskListItem)itemsGridView.CurrentRow.DataBoundItem; int taskListId = int.Parse(taskListBox.SelectedValue.ToString()); TaskList taskList = _taskListManager.GetTaskList(taskListId); int itemId = currentItemObject.Id; string text = currentItemObject.Text; bool completed = currentItemObject.IsCompleted; TaskListItem taskListItem = new TaskListItem { Id = itemId, Text = text, IsCompleted = completed, TaskList = taskList }; try { _taskListManager.DeleteTaskListItem(taskListItem); } catch (TaskListItemException e) { MessageBox.Show(e.Message); } catch { MessageBox.Show("There is nothing selected to delete"); } }
public static async Task <TaskListItem> RetryAddTaskList(IList <object> obj) { var restRequest = new RestRequest(Method.POST) { RequestFormat = DataFormat.Json, Resource = "https://www.googleapis.com/tasks/v1/users/@me/lists", Timeout = GTaskSettings.RequestTimeout }; var ignored = "{title:\"" + ((TaskListItem)obj[0]).title + "\"}"; restRequest.AddParameter("application/json", ignored, ParameterType.RequestBody); //Make the call var restResponse = await GTaskSettings.ExecuteRestTask(restRequest); try { if (restResponse.StatusCode == HttpStatusCode.OK) { if (obj.Count > 1) { var callback = obj[1] as Action <bool>; if (callback != null) { callback(true); } } var TaskListObject = JObject.Parse(restResponse.Content); var TaskList = new TaskListItem((string)TaskListObject.SelectToken("title"), (string)TaskListObject.SelectToken("id"), (string)TaskListObject.SelectToken("kind"), (string)TaskListObject.SelectToken("selfLink"), (string)TaskListObject.SelectToken("updated")); // Submit new task list to local storage too List <TaskListItem> list = await TaskListHelper.GetTaskListFromApplicationStorage(); TaskListItem newList = new TaskListItem((string)TaskListObject.SelectToken("title"), (string)TaskListObject.SelectToken("id"), (string)TaskListObject.SelectToken("kind"), (string)TaskListObject.SelectToken("selfLink"), (string)TaskListObject.SelectToken("updated")); // Add this new list to the local list list.Add(newList); // Submit the list to local storage await TaskListHelper.SubmitToLocalStorage(list); return(TaskList); } } catch { } return(null); }
public void UpdateView() { foreach (LogEntry entry in FEntries) { TaskListItem OTask = entry.GetTask(FvsHierarchy); OTask.Navigate += OTask_Navigate; FProvider.Tasks.Add(OTask); } }
void OTask_Navigate(object sender, EventArgs e) { TaskListItem OTask = (TaskListItem)sender; OTask.Line++; OTask.Column++; FProvider.Navigate(OTask, new Guid(EnvDTE.Constants.vsViewKindCode)); OTask.Line--; OTask.Column--; }
public static TaskListItemViewModel ToViewModel(this TaskListItem item) { return(new TaskListItemViewModel { Id = item.Id, Title = item.Title, Creator = item.Creator, Contractor = item.Contractor, CreatedDate = item.CreatedDate.ToString() }); }
private static MessageDispatchException GetDispatchException(TaskListItem <MessageDispatchInfo> taskItem) { var sourceEx = taskItem.Task.Exception?.InnerException; if (sourceEx is MessageDispatchException dispatchEx) { return(dispatchEx); } return(new MessageDispatchException("Error calling message consumer.", taskItem.Invoker, sourceEx)); }
public void DeleteTask(TaskListItem item, Task task) { TasksLayoutPanel.Controls.Remove(item); DataContext.tasks.Remove(task); using (FileStream fs = new FileStream("tasks.xml", FileMode.Create)) { DataContext.taskFormatter.Serialize(fs, DataContext.tasks); StatusLabel.Text = $"Таск с именем {task.Profile.Name} удален."; } }
private void ShowDetailsButton_Click(object sender, EventArgs e) { if (ItemsGridView.CurrentRow != null) { TaskListItem currentObject = (TaskListItem)ItemsGridView.CurrentRow.DataBoundItem; string text = currentObject.Text.ToString(); TaskListItemWinForm taskListItemWinForm = DependencyResolver.Container.Resolve <TaskListItemWinForm>(); taskListItemWinForm.ShowDetails(text); } else { MessageBox.Show("Nothing to show"); } }
private void ItemsGridView_CellClick(object sender, DataGridViewCellEventArgs e) { TaskListItem currentObject = (TaskListItem)ItemsGridView.CurrentRow.DataBoundItem; string text = currentObject.Text.ToString(); if (string.IsNullOrEmpty(text)) { selectedItem.Text = text; } else { selectedItem.Text = text.Length <= 25 ? text : text.Substring(0, 25) + "..."; } }
/// <summary> /// Remove an item to the list /// </summary> /// <param name="itemText">Title of the added Item</param> public void RemoveListItem(TaskListItem item) { items.Remove(item); foreach (var taskListItem in content.transform.GetComponentsInChildren <TaskListItem>()) { if (taskListItem.Id == item.Id) { Destroy(taskListItem.gameObject); Debug.Log($"Removed {item.name}"); } } UpdateList(); }
public async void OnTappedTasks(object sender, EventArgs e) { try { if (Device.RuntimePlatform.ToLower() != "android") { return; } if (sender is StackLayout) { // lstCurrentItems.BeginRefresh(); var menuItem = ((StackLayout)sender); if (menuItem != null && menuItem.BindingContext != null) { TaskListItem item = ((TaskListItem)menuItem.BindingContext); bool wasExpanded = item.IsExpanded; foreach (var task in viewModel.CurrentItems) { if (task.TaskScheduleCurrentState == item.TaskScheduleCurrentState) { if (task.IsHeader) { task.IsExpanded = !wasExpanded; if (task.IsExpanded) { task.Icon = "Arrow_down.png"; } else { task.Icon = "Arrow_right.png"; } } else { task.IsItemVisible = !wasExpanded; } } } } } } catch (Exception ex) { } }
/// <summary> /// Constructor. /// </summary> /// <param name="taskItem">The task item containing the exception.</param> public EnricherException(TaskListItem <IMessageEnricher> taskItem) : base("Enricher Exception", GetSourceException(taskItem)) { if (taskItem == null) { throw new NullReferenceException(nameof(taskItem)); } var sourceException = GetSourceException(taskItem); Details = new Dictionary <string, object> { { "Exception", sourceException?.ToString() }, { "Enricher", taskItem.Invoker.GetType().FullName } }; }
public IHttpActionResult PostNewTask(int taskListId, string text, bool isCompleted) { try { var taskList = _taskListManager.GetTaskList(taskListId); TaskListItem task = new TaskListItem { Text = text, IsCompleted = isCompleted, TaskList = taskList }; _taskListManager.CreateTaskListItem(task); return(Ok("Task: " + text + " IsCompleted: " + isCompleted + " created")); } catch (TaskListNotFoundException e) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, e.Message))); } }
public ActionResult EditTaskListItem(int id, string text, bool isCompleted) { TaskListItem emptyTaskListItem = null; int taskListId = int.Parse(Session["TaskListId"].ToString()); TaskList taskList = _taskListManager.GetTaskList(taskListId); TaskListItem taskListItem = new TaskListItem { Id = id, Text = text, IsCompleted = isCompleted, TaskList = taskList }; try { _taskListManager.UpdateTaskListItem(taskListItem); TempData["ConfirmationMessage"] = "Task edited successfully"; return(RedirectToAction("GetTaskListItems", "TaskListItem", new { Id = Session["TaskListId"] })); } catch (TaskListItemException e) { ModelState.AddModelError("", e.Message); TempData["ConfirmationMessage"] = "Task not edited"; return(View(emptyTaskListItem)); } //string apiUrl = "http://localhost:51004/TaskList/Tasks/Update/"; //using (HttpClient client = new HttpClient()) //{ // client.BaseAddress = new Uri(apiUrl); // client.DefaultRequestHeaders.Accept.Clear(); // client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); // var parameters = new Dictionary<string, string> { { "id", Id }, { "text", text }, { "isCompleted", _isCompleted} }; // var encodedContent = new FormUrlEncodedContent(parameters); // var putTask = client.PutAsJsonAsync(apiUrl + TaskListId +"/" +Id + "/" + text + "/" + _isCompleted, parameters); // putTask.Wait(); // var result = putTask.Result; // if (result.IsSuccessStatusCode) // { // return RedirectToAction("GetTaskListItems", "TaskListItem", new { Id = Session["TaskListId"] }); // } // return View(taskListItem); //} }
public IHttpActionResult DeleteTask(int taskListId, int taskId) { var taskList = _taskListManager.GetTaskList(taskListId); TaskListItem task = new TaskListItem { Id = taskId, TaskList = taskList }; try { _taskListManager.DeleteTaskListItem(task); return(Ok("Task with Id: " + taskId + " deleted")); } catch { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Task not deleted"))); } }
public ActionResult CreateTaskListItem(string text, bool isCompleted) { int id = int.Parse(Session["TaskListId"].ToString()); try { TaskList taskList = _taskListManager.GetTaskList(id); TaskListItem taskListItem = new TaskListItem { Text = text, IsCompleted = isCompleted, TaskList = taskList }; _taskListManager.CreateTaskListItem(taskListItem); TempData["ConfirmationMessage"] = "Task created successfully"; return(RedirectToAction("CreateTaskListItemView", "TaskListItem")); } catch (TaskListItemException e) { ModelState.AddModelError("", e.Message); TempData["ConfirmationMessage"] = "Task not created"; return(RedirectToAction("CreateTaskListItemView", "TaskListItem")); } //string apiUrl = "http://localhost:51004/TaskList/Tasks/Add/"; //using (HttpClient client = new HttpClient()) //{ // string _isCompleted = isCompleted.ToString(); // client.BaseAddress = new Uri(apiUrl); // client.DefaultRequestHeaders.Accept.Clear(); // client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); // var parameters = new Dictionary<string, string> { { "name", text }, { "isCompleted", _isCompleted } }; // var encodedContent = new FormUrlEncodedContent(parameters); // var postTask = client.PostAsJsonAsync(apiUrl + id + "/"+ text + "/" + isCompleted, parameters); // postTask.Wait(); // var result = postTask.Result; // if (result.IsSuccessStatusCode) // { // return RedirectToAction("CreateTaskListItemView", "TaskListItem"); // } // return RedirectToAction("CreateTaskListItemView", "TaskListItem"); //} }
private void DeleteTaskListItemButton_Click(object sender, EventArgs e) { TaskListItemWinForm taskListItemWinForm = DependencyResolver.Container.Resolve <TaskListItemWinForm>(); if (selectedItem.Text != "") { TaskListItem currentObject = (TaskListItem)ItemsGridView.CurrentRow.DataBoundItem; int currentItem = currentObject.Id; taskListItemWinForm.DeleteTaskListItem(currentItem); selectedItem.Text = ""; int currentTaskList = (int)(taskList.SelectedValue); taskListItemWinForm.ShowTaskListItems(currentTaskList); } else { MessageBox.Show("There is no Task List Item selected"); } }
public async Task <IActionResult> Create([Bind("Id,TaskTitle,TaskDescription,Status,Category,TaskStartDate,Expiration,DatePosted")] TaskListItem taskListItem) { if (ModelState.IsValid) { var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value; var customer = await _context.Customers .FirstOrDefaultAsync(customer => customer.UserId == userId); taskListItem.CustomerID = customer.ID; _context.Add(taskListItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CustomerID"] = new SelectList(_context.Set <Customer>(), "ID", "ID", taskListItem.CustomerID); return(View(taskListItem)); }
//启动任务 private void RunTask(TaskListItem _item) { //先设置任务为1; _item.State = 1; try { BackgroundWorker _worker = new BackgroundWorker(); _worker.WorkerReportsProgress = true; _worker.DoWork += new DoWorkEventHandler(_worker_DoWork); _worker.ProgressChanged += new ProgressChangedEventHandler(_worker_ProgressChanged); _worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_worker_RunWorkerCompleted); _worker.RunWorkerAsync(_item); } catch (Exception ex) { application.WriteMessage(string.Format("启动任务[{0}]失败!{1}", _item.TaskName, ex.Message), EventLogEntryType.Error); } }
/// <summary> /// Add an item to the list /// </summary> /// <param name="itemText">Title of the added Item</param> public void AddListItem(string itemText) { TaskListItem newItem = Instantiate(prefabTaskListItem, content.transform); items.Add(newItem); newItem.text = itemText.Trim(); //Gets the actual size of the message by iterating each lines of the text TextMeshProUGUI label = newItem.label; label.GetComponent <RectTransform>().sizeDelta = new Vector2(label.GetComponent <RectTransform>().sizeDelta.x, 0); float chatItemHeight = 0; foreach (var line in label.GetTextInfo(newItem.text).lineInfo) { chatItemHeight += line.lineHeight; } //Checks if the chatItemHeight is below the minimum of 5, if it ain't then we apply the new height) chatItemHeight = chatItemHeight < 30 ? 30 : chatItemHeight; RectTransform chatItemRectTransform = label.GetComponent <RectTransform>(); //SizeDelta.x is the Width of the RectTransform (this could be done in the ChatItem component) chatItemRectTransform.sizeDelta = new Vector2(chatItemRectTransform.sizeDelta.x, chatItemHeight); //Dynamically sets the height of the chat (this could be done in a ChatContent component) RectTransform chatContentRecTransform = content.GetComponent <RectTransform>(); float finalHeight = chatItemHeight + chatContentRecTransform.GetComponent <VerticalLayoutGroup>().spacing + chatContentRecTransform.GetComponent <VerticalLayoutGroup>().padding.top + chatContentRecTransform.GetComponent <VerticalLayoutGroup>().padding.bottom; chatContentRecTransform.sizeDelta = new Vector2(chatContentRecTransform.sizeDelta.x, chatContentRecTransform.sizeDelta.y + finalHeight); UpdateList(); }
protected override void OnRequestComplete(object response) { if (response == null) { MessageBox.Show("Communication or internal error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var respType = response.GetType(); if (respType == typeof(BplCollection<DiagnosticsTaskInfo>)) { var tasks = (BplCollection<DiagnosticsTaskInfo>)response; listTasks.Items.Clear(); _selectedTask = null; _selectedDevice = null; listDevices.Items.Clear(); if (tasks.Count > 0) { foreach (var task in tasks) { var li = new TaskListItem(task); listTasks.Items.Add(li); } _onSizeChanged(null, null); } } else if (respType == typeof(BplCollection<DiagnosticsTaskDevice>)) { var devices = (BplCollection<DiagnosticsTaskDevice>)response; this.Freeze(); var comparer = listDevices.ListViewItemSorter; listDevices.ListViewItemSorter = null; listDevices.Items.Clear(); _selectedDevice = null; if (devices.Count > 0) { foreach (var dev in devices) { var li = new DeviceListItem(dev); listDevices.Items.Add(li); } _onSizeChanged(null, null); } listDevices.ListViewItemSorter = comparer; this.Unfreeze(); } else if (respType == typeof(DeleteDiagnosticsTaskResponse)) { var swlr = ((SwlResponse)response).swlr; if (swlr != SwlResult.OK) { var taskItem = (TaskListItem)listTasks.SelectedItems[0]; MessageBox.Show("Failed to delete task.", "Delete task \x22" + taskItem.Task.TaskName + "\x22", MessageBoxButtons.OK, MessageBoxIcon.Error); } _listTasksRefresh(); } else if (respType == typeof(AddDevicesToDiagnosticsTaskResponse)) { var resp = (AddDevicesToDiagnosticsTaskResponse)response; if (resp.swlr != SwlResult.OK) { var taskItem = (TaskListItem)listTasks.SelectedItems[0]; if (resp.DeviceIds.Count == 0) { MessageBox.Show("Failed to add device(s) to task.", "Add device(s) to task \x22" + taskItem.Task.TaskName + "\x22", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { var caption = "Failed to add device(s) to task\x22" + taskItem.Task.TaskName + "\x22"; var msg = "Following device(s) already have this task type:\r\n"; foreach (var deviceId in resp.DeviceIds) { msg += (deviceId.LocalId.ToString() + "\r\n"); } MessageBox.Show(msg, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } _listDevicesRefresh(); } else if (respType == typeof(RemoveDeviceFromDiagnosticsTaskResponse)) { var swlr = ((SwlResponse)response).swlr; if (swlr != SwlResult.OK) { var taskItem = (TaskListItem)listTasks.SelectedItems[0]; MessageBox.Show("Failed to remove device from task.", "Remove device from task \x22" + taskItem.Task.TaskName + "\x22", MessageBoxButtons.OK, MessageBoxIcon.Error); } _listDevicesRefresh(); } }