mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Enable Multiple Assessments (#1219)
* wip * wip * modified assessments to handle multiple DBs * pr comment change * cleanup * cleanup * cleanup
This commit is contained in:
@@ -11,6 +11,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
|||||||
public class MigrationAssessmentsParams
|
public class MigrationAssessmentsParams
|
||||||
{
|
{
|
||||||
public string OwnerUri { get; set; }
|
public string OwnerUri { get; set; }
|
||||||
|
public string[] Databases { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MigrationAssessmentResult
|
public class MigrationAssessmentResult
|
||||||
|
|||||||
@@ -134,12 +134,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
|
|||||||
Version = Version.Parse(serverInfo.ServerVersion),
|
Version = Version.Parse(serverInfo.ServerVersion),
|
||||||
Platform = hostInfo.Platform
|
Platform = hostInfo.Platform
|
||||||
};
|
};
|
||||||
|
var connectionStrings = new List<string>();
|
||||||
var db = SqlAssessmentService.GetDatabaseLocator(server, connection.Database);
|
if (parameters.Databases != null)
|
||||||
var connectionString = ConnectionService.BuildConnectionString(connInfo.ConnectionDetails);
|
{
|
||||||
|
foreach (string database in parameters.Databases)
|
||||||
var results = await GetAssessmentItems(connectionString);
|
{
|
||||||
await requestContext.SendResult(results);
|
connInfo.ConnectionDetails.DatabaseName = database;
|
||||||
|
connectionStrings.Add(ConnectionService.BuildConnectionString(connInfo.ConnectionDetails));
|
||||||
|
}
|
||||||
|
string[] assessmentConnectionStrings = connectionStrings.ToArray();
|
||||||
|
var results = await GetAssessmentItems(assessmentConnectionStrings);
|
||||||
|
await requestContext.SendResult(results);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -179,12 +185,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<MigrationAssessmentResult> GetAssessmentItems(string connectionString)
|
internal async Task<MigrationAssessmentResult> GetAssessmentItems(string[] connectionStrings)
|
||||||
{
|
{
|
||||||
SqlAssessmentConfiguration.EnableLocalLogging = true;
|
SqlAssessmentConfiguration.EnableLocalLogging = true;
|
||||||
SqlAssessmentConfiguration.EnableReportCreation = true;
|
SqlAssessmentConfiguration.EnableReportCreation = true;
|
||||||
SqlAssessmentConfiguration.AssessmentReportAndLogsRootFolderPath = Path.GetDirectoryName(Logger.LogFileFullPath);
|
SqlAssessmentConfiguration.AssessmentReportAndLogsRootFolderPath = Path.GetDirectoryName(Logger.LogFileFullPath);
|
||||||
DmaEngine engine = new DmaEngine(connectionString);
|
DmaEngine engine = new DmaEngine(connectionStrings);
|
||||||
var assessmentResults = await engine.GetTargetAssessmentResultsList();
|
var assessmentResults = await engine.GetTargetAssessmentResultsList();
|
||||||
Dictionary<string, ISqlMigrationAssessmentResult> assessmentResultLookup = new Dictionary<string, ISqlMigrationAssessmentResult>();
|
Dictionary<string, ISqlMigrationAssessmentResult> assessmentResultLookup = new Dictionary<string, ISqlMigrationAssessmentResult>();
|
||||||
foreach (ISqlMigrationAssessmentResult r in assessmentResults)
|
foreach (ISqlMigrationAssessmentResult r in assessmentResults)
|
||||||
|
|||||||
Reference in New Issue
Block a user