添加图层发布

DataMaintenance
zhangbin 2025-04-29 10:34:54 +08:00
parent 69e0185ded
commit 2c54915cad
2 changed files with 49 additions and 10 deletions

View File

@ -1,7 +1,10 @@
using DocumentFormat.OpenXml.Office2016.Excel;
using DocumentFormat.OpenXml.Bibliography;
using DocumentFormat.OpenXml.Office2016.Excel;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml.Wordprocessing;
using Infrastructure;
using Infrastructure.Utils;
using NetTopologySuite;
using NetTopologySuite.Features;
using NetTopologySuite.Geometries;
using NetTopologySuite.IO;
@ -18,6 +21,7 @@ using OpenAuth.Repository;
using OpenAuth.Repository.Core;
using OpenAuth.Repository.Domain.DataMaintenance;
using Org.BouncyCastle.Asn1.Cms;
using Org.BouncyCastle.Ocsp;
using SqlSugar;
using System;
using System.Collections;
@ -99,15 +103,44 @@ namespace OpenAuth.App.ServiceApp.DataMaintenance
}
//添加应用
public async Task<Response<bool>> Add(ApplicationData app)
{
using (var db = UnitWork.CreateContext())
{
app.Id = YitIdHelper.NextId();
app.CreateUserId = _auth.GetCurrentUser().User.Id;
app.CreateTime = DateTime.Now;
if (await Repository.AsInsertable(app).ExecuteCommandAsync() > 0)
if (await db.ApplicationData.AsInsertable(app).ExecuteCommandAsync() > 0)
{
if (app.IsServer == 1)
{
//先插入一条数据
var geography = NtsGeometryServices.Instance.CreateGeometryFactory(int.Parse("4326"));
var point = geography.CreatePoint(new Coordinate(0, 0));
await db.Db.InsertableByDynamic(new { Id = 0, geom = point.AsText() }).AS(app.TableName).ExecuteCommandAsync();
var response = await GeoUtil.CreateStoreAndLayer("", "EPSG:4326", app.TableName, "");
if (response)
{
//删除数据
await db.Db.Deleteable<object>().AS(app.TableName).Where("\"Id\"=@Id", new { Id = 0 }).ExecuteCommandAsync();
}
}
if (db.Commit())
{
return new Response<bool> { Result = true };
}
else
{
return new Response<bool> { Result = false, Message = "添加失败" };
}
}
else
return new Response<bool> { Result = false, Message = "添加失败" };
}
}
//编辑应用
public async Task<Response<bool>> Update(ApplicationData app)
{

View File

@ -78,6 +78,12 @@ namespace OpenAuth.Repository.Domain.DataMaintenance
/// </summary>
public int IsServer { get; set; }
/// <summary>
/// Desc:表名
/// Default:NULL::character varying
/// Nullable:True
/// </summary>
public string TableName { get; set; }
/// <summary>
/// Desc:点线面
/// Default:NULL::character varying
/// Nullable:True