diff --git a/24Hour/Controllers/Common/CommonController.cs b/24Hour/Controllers/Common/CommonController.cs index 214037a..050d67e 100644 --- a/24Hour/Controllers/Common/CommonController.cs +++ b/24Hour/Controllers/Common/CommonController.cs @@ -8,7 +8,9 @@ using Elight.Utility; using Elight.Utility.Code; using Elight.Utility.Extensions; using Elight.Utility.logs; +using java.io; using java.util; +using javax.smartcardio; using javax.xml.crypto; using jdk.nashorn.@internal.ir; using Microsoft.AspNetCore.Authorization; @@ -1488,7 +1490,7 @@ namespace _24Hour.Controllers.Common var Lawyerboldata = Lawyerbol.FirstOrDefault(); if (dto.Type == 1) { - if (Lawyerboldata.state ==4) + if (Lawyerboldata.state == 4) { result.IsSucceed = false; result.result = "预约已被取消"; @@ -2747,7 +2749,7 @@ namespace _24Hour.Controllers.Common public async Task Upload_Files(IFormFile file) { Result outParm = new Result(); - return await Task.Run(() => + return await Task.Run(async () => { if (file.Length <= 0) { @@ -2761,22 +2763,38 @@ namespace _24Hour.Controllers.Common IFormFile file = Request.Form.Files.FirstOrDefault(); var fname = $@"{file.FileName}"; var hzname = $"{Path.GetExtension(fname)}"; - var _path = $"/CaseFile/video/{DateTime.Now.ToString("yyyy-MM-dd")}"; - var dic = Path.Combine(Environment.CurrentDirectory, "wwwroot"); - if (!string.IsNullOrEmpty(_path)) - dic += _path; + var _path = Path.Combine("CaseFile", "card", DateTime.Now.ToString("yyyy-MM-dd")); + var dic = Path.Combine(Environment.CurrentDirectory, "wwwroot", _path); + if (!System.IO.Directory.Exists(dic)) Directory.CreateDirectory(dic); var filename = $"{DateTime.Now:yyyyMMddHHmmssfff}{Path.GetExtension(fname)}"; var filepath = Path.Combine(_path, $"{filename}"); var path = Path.Combine(dic, $"{filename}"); + var __path = Path.Combine(_path, filename); + path = System.IO.Path.ChangeExtension(path, "aks"); + using (var stream = new FileStream(path, FileMode.OpenOrCreate)) { - file.CopyToAsync(stream).Wait(); + await file.CopyToAsync(stream); } - var __path = $"{_path}/{filename}"; + // var __path = $"{_path}/{filename}"; + + + __path = System.IO.Path.ChangeExtension(__path, "aks"); + + + var repath = "/" + __path.Replace(@"\", @"/"); outParm.IsSucceed = true; - outParm.result = new { hzname = hzname, url = __path, tile = Path.GetFileNameWithoutExtension(file.FileName), size, DataPath = path, filePath = dic }; + outParm.result = new + { + hzname = hzname, + url = repath, + tile = Path.GetFileNameWithoutExtension(file.FileName), + size, + DataPath = path, + filePath = dic + }; } catch (Exception e) { @@ -2786,6 +2804,30 @@ namespace _24Hour.Controllers.Common return Json(outParm); }); } + [HttpGet] + [Route("GetImageFile")] + public async Task GetImageFile(string file) + { + Result result = new Result(); + var urlpath = file.Replace("/", @"\"); + var path = Path.Combine(Environment.CurrentDirectory, "wwwroot"+urlpath); + if (System.IO.File.Exists(path)) + { + var str = Convert.ToBase64String(System.IO.File.ReadAllBytes(path)); + result.result = new + { + BaseStr = str + }; + result.IsSucceed = true; + } + else + { + result.IsSucceed = false; + result.Message = "文件不存在"; + } + + return result; + } /// /// 文件上传--附件 /// @@ -2794,6 +2836,7 @@ namespace _24Hour.Controllers.Common [HttpPost] [Route("Upload_Files1")] [AllowAnonymous] + public async Task Upload_Files1(IFormFile file) { Result outParm = new Result(); @@ -2819,12 +2862,18 @@ namespace _24Hour.Controllers.Common var filename = $"{DateTime.Now:yyyyMMddHHmmssfff}{Path.GetExtension(fname)}"; var filepath = Path.Combine(_path, $"{filename}"); var path = Path.Combine(dic, $"{filename}"); + var __path = Path.Combine(_path, filename); + path = System.IO.Path.ChangeExtension(path, "aks"); + using (var stream = new FileStream(path, FileMode.OpenOrCreate)) { await file.CopyToAsync(stream); } // var __path = $"{_path}/{filename}"; - var __path = Path.Combine(_path, filename); + + + __path = System.IO.Path.ChangeExtension(__path, "aks"); + var repath = "/" + __path.Replace(@"\", @"/");