/// <summary> /// 使用当前选中打码平台打码 /// </summary> /// <param name="e"></param> /// <returns></returns> public bool GetVcode(VcodeEventArgs e) { if (currentProvider == null) { throw new NullReferenceException("CurrentPlatform should be set before excuting this method."); } return(currentProvider.GetVcode(e)); }
/// <summary> /// 上报错误验证码,打码平台一般都提供了此接口 /// </summary> /// <param name="e">GetVcode返回的结果</param> /// <returns></returns> public bool ReportErr(VcodeEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } Initialize(); if (!inited) { throw new InvalidOperationException("Initialization not excuted."); } return(InternalReportErr(e.VcodeId)); }
/// <summary> /// 识别验证码的主要操作 /// </summary> /// <param name="e"></param> /// <returns></returns> public bool GetVcode(VcodeEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } if (e.Bytes == null) { throw new ArgumentNullException("e.Bytes"); } Initialize(); if (!inited) { throw new InvalidOperationException("Initialization not excuted."); } string typeCode, result, vcodeId, msg; typeCode = GetImageTypeCode(e.ImgType); if (typeCode == null && e.ImgType != null) { this.imgTypeDict.TryGetValue(e.ImgType, out typeCode); } if (typeCode == null && e.ImgType != VcodeImgType.Any) { typeCode = GetImageTypeCode(VcodeImgType.Any); } if (typeCode == null && e.ImgType != VcodeImgType.Any) { this.imgTypeDict.TryGetValue(VcodeImgType.Any, out typeCode); } if (typeCode == null) { throw new NotSupportedException("Not support the imgtype that e.Type stands for."); } var vResult = InternalGetVcode(typeCode, e.Bytes, out result, out vcodeId, out msg); e.Handled = true; e.Platform = this.platform; e.Result = result; e.VcodeId = vcodeId; e.Msg = msg; return(vResult); }
/// <summary> /// 上传错误码 /// </summary> /// <param name="e"></param> /// <returns></returns> public bool ReportErr(VcodeEventArgs e) { if (e == null) { throw new ArgumentNullException("e"); } if (currentProvider != null && e.Platform == currentProvider.Platform) { return(currentProvider.ReportErr(e)); } if (e.Platform == null || !vcodeDict.ContainsKey(e.Platform)) { return(false); } else { return(vcodeDict[e.Platform].ReportErr(e)); } }