private async void SaveQueryAs(object sender, RoutedEventArgs e) { FormatedQuery query = tabQueries.SelectedItem as FormatedQuery; if (query == null) { return; } var address = AddressSelectionBox.GetAddressInput(query.S3Path); if (address == null) { return; } try { await s3.UploadAsJson(address, query); await LoadS3(); query.Changed = false; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }
public static string GetAddressInput(string value = "") { var box = new AddressSelectionBox(); box.tbInput.Text = value; return(box.ShowDialog()); }
private async void CloseQueryView(object sender, RoutedEventArgs e) { var el = sender as FrameworkElement; var query = el.DataContext as FormatedQuery; if (query.Changed) { switch (MessageBox.Show("Do you want to save the query?", "Warning - Unsaved", MessageBoxButton.YesNoCancel)) { case MessageBoxResult.Yes: // save if (query.S3Path != null && await s3.FileExists(query.S3Path)) { await s3.UploadAsJson(query.S3Path, query); var node = FindTreeItem(query); if (node != null) { await node.Load(); } query.Changed = false; } else { var address = AddressSelectionBox.GetAddressInput(); if (address == null) { return; } try { await s3.UploadAsJson(address, query); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } } break; case MessageBoxResult.No: // load the file again from s3 if (query.S3Path != null && await s3.FileExists(query.S3Path)) { var node = FindTreeItem(query); if (node != null) { await node.Load(); } } break; case MessageBoxResult.Cancel: return; } } FormatedQuerySource.Remove(query); }