From e620e2ca65e1f503c4891684c4b5881768be3276 Mon Sep 17 00:00:00 2001 From: Alberto Spelta Date: Fri, 5 Jul 2024 16:32:01 +0200 Subject: [PATCH] Bump Vpax version 1.6.0 --- src/Bravo.csproj | 6 ++--- .../Helpers/ConnectionStringHelper.cs | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Bravo.csproj b/src/Bravo.csproj index 21cf0b8e..c3a11fda 100644 --- a/src/Bravo.csproj +++ b/src/Bravo.csproj @@ -56,11 +56,11 @@ - + - - + + diff --git a/src/Infrastructure/Helpers/ConnectionStringHelper.cs b/src/Infrastructure/Helpers/ConnectionStringHelper.cs index 7f5122b9..bcfec8d0 100644 --- a/src/Infrastructure/Helpers/ConnectionStringHelper.cs +++ b/src/Infrastructure/Helpers/ConnectionStringHelper.cs @@ -3,7 +3,7 @@ using Sqlbi.Bravo.Infrastructure.Security; using Sqlbi.Bravo.Models; using System; - using System.Data.OleDb; + using System.Data.Common; using System.Net; internal static class ConnectionStringHelper @@ -34,7 +34,7 @@ public static string BuildFor(IPEndPoint endPoint) var connectTimeout = 1; var dataSource = endPoint.ToString(); - var builder = new OleDbConnectionStringBuilder() + var builder = new DbConnectionStringBuilder() { { ProviderKey, ProviderMsolapValue }, { DataSourceKey, dataSource }, @@ -53,7 +53,7 @@ public static string BuildFor(PBIDesktopReport report) BravoUnexpectedException.ThrowIfNull(report.ServerName); BravoUnexpectedException.ThrowIfNull(report.DatabaseName); - var builder = new OleDbConnectionStringBuilder() + var builder = new DbConnectionStringBuilder() { { ProviderKey, ProviderMsolapValue }, { DataSourceKey, report.ServerName }, @@ -128,7 +128,7 @@ public static string BuildFor(PBICloudDataset dataset, string accessToken) static string Build(string serverName, string databaseName, string accessToken, string identityProvider) { - var builder = new OleDbConnectionStringBuilder() + var builder = new DbConnectionStringBuilder() { { ProviderKey, ProviderMsolapValue }, { DataSourceKey, serverName }, @@ -144,13 +144,19 @@ static string Build(string serverName, string databaseName, string accessToken, } } - public static (string ServerName, string? DatabaseName) GetConnectionStringProperties(string? connectionString) + public static (string? ServerName, string? DatabaseName) GetConnectionStringProperties(string? connectionString) { - var builder = new OleDbConnectionStringBuilder(connectionString); + var builder = new DbConnectionStringBuilder(useOdbcRules: false); + builder.ConnectionString = connectionString; - var serverName = builder.DataSource; - _ = builder.TryGetValue(InitialCatalogKey, out var initialCatalog); - var databaseName = (string?)initialCatalog; + string? serverName = null; + string? databaseName = null; + + if (builder.TryGetValue(DataSourceKey, out var dataSource)) + serverName = (string)dataSource; + + if (builder.TryGetValue(InitialCatalogKey, out var initialCatalog)) + databaseName = (string)initialCatalog; return (serverName, databaseName); }