public static NormalResult GetState(string style) { try { // 因为 GetState 是可有可无的请求,如果 Url 为空就算了 if (string.IsNullOrEmpty(Base.Url)) { return(new NormalResult()); } BaseChannel <IBioRecognition> channel = Base.GetChannel(); try { var result = channel.Object.GetState(style); 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 = $"人脸中心出现异常: {ExceptionUtil.GetAutoText(ex)}" }); return(new NormalResult { Value = -1, ErrorInfo = ex.Message, ErrorCode = NotResponseException.GetErrorCode(ex) }); } }
public static NormalResult EnableSendkey(bool enable) { try { // 因为 EnableSendkey 是可有可无的请求,如果 Url 为空就算了 if (string.IsNullOrEmpty(Base.Url)) { return(new NormalResult()); } BaseChannel <IRfid> 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.Clear(); Base.TriggerSetError(ex, new SetErrorEventArgs { Error = NotResponseException.IsNotResponse(ex) ? $"RFID 中心({Base.Url})没有响应" : $"RFID 中心出现异常: {ExceptionUtil.GetExceptionText(ex)}" }); return(new NormalResult { Value = -1, ErrorInfo = ex.Message }); } }