Пример #1
0
        private void ApplySettings()
        {
            if (_host != null)
            {
                _host.Close();
                _host.Instance.Dispose();
                _logManager.Sources.Remove(_host.Instance);
            }

            if (_entityRegistry.Settings.IsServer)
            {
                IRemoteStorageAuthorization authorization;

                switch (_entityRegistry.Settings.Authorization)
                {
                case AuthorizationModes.Anonymous:
                    authorization = new AnonymousRemoteStorageAuthorization();
                    break;

                case AuthorizationModes.Windows:
                    authorization = new WindowsRemoteStorageAuthorization();
                    break;

                case AuthorizationModes.Community:
                    authorization = new CommunityRemoteStorageAuthorization();
                    break;

                case AuthorizationModes.Custom:
                    authorization = _customAutorization;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                var server = new HydraServer(_storageRegistry, _entityRegistry, Sources)
                {
                    Authorization    = authorization,
                    MaxSecurityCount = _entityRegistry.Settings.MaxSecurityCount
                };

                _logManager.Sources.Add(server);

                _host = new ServiceHost <HydraServer>(server);
                _host.Open();
            }

            if (_timer != null)
            {
                _timer.Stop();

                if (_killTimer != null)
                {
                    _killTimer.Stop();
                }
            }

            if (_entityRegistry.Settings.AutoStop)
            {
                _timer = new Timer(TimeSpan.FromSeconds(30).TotalMilliseconds)
                {
                    AutoReset = true
                };
                _timer.Elapsed += (s, args) =>
                {
                    var time = DateTime.Now.TimeOfDay;
                    if (time >= _entityRegistry.Settings.StopTime && time < _entityRegistry.Settings.StopTime + TimeSpan.FromMinutes(5))
                    {
                        GuiDispatcher.GlobalDispatcher.AddAction(AutoStopAndKill);
                    }
                };
                _timer.Start();
            }

            //if (!CurrentSources.IsNull())
            //{
            //	DockSite.DocumentWindows
            //		.Where(d => d is SourceWindow)
            //		.ForEach(d => ((SourceWindow)d).TaskControl.SecuritiesCtrl.ChangeExtendedColumnVisible());
            //}
        }
Пример #2
0
		private void ApplySettings()
		{
			if (_host != null)
			{
				_host.Close();
				_host.Instance.Dispose();
				_logManager.Sources.Remove(_host.Instance);
			}

			if (_entityRegistry.Settings.IsServer)
			{
				IRemoteStorageAuthorization authorization;

				switch (_entityRegistry.Settings.Authorization)
				{
					case AuthorizationModes.Anonymous:
						authorization = new AnonymousRemoteStorageAuthorization();
						break;
					case AuthorizationModes.Windows:
						authorization = new WindowsRemoteStorageAuthorization();
						break;
					case AuthorizationModes.Community:
						authorization = new CommunityRemoteStorageAuthorization();
						break;
					case AuthorizationModes.Custom:
						authorization = _customAutorization;
						break;
					default:
						throw new ArgumentOutOfRangeException();
				}

				var server = new HydraServer(_storageRegistry, _entityRegistry, Sources)
				{
					Authorization = authorization,
					MaxSecurityCount = _entityRegistry.Settings.MaxSecurityCount
				};

				_logManager.Sources.Add(server);

				_host = new ServiceHost<HydraServer>(server);
				_host.Open();
			}

			if (_timer != null)
			{
				_timer.Stop();

				if (!_killTimer.IsNull())
					_killTimer.Stop();
			}

			if (_entityRegistry.Settings.AutoStop)
			{
				_timer = new Timer(TimeSpan.FromSeconds(30).TotalMilliseconds) { AutoReset = true };
				_timer.Elapsed += (s, args) =>
				{
					var time = DateTime.Now.TimeOfDay;
					if (time >= _entityRegistry.Settings.StopTime && time < _entityRegistry.Settings.StopTime + TimeSpan.FromMinutes(5))
					{
						GuiDispatcher.GlobalDispatcher.AddAction(AutoStopAndKill);
					}
				};
				_timer.Start();
			}

			//if (!CurrentSources.IsNull())
			//{
			//	DockSite.DocumentWindows
			//		.Where(d => d is SourceWindow)
			//		.ForEach(d => ((SourceWindow)d).TaskControl.SecuritiesCtrl.ChangeExtendedColumnVisible());
			//}
		}