private bool BuildTnetDriverLicLog(TnetDriveLicLog oldTnetDriveLicLog, DriverResult driResult, AuthDriverLicenseReq req) { string host = HttpContext.Current.Request.Url.Host; host = "http://images2." + host.Substring(host.IndexOf('.') + 1); oldTnetDriveLicLog.Name = driResult.姓名.words; oldTnetDriveLicLog.Addr = driResult.住址.words; oldTnetDriveLicLog.Birthday = driResult.出生日期 == null ? "" : driResult.出生日期.words; oldTnetDriveLicLog.Cardimg = req.FrontImgUrl.Replace("/images2", host); oldTnetDriveLicLog.CardimgAppendix = req.AppendixImgUrl.Replace("/images2", host); oldTnetDriveLicLog.Cardno = driResult.证号 == null ? "" : driResult.证号.words; oldTnetDriveLicLog.Country = driResult.国籍 == null ? "" : driResult.国籍.words; oldTnetDriveLicLog.Enddate = driResult.至 == null ? "" : driResult.至.words; oldTnetDriveLicLog.VehicleType = driResult.准驾车型 == null ? "" : driResult.准驾车型.words; oldTnetDriveLicLog.ValidPeriod = driResult.效期限 == null ? "" : driResult.效期限.words; oldTnetDriveLicLog.Sex = driResult.性别 == null ? "" : driResult.性别.words; oldTnetDriveLicLog.Nodeid = req.Nodeid; oldTnetDriveLicLog.Firtdate = driResult.初次领证日期 == null ? "" : driResult.初次领证日期.words; oldTnetDriveLicLog.Remarks = ""; oldTnetDriveLicLog.Status = 1; oldTnetDriveLicLog.Fileno = req.FileNo; return(true); }
/// <summary> /// 驾驶证绑定 /// </summary> /// <param name="req"></param> /// <returns></returns> public DriverLicenseDto AuthDriverLicense(AuthDriverLicenseReq req) { List <string> oldImgPath = new List <string>(); req.FrontImgUrl = req.FrontImgUrl.Replace(Common.Facade.Helper.DomainUrl, "").Replace(AppConfig.FileRootDir, ""); req.AppendixImgUrl = req.FrontImgUrl.Replace(Common.Facade.Helper.DomainUrl, "").Replace(AppConfig.FileRootDir, ""); if (!File.Exists(FileService.GetPhysicsFilePath(req.FrontImgUrl)) || !File.Exists(FileService.GetPhysicsFilePath(req.AppendixImgUrl)) ) { Alert("图片不存在,请先上传图片"); return(null); } var reginfo = HttpContext.Current.GetRegInfo(); if (reginfo.Isconfirmed == 0) { Alert("您必须通过实名认证后才能绑定驾驶证"); return(null); } var driveLicLog = db.TnetDriveLicLogSet.FirstOrDefault(w => w.Nodeid == req.Nodeid); if (driveLicLog != null) { if (req.FrontImgUrl == driveLicLog.Cardimg && req.FileNo.Equals(driveLicLog.Fileno)) { return(new DriverLicenseDto { DriverLicenseUrl = driveLicLog.Cardimg, AppendixUrl = driveLicLog.CardimgAppendix, FileNo = driveLicLog.Fileno, Name = driveLicLog.Name, Status = driveLicLog.Status }); } oldImgPath.Add(new Uri(driveLicLog.Cardimg).LocalPath.Replace("/driverlicense/", "/images2/driverlicense/")); oldImgPath.Add(new Uri(driveLicLog.CardimgAppendix).LocalPath.Replace("/driverlicense/", "/images2/driverlicense/")); } if (driveLicLog == null) { driveLicLog = new TnetDriveLicLog(); } string photoPhysicalPath = FileService.GetPhysicsFilePath(req.FrontImgUrl); //(uri_driver.LocalPath); (bool success, string message, object result) = ScanLicense.GetInstance(LicenseTypeEnum.Driver).Execute(new ExecuteEntity() { PhotoPhysicalPath = photoPhysicalPath }); if (!success) { Alert(message); return(null); } DriverResult driResult = ((DriverResp)result).words_result; var tnetNodeInfo = db.TnetNodeinfoSet.FirstOrDefault(w => w.Nodeid == req.Nodeid); if (tnetNodeInfo == null) { Alert("用户认证信息错误,请联系管理员"); return(null); } if (tnetNodeInfo.Name.Trim() != driResult.姓名.words.Trim() || tnetNodeInfo.Idcardno.Trim() != driResult.证号.words.Trim()) { Alert("驾驶证信息需要与身份证信息一致才能通过审核"); //Alert("您上传的驾驶证姓名【" + driResult.姓名.words + "】与认证用户名字【" + tnetNodeInfo.Name + "】不一致"); return(null); } //if (tnetNodeInfo.Idcardno.Trim() != driResult.证号.words.Trim()) //{ // Alert("您上传的驾驶证证件号【" + driResult.证号.words + "】与认证用户证件号【" + tnetNodeInfo.Idcardno + "】不一致"); // return false; //} string datetime = DateTime.Now.ToString("yyyyMMddHHmmss"); string reallyPath_front = driverImagePath + req.Nodeid + "-" + datetime + "-Driver" + Path.GetExtension(req.FrontImgUrl); string reallyPath_appendix = driverImagePath + req.Nodeid + "-" + datetime + "-Appendix" + Path.GetExtension(req.AppendixImgUrl); if ( !Common.Facade.Helper.CopyFile(FileService.GetPhysicsFilePath(req.FrontImgUrl), HttpContext.Current.Server.MapPath(reallyPath_front)) || !Common.Facade.Helper.CopyFile(FileService.GetPhysicsFilePath(req.AppendixImgUrl), HttpContext.Current.Server.MapPath(reallyPath_appendix)) ) { log.Info("拷贝图片失败:{" + req.FrontImgUrl + "}To{" + reallyPath_front + "}"); log.Info("{" + req.AppendixImgUrl + "}To{" + reallyPath_appendix + "}"); DeleteFile(new string[] { reallyPath_front }); Alert("驾驶证绑定失败"); return(null); } req.FrontImgUrl = reallyPath_front; req.AppendixImgUrl = reallyPath_appendix; BuildTnetDriverLicLog(driveLicLog, driResult, req); if (driveLicLog.Id == 0) { db.TnetDriveLicLogSet.Add(driveLicLog); } if (db.SaveChanges() <= 0) { DeleteFile(new string[] { reallyPath_front, reallyPath_appendix }); Alert("驾驶证绑定失败"); return(null); } if (oldImgPath.Count > 0) { DeleteFile(oldImgPath.ToArray()); } return(new DriverLicenseDto { DriverLicenseUrl = driveLicLog.Cardimg, AppendixUrl = driveLicLog.CardimgAppendix, FileNo = driveLicLog.Fileno, Name = driveLicLog.Name, Status = driveLicLog.Status });; }