Exemple #1
0
 public async Task <IActionResult> NoidUpload([FromBody] NoidInput input)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         using (var db = new dbmodel.faceContext())
         {
             db.Noidlog.Add(new Noidlog
             {
                 Idcardno     = input.id,
                 Capturephoto = new PictureInfoNoid {
                     base64pic1 = input.pic1,
                     base64pic2 = input.pic2,
                     base64pic3 = input.pic3,
                 },
                 Businessnumber = "demo"
             });
             await db.SaveChangesAsync();
         }
         var temp = Path.Combine(Path.GetTempPath(), input.id);
         System.IO.File.WriteAllText(temp, JsonConvert.SerializeObject(input));
         //   FtpUploadFile(temp);
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
     return(Ok(new commonresponse {
         status = 0, explanation = "ok"
     }));
 }
Exemple #2
0
 public async Task <IActionResult> PostCompared([FromBody] ComparedInfo trails)
 {
     _log.LogDebug("{0}", 111111);
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     _log.LogDebug("{0}", 2222);
     try
     {
         using (var db = new dbmodel.faceContext())
         {
             _log.LogDebug("{0}", 3333);
             var person = db.Person.FirstOrDefault(c => c.Idcardno == trails.id);
             if (person == null)
             {
                 db.Person.Add(new Person
                 {
                     Idcardno    = trails.id,
                     Name        = trails.name,
                     Nation      = trails.nation,
                     Nationality = trails.nationality,
                     Birthday    = trails.birthday,
                     Address     = trails.idaddress,
                     Startdate   = trails.startdate,
                     Enddate     = trails.enddate,
                     Gender      = trails.gender,
                     Issuer      = trails.issuer,
                     Info        = new PictureInfo {
                         base64pic = trails.idphoto
                     },
                 });
             }
             _log.LogDebug("{0}", Convert.ToBase64String(trails.capturephoto).Take(30));
             _log.LogDebug("{0}", Convert.ToBase64String(trails.capturephoto).Skip(3000).Take(30));
             _log.LogDebug("{0}", Convert.ToBase64String(trails.capturephoto).TakeLast(30));
             db.Trails.Add(new Trails
             {
                 TimeStamp       = DateTime.Now,
                 Address         = trails.address,
                 Idcardno        = trails.id,
                 Operatingagency = trails.operatingagency,
                 Info            = new PictureInfo {
                     base64pic = trails.capturephoto
                 },
             });
             await db.SaveChangesAsync();
         }
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
     return(Ok(new commonresponse {
         status = 0, explanation = "ok"
     }));
 }
Exemple #3
0
        public async Task <IActionResult> GetNoidResult(string businessnumber)
        {
            _log.LogError("ip={0},port={1},businessid={2}", Request.HttpContext.Connection.RemoteIpAddress,
                          Request.HttpContext.Connection.RemotePort, businessnumber);
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                _log.LogError("ip={0},port={1},businessid={2}", Request.HttpContext.Connection.RemoteIpAddress,
                              Request.HttpContext.Connection.RemotePort, businessnumber);

                using (var db = new dbmodel.faceContext())
                {
                    var result = db.Noidlog.Where(c => c.Businessnumber == businessnumber && c.Compared
                                                  //&& !c.Notified
                                                  );
                    var rl = new List <NoidResult>();
                    foreach (var a in result)
                    {
                        a.Notified = true;
                        rl.Add(new NoidResult
                        {
                            id     = a.Idcardno,
                            status = (CompareResult)a.Result
                        });
                        db.Noidloghis.Add(new Noidloghis
                        {
                            Idcardno       = a.Idcardno,
                            Capturephoto   = a.Capturephoto,
                            Compared       = a.Compared,
                            Result         = a.Result,
                            Businessnumber = a.Businessnumber,
                            Stamp          = DateTime.Now
                        });
                        db.Noidlog.Remove(a);
                    }
                    await db.SaveChangesAsync();

                    return(Ok(rl));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }