Ejemplo n.º 1
0
        public static NormalResult EnableSendkey(bool enable)
        {
            try
            {
                // 因为 EnableSendkey 是可有可无的请求,如果 Url 为空就算了
                if (string.IsNullOrEmpty(Base.Url))
                {
                    return(new NormalResult());
                }

                BaseChannel <IBioRecognition> channel = Base.GetChannel();
                try
                {
                    var result = channel.Object.EnableSendKey(enable);
                    if (result.Value == -1)
                    {
                        Base.TriggerSetError(result,
                                             new SetErrorEventArgs {
                            Error = result.ErrorInfo
                        });
                    }
                    else
                    {
                        Base.TriggerSetError(result,
                                             new SetErrorEventArgs {
                            Error = null
                        });                                          // 清除以前的报错
                    }
                    return(result);
                }
                finally
                {
                    Base.ReturnChannel(channel);
                }
            }
            catch (Exception ex)
            {
                Base.TriggerSetError(ex,
                                     new SetErrorEventArgs
                {
                    Error = RfidManager.IsNotResponse(ex)
                        ? $"人脸中心({Base.Url})没有响应"
                        : $"人脸中心出现异常: {ExceptionUtil.GetAutoText(ex)}"
                });
                return(new NormalResult {
                    Value = -1, ErrorInfo = ex.Message
                });
            }
        }
Ejemplo n.º 2
0
#pragma warning disable VSTHRD100 // 避免使用 Async Void 方法
        private async void PageShelf_Loaded(object sender, RoutedEventArgs e)
#pragma warning restore VSTHRD100 // 避免使用 Async Void 方法
        {
            FingerprintManager.SetError += FingerprintManager_SetError;
            FingerprintManager.Touched  += FingerprintManager_Touched;

            App.TagChanged += CurrentApp_TagChanged;

            RfidManager.ListLocks += RfidManager_ListLocks;

            RfidManager.ClearCache();
            // 注:将来也许可以通过(RFID 以外的)其他方式输入图书号码
            if (string.IsNullOrEmpty(RfidManager.Url))
            {
                this.SetGlobalError("rfid", "尚未配置 RFID 中心 URL");
            }

            /*
             * _layer = AdornerLayer.GetAdornerLayer(this.mainGrid);
             * _adorner = new LayoutAdorner(this);
             */
            InitializeLayer(this.mainGrid);

            {
                List <string> style = new List <string>();
                if (string.IsNullOrEmpty(App.RfidUrl) == false)
                {
                    style.Add("rfid");
                }
                if (string.IsNullOrEmpty(App.FingerprintUrl) == false)
                {
                    style.Add("fingerprint");
                }
                if (string.IsNullOrEmpty(App.FaceUrl) == false)
                {
                    style.Add("face");
                }
                this.patronControl.SetStartMessage(StringUtil.MakePathList(style));
            }

            // RfidManager.LockCommands = DoorControl.GetLockCommands();

            await FillAsync(new CancellationToken());
        }
Ejemplo n.º 3
0
        async Task <NormalResult> Update(
            BaseChannel <IRfid> channel_param,
            List <Entity> update_entities,
            CancellationToken token)
        {
            if (update_entities.Count > 0)
            {
                try
                {
                    BaseChannel <IRfid> channel = channel_param;
                    if (channel == null)
                    {
                        channel = RfidManager.GetChannel();
                    }
                    try
                    {
                        await FillBookFields(channel, update_entities, token);
                    }
                    finally
                    {
                        if (channel_param == null)
                        {
                            RfidManager.ReturnChannel(channel);
                        }
                    }
                }
                catch (Exception ex)
                {
                    string error = $"填充图书信息时出现异常: {ex.Message}";
                    SetGlobalError("rfid", error);
                    return(new NormalResult {
                        Value = -1, ErrorInfo = error
                    });
                }

                // 自动检查 EAS 状态
                // CheckEAS(update_entities);
            }
            return(new NormalResult());
        }
Ejemplo n.º 4
0
        private async void PageShelf_Loaded(object sender, RoutedEventArgs e)
        {
            FingerprintManager.SetError += FingerprintManager_SetError;
            FingerprintManager.Touched  += FingerprintManager_Touched;

            App.CurrentApp.TagChanged += CurrentApp_TagChanged;

            RfidManager.ClearCache();
            // 注:将来也许可以通过(RFID 以外的)其他方式输入图书号码
            if (string.IsNullOrEmpty(RfidManager.Url))
            {
                this.SetGlobalError("rfid", "尚未配置 RFID 中心 URL");
            }

            _layer   = AdornerLayer.GetAdornerLayer(this.mainGrid);
            _adorner = new LayoutAdorner(this);

            {
                List <string> style = new List <string>();
                if (string.IsNullOrEmpty(App.RfidUrl) == false)
                {
                    style.Add("rfid");
                }
                if (string.IsNullOrEmpty(App.FingerprintUrl) == false)
                {
                    style.Add("fingerprint");
                }
                if (string.IsNullOrEmpty(App.FaceUrl) == false)
                {
                    style.Add("face");
                }
                this.patronControl.SetStartMessage(StringUtil.MakePathList(style));
            }


            await Fill(new CancellationToken());
        }
Ejemplo n.º 5
0
        // 填充读者信息的其他字段(第二阶段)
        async Task <NormalResult> FillPatronDetail(bool force = false)
        {
            // 已经填充过了
            if (_patron.PatronName != null &&
                force == false)
            {
                return(new NormalResult());
            }

            string pii = _patron.PII;

            if (string.IsNullOrEmpty(pii))
            {
                pii = _patron.UID;
            }

            if (string.IsNullOrEmpty(pii))
            {
                return(new NormalResult());
            }

            // return.Value:
            //      -1  出错
            //      0   读者记录没有找到
            //      1   成功
            GetReaderInfoResult result = await
                                         Task <GetReaderInfoResult> .Run(() =>
            {
                return(GetReaderInfo(pii));
            });

            if (result.Value != 1)
            {
                string error = $"读者 '{pii}': {result.ErrorInfo}";
                SetPatronError("getreaderinfo", error);
                return(new NormalResult {
                    Value = -1, ErrorInfo = error
                });
            }

            SetPatronError("getreaderinfo", "");

            if (string.IsNullOrEmpty(_patron.State) == true)
            {
                OpenDoor();
            }

            if (force)
            {
                _patron.PhotoPath = "";
            }
            // string old_photopath = _patron.PhotoPath;
            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                _patron.SetPatronXml(result.RecPath, result.ReaderXml, result.Timestamp);
                this.patronControl.SetBorrowed(result.ReaderXml);
            }));

            // 显示在借图书列表
            List <Entity> entities = new List <Entity>();

            foreach (Entity entity in this.patronControl.BorrowedEntities)
            {
                entities.Add(entity);
            }
            if (entities.Count > 0)
            {
                try
                {
                    BaseChannel <IRfid> channel = RfidManager.GetChannel();
                    try
                    {
                        await FillBookFields(channel, entities, new CancellationToken());
                    }
                    finally
                    {
                        RfidManager.ReturnChannel(channel);
                    }
                }
                catch (Exception ex)
                {
                    string error = $"填充读者信息时出现异常: {ex.Message}";
                    SetGlobalError("rfid", error);
                    return(new NormalResult {
                        Value = -1, ErrorInfo = error
                    });
                }
            }
#if NO
            // 装载图象
            if (old_photopath != _patron.PhotoPath)
            {
                Task.Run(() => {
                    LoadPhoto(_patron.PhotoPath);
                });
            }
#endif
            return(new NormalResult());
        }