/// <summary>Initializes a new instance of the T2GConnectionManager class.</summary> /// <param name="sessionData">Information describing the session.</param> /// <param name="connectionListener">The connection listener.</param> public T2GConnectionManager(T2GSessionData sessionData, IT2GConnectionListener connectionListener) { if (sessionData == null) { throw new ArgumentNullException("sessionData"); } if (connectionListener == null) { throw new ArgumentNullException("connectionListener"); } _sessionData = sessionData; _connectionListener = connectionListener; // First, call the T2G session establishment routine right away once try { CheckSession(null, null); } catch (System.Threading.ThreadAbortException ex) { LogManager.WriteLog(TraceType.DEBUG, "Check session aborded", "PIS.Ground.Core.T2G.T2GConnectionManager", ex, EventIdEnum.GroundCore); } catch (Exception ex) { LogManager.WriteLog(TraceType.EXCEPTION, "Check session failed", "PIS.Ground.Core.T2G.T2GConnectionManager", ex, EventIdEnum.GroundCore); } // Second, schedule it to re-execute periodically _timer = new Timer(SessionKeepAliveTimerPeriodMillis); _timer.Elapsed += this.CheckSession; _timer.Enabled = true; }
/// <summary>Initializes a new instance of the T2GManager class. This constructor is used for unit tests.</summary> /// <param name="sessionData">Information describing the session.</param> /// <param name="localDataStorage">The local data storage.</param> /// <param name="fileDistributionManager">Manager for file distribution.</param> /// <param name="notifier">The notifier.</param> /// <param name="connectionManager">Manager for connection.</param> internal T2GManager(T2GSessionData sessionData, T2GLocalDataStorage localDataStorage, T2GFileDistributionManager fileDistributionManager, IT2GNotificationProcessor notifier, IT2GConnectionManager connectionManager) { _systemChangedEventHandlers = new Dictionary <string, EventHandler <SystemChangedNotificationArgs> >(); _systemDeletedEventHandlers = new Dictionary <string, EventHandler <SystemDeletedNotificationArgs> >(); _T2GOnlineOfflineEventHandlers = new Dictionary <string, EventHandler <T2GOnlineStatusNotificationArgs> >(); _elementEventHandlers = new Dictionary <string, EventHandler <ElementEventArgs> >(); _filePublicationNotificationEventHandlers = new Dictionary <string, EventHandler <FilePublicationNotificationArgs> >(); _filePublishedNotificationEventHandlers = new Dictionary <string, EventHandler <FilePublishedNotificationArgs> >(); _fileReceivedNotificationEventHandlers = new Dictionary <string, EventHandler <FileReceivedArgs> >(); _fileDistributionEventHandlers = new Dictionary <string, EventHandler <FileDistributionStatusArgs> >(); _sessionData = sessionData; _localDataStorage = localDataStorage; _fileDistributionManager = fileDistributionManager; _notifier = notifier; _connectionManager = connectionManager; }
/// <summary>Initializes a new instance of the T2GManager class.</summary> internal T2GManager() { _systemChangedEventHandlers = new Dictionary <string, EventHandler <SystemChangedNotificationArgs> >(); _systemDeletedEventHandlers = new Dictionary <string, EventHandler <SystemDeletedNotificationArgs> >(); _T2GOnlineOfflineEventHandlers = new Dictionary <string, EventHandler <T2GOnlineStatusNotificationArgs> >(); _elementEventHandlers = new Dictionary <string, EventHandler <ElementEventArgs> >(); _filePublicationNotificationEventHandlers = new Dictionary <string, EventHandler <FilePublicationNotificationArgs> >(); _filePublishedNotificationEventHandlers = new Dictionary <string, EventHandler <FilePublishedNotificationArgs> >(); _fileReceivedNotificationEventHandlers = new Dictionary <string, EventHandler <FileReceivedArgs> >(); _fileDistributionEventHandlers = new Dictionary <string, EventHandler <FileDistributionStatusArgs> >(); _sessionData = new T2GSessionData(); _localDataStorage = new T2GLocalDataStorage(_sessionData, null); if (!string.IsNullOrEmpty(ServiceConfiguration.T2GServiceNotificationUrl)) { _fileDistributionManager = new T2GFileDistributionManager(_sessionData, this); } _notifier = new T2GNotificationProcessor(this, _localDataStorage, _fileDistributionManager); _connectionManager = new T2GConnectionManager(_sessionData, this); }
/// <summary> /// Prevents a default instance of the LocalDataStorage class from being created. /// </summary> /// <param name="sessionData">Information to hold T2G session data.</param> /// <param name="filterLocalTrainService">Indicates if the filtering on local train service is enabled or not. /// If not specified, the value is retrieved from the configuration file.</param> internal T2GLocalDataStorage(T2GSessionData sessionData, bool?filterLocalTrainService) { if (sessionData == null) { throw new ArgumentNullException("sessionData"); } _sessionData = sessionData; _messageIdList = new List <string>( new string[] { T2GDataConverter.PisBaseline, T2GDataConverter.PisVersion, T2GDataConverter.PisMission, T2GDataConverter.SivngMission }); _serviceIdList = new List <eServiceID>( new eServiceID[] { eServiceID.eSrvSIF_DataPackageServer, eServiceID.eSrvSIF_InstantMessageServer, eServiceID.eSrvSIF_LiveVideoControlServer, eServiceID.eSrvSIF_MaintenanceServer, eServiceID.eSrvSIF_MissionServer, eServiceID.eSrvSIF_RealTimeServer, eServiceID.eSrvSIF_ReportExchangeServer }); if (filterLocalTrainService.HasValue) { _filterLocalServiceOnly = filterLocalTrainService.Value; } else { // Value not specified, use value stored into the configuration file _filterLocalServiceOnly = ServiceConfiguration.FilterLocalTrainService; } }