public DispatcherControlModel()
        {
            _botLogic  = new LogicBot();
            _container = new UnityContainer();
            _container.RegisterType <IClientMessageService, ClientMessageService>();
            _container.RegisterType <IClientService, ClientService>();
            _container.RegisterType <IDispatcherMessageService, DispatcherMessageService>();
            _container.RegisterType <IWorkTimeDispatcherService, WorkTimeDispatcherService>();
            _container.RegisterType <IUserService, UserService>();
            _modelClientMessageService     = new ModelClientMessageService(_container);
            _modelClientService            = new ModelClientService(_container);
            _modelDespatcherMessageService = new ModelDespatcherMessageService(_container);
            _modelUserService = new ModelUserService(_container);

            _clients     = _modelClientService.GetClients();
            _users       = _modelUserService.GetUsers();
            _clientsChat = new ObservableCollection <ClientInfo>();
            Messages     = new ObservableCollection <DisBotMessage>();

            _user         = new UserModel();
            _mainListBox  = new ListBox();
            _сhoiceClient = new ClientInfo();
            _isConnect    = true;


            Context            = SynchronizationContext.Current;
            SendMessageCommand = new RelayCommand(OnSendMessageCommandExecute);
            ConnectCommand     = new RelayCommand(OnConnectCommand);
            DisconnectCommand  = new RelayCommand(OnDisconnectCommand);

            _botLogic.LogStart += BotLogicLogStart;
            UserName            = ((MainWindow)Application.Current.MainWindow).tbLogin.Text;
            EventClosedWindow();
            InitUser();
        }
        public DispatcherViewModel()
        {
            _botLogic  = new LogicBot();
            _container = new UnityContainer();
            _container.RegisterType <IClientMessageService, ClientMessageService>();
            _container.RegisterType <IClientService, ClientService>();
            _container.RegisterType <IDispatcherMessageService, DispatcherMessageService>();
            _container.RegisterType <IWorkTimeDispatcherService, WorkTimeDispatcherService>();
            _modelClientMessageService      = new ModelClientMessageService(_container);
            _modelClientService             = new ModelClientService(_container);
            _modelDespatcherMessageService  = new ModelDespatcherMessageService(_container);
            _modelWorkTimeDispatcherService = new ModelWorkTimeDispatcherService(_container);

            _clients     = _modelClientService.GetClients();
            _clientsChat = new ObservableCollection <ClientInfo>();

            _mainListBox = new ListBox();

            for (int i = 0; i < Application.Current.Windows.Count; i++)
            {
                var window = Application.Current.Windows[i];
                if (window.Tag == null)
                {
                    continue;
                }
                else if (window.Tag.Equals("DispatcherWindow"))
                {
                    Application.Current.Windows[i].Closing += DispatcherViewModel_Closed;
                    break;
                }
            }

            Messages           = new ObservableCollection <DisBotMessage>();
            _сhoiceClient      = new ClientInfo();
            _isConnect         = true;
            SendMessageCommand = new RelayCommand(OnSendMessageCommandExecute);
            ConnectCommand     = new RelayCommand(OnConnectCommand);
            DisconnectCommand  = new RelayCommand(OnDisconnectCommand);
            //EventPost();

            _botLogic.LogStart += _botLogic_LogStart;

            UserInfo = StaticLogicBot.UserInfo;
        }