This commit is contained in:
2021-07-31 22:27:59 +05:00
parent 39236f43b4
commit 52eaaaac79
505 changed files with 36230 additions and 1019 deletions

View File

@@ -1,19 +1,81 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using Newtonsoft;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;
using NLog;
using DataClient.Struct;
using System.IO;
using ApiServer.ApiStruct;
namespace ApiServer.Controllers
{
[Route("[controller]")]
[ApiController]
[ApiController, Route("[controller]")]
public class PasportController : ControllerBase
{
[HttpPost]
public string ()
private Logger log = LogManager.GetCurrentClassLogger();
[HttpPost, Route("check")]
public PasportCheckReq Check([FromBody] object value)
{
return View();
try
{
var reply = JsonConvert.DeserializeObject<PasportCheckRep>(value.ToString());
if (!reply.HasData || string.IsNullOrEmpty(reply.Name)) throw new Exception();
var paspName =
reply.DateAndTime.Hour.ToString("D2") +
reply.DateAndTime.Minute.ToString("D2") +
reply.DateAndTime.Second.ToString("D2") +
"-" + reply.Name;
var paspDir = Path.Combine(
Directory.GetCurrentDirectory(),
"data", "pasport",
reply.DateAndTime.Year.ToString("D4"),
reply.DateAndTime.Month.ToString("D2"),
reply.DateAndTime.Day.ToString("D2"),
paspName);
if (!System.IO.File.Exists(paspDir))
return new PasportCheckReq { Status = true, Exist = false };
return new PasportCheckReq { Status = true, Exist = true, Pasp = new Pasport(System.IO.File.ReadAllBytes(paspDir)) };
}
catch { return new PasportCheckReq { Status = false }; }
}
[HttpPost, Route("create")]
public PasportCreateReq Create([FromBody] object value)
{
try
{
var reply = JsonConvert.DeserializeObject<PasportCreateRep>(value.ToString());
if (!reply.HasData || string.IsNullOrEmpty(reply.Name)) throw new Exception();
var paspName =
reply.DateAndTime.Hour.ToString("D2") +
reply.DateAndTime.Minute.ToString("D2") +
reply.DateAndTime.Second.ToString("D2") +
"-" + reply.Name;
var dir = Path.Combine(
Directory.GetCurrentDirectory(),
"data", "pasport",
reply.DateAndTime.Year.ToString("D4"),
reply.DateAndTime.Month.ToString("D2"),
reply.DateAndTime.Day.ToString("D2"));
var paspDir = Path.Combine(dir, paspName);
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
System.IO.File.WriteAllBytes(paspDir, reply.Pasp.PaspByte);
return new PasportCreateReq { Status = true };
}
catch { return new PasportCreateReq { Status = false }; }
}
}
}