@ -23,6 +23,7 @@ using OpenAuth.Auth.Interface;
using System.Diagnostics ;
using NPOI.Util ;
using Utils.Web.Model ;
using NPOI.SS.Formula.Functions ;
namespace OpenAuth.App
{
@ -281,7 +282,7 @@ namespace OpenAuth.App
ParentNodeId = parentNodeId ,
ParentProcessId = parentProcessId ,
ParentTaskId = parentTaskId ,
CreateUserId = currentUser ? . Id . ToString ( ) ,
CreateUserId = currentUser ? . Id . ToString ( ) ,
CreateUserName = currentUser ? . Name ,
CreateUserAccount = currentUser ? . Account ,
UserId = currentUser ? . Id . ToString ( )
@ -451,7 +452,7 @@ namespace OpenAuth.App
var scriptTaskList = myTaskList . FindAll ( t = > t . Type = = 10 ) ;
foreach ( var item in scriptTaskList )
{
var result = await ExecuteScript ( item , "create" , processId , "" , "" , iWFEngine . CreateUser , iWFEngine , null , "" ) ;
var result = await ExecuteScript ( item , "create" , processId , "" , "" , iWFEngine . CreateUser , iWFEngine , null , "" ) ;
scriptResults . Add ( result ) ;
}
@ -583,7 +584,7 @@ namespace OpenAuth.App
var scriptTaskList = myTaskList . FindAll ( t = > t . Type = = 10 ) ;
foreach ( var item in scriptTaskList )
{
var result = await ExecuteScript ( item , "create" , processId , "" , "" , iWFEngine . CreateUser , iWFEngine , null , "" ) ;
var result = await ExecuteScript ( item , "create" , processId , "" , "" , iWFEngine . CreateUser , iWFEngine , null , "" ) ;
scriptResults . Add ( result ) ;
}
@ -667,7 +668,7 @@ namespace OpenAuth.App
var scriptTaskList = myTaskList . FindAll ( t = > t . Type = = 10 ) ;
foreach ( var item in scriptTaskList )
{
var result = await ExecuteScript ( item , "createAgain" , processId , "" , "" , iWFEngine . CreateUser , iWFEngine , null , "" ) ;
var result = await ExecuteScript ( item , "createAgain" , processId , "" , "" , iWFEngine . CreateUser , iWFEngine , null , "" ) ;
scriptResults . Add ( result ) ;
}
@ -746,7 +747,7 @@ namespace OpenAuth.App
foreach ( var item in taskList )
{
if ( item . Type = = 1 | | item . Type = = 3 | | item . Type = = 5 | | item . Type = = 6 | | item . Type = = 7 )
if ( item . Type = = 1 | | item . Type = = 3 | | item . Type = = 5 | | item . Type = = 6 | | item . Type = = 7 )
{
item . IsUrge = 1 ;
item . UrgeTime = DateTime . Now ;
@ -828,7 +829,7 @@ namespace OpenAuth.App
var iWFEngine = await Bootstraper ( "" , taskEntiy . ProcessId , null , nextUsers ) ;
// 1.判断任务类型 1 普通任务 5 会签任务
if ( taskEntiy . Type = = 1 | | taskEntiy . Type = = 7 )
if ( taskEntiy . Type = = 1 | | taskEntiy . Type = = 7 )
{
await AuditNode ( iWFEngine , taskEntiy , code , name , des , stampImg , nextId ) ;
}
@ -1244,7 +1245,7 @@ namespace OpenAuth.App
foreach ( var item in taskList )
{
if ( ( item . Type = = 1 | | item . Type = = 3 | | item . Type = = 5 | | item . Type = = 7 ) & & item . User . IsNew )
if ( ( item . Type = = 1 | | item . Type = = 3 | | item . Type = = 5 | | item . Type = = 7 ) & & item . User . IsNew )
{
if ( ! res . ContainsKey ( item . UnitId ) )
{
@ -1343,11 +1344,12 @@ namespace OpenAuth.App
response . Result = true ;
response . Message = "success" ;
}
else {
else
{
response . Result = false ;
response . Message = "error" ;
}
return response ;
}
@ -1696,6 +1698,8 @@ namespace OpenAuth.App
List < string > userIds = new List < string > ( ) ;
foreach ( var item in auditorList )
{
var link = UnitWork . Db . Queryable < Repository . Domain . SysDatabaseLink > ( ) . Where ( r = > r . DBName = = item . DbCode ) . First ( ) ;
switch ( item . Type )
{
//岗位
@ -1797,51 +1801,57 @@ namespace OpenAuth.App
break ;
//数据库表字段
case "6" :
//using (var db = this.CodeClient(item.DbCode, _configuration))
//{
// DataTable dt = await db.Ado.GetDataTableAsync(string.Format("select {0} from {1} where {2} = @processId ", item.AuditorField, item.Table, item.Rfield), new { processId });
// foreach (DataRow row in dt.Rows)
// {
// var userIdString = row[0].ToString();
// if (!string.IsNullOrEmpty(userIdString))
// {
// var userIdList = userIdString.Split(",");
// foreach (var userIdItem in userIdList)
// {
// userIds.Add(userIdItem);
// }
// }
// }
// break;
//}
if ( link ! = null )
{
using ( var db = this . CodeClient ( link . DBConnection , link . DBType ) )
{
DataTable dt = await db . Ado . GetDataTableAsync ( string . Format ( "select {0} from {1} where {2} = @processId " , item . AuditorField , item . Table , item . Rfield ) , new { processId } ) ;
foreach ( DataRow row in dt . Rows )
{
var userIdString = row [ 0 ] . ToString ( ) ;
if ( ! string . IsNullOrEmpty ( userIdString ) )
{
var userIdList = userIdString . Split ( "," ) ;
foreach ( var userIdItem in userIdList )
{
userIds . Add ( userIdItem ) ;
}
}
}
}
}
break ;
//数据库表字段
case "7" :
//using (var db = this.CodeClient(item.DbCode, _configuration))
//{
// //获取数据id
// var process = await client.Queryable<WFProcess>().FirstAsync(a => a.Id == processId);
// WFInstanceInfo instanceInfo = null;
// if (process != null)
// {
// // instanceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<WFInstanceInfo>(process.InstanceInfo);
// instanceInfo = process.InstanceInfo;
// }
// DataTable dt = await db.Ado.GetDataTableAsync(string.Format(item.Sql), new { pkeyValue = instanceInfo.pkeyValue });
// foreach (DataRow row in dt.Rows)
// {
// var userIdString = row[0].ToString();
// if (!string.IsNullOrEmpty(userIdString))
// {
// var userIdList = userIdString.Split(",");
// foreach (var userIdItem in userIdList)
// {
// userIds.Add(userIdItem);
// }
// }
// }
// break;
//}
if ( link ! = null )
{
using ( var db = this . CodeClient ( link . DBConnection , link . DBType ) )
{
//获取数据id
var process = await client . Queryable < WFProcess > ( ) . FirstAsync ( a = > a . Id = = processId ) ;
WFInstanceInfo instanceInfo = null ;
if ( process ! = null )
{
// instanceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<WFInstanceInfo>(process.InstanceInfo);
instanceInfo = process . InstanceInfo ;
}
DataTable dt = await db . Ado . GetDataTableAsync ( string . Format ( item . Sql ) , new { pkeyValue = instanceInfo . pkeyValue } ) ;
foreach ( DataRow row in dt . Rows )
{
var userIdString = row [ 0 ] . ToString ( ) ;
if ( ! string . IsNullOrEmpty ( userIdString ) )
{
var userIdList = userIdString . Split ( "," ) ;
foreach ( var userIdItem in userIdList )
{
userIds . Add ( userIdItem ) ;
}
}
}
}
}
break ;
}
}
@ -2054,7 +2064,7 @@ namespace OpenAuth.App
ProcessUserName = iWFEngine . CreateUser . Name ,
ProcessCode = iWFEngine . Config . Params . SchemeCode ,
ProcessTitle = iWFEngine . Config . Params . Title ,
IsRetract = 0
IsRetract = 0
} ;
if ( users [ 0 ] . IsOvertimeMessage )
{
@ -2156,7 +2166,7 @@ namespace OpenAuth.App
ProcessUserName = iWFEngine . CreateUser . Name ,
ProcessCode = iWFEngine . Config . Params . SchemeCode ,
ProcessTitle = iWFEngine . Config . Params . Title ,
IsRetract = 0
IsRetract = 0
} ;
if ( item . IsOvertimeMessage )
{
@ -2287,7 +2297,7 @@ namespace OpenAuth.App
/// <param name="iWFEngine"></param>
/// <param name="preTask"></param>
/// <returns></returns>
private async Task < bool > ExecuteScript ( WFTask task , string code , string processId , string prevTaskId , string nextid , WFUserInfo createUser , IWFEngine iWFEngine , WFTask preTask , string des )
private async Task < bool > ExecuteScript ( WFTask task , string code , string processId , string prevTaskId , string nextid , WFUserInfo createUser , IWFEngine iWFEngine , WFTask preTask , string des )
{
SysUser userInfo ;
if ( preTask = = null )
@ -2316,8 +2326,8 @@ namespace OpenAuth.App
WFInstanceInfo instanceInfo = null ;
if ( process ! = null )
{
// instanceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<WFInstanceInfo>(process.InstanceInfo);
instanceInfo = process . InstanceInfo ;
// instanceInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<WFInstanceInfo>(process.InstanceInfo);
instanceInfo = process . InstanceInfo ;
}
var param = new
@ -2333,9 +2343,9 @@ namespace OpenAuth.App
//companyId2 = userInfo.F_CompanyId,
//departmentId2 = userInfo.F_DepartmentId,
code ,
nodeName = nextnode ,
nodeName = nextnode ,
pkeyValue = instanceInfo = = null ? "" : instanceInfo . pkeyValue ,
des = des
des = des
} ;
try
{
@ -2622,7 +2632,7 @@ namespace OpenAuth.App
var scriptTaskList = myTaskList . FindAll ( t = > t . Type = = 10 ) ;
foreach ( var item in scriptTaskList )
{
await ExecuteScript ( item , code , taskEntity . ProcessId , taskEntity . Id , nextId , iWFEngine . CreateUser , iWFEngine , taskEntity , des ) ;
await ExecuteScript ( item , code , taskEntity . ProcessId , taskEntity . Id , nextId , iWFEngine . CreateUser , iWFEngine , taskEntity , des ) ;
}
}
@ -2690,7 +2700,7 @@ namespace OpenAuth.App
var scriptTaskList = myTaskList . FindAll ( t = > t . Type = = 10 ) ;
foreach ( var item in scriptTaskList )
{
await ExecuteScript ( item , code , processId , taskEntity . Id , nextId , iWFEngine . CreateUser , iWFEngine , taskEntity , "" ) ;
await ExecuteScript ( item , code , processId , taskEntity . Id , nextId , iWFEngine . CreateUser , iWFEngine , taskEntity , "" ) ;
}
}
@ -2934,10 +2944,10 @@ namespace OpenAuth.App
# endregion
public async Task < Response < bool > > Supervise ( string processId , int supervise = 1 )
public async Task < Response < bool > > Supervise ( string processId , int supervise = 1 )
{
// todo 实现督办
var iWFEngine = await Bootstraper ( string . Empty , processId , null , null ) ;
// 获取未完成的任务
var taskList = await GetUnFinishTaskList ( processId ) ;
@ -2946,9 +2956,9 @@ namespace OpenAuth.App
foreach ( var item in taskList )
{
if ( item . Type = = 1 | | item . Type = = 3 | | item . Type = = 5 | | item . Type = = 6 | | item . Type = = 7 )
if ( item . Type = = 1 | | item . Type = = 3 | | item . Type = = 5 | | item . Type = = 6 | | item . Type = = 7 )
{
// 督办时间督办标志
item . IsSupervise = supervise ;
item . SuperviseTime = DateTime . Now ;
@ -3013,9 +3023,9 @@ namespace OpenAuth.App
{
throw ( new Exception ( "找不到对应流程任务!" ) ) ;
}
else if ( taskEntiy . State ! = 3 & & taskEntiy . State ! = 4 )
else if ( taskEntiy . State ! = 3 & & taskEntiy . State ! = 4 )
{
throw ( new Exception ( "该任务未完成!" ) ) ;
throw ( new Exception ( "该任务未完成!" ) ) ;
}
//后期改
@ -3064,11 +3074,11 @@ namespace OpenAuth.App
//修改原有任务的IsLast状态
await client . Updateable < WFTask > ( )
. SetColumns ( t = > new WFTask ( ) { IsLast = 0 } )
. Where ( t = > t . Id = = taskEntity . Id )
. Where ( t = > t . Id = = taskEntity . Id )
. ExecuteCommandAsync ( ) ;
//删除该节点之后生成的所有任务
var dellist = client . Queryable < WFTask > ( ) . Where ( r = > r . CreateDate > taskEntity . CreateDate & & r . ProcessId = = taskEntity . ProcessId ) . ToList ( ) ;
var dellist = client . Queryable < WFTask > ( ) . Where ( r = > r . CreateDate > taskEntity . CreateDate & & r . ProcessId = = taskEntity . ProcessId ) . ToList ( ) ;
await client . Deleteable < WFTask > ( dellist ) . ExecuteCommandAsync ( ) ;
// 处理任务并更新数据
using ( var uwo = UnitWork . CreateContext ( ) )
@ -3076,7 +3086,7 @@ namespace OpenAuth.App
var process = await uwo . WFProcess . GetByIdAsync ( taskEntity . ProcessId ) ;
await uwo . Db . Updateable < WFProcess > ( )
. SetColumns ( p = > new WFProcess { IsStart = 1 , IsCancel = 0 } )
. SetColumns ( p = > p . IsFinished = = 0 )
. SetColumns ( p = > p . IsFinished = = 0 )
. SetColumnsIF ( taskList . FindIndex ( t = > t . Type = = 100 ) ! = - 1 , p = > p . IsFinished = = 1 )
. SetColumnsIF ( taskList . FindIndex ( t = > t . Type = = 4 ) ! = - 1 , p = > p . IsAgain = = 1 )
. Where ( p = > p . Id = = taskEntity . ProcessId )
@ -3122,8 +3132,8 @@ namespace OpenAuth.App
CreateDate = DateTime . Now ,
CreateUserId = _auth . GetUserId ( ) ,
CreateUserName = _auth . GetUserName ( ) ,
IsLast = 1 ,
IsRetract = 1
IsLast = 1 ,
IsRetract = 1
} ;
await uwo . WFTask . InsertAsync ( newTask ) ;