bugfix:修复附件bug
This commit is contained in:
@@ -17,6 +17,8 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Furion.RemoteRequest.Extensions;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace Ewide.NbzsZheliban.Service
|
||||
{
|
||||
@@ -26,11 +28,12 @@ namespace Ewide.NbzsZheliban.Service
|
||||
private readonly ISqlSugarRepository repository;
|
||||
private readonly SqlSugarClient db;
|
||||
private readonly IJsonSerializerProvider _jsonSerializer;
|
||||
public DataService(ISqlSugarRepository sqlSugarRepository, IJsonSerializerProvider jsonSerializer)
|
||||
public DataService(ISqlSugarRepository sqlSugarRepository, IJsonSerializerProvider jsonSerializer, IHostingEnvironment hostingEnvironment)
|
||||
{
|
||||
repository = sqlSugarRepository;
|
||||
db = repository.Context;
|
||||
_jsonSerializer = jsonSerializer;
|
||||
this._hostingEnvironment = hostingEnvironment;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -330,22 +333,26 @@ namespace Ewide.NbzsZheliban.Service
|
||||
throw Oops.Oh("ID错误");
|
||||
}
|
||||
if (string.IsNullOrEmpty(XyFile))
|
||||
throw Oops.Oh("未上传附件");
|
||||
throw Oops.Oh(-2001, "无附件");
|
||||
var pics = new List<string>();
|
||||
var nbzs_file_path = App.Configuration["nbzs_file_path"];
|
||||
//var nbzs_file_path = App.Configuration["nbzs_file_path"];
|
||||
var nbzs_domain = App.Configuration["nbzs_domain"];
|
||||
var filePath = nbzs_file_path + XyFile;
|
||||
var current_domain = App.Configuration["current_domain"];
|
||||
|
||||
var filePath = GetCurrentRootPath() + XyFile;
|
||||
var pdfFile = new FileInfo(filePath);
|
||||
if (File.Exists(pdfFile.Directory + "\\lock"))
|
||||
{
|
||||
var picCount = pdfFile.Directory.GetFiles(pdfFile.Name + "-*.jpg").Length;
|
||||
for (int i = 0; i < picCount; i++)
|
||||
{
|
||||
pics.Add(nbzs_domain + XyFile + "-" + i + ".jpg");
|
||||
pics.Add(current_domain + XyFile + "-" + i + ".jpg");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var s = (nbzs_domain + XyFile).GetAsStreamAsync().Result;
|
||||
StreamToFile(s, XyFile);
|
||||
MagickReadSettings settings = new MagickReadSettings();
|
||||
settings.Density = new Density(400, 400); //设置质量
|
||||
using (MagickImageCollection images = new MagickImageCollection())
|
||||
@@ -359,7 +366,7 @@ namespace Ewide.NbzsZheliban.Service
|
||||
image.Format = MagickFormat.Jpg;
|
||||
var imagename = filePath + "-" + i + ".jpg";
|
||||
image.Write(imagename);
|
||||
pics.Add(nbzs_domain + XyFile + "-" + i + ".jpg");
|
||||
pics.Add(current_domain + XyFile + "-" + i + ".jpg");
|
||||
if (i == 0)
|
||||
{
|
||||
File.WriteAllText(pdfFile.Directory.FullName + "\\lock", "lock");
|
||||
@@ -368,11 +375,47 @@ namespace Ewide.NbzsZheliban.Service
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw Oops.Oh(ex.Message);
|
||||
//throw Oops.Oh(ex.Message);
|
||||
throw Oops.Oh(-2002, "无附件文件[" + nbzs_domain + XyFile + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
return new { pics, pdf = nbzs_domain + XyFile };
|
||||
return new { pics, pdf = current_domain + XyFile };
|
||||
}
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private string GetCurrentRootPath()
|
||||
{
|
||||
return _hostingEnvironment.WebRootPath;
|
||||
//return Path.GetDirectoryName(this.GetType().Assembly.Location);
|
||||
}
|
||||
private string StreamToFile(Stream s, string filename)
|
||||
{
|
||||
var d = GetCurrentRootPath() + filename;
|
||||
FileInfo f = new(d);
|
||||
if (!f.Directory.Exists)
|
||||
f.Directory.Create();
|
||||
using (MemoryStream stmMemory = new MemoryStream())
|
||||
{
|
||||
byte[] buffer = new byte[s.Length];
|
||||
int i;
|
||||
//将字节逐个放入到Byte中
|
||||
while ((i = s.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
stmMemory.Write(buffer, 0, i);
|
||||
}
|
||||
var fileBytes = stmMemory.ToArray();//文件流Byte,需要文件流可直接return,不需要下面的保存代码
|
||||
stmMemory.Close();
|
||||
using (MemoryStream m = new(fileBytes))
|
||||
{
|
||||
using (FileStream fs = new(d, FileMode.OpenOrCreate))
|
||||
{
|
||||
m.WriteTo(fs);
|
||||
fs.Close();
|
||||
}
|
||||
m.Close();
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
/// <summary>
|
||||
/// 分布评估详细
|
||||
|
||||
@@ -38,5 +38,7 @@ namespace Ewide.NbzsZheliban
|
||||
{
|
||||
return await repository.Ado.GetDataTableAsync("select * from TCodeScore"); ;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -46,6 +46,6 @@ http://118.178.224.202:3000/ewide/zsxt_nbzs_h5
|
||||
https://mapi.zjzwfw.gov.cn/web/mgop/gov-open/zj/2001833218/reserved/index.html#/?1=1&ticket=
|
||||
|
||||
部署命令
|
||||
dotnet DockerRelease.dll --urls=http://*:9002 --ip="127.0.0.1" --port=9001
|
||||
dotnet DockerRelease.dll --urls=http://*:9002 --ip="127.0.0.1" --port=9003
|
||||
dotnet DockerRelease.dll --urls=http://*:9001 --ip="127.0.0.1" --port=9001
|
||||
dotnet DockerRelease.dll --urls=http://*:9002 --ip="127.0.0.1" --port=9003
|
||||
dotnet DockerRelease.dll --urls=http://*:9003 --ip="127.0.0.1" --port=9003
|
||||
@@ -34,7 +34,9 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"nbzs_file_path": "D:\\1_发布程序",
|
||||
"nbzs_domain": "https://zsxt.nbzs.org.cn",
|
||||
"nbzs_domain-bak": "https://zsxt.nbzs.org.cn",
|
||||
"nbzs_domain": "http://118.178.224.202:2258/",
|
||||
"current_domain": "http://localhost:5566/",
|
||||
"CorsAccessorSettings": {
|
||||
"PolicyName": "自定义跨域策略名",
|
||||
"WithOrigins": [ "http://localhost:8080", "https://mapi.zjzwfw.gov.cn" ]
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 489 KiB |
@@ -0,0 +1 @@
|
||||
lock
|
||||
Reference in New Issue
Block a user