// ** CHANGES BELOW ARE NOT REQUIRED UNLESS YOUR ACCESS REQUIRES ADDITIONAL PARAMETERS ** // GetSession // Based on the above Session Type, retrieve the Session used to define how you want to access the platform. // public static ISession GetSession(SessionTypeEnum?session = null) { session = session ?? SessionType; return(session switch { SessionTypeEnum.RDP => PlatformSession.Definition().AppKey(Credentials.AppKey) .OAuthGrantType(new GrantPassword().UserName(Credentials.RDPUser) .Password(Credentials.RDPPassword)) .TakeSignonControl(true) .GetSession().OnState((s, state, msg) => Console.WriteLine($"{DateTime.Now}: State: {state}. {msg}")) .OnEvent((s, eventCode, msg) => Console.WriteLine($"{DateTime.Now}: Event: {eventCode}. {msg}")), SessionTypeEnum.DESKTOP => DesktopSession.Definition().AppKey(Credentials.AppKey) .GetSession().OnState((s, state, msg) => Console.WriteLine($"{DateTime.Now}: State: {state}. {msg}")) .OnEvent((s, eventCode, msg) => Console.WriteLine($"{DateTime.Now}: Event: {eventCode}. {msg}")), SessionTypeEnum.DEPLOYED => PlatformSession.Definition().Host(Credentials.ADSHost) .GetSession().OnState((s, state, msg) => Console.WriteLine($"{DateTime.Now}: State: {state}. {msg}")) .OnEvent((s, eventCode, msg) => Console.WriteLine($"{DateTime.Now}: Event: {eventCode}. {msg}")), _ => throw new IndexOutOfRangeException($"Unknown Session Type: {SessionType}"), });
static void Main(string[] args) { // Programmatically override the default log level defined for the Refinitiv Data Library. Log.Level = NLog.LogLevel.Debug; // Create a session into the desktop application var session = DesktopSession.Definition().AppKey(Credentials.AppKey) .GetSession().OnState((s, state, msg) => Console.WriteLine($"State: {state}. {msg}")) .OnEvent((s, eventCode, msg) => Console.WriteLine($"Event: {eventCode}. {msg}")); if (session.Open() == Session.State.Opened) { Console.WriteLine("Session successfully opened"); } else { Console.WriteLine("Session failed to open"); } }