refactor: address code review findings across all projects
Apply comprehensive fixes from code reviews including: - Extract shared utilities (SqlFormatHelper, CellValueConverter, DbDestinationBase) - Add interface abstractions (IAuthenticationService, IDatabaseMigrator, IMisQueryBuilder) - Implement SecureStore for encrypted secrets storage - Fix error handling with proper HTTP status codes and logging - Optimize double enumeration in DevEtlRegistry - Add DataSync.Dev README for developer onboarding - Extract filter panel base classes to reduce duplication - Update code review docs to mark all issues as fixed
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using JdeScoping.Core.Models.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace JdeScoping.Core.Models.Search;
|
||||
|
||||
@@ -58,17 +59,8 @@ public class Search
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(CriteriaJson))
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
return JsonSerializer.Deserialize<SearchCriteria>(CriteriaJson);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
TryGetCriteria(out var criteria);
|
||||
return criteria;
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -78,6 +70,31 @@ public class Search
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to deserialize the search criteria from JSON.
|
||||
/// </summary>
|
||||
/// <param name="criteria">The deserialized criteria, or null if deserialization fails or JSON is empty.</param>
|
||||
/// <param name="logger">Optional logger for warning on deserialization failures.</param>
|
||||
/// <returns>True if deserialization succeeded or JSON was empty; false if deserialization failed.</returns>
|
||||
public bool TryGetCriteria(out SearchCriteria? criteria, ILogger? logger = null)
|
||||
{
|
||||
criteria = null;
|
||||
|
||||
if (string.IsNullOrEmpty(CriteriaJson))
|
||||
return true; // Empty is valid, not an error
|
||||
|
||||
try
|
||||
{
|
||||
criteria = JsonSerializer.Deserialize<SearchCriteria>(CriteriaJson);
|
||||
return true;
|
||||
}
|
||||
catch (JsonException ex)
|
||||
{
|
||||
logger?.LogWarning(ex, "Failed to deserialize search criteria for Search ID {SearchId}", Id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Excel search results file (binary)
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user