private async Task DeleteItemById(Instance selected) { var sRoot = Communication.GetInstance().DeleteInstance(selected._id); var xRoot = XElement.Parse(sRoot); var result = xRoot.GetAttributeValue(Constants.RESULT); if (string.IsNullOrEmpty(result)) return; if (result.Equals(Constants.ERROR)) { MessageBox.Show("Delete Instance failed!\nReason:" + xRoot.GetAttributeValue("Reason")); } else { var source = InstanceTable.ItemsSource as List<Instance>; if (source != null) { source.Remove(selected); InstanceTable.Items.Clear(); InstanceTable.ItemsSource = source; } } }
private void StartSuiteTask(object sender, RoutedEventArgs e, Instance selected) { try { var sRoot = Communication.GetInstance().StartInstance(selected._id); var xRoot = XElement.Parse(sRoot); var result = xRoot.GetAttributeValue(Constants.RESULT); if (string.IsNullOrEmpty(result)) return; if (result.Equals(Constants.ERROR)) { MessageBox.Show("Start Instance failed!\nReason:" + xRoot.GetAttributeValue("Reason")); } else { //update the table RefreshSuite(sender, e); } } catch (Exception ex) { MessageBox.Show(ExceptionHelper.FormatStackTrace(ex), "Exception", MessageBoxButton.OK, MessageBoxImage.Error); } }