private void Initialize() { var connectionConfiguration = ConfigurationProvider.GetConnectionConfiguration(CurrentConnection.Name); var infrastructureFactory = connectionConfiguration.InfrastructureFactory; _databaseMonitor = infrastructureFactory.CreateDatabaseMonitor(CurrentConnection); _sessionDetailViewer = _databaseMonitor.CreateSessionDetailViewer(); _sessionDetailViewer.RestoreConfiguration(_customProperties); var providerConfiguration = WorkDocumentCollection.GetProviderConfiguration(CurrentConnection.ProviderName); ActiveSessionOnly = providerConfiguration.DatabaseMonitorConfiguration.ActiveSessionOnly; UserSessionOnly = providerConfiguration.DatabaseMonitorConfiguration.UserSessionOnly; MasterSessionOnly = providerConfiguration.DatabaseMonitorConfiguration.MasterSessionOnly; if (!String.IsNullOrEmpty(providerConfiguration.DatabaseMonitorConfiguration.SortMemberPath)) { SessionDataGridSource.SortDescriptions.Clear(); SessionDataGridSource.SortDescriptions.Add(new SortDescription(providerConfiguration.DatabaseMonitorConfiguration.SortMemberPath, providerConfiguration.DatabaseMonitorConfiguration.SortColumnOrder)); } lock (_databaseSessions) { _databaseSessions.Clear(); } Refresh(); }
private void WindowTraceLogClosingHandler(object sender, CancelEventArgs args) { WorkDocumentCollection.StoreWindowProperties(this); args.Cancel = true; Hide(); }
private void WindowLoadedHandler(object sender, RoutedEventArgs args) { _windowDatabaseMonitor.Owner = WindowTraceLog.Instance.Owner = this; CommandBindings.Add(new CommandBinding(GenericCommands.SaveAll, SaveAllCommandExecutedHandler)); WorkDocumentCollection.RestoreWindowProperties(this); _windowDatabaseMonitor.RestoreAppearance(); if (WorkDocumentCollection.WorkingDocuments.Count > 0) { foreach (var workingDocument in WorkDocumentCollection.WorkingDocuments.OrderBy(d => d.TabIndex)) { AddNewDocumentPage(workingDocument); } } else { AddNewDocumentPage(); } DocumentTabControl.SelectionChanged += TabControlSelectionChangedHandler; DocumentTabControl.SelectedIndex = WorkDocumentCollection.ActiveDocumentIndex; ClipboardManager.RegisterWindow(this); ClipboardManager.ClipboardChanged += ClipboardChangedHandler; EditorNavigationService.Initialize(ActiveDocument.WorkDocument); }
public OutputViewer(DocumentPage documentPage) { DocumentPage = documentPage; FileResultViewer = new FileResultViewer(this); InitializeComponent(); _timerExecutionMonitor = new DispatcherTimer(DispatcherPriority.Normal, Dispatcher) { Interval = TimeSpan.FromMilliseconds(100) }; _timerExecutionMonitor.Tick += TimerExecutionMonitorTickHandler; Application.Current.Deactivated += ApplicationDeactivatedHandler; Initialize(); _providerConfiguration = WorkDocumentCollection.GetProviderConfiguration(DocumentPage.CurrentConnection.ProviderName); ConnectionAdapter = DocumentPage.DatabaseModel.CreateConnectionAdapter(); StatementValidator = DocumentPage.InfrastructureFactory.CreateStatementValidator(); ExecutionPlanViewer = DocumentPage.InfrastructureFactory.CreateExecutionPlanViewer(this); TabExecutionPlan.Content = ExecutionPlanViewer.Control; TraceViewer = DocumentPage.InfrastructureFactory.CreateTraceViewer(ConnectionAdapter); TabTrace.Content = TraceViewer.Control; BreakOnExceptions = DocumentPage.WorkDocument.BreakOnExceptions; }
internal static void ShowExecutionHistory(string providerName) { lock (ExecutionHistoryWindows) { MainWindow.ActiveDocument.EnsurePopupClosed(); var configuration = WorkDocumentCollection.GetProviderConfiguration(providerName); if (!ExecutionHistoryWindows.TryGetValue(providerName, out var window)) { ExecutionHistoryWindows[providerName] = window = new StatementExecutionHistory(providerName) { Owner = MainWindow }; } window.ExecutionHistoryEntries.Clear(); window.ExecutionHistoryEntries.AddRange(configuration.StatementExecutionHistory); if (window.IsVisible) { window.Focus(); } else { window.Show(); } } }
private void UpdateFilterSettings(Action <DatabaseMonitorConfiguration> updateConfigurationAction) { var providerConfiguration = WorkDocumentCollection.GetProviderConfiguration(CurrentConnection.ProviderName); updateConfigurationAction(providerConfiguration.DatabaseMonitorConfiguration); SessionDataGridSource.View.Refresh(); }
public StatementExecutionHistory(string providerName) { InitializeComponent(); _providerConfiguration = WorkDocumentCollection.GetProviderConfiguration(providerName); _collectionView = CollectionViewSource.GetDefaultView(_historyEntries); _collectionView.SortDescriptions.Add(new SortDescription("ExecutedAt", ListSortDirection.Descending)); }
public void RestoreAppearance() { _customProperties = WorkDocumentCollection.RestoreWindowProperties(this); double sessionDataGridHeight = 0; if (_customProperties?.TryGetValue(SessionDataGridHeightProperty, out sessionDataGridHeight) == true) { RowDefinitionSessionDataGrid.Height = new GridLength(sessionDataGridHeight); } }
private void SessionDataGridSortingHandler(object sender, DataGridSortingEventArgs args) { var sortDirection = args.Column.SortDirection == ListSortDirection.Ascending ? ListSortDirection.Descending : ListSortDirection.Ascending; var providerConfiguration = WorkDocumentCollection.GetProviderConfiguration(CurrentConnection.ProviderName); providerConfiguration.DatabaseMonitorConfiguration.SortMemberPath = args.Column.SortMemberPath; providerConfiguration.DatabaseMonitorConfiguration.SortColumnOrder = sortDirection; }
private void StoreWindowConfiguration() { _customProperties = new Dictionary <string, double> { { SessionDataGridHeightProperty, RowDefinitionSessionDataGrid.ActualHeight } }; _sessionDetailViewer?.StoreConfiguration(_customProperties); WorkDocumentCollection.StoreWindowProperties(this, _customProperties); }
internal void SaveWorkingDocuments() { foreach (var document in AllDocuments) { document.SaveWorkingDocument(); document.WorkDocument.TabIndex = DocumentTabControl.Items.IndexOf(document.TabItem); } WorkDocumentCollection.StoreWindowProperties(this); WorkDocumentCollection.Save(); TraceLog.WriteLine($"Working document collection saved. "); }
private DocumentPage OpenExistingFile(string fileName) { if (!File.Exists(fileName)) { return(null); } var document = WorkDocument.IsSqlxFile(fileName) ? WorkDocumentCollection.LoadDocumentFromFile(fileName) : new WorkDocument { DocumentFileName = fileName }; return(OpenExistingWorkDocument(document)); }
private DocumentPage OpenExistingWorkDocument(WorkDocument document) { DocumentPage documentPage; if (WorkDocumentCollection.TryGetWorkingDocumentFor(document.DocumentFileName, out var workDocument)) { documentPage = AllDocuments.Single(d => d.WorkDocument == workDocument); DocumentTabControl.SelectedItem = documentPage.TabItem; } else { WorkDocumentCollection.AddDocument(document); documentPage = AddNewDocumentPage(document); } return(documentPage); }
private static void Initialize() { ReleaseConfigurationLock(); try { _lockFile = new FileStream(Path.Combine(ConfigurationProvider.FolderNameWorkArea, LockFileName), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); } catch (Exception e) { TraceLog.WriteLine("Configuration lock aquire failed: " + e); } if (!ReadConfiguration(_fileName)) { _allowBackupOverwrite = ReadConfiguration(_backupFileName); } if (_instance == null) { _instance = new WorkDocumentCollection(); } else { if (_instance._workingDocuments == null) { _instance._workingDocuments = new Dictionary <Guid, WorkDocument>(); } if (_instance._recentFiles == null) { _instance._recentFiles = new List <WorkDocument>(); } if (_instance._windowConfigurations == null) { _instance._windowConfigurations = new Dictionary <Type, WindowProperties>(); } } if (_instance._databaseProviderConfigurations == null) { _instance._databaseProviderConfigurations = new Dictionary <string, DatabaseProviderConfiguration>(); } }
private void OpenRecentFileHandler(object sender, ExecutedRoutedEventArgs args) { var workDocument = (WorkDocument)args.Parameter; if (workDocument.File.Exists) { WorkDocumentCollection.AddRecentDocument(workDocument); OpenExistingWorkDocument(workDocument); } else { var result = MessageBox.Show(this, $"File '{workDocument.DocumentFileName}' does not exist anymore. Do you want to remove the link? ", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); if (result == MessageBoxResult.Yes) { WorkDocumentCollection.RemoveRecentDocument(workDocument); } } }
internal bool CloseDocument(DocumentPage document) { DocumentTabControl.SelectedItem = document.TabItem; if (document.IsDirty && !ConfirmDocumentSave(document)) { return(false); } document.SaveWorkingDocument(); SelectNewTabItem(); DocumentTabControl.RemoveTabItemWithoutBindingError(document.TabItem); WorkDocumentCollection.CloseDocument(document.WorkDocument); document.Dispose(); return(true); }
public static void Initialize() { if (Instance != null) { throw new InvalidOperationException("Trace log window has been already initialized. "); } var contentBuilder = new StringBuilder(); foreach (var message in _messages.OrderBy(m => m)) { contentBuilder.AppendLine(message); } Instance = new WindowTraceLog { TraceLog = contentBuilder.ToString() }; _messages = new ConcurrentBag <string>(); WorkDocumentCollection.RestoreWindowProperties(Instance); }
private static bool ReadConfiguration(string fileName) { if (!File.Exists(fileName)) { return(true); } using (var file = File.OpenRead(fileName)) { try { _instance = (WorkDocumentCollection)Serializer.Deserialize(file, _instance, typeof(WorkDocumentCollection)); TraceLog.WriteLine($"WorkDocumentCollection ({_instance._workingDocuments.Count} document(s)) successfully loaded from '{fileName}'. "); return(true); } catch (Exception e) { TraceLog.WriteLine($"WorkDocumentCollection deserialization from '{fileName}' failed: {e}"); } } return(false); }
private static void ConfigureWorkArea() { CreateDirectoryIfNotExists(FolderNameWorkArea); WorkDocumentCollection.Configure(); }
public static void Dispose() { ConfigurationWatcher.Dispose(); WorkDocumentCollection.ReleaseConfigurationLock(); }
public static void Configure() { _instance = null; _fileName = GetWorkingDocumentConfigurationFileName(ConfigurationProvider.FolderNameWorkArea); ConfigureBackupFile(); }