From 8699104979de89ccbf114b068cdea1ddaf870993 Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Thu, 19 Mar 2026 20:04:58 -0400 Subject: [PATCH] Add time display picker (Local/UTC/Server) and parameterize SQL - Time display ComboBox on QS grid toolbar: Local, UTC, Server modes - TimeDisplayHelper shared across grid, slicer, and history window - Server UTC offset fetched on connect via DATEDIFF(MINUTE, GETUTCDATE(), GETDATE()) - All timestamps update live when switching modes - Parameterized hoursBack and daysBack in QueryStoreService SQL queries Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Controls/QuerySessionControl.axaml.cs | 17 +++++++ .../Controls/QueryStoreGridControl.axaml | 9 ++++ .../Controls/QueryStoreGridControl.axaml.cs | 28 +++++++++++- .../Controls/TimeRangeSlicerControl.axaml.cs | 9 ++-- .../Dialogs/QueryStoreHistoryWindow.axaml.cs | 6 +-- .../Models/QueryStoreHistoryRow.cs | 5 ++- .../Services/QueryStoreService.cs | 10 +++-- .../Services/TimeDisplayHelper.cs | 45 +++++++++++++++++++ 8 files changed, 115 insertions(+), 14 deletions(-) create mode 100644 src/PlanViewer.Core/Services/TimeDisplayHelper.cs diff --git a/src/PlanViewer.App/Controls/QuerySessionControl.axaml.cs b/src/PlanViewer.App/Controls/QuerySessionControl.axaml.cs index 3cb0528..2764dc9 100644 --- a/src/PlanViewer.App/Controls/QuerySessionControl.axaml.cs +++ b/src/PlanViewer.App/Controls/QuerySessionControl.axaml.cs @@ -362,6 +362,7 @@ private async Task ShowConnectionDialogAsync() await PopulateDatabases(); await FetchServerMetadataAsync(); + await FetchServerUtcOffset(); if (_selectedDatabase != null) { @@ -439,6 +440,22 @@ private async Task FetchServerMetadataAsync() } } + private async Task FetchServerUtcOffset() + { + if (_connectionString == null) return; + try + { + await using var conn = new SqlConnection(_connectionString); + await conn.OpenAsync(); + await using var cmd = new SqlCommand( + "SELECT DATEDIFF(MINUTE, GETUTCDATE(), GETDATE())", conn); + var offset = await cmd.ExecuteScalarAsync(); + if (offset is int mins) + PlanViewer.Core.Services.TimeDisplayHelper.ServerUtcOffsetMinutes = mins; + } + catch { } + } + private async Task FetchDatabaseMetadataAsync() { if (_connectionString == null || _serverMetadata == null) return; diff --git a/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml b/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml index bff0fb5..697ad74 100644 --- a/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml +++ b/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml @@ -67,6 +67,15 @@ Watermark="0x1AB2C3, dbo.MyProc" KeyDown="SearchValue_KeyDown"/> + + + + + + + +