Example #1
0
        static async Task ProcessingAsync()
        {
            var list = CopyList();

            foreach (var entity in list)
            {
                // 获得册记录和书目摘要
                // .Value
                //      -1  出错
                //      0   没有找到
                //      1   找到
                var result = await LibraryChannelUtil.GetEntityDataAsync(entity.PII, "network");

                if (result.Value == -1)
                {
                    entity.AppendError(result.ErrorInfo, "red", result.ErrorCode);
                }
                else
                {
                    if (string.IsNullOrEmpty(result.Title) == false)
                    {
                        entity.Title = PageBorrow.GetCaption(result.Title);
                    }
                    if (string.IsNullOrEmpty(result.ItemXml) == false)
                    {
                        entity.SetData(result.ItemRecPath, result.ItemXml);
                    }
                }
            }

            // 把处理过的 entity 从 list 中移走
            RemoveList(list);
        }
Example #2
0
        private void PageMenu_Loaded(object sender, RoutedEventArgs e)
        {
            // 只初始化一次。
            // 但初始化必须放在 _loaded 事件里面,因为只有这里才能得到 Application.Current.MainWindow。构造函数那里时机偏早了,MainWindow 还没有来得及创建
            if (_initialized == false)
            {
                Initial();
                _initialized = true;

                // 初始化智能书柜
                // 过程中需要检查门锁是否关上,如果没有关上要警告,只有关上了才能进入正常的菜单画面
                if (App.Function == "智能书柜")
                {
                    NavigatePageShelf("initial");
                }
            }

            // 如果有读者卡,要延时提醒不要忘了拿走读者卡
            if (TagList.Patrons?.Count > 0)
            {
                PageBorrow.BeginNotifyTask();
            }

            App.CurrentApp.TagChanged += CurrentApp_TagChanged;
        }
Example #3
0
 private void CurrentApp_TagChanged(object sender, TagChangedEventArgs e)
 {
     // 如果有读者卡,要延时提醒不要忘了拿走读者卡
     if (/*PageBorrow.isPatronChanged(e) &&*/ TagList.Patrons?.Count > 0)
     {
         PageBorrow.BeginNotifyTask();
     }
 }
Example #4
0
        void NavigatePageBorrow(string buttons)
        {
            if (_pageBorrow == null)
            {
                _pageBorrow = new PageBorrow();
            }

            _pageBorrow.ActionButtons = buttons;
            this.NavigationService.Navigate(_pageBorrow);
        }
Example #5
0
        private void Button_Borrow_Click(object sender, RoutedEventArgs e)
        {
#if NO
            Window mainWindow = Application.Current.MainWindow;
            var    page       = new PageBorrow();
            // page.Background = Brushes.Red;
            mainWindow.Content = page;
#endif
            this.NavigationService.Navigate(new PageBorrow("borrow"));
        }
Example #6
0
        // 第二阶段:填充图书信息的 PII 和 Title 字段
        async Task FillBookFields(BaseChannel <IRfid> channel,
                                  List <Entity> entities,
                                  CancellationToken token)
        {
            try
            {
                foreach (Entity entity in entities)
                {
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }

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

                    // 获得 PII
                    // 注:如果 PII 为空,文字中要填入 "(空)"
                    if (string.IsNullOrEmpty(entity.PII))
                    {
                        if (entity.TagInfo == null)
                        {
                            continue;
                        }

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

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

                    // 获得 Title
                    // 注:如果 Title 为空,文字中要填入 "(空)"
                    if (string.IsNullOrEmpty(entity.Title) &&
                        string.IsNullOrEmpty(entity.PII) == false && entity.PII != "(空)")
                    {
                        GetEntityDataResult result = await
                                                     Task <GetEntityDataResult> .Run(() =>
                        {
                            return(GetEntityData(entity.PII));
                        });

                        if (result.Value == -1)
                        {
                            entity.SetError(result.ErrorInfo);
                            continue;
                        }
                        entity.Title = PageBorrow.GetCaption(result.Title);
                        entity.SetData(result.ItemRecPath, result.ItemXml);
                    }

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

                booksControl.SetBorrowable();
            }
            catch (Exception ex)
            {
                SetGlobalError("current", ex.Message);
            }
        }