修改异步方法

DataMaintenance
zhangbin 2025-04-11 16:39:26 +08:00
parent fed60bc680
commit b0bd18ec40
2 changed files with 19 additions and 8 deletions

View File

@ -443,7 +443,7 @@ namespace OpenAuth.App.ServiceApp.DataMaintenance
/// <param name="shpFilePath"></param> /// <param name="shpFilePath"></param>
/// <param name="shpFilePathzip"></param> /// <param name="shpFilePathzip"></param>
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public async void ExportShapefile(TableDataReq tableDataReq, string shpFilePath, string shpFilePathzip, List<ModuleColumn> headers) public async Task ExportShapefile(TableDataReq tableDataReq, string shpFilePath, string shpFilePathzip, List<ModuleColumn> headers)
{ {
var data = await GetDataAllList(tableDataReq); var data = await GetDataAllList(tableDataReq);
if (data == null || data.Count == 0) if (data == null || data.Count == 0)

View File

@ -13,6 +13,7 @@ using OpenAuth.Repository.Domain.DataMaintenance;
using OpenAuth.WebApi.Model.CustomAttribute; using OpenAuth.WebApi.Model.CustomAttribute;
using System.Data; using System.Data;
using OpenAuth.App.CodeTable; using OpenAuth.App.CodeTable;
using System.Threading.Tasks;
namespace OpenAuth.WebApi.Controllers.ServiceControllers.DataMaintenance namespace OpenAuth.WebApi.Controllers.ServiceControllers.DataMaintenance
{ {
@ -105,12 +106,12 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers.DataMaintenance
/// <param name="tableName"></param> /// <param name="tableName"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
public Response<List<dynamic>> GetTableColumnList( string tableName) public Response<List<dynamic>> GetTableColumnList(string tableName)
{ {
var result = new Response<List<dynamic>>(); var result = new Response<List<dynamic>>();
try try
{ {
result.Result = _app.GetTableAndViewColumnList( tableName); result.Result = _app.GetTableAndViewColumnList(tableName);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -141,7 +142,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers.DataMaintenance
c.value = item.description.ToString(); c.value = item.description.ToString();
cl.Add(c); cl.Add(c);
} }
var excelRes =await _app.ListToExcel(tableDataReq, cl); var excelRes = await _app.ListToExcel(tableDataReq, cl);
if (excelRes.Code == 200) if (excelRes.Code == 200)
{ {
return File(excelRes.Result.ToArray(), return File(excelRes.Result.ToArray(),
@ -160,7 +161,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers.DataMaintenance
/// <param name="req"></param> /// <param name="req"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public IActionResult ExportShapefile(TableDataReq tableDataReq) public async Task<IActionResult> ExportShapefile(TableDataReq tableDataReq)
{ {
try try
{ {
@ -175,7 +176,7 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers.DataMaintenance
} }
string shpFilePath = Path.Combine(Path.GetTempPath(), $"数据信息{DateTime.Now:yyyyMMddHHmmss}.shp"); string shpFilePath = Path.Combine(Path.GetTempPath(), $"数据信息{DateTime.Now:yyyyMMddHHmmss}.shp");
string shpFilePathzip = Path.Combine(Path.GetTempPath(), $"数据信息{DateTime.Now:yyyyMMddHHmmss}.zip"); string shpFilePathzip = Path.Combine(Path.GetTempPath(), $"数据信息{DateTime.Now:yyyyMMddHHmmss}.zip");
_app.ExportShapefile(tableDataReq, shpFilePath, shpFilePathzip, cl); await _app.ExportShapefile(tableDataReq, shpFilePath, shpFilePathzip, cl);
byte[] fileBytes = System.IO.File.ReadAllBytes(shpFilePathzip); byte[] fileBytes = System.IO.File.ReadAllBytes(shpFilePathzip);
return File(fileBytes, "application/octet-stream", $"数据信息{DateTime.Now:yyyyMMddHHmmss}.zip"); return File(fileBytes, "application/octet-stream", $"数据信息{DateTime.Now:yyyyMMddHHmmss}.zip");
} }
@ -192,9 +193,19 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers.DataMaintenance
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<Response<bool>> UpdateBatch(UpdateBatchDataReq req) public async Task<Response<bool>> UpdateBatch(UpdateBatchDataReq req)
{
var result = new Response<bool>();
try
{ {
return await _app.UpdateBatch(req); return await _app.UpdateBatch(req);
} }
catch (Exception ex)
{
result.Code = 500;
result.Message = ex.Message;
}
return result;
}
#endregion #endregion
} }
} }