Exemplo n.º 1
0
        /// <summary>
        /// Метод выполняет соединения с шиной RFID
        /// </summary>
        private async void Connect()
        {
            try
            {
                var pbCommunication = new PbCommunicationDescription();
                var config          = new ParametersValues(pbCommunication.GetClientConfiguration());
                config.SetValue(ConfigConstants.PARAMETER_HOST, Settings.Default.BusHost);
                config.SetValue(ConfigConstants.PARAMETER_PORT, Settings.Default.BusPort);

                _client = new RfidBusClient(pbCommunication, config);

                if (!_client.Authorize(Settings.Default.BusLogin, Settings.Default.BusPassword))
                {
                    throw new BaseException(RfidErrorCode.InvalidLoginAndPassword);
                }

                _client.ReceivedEvent += RfidBusReceivedEvent;
                var result = await _client.SendRequestAsync(new GetLoadedRfidPrinters());

                if (result.Status != ResponseStatus.Ok)
                {
                    throw new BaseException(String.Format("Ошибка авторизации. Код статуса: {0}", result.Status));
                }

                LoadedPrinters.Clear();

                if (!result.RfidPrinters.Any())
                {
                    return;
                }

                foreach (var printer in result.RfidPrinters)
                {
                    LoadedPrinters.Add(printer);
                }

                SelectedPrinter = LoadedPrinters.First();
            }

            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Не удалось установить соединение с шиной RFID. {0}", ex.Message));
            }
        }
Exemplo n.º 2
0
        private void Initialize()
        {
            Console.WriteLine("Establishing connection to RFID Bus...");
            var protocol = new PbCommunicationDescription();
            var config = new ParametersValues(protocol.GetClientConfiguration());
            config.SetValue(ConfigConstants.PARAMETER_HOST, "127.0.0.1");
            config.SetValue(ConfigConstants.PARAMETER_PORT, 20000);

            this._client = new RfidBusClient(protocol, config)
            {
                AllowReconnect = true,
                RequestTimeOut = TimeSpan.FromSeconds(30),
            };
            this._client.Connect();

            if (!this._client.Authorize("admin", "admin"))
                throw new Exception("Invalid login-password.");
            Console.WriteLine("Connection established.");
        }
Exemplo n.º 3
0
        private void Initialize()
        {
            Console.WriteLine("Establishing connection to RFID Bus...");
            var protocol = new PbCommunicationDescription();
            var config   = new ParametersValues(protocol.GetClientConfiguration());

            config.SetValue(ConfigConstants.PARAMETER_HOST, "127.0.0.1");
            config.SetValue(ConfigConstants.PARAMETER_PORT, 20000);

            this._client = new RfidBusClient(protocol, config)
            {
                AllowReconnect = true,
                RequestTimeOut = TimeSpan.FromSeconds(30),
            };
            this._client.Connect();

            if (!this._client.Authorize("admin", "admin"))
            {
                throw new Exception("Invalid login-password.");
            }
            Console.WriteLine("Connection established.");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Метод выполняет соединения с шиной RFID
        /// </summary>
        private async void Connect()
        {
            try
            {
                var pbCommunication = new PbCommunicationDescription();
                var config = new ParametersValues(pbCommunication.GetClientConfiguration());
                config.SetValue(ConfigConstants.PARAMETER_HOST, Settings.Default.BusHost);
                config.SetValue(ConfigConstants.PARAMETER_PORT, Settings.Default.BusPort);

                _client = new RfidBusClient(pbCommunication, config);

                if (!_client.Authorize(Settings.Default.BusLogin, Settings.Default.BusPassword))
                    throw new BaseException(RfidErrorCode.InvalidLoginAndPassword);

                _client.ReceivedEvent += RfidBusReceivedEvent;
                var result = await _client.SendRequestAsync(new GetLoadedRfidPrinters());
                if (result.Status != ResponseStatus.Ok)
                {
                    throw new BaseException(String.Format("Ошибка авторизации. Код статуса: {0}", result.Status));
                }

                LoadedPrinters.Clear();

                if (!result.RfidPrinters.Any()) return;

                foreach (var printer in result.RfidPrinters)
                {
                    LoadedPrinters.Add(printer);
                }

                SelectedPrinter = LoadedPrinters.First();
            }

            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Не удалось установить соединение с шиной RFID. {0}", ex.Message));
            }
        }