Skip to content

Commit

Permalink
85389 remove use of SessionManager GetActiveSessions (#36)
Browse files Browse the repository at this point in the history
* Remove use of depricated SessionManager.GetActiveSessions

* Remove use of depricated SessionManager.GetActiveSessions
  • Loading branch information
Roman-McLaren authored Jul 23, 2024
1 parent a2dd2ee commit d5b047a
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions MAT.SqlRace.StandaloneRecorder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ internal class Program
// The ADS Host:Name
private const string RecorderDataServer = "M801338:Default";

private static string sqlConnectionString;

private static DataServerTelemetryRecorder recorder;
private static RecorderState recordingState;

Expand All @@ -37,7 +39,7 @@ public static void Main(string[] args)
var dbEngine = "SQLite";
var dataSource = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
@"\McLaren Applied Technologies\ATLAS 10\SQL Race\LiveSessionCache.ssn2";
var sqlConnString = $@"DbEngine={dbEngine};Data Source={dataSource};";
sqlConnectionString = $@"DbEngine={dbEngine};Data Source={dataSource};";

Core.Initialize();

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 44 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'Core.Initialize()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
var sessionManager = SessionManager.CreateSessionManager();

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 45 in MAT.SqlRace.StandaloneRecorder/Program.cs

View workflow job for this annotation

GitHub Actions / build

This call site is reachable on all platforms. 'SessionManager.CreateSessionManager()' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
Expand All @@ -54,7 +56,7 @@ public static void Main(string[] args)
recorder = Recorders.CreateDataServerTelemetryRecorder();
recorder.SetSessionIdentifier("%y%m%d%H%M%S");
recorder.OnStatusChanged += recorder_OnStatusChanged;
recorder.SetSQLRaceConnection(Guid.NewGuid(), dbEngine, dataSource, sqlConnString, sqlConnString, false);
recorder.SetSQLRaceConnection(Guid.NewGuid(), dbEngine, dataSource, sqlConnectionString, sqlConnectionString, false);

Console.WriteLine("Getting Available Server List");
recorder.RefreshServerList();
Expand Down Expand Up @@ -96,45 +98,47 @@ private static void StartGetData(SessionKey sessionKey)
{
var sessionManager = SessionManager.CreateSessionManager();
var session = sessionManager.GetActiveSessions(x => x.Key == sessionKey)
.FirstOrDefault()
.Value;
var mrs = new ManualResetEvent(false);
session.RdaParametersChanged += (sender, args) =>
var sessionSummary = sessionManager.FindSummaryBy(sessionKey, sqlConnectionString);
using (var clientSession = sessionManager.Load(sessionSummary.Key, sessionSummary.GetConnectionString()))
{
Console.WriteLine($"Parameter number is {session.Parameters.Count}");
if (session.ContainsParameter("vCar:Chassis"))
var session = clientSession.Session;
var mrs = new ManualResetEvent(false);
session.RdaParametersChanged += (sender, args) =>
{
mrs.Set();
}
};
Console.WriteLine($"Parameter number is {session.Parameters.Count}");
if (session.ContainsParameter("vCar:Chassis"))
{
mrs.Set();
}
};
// wait for the configuration to be processed
mrs.WaitOne();
// wait for the configuration to be processed
mrs.WaitOne();
var parameter = SessionHelper.CreateSessionConfigurationForOneParameter(session);
var parameter = SessionHelper.CreateSessionConfigurationForOneParameter(session);
// pulls vCar data out every 2 seconds
try
{
using (var pda = session.CreateParameterDataAccess("vCar:Chassis"))
// pulls vCar data out every 2 seconds
try
{
using (var pdaNewParameter = session.CreateParameterDataAccess(parameter.Identifier))
using (var pda = session.CreateParameterDataAccess("vCar:Chassis"))
{
while (true)
using (var pdaNewParameter = session.CreateParameterDataAccess(parameter.Identifier))
{
var samples = ReadData(session, pda);
WriteData(session, parameter, pdaNewParameter, samples);
while (true)
{
var samples = ReadData(session, pda);
WriteData(session, parameter, pdaNewParameter, samples);
Thread.Sleep(2000);
Thread.Sleep(2000);
}
}
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error occurred" + ex.Message);
catch (Exception ex)
{
Console.WriteLine("Error occurred" + ex.Message);
}
}
});
}
Expand Down

0 comments on commit d5b047a

Please sign in to comment.