Exemplo n.º 1
0
 public APIClientVM()
 {
     _connectionLostCallback  = new Callback(UpdateServerDown);
     _requestReceivedCallback = new Callback(UpdateRequestReceived);
     _responseSentCallback    = new Callback(UpdateResponseSent);
     _client = new APIClientWrapper(_connectionLostCallback, _requestReceivedCallback, _responseSentCallback);
     APIClientWrapper.InitClient();
 }
Exemplo n.º 2
0
        public APIClientVM(IDialogService dialogService) // injects services
        {
            _dialogService = dialogService;

            _connectionLostCallback  = new Callback(UpdateServerDown);
            _requestReceivedCallback = new Callback(UpdateRequestReceived);
            _responseSentCallback    = new Callback(UpdateResponseSent);
            _client = new APIClientWrapper(_connectionLostCallback, _requestReceivedCallback, _responseSentCallback);

            _reloadReaders    = new DelegateCommand(OnReloadReaders, null);
            _connectClient    = new DelegateCommand(OnConnectClient, CanConnectClient);
            _disconnectClient = new DelegateCommand(OnDisconnectClient, CanDisconnectClient);
            _clearLogs        = new DelegateCommand(OnClearLogs, null);

            CheckError(APIClientWrapper.InitClient());
        }
Exemplo n.º 3
0
        private void DelDisconnectClient()
        {
            APIClientModel old = _clientData.FirstOrDefault();

            if (old.ClientState.Equals("DISCONNECTED"))
            {
                MessageBox.Show("Error: Client already disconnected");
                return;
            }
            _clientData = new ObservableCollection <APIClientModel>();
            _clientData.Add(new APIClientModel("DISCONNECTED", old.IpClientConnected, old.PortClientConnected));
            OnPropertyChanged("ClientData");
            ResponseDLL response = APIClientWrapper.DisconnectClient();

            CheckError(response);
        }
Exemplo n.º 4
0
        private ObservableCollection <ReaderModel> LoadReaders()
        {
            ResponseDLL response = APIClientWrapper.LoadAndListReaders();

            _readersList = new ObservableCollection <ReaderModel>();
            if (CheckError(response))
            {
                return(_readersList);
            }
            String[] data = response.response.Split('|');

            for (int i = 0; i < data.Length - 1; i += 2)
            {
                _readersList.Add(new ReaderModel(i / 2, data[i + 1]));
            }
            return(_readersList);
        }
Exemplo n.º 5
0
        private void DelConnectClient()
        {
            if (_selectedReader == null)
            {
                MessageBox.Show("Error: A reader must be selected");
                return;
            }
            APIClientModel old      = _clientData.FirstOrDefault();
            ResponseDLL    response = APIClientWrapper.ConnectClient(_selectedReader.ReaderName, old.IpClientConnected, old.PortClientConnected);

            if (CheckError(response))
            {
                return;
            }
            _clientData = new ObservableCollection <APIClientModel>();
            _clientData.Add(new APIClientModel("CONNECTED", old.IpClientConnected, old.PortClientConnected));
            OnPropertyChanged("ClientData");
        }