Ejemplo n.º 1
0
        /// <summary>
        /// Метод выполняет печать информации на метке
        /// </summary>
        private async void Print()
        {
            if (_client == null || !_client.IsConnected)
            {
                MessageBox.Show("Нет установленного соединения с шиной RFID");
                return;
            }
            try
            {
                //кодировщик
                var encoder = new EpcSgtin96Encoder(CompanyPrefix, ProductId, StartSerial);

                //баркод
                var barcode = new Code128BarCodeElement(5, 35, 45, 5, codeFontSize: 14)
                {
                    Value = CompanyPrefix.ToString(CultureInfo.InvariantCulture) + ProductId
                };

                for (var i = 0; i < TagsCount; i++)
                {
                    var label = new RfidPrintLabel {
                        Width = 50, Height = 50
                    };

                    //текстовый элемент epc
                    var epcElement = new TextElement(5, 20, 45, 25, "Arial", 35, BaseTools.GetStringFromBinary(encoder.Epc));

                    label.Elements.Add(epcElement);
                    label.Elements.Add(barcode);

                    if (IsWriteEpcData)
                    {
                        //элемент записи rfid данных
                        var writeEpcElement = new WriteDataLabelElement(encoder.Epc, retries: 1);
                        label.Elements.Add(writeEpcElement);
                    }

                    var printResult =
                        await _client.SendRequestAsync(new EnqueuePrintLabelTask(SelectedPrinter.Id, label));

                    if (printResult.Status != ResponseStatus.Ok)
                    {
                        MessageBox.Show(String.Format("Не удалось добавить задачу в очередь на печать. Код статуса: {0}", printResult.Status));
                    }

                    encoder++;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Не удалось добавить задачу на печать. Описание: {0}", ex.Message));
            }
        }
Ejemplo n.º 2
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));
            }
        }
Ejemplo n.º 3
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));
            }
        }