public BackgroundPresentationManager(IServerConfiguration config,
     IPresentationWorker worker,
     PresentationShowPreparator preparator,
     DisplayAndEquipmentMonitor monitor,
     IShowDisplayAndDeviceCommand showDisplayAndDeviceCommand,
     UserIdentity systemUser)
 {
     _config = config;
     _showPreparator = preparator;
     _monitor = monitor;
     _worker = worker;
     _showDisplayAndDeviceCommand = showDisplayAndDeviceCommand;
     _systemUser = systemUser;
     _restoreShowTimer = new Timer(RestoreShow);
     TimeSpan interval =TimeSpan.FromSeconds(BackgroundPresentationRestoreTimeout);
     _backgroundPresentationChange = new Timer(MonitorForBackgroundPresentation, null, interval, interval);
     // мониторинг оборудования
     _monitor.OnStateChange += new EventHandler<TechnicalServices.Interfaces.ConfigModule.Server.EqiupmentStateChangeEventArgs>(_monitor_OnStateChange);
     // мониторинг изменения в фоновом сценарии
     _worker.OnPresentationChanged += new EventHandler<PresentationChangedEventArgs>(_worker_OnPresentationChanged);
 }
Exemplo n.º 2
0
        public ShowService(IServerConfiguration config, IPresentationWorker worker, UserIdentity identity)
        {
            Debug.Assert(config != null, "IServerConfiguration не может быть null");
            Debug.Assert(worker != null, "IPresentationWorker не может быть null");
            Debug.Assert(identity != null, "UserIdentity не может быть null");

            _sourceIdDisplayMappingSyncObject = ((ICollection)_sourceIdDisplayMapping).SyncRoot;
            _config = config;
            _worker = worker;
            _systemUser = identity;

            _globalNotifier = NotificationManager<IShowCommon>.Instance.
                RegisterDuplexService<UserIdentity, IShowNotifier>(NotifierBehaviour.OneInstance);

            _controller = ControllerFactory.CreateController(config.EventLog, config.ControllerLibrary, config.ControllerURI, config.ControllerReceiveTimeout, config.ControllerCheckTimeout);
            _externalSystemController = ExternalSystemControllerFactory.CreateController(
                config.ExternalSystemControllerLibrary, config.ExternalSystemControllerUri, config.EventLog);
            _scheduler = new Scheduler(_config);
            _scheduler.OnTick += new Action<int>(_scheduler_OnTick);
            _monitor = new DisplayAndEquipmentMonitor(_controller, _config);
            _monitor.OnStateChange += _monitor_OnStateChange;
            _externalSystemController.OnGoToLabel += _externalSystemController_OnGotoLabelReceive;
            _externalSystemController.OnGoToSlideById += _externalSystemController_OnGoToSlideById;
            _externalSystemController.OnGoToNextSlide += _externalSystemController_OnGoToNextSlide;
            _externalSystemController.OnGoToPrevSlide += _externalSystemController_OnGoToPrevSlide;
            //_controller.OnCheck += new EventHandler<DeviceCheckResultEventArgs>(_controller_OnCheck);
            foreach (IModule module in _config.ModuleList)
            {
                foreach (Type type in module.SystemModule.Presentation.GetDevice())
                    _mappingList.Add(type, module);
                foreach (Type type in module.SystemModule.Presentation.GetDisplay())
                    _mappingList.Add(type, module);
                foreach (Type type in module.SystemModule.Presentation.GetSource())
                    _mappingList.Add(type, module);

                // так же сделаем мапинг для типов из конфигурации чтобы мягко перейти везде где возможно на конфигурационные типы
                foreach (Type type in module.SystemModule.Configuration.GetDevice())
                    _mappingList.Add(type, module);
                foreach (Type type in module.SystemModule.Configuration.GetDisplay())
                    _mappingList.Add(type, module);
                foreach (Type type in module.SystemModule.Configuration.GetSource())
                    _mappingList.Add(type, module);

                module.ServerModule.Init(_config, module, _controller);
                WatchDog.WatchDogAction(_config.EventLog.WriteError, module.ServerModule.CheckLicense);
            }
            _worker.OnPresentationChanged += new EventHandler<PresentationChangedEventArgs>(_worker_OnPresentationChanged);
            _worker.OnSlideChanged += new EventHandler<SlideChangedEventArgs>(_worker_OnSlideChanged);

            _showPreparator = new PresentationShowPreparator(_config, _worker, _monitor, _mappingList);
            //_showPreparator.OnPreparationFinish += _showPreparator_OnPreparationFinish;
            //_showPreparator.OnResourceTransmit += _showPreparator_OnResourceTransmit;
            _backgroundPresentationManager = new BackgroundPresentationManager(_config,
                _worker, _showPreparator, _monitor, this, _systemUser);
            _backgroundPresentationManager.StartShow();

            _playerMonitoringTimer.Elapsed += new System.Timers.ElapsedEventHandler(_playerMonitoringTimer_Elapsed);
            _playerMonitoringTimer.Interval = TimeSpan.FromSeconds(_config.LoadSystemParameters().BackgroundPresentationRestoreTimeout).TotalMilliseconds;
            _playerMonitoringTimer.Start();
            //_blockedPresentationMonitor = new BlockedPresentationMonitor(_systemUser, _worker, _config);
        }