Пример #1
0
        public AgrServerApplication()
        {
            LogManager.LogEmit += LogManager_LogEmit;

            var binding = new NetTcpBinding();

            binding.Name = "my_binding";
            binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
            binding.Security.Mode          = SecurityMode.None;
            binding.MaxConnections         = (int)AppConfig.MaxClients;

            // лимит на соединения
            var throttling = new ServiceThrottlingBehavior();

            throttling.MaxConcurrentSessions = (int)AppConfig.MaxClients;

            host = new ServiceHost(typeof(RLTTaskManagerService));
            host.Description.Behaviors.Add(throttling);
            host.AddServiceEndpoint(typeof(IRLTTaskManagerService), binding, HostManager.GetServerHost());
            host.Open();

            LogManager.LogInfo(unit, string.Format("Запуск сервера. Максимальное количество клиентов: {0}", AppConfig.MaxClients));

            _mNotifyIcon.MouseClick        += MNotifyIconMouseClick;
            _mNotifyIcon.BalloonTipClicked += MNotifyIconClick;
            var menu = new ContextMenuStrip();

            ToolStripItem item = menu.Items.Add("Настройка", AgrServer.Properties.Resources.users_1);

            item.Click += MNotifyIconClick;

            item        = menu.Items.Add("Сообщения", AgrServer.Properties.Resources.info);
            item.Click += InfoIconClick;

            menu.Items.Add("-");

            item        = menu.Items.Add("Выход", AgrServer.Properties.Resources.Turn2);
            item.Click += ItemClick;
            _mNotifyIcon.ContextMenuStrip = menu;
            _mNotifyIcon.Icon             = AgrServer.Properties.Resources.user_green1;

            _mNotifyIcon.Visible = true;

            ShutdownMode = ShutdownMode.OnExplicitShutdown;
        }