2022-11-01 19:15:02 +08:00
using FrontendWebApi.Models ;
using Microsoft.AspNetCore.Http ;
2022-11-01 10:49:22 +08:00
using Microsoft.AspNetCore.Mvc ;
using Microsoft.Extensions.Logging ;
using Repository.BackendRepository.Implement ;
using System.Collections.Generic ;
using System.Threading.Tasks ;
using System ;
using System.Linq ;
2022-11-10 14:34:53 +08:00
using System.Web ;
2022-11-01 10:49:22 +08:00
using Repository.BackendRepository.Interface ;
using Repository.FrontendRepository.Interface ;
using System.IO ;
2022-11-11 10:12:27 +08:00
using static Microsoft . Extensions . Logging . EventSource . LoggingEventSource ;
2022-11-01 10:49:22 +08:00
namespace FrontendWebApi.ApiControllers
{
2022-11-09 11:06:17 +08:00
//[Route("api/[controller]")]
//[ApiController]
2022-11-01 10:49:22 +08:00
public class GraphManageController : MyBaseApiController < GraphManageController >
{
private readonly IBackendRepository backendRepository ;
private readonly IFrontendRepository frontendRepository ;
2022-12-13 18:41:32 +08:00
private string graph_manage_layer = "graph_manage_layer" ;
2022-11-01 10:49:22 +08:00
private string graph_manage_layer1 = "graph_manage_layer1" ;
private string graph_manage_layer2 = "graph_manage_layer2" ;
private string graphManageFileSaveAsPath = "" ;
public GraphManageController ( IBackendRepository backendRepository , IFrontendRepository frontendRepository )
{
this . backendRepository = backendRepository ;
this . frontendRepository = frontendRepository ;
graphManageFileSaveAsPath = Path . Combine ( Directory . GetCurrentDirectory ( ) , "wwwroot" , "upload" , "graph_manage" ) ;
}
2022-12-13 18:41:32 +08:00
2022-12-12 16:11:04 +08:00
/// <summary>
/// 圖資類別列表
/// </summary>
/// <returns></returns>
2022-12-12 16:09:44 +08:00
[HttpPost]
2023-05-16 12:15:38 +08:00
public async Task < ApiResult < List < GraphManageTree > > > GraphManageTreeList ( )
2022-12-12 16:09:44 +08:00
{
2023-05-16 12:15:38 +08:00
ApiResult < List < GraphManageTree > > apiResult = new ApiResult < List < GraphManageTree > > ( ) ;
List < GraphManageTree > gmTree = new List < GraphManageTree > ( ) ;
2022-12-12 16:09:44 +08:00
try
{
2023-05-16 12:15:38 +08:00
var sqlString = @ $ "select * from graph_manage_tree
where deleted = 0
2022-12-12 16:09:44 +08:00
order by id asc ";
2023-05-16 12:15:38 +08:00
gmTree = await backendRepository . GetAllAsync < GraphManageTree > ( sqlString ) ;
2022-12-12 16:09:44 +08:00
apiResult . Code = "0000" ;
2023-05-16 12:15:38 +08:00
apiResult . Data = gmTree ;
2022-12-12 16:09:44 +08:00
}
catch ( Exception exception )
{
apiResult . Code = "9999" ;
apiResult . Msg = "系統內部錯誤,請聯絡管理者。" ;
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + exception . Message ) ;
}
return apiResult ;
}
2022-12-12 16:11:04 +08:00
/// <summary>
/// 新增圖資類別
/// </summary>
/// <param name="gv"></param>
/// <returns></returns>
[HttpPost]
2023-05-16 12:15:38 +08:00
public async Task < ApiResult < string > > SaveGraphManageTree ( [ FromBody ] GraphManageTree gmTree )
2022-12-12 16:11:04 +08:00
{
ApiResult < string > apiResult = new ApiResult < string > ( ) ;
try
{
2023-05-16 12:15:38 +08:00
Dictionary < string , object > newGmTree = new Dictionary < string , object > ( ) ;
var system_priority = backendRepository . GetOneAsync < string > ( "select priority from graph_manage_tree where deleted = 0 order by priority desc limit 1" ) . Result ;
newGmTree . Add ( "@deleted" , 0 ) ;
newGmTree . Add ( "@name" , gmTree . name ) ;
newGmTree . Add ( "@parent_id" , gmTree . parent_id ) ;
newGmTree . Add ( "@remark" , "圖資管理-" + gmTree . name ) ;
newGmTree . Add ( "@priority" , Int32 . Parse ( system_priority ) + 1 ) ;
newGmTree . Add ( "@created_by" , myUser . userinfo_guid ) ;
newGmTree . Add ( "@created_at" , DateTime . Now ) ;
var id = await backendRepository . AddOneByCustomTableReturnId ( newGmTree , "graph_manage_tree" ) ;
2022-12-12 16:11:04 +08:00
apiResult . Code = "0000" ;
2022-12-13 18:41:32 +08:00
apiResult . Data = id . ToString ( ) ;
2022-12-12 16:11:04 +08:00
}
catch ( Exception exception )
{
apiResult . Code = "9999" ;
apiResult . Msg = "系統內部錯誤,請聯絡管理者。" ;
2023-05-16 12:15:38 +08:00
string json = System . Text . Json . JsonSerializer . Serialize ( gmTree ) ;
2022-12-12 16:11:04 +08:00
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + json ) ;
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + exception . Message ) ;
}
return apiResult ;
}
/// <summary>
/// 編輯圖資類別
/// </summary>
/// <param name="gv"></param>
/// <returns></returns>
[HttpPost]
2023-05-16 12:15:38 +08:00
public async Task < ApiResult < string > > EditGraphManageTree ( [ FromBody ] GraphManageTree gmTree )
2022-12-12 16:11:04 +08:00
{
ApiResult < string > apiResult = new ApiResult < string > ( ) ;
2023-05-16 12:15:38 +08:00
var gm = await backendRepository . GetOneAsync < GraphInsInfo > ( "select * from graph_manage_tree where id = @id and deleted = 0" , new { @id = gmTree . id } ) ;
2022-12-12 16:11:04 +08:00
2022-12-13 18:41:32 +08:00
if ( gm = = null )
2022-12-12 16:11:04 +08:00
{
apiResult . Code = "0002" ;
apiResult . Data = "無法找到圖資" ;
return apiResult ;
}
try
{
2023-05-16 12:15:38 +08:00
Dictionary < string , object > newGmTree = new Dictionary < string , object > ( ) ;
2022-12-12 16:11:04 +08:00
2023-05-16 12:15:38 +08:00
newGmTree . Add ( "@name" , gmTree . name ) ;
newGmTree . Add ( "@remark" , "圖資管理-" + gmTree . name ) ;
newGmTree . Add ( "@updated_by" , myUser . userinfo_guid ) ;
newGmTree . Add ( "@updated_at" , DateTime . Now ) ;
2022-12-12 16:11:04 +08:00
2023-05-16 12:15:38 +08:00
await backendRepository . UpdateOneByCustomTable ( newGmTree , "graph_manage_tree" , "id = " + gmTree . id ) ;
2022-12-12 16:11:04 +08:00
apiResult . Code = "0000" ;
apiResult . Data = "編輯成功" ;
}
catch ( Exception exception )
{
apiResult . Code = "9999" ;
apiResult . Msg = "系統內部錯誤,請聯絡管理者。" ;
2023-05-16 12:15:38 +08:00
string json = System . Text . Json . JsonSerializer . Serialize ( gmTree ) ;
2022-12-12 16:11:04 +08:00
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + json ) ;
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + exception . Message ) ;
}
return apiResult ;
}
/// <summary>
/// 刪除圖資類別
/// </summary>
/// <param name="gv"></param>
/// <returns></returns>
[HttpPost]
2023-05-16 12:15:38 +08:00
public async Task < ApiResult < string > > DelGraphManageTree ( [ FromBody ] GraphManageTree gmTree )
2022-12-12 16:11:04 +08:00
{
ApiResult < string > apiResult = new ApiResult < string > ( ) ;
try
{
2023-05-16 12:15:38 +08:00
var sqlString = @ $"UPDATE graph_manage_tree SET deleted = 1, updated_at = @time, updated_by = @user WHERE id = @id" ;
2022-12-12 16:11:04 +08:00
2023-05-16 12:15:38 +08:00
var param = new { @id = gmTree . id , @time = DateTime . Now , @user = myUser . userinfo_guid } ;
2022-12-12 16:11:04 +08:00
await backendRepository . ExecuteSql ( sqlString , param ) ;
apiResult . Code = "0000" ;
apiResult . Data = "刪除成功" ;
}
catch ( Exception exception )
{
apiResult . Code = "9999" ;
apiResult . Msg = "系統內部錯誤,請聯絡管理者。" ;
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + exception . Message ) ;
}
return apiResult ;
}
2022-11-01 10:49:22 +08:00
[HttpPost]
2022-11-09 11:06:17 +08:00
public async Task < ApiResult < List < GraphList > > > GraManList ( [ FromBody ] GraphInfo gi )
2022-11-01 10:49:22 +08:00
{
ApiResult < List < GraphList > > apiResult = new ApiResult < List < GraphList > > ( ) ;
List < GraphList > graManList = new List < GraphList > ( ) ;
try
{
2023-05-16 12:15:38 +08:00
var param = new { layer_id = gi . layer_id , graph_manage_layer = graph_manage_layer , keyWord = gi . keyWord } ;
2022-11-11 10:12:27 +08:00
if ( gi . keyWord ! = null & & ! string . IsNullOrEmpty ( gi . keyWord ) )
{
graManList = await backendRepository . GetAllAsync < GraphList > ( @ $ "SELECT gm.*
2022-11-01 10:49:22 +08:00
FROM graph_manage gm
2023-05-16 12:15:38 +08:00
JOIN graph_manage_tree gmtree ON gmtree . id = @layer_id and gmtree . deleted = 0
2022-12-13 18:41:32 +08:00
WHERE gm . deleted = 0
2023-05-16 12:15:38 +08:00
AND ( gm . code like ' % { gi . keyWord } % ' OR gm . name like ' % @keyWord % ' OR gm . oriOrgName like ' % @keyWord % ' OR gm . donOrgName like ' % @keyWord % ' )
2022-11-11 10:12:27 +08:00
ORDER BY gm . priority , gm . created_at desc ", param);
}
else
2022-11-01 10:49:22 +08:00
{
2022-11-11 10:12:27 +08:00
var sqlString = @ $ "SELECT gm.*
2022-11-01 10:49:22 +08:00
FROM graph_manage gm
2023-05-16 12:15:38 +08:00
JOIN graph_manage_tree gmtree ON gmtree . id = @layer_id and gmtree . deleted = 0
2022-12-13 18:41:32 +08:00
WHERE gm . deleted = 0 and gm . layer_id = @layer_id
2022-11-11 10:12:27 +08:00
ORDER BY gm . priority , gm . created_at desc ";
graManList = await backendRepository . GetAllAsync < GraphList > ( sqlString , param ) ;
2022-11-01 10:49:22 +08:00
}
apiResult . Code = "0000" ;
apiResult . Data = graManList ;
}
catch ( Exception exception )
{
apiResult . Code = "9999" ;
apiResult . Msg = "系統內部錯誤,請聯絡管理者。" ;
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + exception . Message ) ;
}
2022-11-09 15:22:18 +08:00
return apiResult ;
}
[HttpPost]
public async Task < ApiResult < GraphList > > GraManRead ( [ FromBody ] GraphInfo gi )
{
ApiResult < GraphList > apiResult = new ApiResult < GraphList > ( ) ;
GraphList graManList = new GraphList ( ) ;
try
{
var sqlString = @ $ "SELECT *
FROM graph_manage gm
2023-05-16 12:15:38 +08:00
JOIN graph_manage_tree gmtree ON convert ( gmtree . id , nchar ) = gm . layer_id and gmtree . deleted = 0
2022-12-14 10:53:28 +08:00
WHERE gm . id = @id AND gm . deleted = 0
2022-11-09 15:22:18 +08:00
ORDER BY gm . priority , gm . created_at desc ";
2022-12-14 10:53:28 +08:00
var param = new { @id = gi . id , @graph_manage_layer = graph_manage_layer } ;
2022-11-09 15:22:18 +08:00
graManList = await backendRepository . GetOneAsync < GraphList > ( sqlString , param ) ;
if ( graManList = = null )
{
apiResult . Code = "0002" ;
apiResult . Msg = "找不到圖資" ;
return apiResult ;
}
apiResult . Code = "0000" ;
apiResult . Data = graManList ;
}
catch ( Exception exception )
{
apiResult . Code = "9999" ;
apiResult . Msg = "系統內部錯誤,請聯絡管理者。" ;
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + exception . Message ) ;
}
2022-11-01 10:49:22 +08:00
return apiResult ;
}
[HttpPost]
2022-11-09 15:16:43 +08:00
public async Task < ApiResult < string > > DelOneGraMan ( [ FromBody ] GraphInfo gi )
2022-11-01 10:49:22 +08:00
{
ApiResult < string > apiResult = new ApiResult < string > ( ) ;
try
{
2022-11-09 18:01:22 +08:00
var sqlString = @ $"UPDATE graph_manage SET deleted = 1, updated_at = @time, updated_by = @user WHERE id = @id" ;
2022-11-01 10:49:22 +08:00
2022-11-09 18:01:22 +08:00
var param = new { @id = gi . id , @time = DateTime . Now , @user = myUser . userinfo_guid } ;
2022-11-01 10:49:22 +08:00
await backendRepository . ExecuteSql ( sqlString , param ) ;
apiResult . Code = "0000" ;
apiResult . Data = "刪除成功" ;
}
catch ( Exception exception )
{
apiResult . Code = "9999" ;
apiResult . Msg = "系統內部錯誤,請聯絡管理者。" ;
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + exception . Message ) ;
}
return apiResult ;
}
[HttpPost]
public async Task < ApiResult < string > > EdtOneGraMan ( [ FromForm ] GraphInsInfo gii )
{
ApiResult < string > apiResult = new ApiResult < string > ( ) ;
try
{
2022-12-14 15:57:49 +08:00
if ( gii . oriOrgName = = "null" )
{
gii . oriOrgName = null ;
}
if ( gii . donOrgName = = "null" )
{
gii . donOrgName = null ;
}
if ( gii . oriSavName = = "null" )
{
gii . oriSavName = null ;
}
if ( gii . donSavName = = "null" )
{
gii . donSavName = null ;
}
2022-12-13 18:41:32 +08:00
var sWhere = $@"deleted = 0 and id != @id and code = @code and layer_id = @layer_id" ;
var gm = await backendRepository . GetOneAsync < GraphInsInfo > ( "graph_manage" , sWhere , new { @id = gii . id , @code = gii . code , @layer_id = gii . layer_id } ) ;
2022-11-09 18:52:21 +08:00
if ( gm ! = null )
{
apiResult . Code = "0002" ;
apiResult . Data = "無法找到圖資" ;
return apiResult ;
}
sWhere = @ $"deleted = 0 AND id = @id" ;
gm = await backendRepository . GetOneAsync < GraphInsInfo > ( "graph_manage" , sWhere , new { @id = gii . id } ) ;
2022-11-10 14:34:53 +08:00
2022-11-01 10:49:22 +08:00
if ( gm = = null )
{
apiResult . Code = "0001" ;
apiResult . Data = "無法找到圖資" ;
return apiResult ;
}
2022-11-09 18:52:21 +08:00
Dictionary < string , object > graph_manage = new Dictionary < string , object > ( ) ;
2022-11-10 09:32:06 +08:00
//edit file
//原設計圖修改
2022-11-09 18:52:21 +08:00
var new_guid = Guid . NewGuid ( ) ;
2022-12-14 18:27:51 +08:00
long? fileSize = gm . oriSize ? ? null ;
2022-11-09 18:52:21 +08:00
//刪除原本檔案
2022-12-14 15:57:49 +08:00
if ( gm . oriSavName ! = null & & gii . oriSavName ! = gm . oriSavName )
2022-11-10 09:32:06 +08:00
{
FolderFunction folderFunction = new FolderFunction ( ) ;
folderFunction . DeleteFile ( Path . Combine ( graphManageFileSaveAsPath , gm . oriSavName ) ) ;
2022-12-14 18:27:51 +08:00
fileSize = null ;
2022-11-10 09:32:06 +08:00
}
2022-11-09 18:52:21 +08:00
2022-12-14 15:57:49 +08:00
string fileName = gii . oriSavName ? ? null ;
2022-12-14 18:27:51 +08:00
2022-11-10 14:34:53 +08:00
if ( gii . oriOrgName ! = null & & gii . oriFile ! = null )
2022-11-10 09:32:06 +08:00
{
fileName = new_guid + "." + gii . oriOrgName . Split ( '.' ) [ 1 ] ;
2022-11-09 18:52:21 +08:00
2022-11-10 09:32:06 +08:00
var fullPath = Path . Combine ( graphManageFileSaveAsPath , fileName ) ;
2022-11-09 18:52:21 +08:00
2022-11-10 09:32:06 +08:00
using ( var stream = new FileStream ( fullPath , FileMode . Create ) )
{
gii . oriFile . CopyTo ( stream ) ;
}
2022-12-14 18:27:51 +08:00
fileSize = gii . oriFile . Length ;
2022-12-14 15:57:49 +08:00
2022-11-09 18:01:22 +08:00
}
2022-12-14 18:27:51 +08:00
graph_manage . Add ( "@oriSize" , fileSize ) ;
2022-11-09 18:52:21 +08:00
graph_manage . Add ( "@oriOrgName" , gii . oriOrgName ) ;
graph_manage . Add ( "@oriSavName" , fileName ) ;
2022-11-01 10:49:22 +08:00
2022-12-14 15:57:49 +08:00
fileName = gii . donSavName ? ? null ;
2022-11-10 09:32:06 +08:00
//竣工圖修改
2022-11-09 18:52:21 +08:00
new_guid = Guid . NewGuid ( ) ;
2022-12-14 18:27:51 +08:00
fileSize = gm . donSize ? ? null ;
2022-11-09 18:52:21 +08:00
//刪除原本檔案
2022-12-14 15:57:49 +08:00
if ( gm . donSavName ! = null & & gii . donSavName ! = gm . donSavName )
2022-11-01 10:49:22 +08:00
{
2022-11-10 09:32:06 +08:00
var folderFunction = new FolderFunction ( ) ;
folderFunction . DeleteFile ( Path . Combine ( graphManageFileSaveAsPath , gm . donSavName ) ) ;
2022-12-14 18:27:51 +08:00
fileSize = null ;
2022-11-09 18:52:21 +08:00
}
2022-11-01 10:49:22 +08:00
2022-11-10 14:34:53 +08:00
if ( gii . donOrgName ! = null & & gii . donFile ! = null )
2022-11-10 09:32:06 +08:00
{
fileName = new_guid + "." + gii . donOrgName . Split ( '.' ) [ 1 ] ;
2022-11-01 10:49:22 +08:00
2022-11-10 09:32:06 +08:00
var fullPath = Path . Combine ( graphManageFileSaveAsPath , fileName ) ;
2022-11-01 10:49:22 +08:00
2022-11-10 09:32:06 +08:00
using ( var stream = new FileStream ( fullPath , FileMode . Create ) )
{
gii . donFile . CopyTo ( stream ) ;
}
2022-12-14 18:27:51 +08:00
fileSize = gii . donFile . Length ;
2022-11-10 09:32:06 +08:00
}
2022-12-14 18:27:51 +08:00
graph_manage . Add ( "@donSize" , fileSize ) ;
2022-11-10 09:32:06 +08:00
graph_manage . Add ( "@donOrgName" , gii . donOrgName ) ;
graph_manage . Add ( "@donSavName" , fileName ) ;
2022-11-09 18:52:21 +08:00
2022-11-09 18:01:22 +08:00
graph_manage . Add ( "@code" , gii . code ) ;
2022-11-01 10:49:22 +08:00
graph_manage . Add ( "@name" , gii . name ) ;
2022-12-13 18:41:32 +08:00
//graph_manage.Add("@main_system_tag", gii.main_system_tag);
//graph_manage.Add("@sub_system_tag", gii.sub_system_tag);
graph_manage . Add ( "@layer_id" , gii . layer_id ) ;
2022-11-09 11:05:33 +08:00
graph_manage . Add ( "@updated_at" , DateTime . Now ) ;
graph_manage . Add ( "@updated_by" , myUser . userinfo_guid ) ;
2022-11-01 10:49:22 +08:00
//graph_manage.Add("@priority", gii.priority);
2022-11-09 18:01:22 +08:00
await backendRepository . UpdateOneByCustomTable ( graph_manage , "graph_manage" , "id = " + gii . id ) ;
2022-11-01 10:49:22 +08:00
apiResult . Code = "0000" ;
apiResult . Data = "修改成功" ;
}
catch ( Exception exception )
{
apiResult . Code = "9999" ;
apiResult . Msg = "系統內部錯誤,請聯絡管理者。" ;
string json = System . Text . Json . JsonSerializer . Serialize ( gii ) ;
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + json ) ;
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + exception . Message ) ;
}
return apiResult ;
}
[HttpPost]
public async Task < ApiResult < string > > SaveGraMan ( [ FromForm ] GraphInsInfo gii )
{
ApiResult < string > apiResult = new ApiResult < string > ( ) ;
try
{
2022-12-13 18:41:32 +08:00
if ( gii . oriOrgName = = "null" ) {
gii . oriOrgName = null ;
}
if ( gii . donOrgName = = "null" )
{
gii . donOrgName = null ;
}
var sWhere = @ $"deleted = 0 AND code = @code AND layer_id = @layer_id" ;
var gm = await backendRepository . GetOneAsync < GraphInsInfo > ( "graph_manage" , sWhere , new { @code = gii . code , @layer_id = gii . layer_id } ) ;
2022-11-01 10:49:22 +08:00
if ( gm ! = null )
{
apiResult . Code = "0002" ;
apiResult . Data = "已有相同的編碼" ;
return apiResult ;
}
Dictionary < string , object > graph_manage = new Dictionary < string , object > ( ) ;
2022-12-14 18:27:51 +08:00
2022-11-01 10:49:22 +08:00
//save file
if ( gii . oriOrgName ! = null | | gii . donOrgName ! = null )
{
if ( ! System . IO . Directory . Exists ( graphManageFileSaveAsPath ) )
System . IO . Directory . CreateDirectory ( graphManageFileSaveAsPath ) ;
if ( gii . oriOrgName ! = null )
{
var new_guid = Guid . NewGuid ( ) ;
var fileName = new_guid + "." + gii . oriOrgName . Split ( '.' ) [ 1 ] ;
var fullPath = Path . Combine ( graphManageFileSaveAsPath , fileName ) ;
using ( var stream = new FileStream ( fullPath , FileMode . Create ) )
{
gii . oriFile . CopyTo ( stream ) ;
}
2022-12-14 18:27:51 +08:00
graph_manage . Add ( "@oriSize" , gii . oriFile . Length ) ;
2022-11-01 10:49:22 +08:00
graph_manage . Add ( "@oriOrgName" , gii . oriOrgName ) ;
graph_manage . Add ( "@oriSavName" , fileName ) ;
}
if ( gii . donOrgName ! = null )
{
var new_guid = Guid . NewGuid ( ) ;
2022-11-10 14:34:53 +08:00
2022-11-01 10:49:22 +08:00
var fileName = new_guid + "." + gii . donOrgName . Split ( '.' ) [ 1 ] ;
var fullPath = Path . Combine ( graphManageFileSaveAsPath , fileName ) ;
using ( var stream = new FileStream ( fullPath , FileMode . Create ) )
{
gii . donFile . CopyTo ( stream ) ;
}
2022-12-14 18:27:51 +08:00
graph_manage . Add ( "@donSize" , gii . donFile . Length ) ;
2022-11-09 15:16:43 +08:00
graph_manage . Add ( "@donOrgName" , gii . donOrgName ) ;
graph_manage . Add ( "@donSavName" , fileName ) ;
2022-11-01 10:49:22 +08:00
}
}
var newPriority = await backendRepository . GetCurrentPriority ( "graph_manage" ) ;
2022-11-09 15:16:43 +08:00
graph_manage . Add ( "@code" , gii . code ) ;
2022-12-13 18:41:32 +08:00
//graph_manage.Add("@main_system_tag", gii.main_system_tag);
//graph_manage.Add("@sub_system_tag", gii.sub_system_tag);
graph_manage . Add ( "@layer_id" , gii . layer_id ) ;
2022-11-01 10:49:22 +08:00
graph_manage . Add ( "@name" , gii . name ) ;
graph_manage . Add ( "@deleted" , 0 ) ;
graph_manage . Add ( "@priority" , newPriority + 1 ) ;
2022-11-10 14:34:53 +08:00
graph_manage . Add ( "@created_by" , myUser . userinfo_guid ) ;
2022-11-09 11:05:33 +08:00
graph_manage . Add ( "@created_at" , DateTime . Now ) ;
2022-11-01 10:49:22 +08:00
await backendRepository . AddOneByCustomTable ( graph_manage , "graph_manage" ) ;
apiResult . Code = "0000" ;
apiResult . Data = "新增成功" ;
}
catch ( Exception exception )
{
apiResult . Code = "9999" ;
apiResult . Msg = "系統內部錯誤,請聯絡管理者。" ;
string json = System . Text . Json . JsonSerializer . Serialize ( gii ) ;
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + json ) ;
Logger . LogError ( "【" + controllerName + "/" + actionName + "】" + exception . Message ) ;
}
return apiResult ;
}
2022-11-10 14:34:53 +08:00
2022-11-01 10:49:22 +08:00
}
2022-11-01 19:15:02 +08:00
}