mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
fix issue #I61V1D 拖拽表单不能关联数据库
This commit is contained in:
parent
a3a8bd509e
commit
8e25b6e8e3
@ -28,7 +28,10 @@ using System.Threading.Tasks;
|
|||||||
using Infrastructure.Const;
|
using Infrastructure.Const;
|
||||||
using Infrastructure.Helpers;
|
using Infrastructure.Helpers;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using OpenAuth.Repository;
|
using OpenAuth.Repository;
|
||||||
|
using OpenAuth.Repository.QueryObj;
|
||||||
|
using Yitter.IdGenerator;
|
||||||
|
|
||||||
namespace OpenAuth.App
|
namespace OpenAuth.App
|
||||||
{
|
{
|
||||||
@ -43,12 +46,13 @@ namespace OpenAuth.App
|
|||||||
private IHttpClientFactory _httpClientFactory;
|
private IHttpClientFactory _httpClientFactory;
|
||||||
private IServiceProvider _serviceProvider;
|
private IServiceProvider _serviceProvider;
|
||||||
private SysMessageApp _messageApp;
|
private SysMessageApp _messageApp;
|
||||||
|
private DbExtension _dbExtension;
|
||||||
|
|
||||||
public FlowInstanceApp(IUnitWork<OpenAuthDBContext> unitWork,
|
public FlowInstanceApp(IUnitWork<OpenAuthDBContext> unitWork,
|
||||||
IRepository<FlowInstance, OpenAuthDBContext> repository
|
IRepository<FlowInstance, OpenAuthDBContext> repository
|
||||||
, RevelanceManagerApp app, FlowSchemeApp flowSchemeApp, FormApp formApp,
|
, RevelanceManagerApp app, FlowSchemeApp flowSchemeApp, FormApp formApp,
|
||||||
IHttpClientFactory httpClientFactory, IAuth auth, IServiceProvider serviceProvider,
|
IHttpClientFactory httpClientFactory, IAuth auth, IServiceProvider serviceProvider,
|
||||||
SysMessageApp messageApp)
|
SysMessageApp messageApp, DbExtension dbExtension)
|
||||||
: base(unitWork, repository, auth)
|
: base(unitWork, repository, auth)
|
||||||
{
|
{
|
||||||
_revelanceApp = app;
|
_revelanceApp = app;
|
||||||
@ -57,6 +61,7 @@ namespace OpenAuth.App
|
|||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
_messageApp = messageApp;
|
_messageApp = messageApp;
|
||||||
|
_dbExtension = dbExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 流程处理API
|
#region 流程处理API
|
||||||
@ -126,6 +131,59 @@ namespace OpenAuth.App
|
|||||||
icf.Add(flowInstance.Id, flowInstance.FrmData);
|
icf.Add(flowInstance.Id, flowInstance.FrmData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//如果工作流配置的表单配置有对应的数据库
|
||||||
|
if (!string.IsNullOrEmpty(form.DbName))
|
||||||
|
{
|
||||||
|
var dbcolumns = _dbExtension.GetDbTableStructure(form.DbName);
|
||||||
|
var json = JsonHelper.Instance.Deserialize<JObject>(addFlowInstanceReq.FrmData);
|
||||||
|
var columnstr = string.Empty; //字段
|
||||||
|
var valstr = string.Empty; //值字符串
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var column in dbcolumns)
|
||||||
|
{
|
||||||
|
if (column.ColumnName == "Id" || column.ColumnName=="id")
|
||||||
|
{
|
||||||
|
var options = new IdGeneratorOptions()
|
||||||
|
{
|
||||||
|
Method = 1,
|
||||||
|
WorkerId = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
YitIdHelper.SetIdGenerator(options);
|
||||||
|
columnstr += "Id,";
|
||||||
|
valstr += "'" + YitIdHelper.NextId().ToString() + "',";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var val = json[column.ColumnName];
|
||||||
|
if (val == null)
|
||||||
|
{
|
||||||
|
switch (column.EntityType)
|
||||||
|
{
|
||||||
|
case "int":
|
||||||
|
val = 0;
|
||||||
|
break;
|
||||||
|
case "string":
|
||||||
|
val = "";
|
||||||
|
break;
|
||||||
|
case "DateTime":
|
||||||
|
val = DateTime.Now.ToString("yyyy-MM-dd");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(val == null) continue;
|
||||||
|
columnstr += column.ColumnName + ",";
|
||||||
|
valstr += "'" + val + "',";
|
||||||
|
}
|
||||||
|
|
||||||
|
columnstr = columnstr.TrimEnd(',');
|
||||||
|
valstr = valstr.TrimEnd(',');
|
||||||
|
var sql = $"insert into {form.DbName}({columnstr}) values ({valstr})";
|
||||||
|
UnitWork.ExecuteSql(sql);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion 根据运行实例改变当前节点状态
|
#endregion 根据运行实例改变当前节点状态
|
||||||
|
|
||||||
#region 流程操作记录
|
#region 流程操作记录
|
||||||
|
Loading…
Reference in New Issue
Block a user