コード例 #1
0
        private void PageBorrow_Unloaded(object sender, RoutedEventArgs e)
        {
            if (_fingerprintChannel != null)
            {
                FingerPrint.EndFingerprintChannel(_fingerprintChannel);
                _fingerprintChannel = null;
            }

            if (_rfidChannel != null)
            {
                RFID.EndRfidChannel(_rfidChannel);
                _rfidChannel = null;
            }

            if (_timer != null)
            {
                _timer.Dispose();
            }
        }
コード例 #2
0
        // 第二阶段:填充图书信息的 PII 和 Title 字段
        void FillBookFields()
        {
#if NO
            RfidChannel channel = RFID.StartRfidChannel(App.RfidUrl,
                                                        out string strError);
            if (channel == null)
            {
                throw new Exception(strError);
            }
#endif
            try
            {
                foreach (Entity entity in _entities)
                {
                    if (_cancelRefresh == null ||
                        _cancelRefresh.IsCancellationRequested)
                    {
                        return;
                    }

                    if (entity.FillFinished == true)
                    {
                        continue;
                    }

                    //if (string.IsNullOrEmpty(entity.Error) == false)
                    //    continue;

                    // 获得 PII
                    // 注:如果 PII 为空,文字重要填入 "(空)"
                    if (string.IsNullOrEmpty(entity.PII))
                    {
                        // var result = channel.Object.GetTagInfo("*", entity.UID);
                        var result = GetTagInfo(_rfidChannel, entity.UID);
                        if (result.Value == -1)
                        {
                            entity.SetError(result.ErrorInfo);
                            continue;
                        }

                        Debug.Assert(result.TagInfo != null);

                        entity.TagInfo = result.TagInfo;

                        LogicChip chip = LogicChip.From(result.TagInfo.Bytes,
                                                        (int)result.TagInfo.BlockSize,
                                                        "" // tag.TagInfo.LockStatus
                                                        );
                        string pii = chip.FindElement(ElementOID.PII)?.Text;
                        entity.PII = GetCaption(pii);
                    }

                    // 获得 Title
                    // 注:如果 Title 为空,文字中要填入 "(空)"
                    if (string.IsNullOrEmpty(entity.Title) &&
                        string.IsNullOrEmpty(entity.PII) == false && entity.PII != "(空)")
                    {
                        var result = GetEntityData(entity.PII,
                                                   out string title,
                                                   out string item_xml,
                                                   out string item_recpath);
                        if (result.Value == -1)
                        {
                            entity.SetError(result.ErrorInfo);
                            continue;
                        }
                        entity.Title = GetCaption(title);
                        // entity.ItemXml = item_xml;
                        entity.SetData(item_recpath, item_xml);
                    }

                    entity.SetError(null);
                    entity.FillFinished = true;
                }

                booksControl.SetBorrowable();
            }
            catch (Exception ex)
            {
#if NO
                this.error.Text       = ex.Message;
                this.error.Visibility = Visibility.Visible;
#endif
                this.Error = ex.Message;
            }
            finally
            {
#if NO
                RFID.EndRfidChannel(channel);
#endif
            }
        }