4.0发布前最后一般脚本;

优化登陆;
优化流程审批;
This commit is contained in:
yubao 2018-04-07 00:36:26 +08:00
parent d5db368a2f
commit e5f911079f
27 changed files with 286 additions and 367 deletions

Binary file not shown.

View File

@ -105,7 +105,7 @@ namespace OpenAuth.App
{
var elementIds = UnitWork.Find<Relevance>(
u =>
(u.FirstId == _user.Id && u.Key == Define.ROLERESOURCE) ||
(u.FirstId == _user.Id && u.Key == Define.USERELEMENT) ||
(u.Key == Define.ROLEELEMENT && _userRoleIds.Contains(u.FirstId))).Select(u => u.SecondId);
return UnitWork.Find<ModuleElement>(u => elementIds.Contains(u.Id));
}

View File

@ -243,28 +243,28 @@ namespace OpenAuth.App.Flow
public string NodeConfluence(string nodeId, Tag tag)
{
string res = "-1";
string _nextNodeId = GetNextNodeByNodeId(nodeId);//获取下一个节点
if (_nextNodeId != "-1")
string nextNodeId = GetNextNodeByNodeId(nodeId);//获取下一个节点
if (nextNodeId != "-1")
{
Dictionary<string, List<FlowLine>> toLines = GetToLineDictionary(_runtimeModel.schemeContentJson);
int allnum = toLines[_nextNodeId].Count;
int allnum = toLines[nextNodeId].Count;
int i = 0;
foreach (var item in _runtimeModel.schemeContentJson.Flow.nodes)
foreach (var item in _runtimeModel.schemeContentJson.nodes)
{
if (item.id.Value == _nextNodeId)
if (item.id == nextNodeId)
{
if (item.setInfo.NodeConfluenceType.Value == "")//0所有步骤通过 todo:先用空格
if (string.IsNullOrEmpty(item.setInfo.NodeConfluenceType))//0所有步骤通过 todo:先用空格
{
if (tag.Taged == 1)
{
if (item.setInfo.ConfluenceOk == null)
{
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceOk = 1;
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceOk = 1;
res = "1";
}
else if (item.setInfo.ConfluenceOk.Value == (allnum - 1))
else if (item.setInfo.ConfluenceOk == (allnum - 1))
{
res = GetNextNodeByNodeId(_nextNodeId);
res = GetNextNodeByNodeId(nextNodeId);
if (res == "-1")
{
throw (new Exception("会签成功寻找不到下一个节点"));
@ -272,16 +272,16 @@ namespace OpenAuth.App.Flow
}
else
{
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceOk++;
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceOk++;
res = "1";
}
}
}
else if (item.setInfo.NodeConfluenceType.Value == "1")//1一个步骤通过即可
else if (item.setInfo.NodeConfluenceType == "1")//1一个步骤通过即可
{
if (tag.Taged ==1)
{
res = GetNextNodeByNodeId(_nextNodeId);
res = GetNextNodeByNodeId(nextNodeId);
if (res == "-1")
{
throw (new Exception("会签成功寻找不到下一个节点"));
@ -291,16 +291,16 @@ namespace OpenAuth.App.Flow
{
if (item.setInfo.ConfluenceNo == null)
{
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceNo = 1;
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceNo = 1;
res = "1";
}
else if (item.setInfo.ConfluenceNo.Value == (allnum - 1))
else if (item.setInfo.ConfluenceNo == (allnum - 1))
{
res = "-1";
}
else
{
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceNo++;
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceNo++;
res = "1";
}
}
@ -311,33 +311,33 @@ namespace OpenAuth.App.Flow
{
if (item.setInfo.ConfluenceOk == null)
{
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceOk = 1;
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceOk = 1;
}
else
{
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceOk++;
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceOk++;
}
}
else
{
if (item.setInfo.ConfluenceNo == null)
{
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceNo = 1;
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceNo = 1;
}
else
{
_runtimeModel.schemeContentJson.Flow.nodes[i].setInfo.ConfluenceNo++;
_runtimeModel.schemeContentJson.nodes[i].setInfo.ConfluenceNo++;
}
}
if ((item.setInfo.ConfluenceNo.Value + item.setInfo.ConfluenceOk.Value) / allnum * 100 > int.Parse(item.setInfo.NodeConfluenceRate.Value))
if ((item.setInfo.ConfluenceNo + item.setInfo.ConfluenceOk) / allnum * 100 > int.Parse(item.setInfo.NodeConfluenceRate))
{
res = GetNextNodeByNodeId(_nextNodeId);
res = GetNextNodeByNodeId(nextNodeId);
if (res == "-1")
{
throw (new Exception("会签成功寻找不到下一个节点"));
}
}
else if ((item.setInfo.ConfluenceNo.Value + item.setInfo.ConfluenceOk.Value) == allnum)
else if ((item.setInfo.ConfluenceNo + item.setInfo.ConfluenceOk) == allnum)
{
res = "-1";
}
@ -353,19 +353,19 @@ namespace OpenAuth.App.Flow
if (res == "-1")
{
tag.Taged = -1;
MakeTagNode(_nextNodeId, tag);
MakeTagNode(nextNodeId, tag);
}
else if (res != "1") //则时res是会签结束节点的ID
{
tag.Taged = 1;
MakeTagNode(_nextNodeId,tag);
MakeTagNode(nextNodeId,tag);
_runtimeModel.nextNodeId = res;
_runtimeModel.nextNodeType = GetNodeType(res);
}
else
{
_runtimeModel.nextNodeId = _nextNodeId;
_runtimeModel.nextNodeType = GetNodeType(_nextNodeId);
_runtimeModel.nextNodeId = nextNodeId;
_runtimeModel.nextNodeType = GetNodeType(nextNodeId);
}
return res;
}
@ -411,7 +411,7 @@ namespace OpenAuth.App.Flow
int i = 0;
foreach (var item in _runtimeModel.schemeContentJson.nodes)
{
if (item.id.Value.ToString() == nodeId)
if (item.id == nodeId)
{
_runtimeModel.schemeContentJson.nodes[i].setInfo.Taged = tag.Taged;
_runtimeModel.schemeContentJson.nodes[i].setInfo.UserId = tag.UserId;

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Infrastructure;
@ -12,21 +12,21 @@ using OpenAuth.Repository.Domain;
namespace OpenAuth.App
{
/// <summary>
/// 工作流实例表操作
/// 工作流实例表操作
/// </summary>
public class FlowInstanceApp : BaseApp<FlowInstance>
{
#region API
#region API
/// <summary>
/// 创建一个实例
/// 创建一个实例
/// </summary>
/// <returns></returns>
public bool CreateInstance(JObject obj)
{
var flowInstance = obj.ToObject<FlowInstance>();
//获取提交的表单数据
//获取提交的表单数据
var frmdata = new JObject();
foreach (var property in obj.Properties().Where(U => U.Name.Contains("data_")))
{
@ -34,37 +34,40 @@ namespace OpenAuth.App
}
flowInstance.FrmData = JsonHelper.Instance.Serialize(frmdata);
//创建运行实例
//创建运行实例
var wfruntime = new FlowRuntime(flowInstance);
var user = AuthUtil.GetCurrentUser();
#region
#region
flowInstance.ActivityId = wfruntime.runtimeModel.nextNodeId;
flowInstance.ActivityType = wfruntime.GetNextNodeType();//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
flowInstance.ActivityType = wfruntime.GetNextNodeType();//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
flowInstance.ActivityName = wfruntime.runtimeModel.nextNode.name;
flowInstance.PreviousId = wfruntime.runtimeModel.currentNodeId;
flowInstance.CreateUserId = user.User.Id;
flowInstance.CreateUserName = user.User.Account;
flowInstance.MakerList = (wfruntime.GetNextNodeType() != 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
flowInstance.MakerList = (wfruntime.GetNextNodeType() != 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
flowInstance.IsFinish = (wfruntime.GetNextNodeType() == 4 ? 1 : 0);
UnitWork.Add(flowInstance);
#endregion
#region
#region
FlowInstanceOperationHistory processOperationHistoryEntity = new FlowInstanceOperationHistory
{
InstanceId = flowInstance.Id,
CreateUserId = user.User.Id,
CreateUserName = user.User.Name,
Content = "【创建】"
CreateDate = DateTime.Now,
Content = "【创建】"
+ user.User.Name
+ "创建了一个流程进程【"
+ "创建了一个流程进程【"
+ flowInstance.Code + "/"
+ flowInstance.CustomName + "】"
+ flowInstance.CustomName + "】"
};
UnitWork.Add(processOperationHistoryEntity);
#endregion
#region
#region
FlowInstanceTransitionHistory processTransitionHistoryEntity = new FlowInstanceTransitionHistory
{
@ -82,96 +85,91 @@ namespace OpenAuth.App
};
#endregion
UnitWork.Add(flowInstance);
UnitWork.Add(processOperationHistoryEntity);
UnitWork.Add(processTransitionHistoryEntity);
UnitWork.Save();
return true;
}
/// <summary>
/// 节点审核
/// 节点审核
/// </summary>
/// <param name="instanceId"></param>
/// <returns></returns>
public bool NodeVerification(string instanceId, bool flag, string description = "")
{
var user = AuthUtil.GetCurrentUser().User;
FlowInstance flowInstance = Get(instanceId);
FlowInstanceOperationHistory flowInstanceOperationHistory = new FlowInstanceOperationHistory
{
InstanceId = instanceId
};//操作记录
FlowInstanceTransitionHistory processTransitionHistoryEntity = null;//流转记录
InstanceId = instanceId,
CreateUserId = user.Id,
CreateUserName = user.Name,
CreateDate = DateTime.Now
};//操作记录
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
var user = AuthUtil.GetCurrentUser().User;
var tag = new Tag
{
UserName = user.Name,
UserId = user.Id,
Description = description
};
#region
if (flowInstance.ActivityType == 0)//会签
#region
if (flowInstance.ActivityType == 0)//会签
{
tag.Taged = 1;
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, tag);//标记当前节点通过
///寻找需要审核的节点Id
string _VerificationNodeId = "";
List<string> _nodelist = wfruntime.GetCountersigningNodeIdList(wfruntime.runtimeModel.currentNodeId);
string _makerList = "";
foreach (string item in _nodelist)
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, tag);//标记当前节点通过
string verificationNodeId = ""; //寻找需要审核的节点Id
List<string> nodelist = wfruntime.GetCountersigningNodeIdList(wfruntime.runtimeModel.currentNodeId);
foreach (string item in nodelist)
{
_makerList = GetMakerList(wfruntime.runtimeModel.nodes[item], wfruntime.runtimeModel.flowInstanceId);
if (_makerList != "-1")
var makerList = GetMakerList(wfruntime.runtimeModel.nodes[item]
, wfruntime.runtimeModel.flowInstanceId);
if (makerList != "-1")
{
var id = AuthUtil.GetCurrentUser().User.Id;
foreach (string one in _makerList.Split(','))
foreach (string one in makerList.Split(','))
{
if (id == one || id.IndexOf(one) != -1)
if (user.Id == one || user.Id.IndexOf(one) != -1)
{
_VerificationNodeId = item;
verificationNodeId = item;
break;
}
}
}
}
if (_VerificationNodeId != "")
if (verificationNodeId != "")
{
if (flag)
{
tag.Taged = 1;
flowInstanceOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.nodes[_VerificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】同意,备注:" + description;
flowInstanceOperationHistory.Content = "【" + wfruntime.runtimeModel.nodes[verificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】同意,备注:" + description;
}
else
{
tag.Taged = -1;
flowInstanceOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.nodes[_VerificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:" + description;
flowInstanceOperationHistory.Content = "【" + wfruntime.runtimeModel.nodes[verificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:" + description;
}
string confluenceres = wfruntime.NodeConfluence(_VerificationNodeId, tag);
string confluenceres = wfruntime.NodeConfluence(verificationNodeId, tag);
switch (confluenceres)
{
case "-1"://不通过
case "-1"://不通过
flowInstance.IsFinish = 3;
break;
case "1"://等待
case "1"://等待
break;
default://通过
default://通过
flowInstance.PreviousId = flowInstance.ActivityId;
flowInstance.ActivityId = wfruntime.runtimeModel.nextNodeId;
flowInstance.ActivityType = wfruntime.runtimeModel.nextNodeType;//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
flowInstance.ActivityType = wfruntime.runtimeModel.nextNodeType;//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
flowInstance.ActivityName = wfruntime.runtimeModel.nextNode.name;
flowInstance.IsFinish = (wfruntime.runtimeModel.nextNodeType == 4 ? 1 : 0);
flowInstance.MakerList = (wfruntime.runtimeModel.nextNodeType == 4 ? "" : GetMakerList(wfruntime));//当前节点可执行的人信息
flowInstance.MakerList = (wfruntime.runtimeModel.nextNodeType == 4 ? "" : GetMakerList(wfruntime));//当前节点可执行的人信息
#region
processTransitionHistoryEntity = new FlowInstanceTransitionHistory
#region
UnitWork.Add(new FlowInstanceTransitionHistory
{
InstanceId = flowInstance.Id,
CreateUserId = user.Id,
@ -184,7 +182,7 @@ namespace OpenAuth.App
ToNodeType = wfruntime.runtimeModel.nextNodeType,
IsFinish = wfruntime.runtimeModel.nextNodeType ==4?1:0,
TransitionSate = 0
};
});
#endregion
break;
@ -192,13 +190,13 @@ namespace OpenAuth.App
}
else
{
throw (new Exception("审核异常,找不到审核节点"));
throw (new Exception("审核异常,找不到审核节点"));
}
}
#endregion
#region
else//一般审核
#region
else//一般审核
{
if (flag)
{
@ -208,11 +206,11 @@ namespace OpenAuth.App
flowInstance.ActivityId = wfruntime.runtimeModel.nextNodeId;
flowInstance.ActivityType = wfruntime.runtimeModel.nextNodeType;
flowInstance.ActivityName = wfruntime.runtimeModel.nextNode.name;
flowInstance.MakerList = wfruntime.runtimeModel.nextNodeType == 4 ? "" : GetMakerList(wfruntime);//当前节点可执行的人信息
flowInstance.MakerList = wfruntime.runtimeModel.nextNodeType == 4 ? "" : GetMakerList(wfruntime);//当前节点可执行的人信息
flowInstance.IsFinish = (wfruntime.runtimeModel.nextNodeType == 4 ? 1 : 0);
#region
#region
processTransitionHistoryEntity = new FlowInstanceTransitionHistory
UnitWork.Add(new FlowInstanceTransitionHistory
{
InstanceId = flowInstance.Id,
CreateUserId = user.Id,
@ -225,21 +223,21 @@ namespace OpenAuth.App
ToNodeType = wfruntime.runtimeModel.nextNodeType,
IsFinish = wfruntime.runtimeModel.nextNodeType == 4 ? 1 : 0,
TransitionSate = 0
};
});
#endregion
flowInstanceOperationHistory.Content = "【" + "todo name" + "】【" + wfruntime.runtimeModel.currentNode.name
+ "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】同意,备注:" + description;
flowInstanceOperationHistory.Content = "【" + wfruntime.runtimeModel.currentNode.name
+ "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】同意,备注:" + description;
}
else
{
flowInstance.IsFinish = 3; //表示该节点不同意
flowInstance.IsFinish = 3; //表示该节点不同意
tag.Taged = -1;
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, tag);
flowInstanceOperationHistory.Content = "【" + "todo name" + "】【"
+ wfruntime.runtimeModel.currentNode.name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:"
flowInstanceOperationHistory.Content = "【"
+ wfruntime.runtimeModel.currentNode.name + "】【"
+ DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:"
+ description;
}
}
@ -249,12 +247,11 @@ namespace OpenAuth.App
UnitWork.Update(flowInstance);
UnitWork.Add(flowInstanceOperationHistory);
UnitWork.Add(processTransitionHistoryEntity);
UnitWork.Save();
return true;
}
/// <summary>
/// 驳回
/// 驳回
/// </summary>
/// <returns></returns>
public bool NodeReject(VerificationReq reqest)
@ -262,16 +259,9 @@ namespace OpenAuth.App
var user = AuthUtil.GetCurrentUser().User;
FlowInstance flowInstance = Get(reqest.FlowInstanceId);
FlowInstanceOperationHistory flowInstanceOperationHistory = new FlowInstanceOperationHistory
{
InstanceId = reqest.FlowInstanceId,
CreateUserId = user.Id,
CreateUserName = user.Name
};
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
string resnode = "";
if (string.IsNullOrEmpty(reqest.NodeRejectStep))
{
@ -291,17 +281,17 @@ namespace OpenAuth.App
};
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, tag);
flowInstance.IsFinish = 4;//4表示驳回需要申请者重新提交表单
flowInstance.IsFinish = 4;//4表示驳回需要申请者重新提交表单
if (resnode != "")
{
flowInstance.PreviousId = flowInstance.ActivityId;
flowInstance.ActivityId = resnode;
flowInstance.ActivityType = wfruntime.GetNodeType(resnode);
flowInstance.ActivityName = wfruntime.runtimeModel.nodes[resnode].name;
flowInstance.MakerList = GetMakerList(wfruntime.runtimeModel.nodes[resnode], flowInstance.PreviousId);//当前节点可执行的人信息
#region
flowInstance.MakerList = GetMakerList(wfruntime.runtimeModel.nodes[resnode], flowInstance.PreviousId);//当前节点可执行的人信息
#region
var processTransitionHistoryEntity = new FlowInstanceTransitionHistory
UnitWork.Add(new FlowInstanceTransitionHistory
{
InstanceId = flowInstance.Id,
CreateUserId = user.Id,
@ -312,21 +302,27 @@ namespace OpenAuth.App
ToNodeId = wfruntime.runtimeModel.nextNodeId,
ToNodeName = wfruntime.runtimeModel.nextNode.name,
ToNodeType = wfruntime.runtimeModel.nextNodeType,
IsFinish = wfruntime.runtimeModel.nextNodeType ==4?1:0,
IsFinish = wfruntime.runtimeModel.nextNodeType == 4 ? 1 : 0,
TransitionSate = 1
};
UnitWork.Add(processTransitionHistoryEntity);
});
#endregion
}
flowInstanceOperationHistory.Content = "【" + "todo name" + "】【"
+ wfruntime.runtimeModel.currentNode.name
+ "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】驳回,备注:" + reqest.VerificationOpinion;
UnitWork.Update(flowInstance);
UnitWork.Add(flowInstanceOperationHistory);
UnitWork.Add(new FlowInstanceOperationHistory
{
InstanceId = reqest.FlowInstanceId
,CreateUserId = user.Id
,CreateUserName = user.Name
,CreateDate = DateTime.Now
,Content = "【"
+ wfruntime.runtimeModel.currentNode.name
+ "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】驳回,备注:"
+ reqest.VerificationOpinion
});
UnitWork.Save();
return true;
@ -334,7 +330,7 @@ namespace OpenAuth.App
#endregion
/// <summary>
/// 寻找该节点执行人
/// 寻找该节点执行人
/// </summary>
/// <param name="wfruntime"></param>
/// <returns></returns>
@ -343,9 +339,9 @@ namespace OpenAuth.App
string makerList = "";
if (wfruntime.runtimeModel.nextNodeId == "-1")
{
throw (new Exception("无法寻找到下一个节点"));
throw (new Exception("无法寻找到下一个节点"));
}
if (wfruntime.runtimeModel.nextNodeType == 0)//如果是会签节点
if (wfruntime.runtimeModel.nextNodeType == 0)//如果是会签节点
{
List<string> _nodelist = wfruntime.GetCountersigningNodeIdList(wfruntime.runtimeModel.nextNodeId);
string _makerList = "";
@ -354,11 +350,11 @@ namespace OpenAuth.App
_makerList = GetMakerList(wfruntime.runtimeModel.nodes[item], wfruntime.runtimeModel.flowInstanceId);
if (_makerList == "-1")
{
throw (new Exception("无法寻找到会签节点的审核者,请查看流程设计是否有问题!"));
throw (new Exception("无法寻找到会签节点的审核者,请查看流程设计是否有问题!"));
}
if (_makerList == "1")
{
throw (new Exception("会签节点的审核者不能为所有人,请查看流程设计是否有问题!"));
throw (new Exception("会签节点的审核者不能为所有人,请查看流程设计是否有问题!"));
}
if (makerList != "")
{
@ -372,14 +368,14 @@ namespace OpenAuth.App
makerList = GetMakerList(wfruntime.runtimeModel.nextNode, wfruntime.runtimeModel.flowInstanceId);
if (makerList == "-1")
{
throw (new Exception("无法寻找到节点的审核者,请查看流程设计是否有问题!"));
throw (new Exception("无法寻找到节点的审核者,请查看流程设计是否有问题!"));
}
}
return makerList;
}
/// <summary>
/// 寻找该节点执行人
/// 寻找该节点执行人
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
@ -393,11 +389,11 @@ namespace OpenAuth.App
}
else
{
if (node.setInfo.NodeDesignate == Setinfo.ALL_USER)//所有成员
if (node.setInfo.NodeDesignate == Setinfo.ALL_USER)//所有成员
{
makerList = "1";
}
else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_USER)//指定成员
else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_USER)//指定成员
{
makerList = GenericHelpers.ArrayToString(node.setInfo.NodeDesignateData.users, makerList);
@ -420,21 +416,21 @@ namespace OpenAuth.App
}
/// <summary>
/// 审核流程
/// <para>李玉宝于2017-01-20 15:44:45</para>
/// 审核流程
/// <para>李玉宝于2017-01-20 15:44:45</para>
/// </summary>
public void Verification(VerificationReq request)
{
//驳回
//驳回
if (request.VerificationFinally == "3")
{
NodeReject(request);
}
else if (request.VerificationFinally == "2")//表示不同意
else if (request.VerificationFinally == "2")//表示不同意
{
NodeVerification(request.FlowInstanceId, false, request.VerificationOpinion);
}
else if (request.VerificationFinally == "1")//表示同意
else if (request.VerificationFinally == "1")//表示同意
{
NodeVerification(request.FlowInstanceId, true, request.VerificationOpinion);
}
@ -447,11 +443,11 @@ namespace OpenAuth.App
public TableData Load(QueryFlowInstanceListReq request)
{
//todo:待办/已办/我的
//todo:待办/已办/我的
var result = new TableData();
var user = AuthUtil.GetCurrentUser();
if (request.type == "wait") //待办事项
if (request.type == "wait") //待办事项
{
result.count = UnitWork.Find<FlowInstance>(u => u.MakerList =="1" || u.MakerList.Contains(user.User.Id)).Count();
@ -459,11 +455,22 @@ namespace OpenAuth.App
u => u.MakerList == "1" || u.MakerList.Contains(user.User.Id)).ToList();
}
else if (request.type == "disposed") //已办事项
else if (request.type == "disposed") //已办事项(即我参与过的流程)
{
result.data = UnitWork.Find<FlowInstance>(request.page, request.limit, "CreateDate descending", null).ToList();
var instances = UnitWork.Find<FlowInstanceTransitionHistory>(u => u.CreateUserId == user.User.Id)
.Select(u => u.InstanceId).Distinct();
var query = from ti in instances
join ct in UnitWork.Find<FlowInstance>(null) on ti equals ct.Id
into tmp
from ct in tmp.DefaultIfEmpty()
select ct;
result.data = query.OrderByDescending(u => u.CreateDate)
.Skip((request.page - 1) * request.limit)
.Take(request.limit).ToList();
result.count = instances.Count();
}
else //我的流程
else //我的流程
{
result.count = UnitWork.Find<FlowInstance>(u => u.CreateUserId == user.User.Id).Count();
result.data = UnitWork.Find<FlowInstance>(request.page, request.limit,

View File

@ -143,7 +143,7 @@ namespace OpenAuth.App.SSO
var value = _helper.Post(new
{
AppKey = appKey,
UserName = username,
Account = username,
Password = pwd
}, requestUri);

View File

@ -5,7 +5,7 @@ namespace OpenAuth.App.SSO
public class PassportLoginRequest
{
public string UserName { get; set; }
public string Account { get; set; }
public string Password { get; set; }
@ -13,7 +13,7 @@ namespace OpenAuth.App.SSO
public void Trim()
{
if (string.IsNullOrEmpty(UserName))
if (string.IsNullOrEmpty(Account))
{
throw new Exception("用户名不能为空");
}
@ -22,7 +22,7 @@ namespace OpenAuth.App.SSO
{
throw new Exception("密码不能为空");
}
UserName = UserName.Trim();
Account = Account.Trim();
Password = Password.Trim();
if(!string.IsNullOrEmpty(AppKey)) AppKey = AppKey.Trim();
}

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Web;
using System.Web.Mvc;
using Infrastructure.Cache;
@ -15,49 +15,50 @@ namespace OpenAuth.App.SSO
try
{
model.Trim();
//获取应用信息
//获取应用信息
var appInfo = new AppInfoService().Get(model.AppKey);
if (appInfo == null)
{
throw new Exception("应用不存在");
throw new Exception("应用不存在");
}
//获取用户信息
//获取用户信息
User userInfo = null;
if (model.UserName == "System")
if (model.Account == "System")
{
userInfo = new User
{
Id = string.Empty,
Id = Guid.Empty.ToString(), //TODO:可以根据需要调整
Account = "System",
Name ="超级管理员",
Name ="超级管理员",
Password = "123456"
};
}
else
{
var usermanager = (UserManagerApp)DependencyResolver.Current.GetService(typeof(UserManagerApp));
userInfo = usermanager.Get(model.UserName);
userInfo = usermanager.Get(model.Account);
}
if (userInfo == null)
{
throw new Exception("用户不存在");
throw new Exception("用户不存在");
}
if (userInfo.Password != model.Password)
{
throw new Exception("密码错误");
throw new Exception("密码错误");
}
var currentSession = new UserAuthSession
{
UserName = model.UserName,
Account = model.Account,
Name = userInfo.Name,
Token = Guid.NewGuid().ToString().GetHashCode().ToString("x"),
AppKey = model.AppKey,
CreateTime = DateTime.Now,
IpAddress = HttpContext.Current.Request.UserHostAddress
};
//创建Session
//创建Session
new ObjCacheProvider<UserAuthSession>().Create(currentSession.Token, currentSession, DateTime.Now.AddDays(10));
result.Code = 200;

View File

@ -9,7 +9,15 @@ namespace OpenAuth.App.SSO
public string AppKey { get; set; }
public string UserName { get; set; }
/// <summary>
/// 用户账号
/// </summary>
public string Account { get; set; }
/// <summary>
/// 用户名
/// </summary>
public string Name { get; set; }
public string IpAddress { get; set; }

View File

@ -9,6 +9,7 @@
// File: AuthenService.cs
// ***********************************************************************
using System;
using System.Linq;
using OpenAuth.Repository.Domain;
@ -17,12 +18,18 @@ namespace OpenAuth.App
/// <summary>
/// 领域服务
/// <para>超级管理员权限</para>
/// <para>todo:超级管理员使用guid.empty为ID可以根据需要修改</para>
/// </summary>
public class SystemAuthService : AuthoriseService
{
public SystemAuthService()
{
_user = new User { Account = "System", Id = string.Empty };
_user = new User
{
Account = "System",
Name = "超级管理员",
Id = Guid.Empty.ToString()
};
}

View File

@ -48,15 +48,12 @@ namespace OpenAuth.Mvc.Controllers
return JsonHelper.Instance.Serialize(resp);
}
/// <summary>
/// 开发者登录
/// </summary>
public string LoginByDev()
public string Login(string username, string password)
{
var resp = new Response();
try
{
var result = AuthUtil.Login(_appKey, "System", "123456");
var result = AuthUtil.Login(_appKey, username, password);
if (result.Code == 200)
{
var cookie = new HttpCookie("Token", result.Token)

View File

@ -196,7 +196,7 @@
<Content Include="js\flow\img\gooflow_icon.png" />
<Content Include="js\flowlayout.js" />
<Content Include="js\utils.js" />
<Content Include="userJs\flowInstanceOp.js" />
<Content Include="userJs\verification.js" />
<Content Include="userJs\flowInstanceEdit.js" />
<Content Include="userJs\flowInstanceWait.js" />
<Content Include="userJs\flowInstanceDisposed.js" />

View File

@ -6,27 +6,31 @@
<link href="/css/formpreview.css" rel="stylesheet" />
}
<form class="layui-form" action="" id="formEdit">
<div class="layui-row">
<form class="layui-form " action="" id="formEdit">
<div class="layui-row ">
<div class="layui-col-xs8">
<div class="layui-tab layui-tab-brief" lay-filter="tab">
<ul class="layui-tab-title">
<li class="layui-this">表单信息</li>
<li>流程信息</li>
<li class="layui-this">流程信息</li>
<li>表单信息</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<div id="frmPreview"></div>
<div id="flowPanel"></div>
</div>
<div class="layui-tab-item">
<div id="flowPanel" ></div>
<div id="frmPreview"></div>
</div>
</div>
</div>
<input type="hidden" id="FlowInstanceId" name="FlowInstanceId" />
</div>
<div class="layui-col-xs4" style="background-color: gainsboro; min-height: 600px">
<input type="hidden" id="FlowInstanceId" name="FlowInstanceId"/>
<div class="layui-form-item">
<label class="layui-form-label">审核结果</label>
<div class="layui-input-block">
@ -39,8 +43,9 @@
<div class="layui-form-item">
<label class="layui-form-label">审核意见</label>
<div class="layui-input-block">
<input type="text" name="VerificationOpinion"
placeholder="" autocomplete="off" class="layui-input">
<textarea name="VerificationOpinion"
placeholder="" autocomplete="off" class="layui-textarea" ></textarea>
</div>
</div>
</div>
</div>
@ -48,5 +53,5 @@
<input type="hidden" lay-submit id="btnSubmit" lay-filter="formSubmit"/>
</form>
<script type="text/javascript" src="/layui/layui.js"></script>
<script type="text/javascript" src="/userJs/flowInstanceOp.js?v2"></script>
<script type="text/javascript" src="/userJs/verification.js?v2"></script>

View File

@ -43,11 +43,11 @@
<form class="layui-form">
<ul>
<li>
<input name="username" type="text" class="loginuser" value="admin"
<input name="username" type="text" class="loginuser" value="System"
placeholder="请输入用户名/手机号码" lay-verify="required">
</li>
<li>
<input name="password" type="password" id="password" value="admin"
<input name="password" type="password" id="password" value="123456"
class="loginpwd ipt" placeholder="请输入密码" lay-verify="required">
</li>
<li>

View File

@ -65,47 +65,6 @@
}();
$("#tree").height($("div.layui-table-view").height());
//添加(编辑)对话框
var editDlg = function () {
var update = false; //是否为更新
var show = function (data) {
var title = update ? "编辑信息" : "添加";
layer.open({
type: 2,
area: ['800px', '700px'], //宽高
maxmin: true, //开启最大化最小化按钮
title: title,
content: '/flowInstances/edit?id=' + data.Id,
btn: ['保存', '关闭'],
yes: function (index, layero) {
var iframeWin = thiswin[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象执行iframe页的方法iframeWin.method();
iframeWin.submit();
},
btn2: function (index) {
layer.close(index);
mainList();
},
cancel: function (index) {
layer.close(index);
mainList();
}
});
}
return {
add: function () { //弹出添加
update = false;
show({
Id: ''
});
},
update: function (data) { //弹出编辑框
update = true;
show(data);
}
};
}();
//监听表格内部按钮
table.on('tool(list)', function (obj) {
@ -117,27 +76,7 @@
//监听页面主按钮操作
var active = {
btnDel: function () { //批量删除
var checkStatus = table.checkStatus('mainList')
, data = checkStatus.data;
openauth.del("/FlowInstances/Delete",
data.map(function (e) { return e.Id; }),
mainList);
}
, btnAdd: function () { //添加
editDlg.add();
}
, btnEdit: function () { //编辑
var checkStatus = table.checkStatus('mainList')
, data = checkStatus.data;
if (data.length != 1) {
layer.msg("请选择编辑的行,且同时只能编辑一行");
return;
}
editDlg.update(data[0]);
}
, btnVerification: function () { //处理
btnDetail: function () { //处理
var checkStatus = table.checkStatus('mainList')
, data = checkStatus.data;
if (data.length != 1) {
@ -147,16 +86,12 @@
layer.open({
type: 2,
area: ['750px', '550px'], //宽高
area: ['800px', '600px'], //宽高
maxmin: true, //开启最大化最小化按钮
title: '处理流程',
content: '/flowInstances/Verification?id=' + data[0].Id,
btn: ['保存', '关闭'],
yes: function (index, layero) {
var iframeWin = thiswin[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象执行iframe页的方法iframeWin.method();
iframeWin.submit();
},
btn2: function (index) {
content: ['/flowInstances/Verification?id=' + data[0].Id, 'no'],
btn: ['关闭'],
yes: function (index) {
layer.close(index);
mainList();
},
@ -166,13 +101,6 @@
}
});
}
, search: function () { //搜索
mainList({ key: $('#key').val() });
}
, btnRefresh: function() {
mainList();
}
};
$('.toolList .layui-btn').on('click', function () {

View File

@ -65,47 +65,6 @@
}();
$("#tree").height($("div.layui-table-view").height());
//添加(编辑)对话框
var editDlg = function () {
var update = false; //是否为更新
var show = function (data) {
var title = update ? "编辑信息" : "添加";
layer.open({
type: 2,
area: ['800px', '700px'], //宽高
maxmin: true, //开启最大化最小化按钮
title: title,
content: '/flowInstances/edit?id=' + data.Id,
btn: ['保存', '关闭'],
yes: function (index, layero) {
var iframeWin = thiswin[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象执行iframe页的方法iframeWin.method();
iframeWin.submit();
},
btn2: function (index) {
layer.close(index);
mainList();
},
cancel: function (index) {
layer.close(index);
mainList();
}
});
}
return {
add: function () { //弹出添加
update = false;
show({
Id: ''
});
},
update: function (data) { //弹出编辑框
update = true;
show(data);
}
};
}();
//监听表格内部按钮
table.on('tool(list)', function (obj) {
@ -117,27 +76,7 @@
//监听页面主按钮操作
var active = {
btnDel: function () { //批量删除
var checkStatus = table.checkStatus('mainList')
, data = checkStatus.data;
openauth.del("/FlowInstances/Delete",
data.map(function (e) { return e.Id; }),
mainList);
}
, btnAdd: function () { //添加
editDlg.add();
}
, btnEdit: function () { //编辑
var checkStatus = table.checkStatus('mainList')
, data = checkStatus.data;
if (data.length != 1) {
layer.msg("请选择编辑的行,且同时只能编辑一行");
return;
}
editDlg.update(data[0]);
}
, btnVerification: function () { //处理
btnVerification: function () { //处理
var checkStatus = table.checkStatus('mainList')
, data = checkStatus.data;
if (data.length != 1) {
@ -147,10 +86,10 @@
layer.open({
type: 2,
area: ['750px', '550px'], //宽高
area: ['800px', '600px'], //宽高
maxmin: true, //开启最大化最小化按钮
title: '处理流程',
content: '/flowInstances/Verification?id=' + data[0].Id,
content: ['/flowInstances/Verification?id=' + data[0].Id,'no'],
btn: ['保存', '关闭'],
yes: function (index, layero) {
var iframeWin = thiswin[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象执行iframe页的方法iframeWin.method();
@ -167,6 +106,31 @@
});
}
, btnDetail: function () { //处理
var checkStatus = table.checkStatus('mainList')
, data = checkStatus.data;
if (data.length != 1) {
layer.msg("请选择要处理的流程,且同时只能选择一条");
return;
}
layer.open({
type: 2,
area: ['800px', '600px'], //宽高
maxmin: true, //开启最大化最小化按钮
title: '处理流程',
content: ['/flowInstances/Verification?id=' + data[0].Id, 'no'],
btn: ['关闭'],
yes: function (index) {
layer.close(index);
mainList();
},
cancel: function (index) {
layer.close(index);
mainList();
}
});
}
, search: function () { //搜索
mainList({ key: $('#key').val() });
}

View File

@ -135,7 +135,7 @@
editDlg.update(data[0]);
}
, btnVerification: function () { //处理
, btnDetail: function () { //处理
var checkStatus = table.checkStatus('mainList')
, data = checkStatus.data;
if (data.length != 1) {
@ -145,16 +145,12 @@
layer.open({
type: 2,
area: ['750px', '550px'], //宽高
area: ['800px', '600px'], //宽高
maxmin: true, //开启最大化最小化按钮
title: '处理流程',
content: '/flowInstances/Verification?id=' + data[0].Id,
btn: ['保存', '关闭'],
yes: function (index, layero) {
var iframeWin = thiswin[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象执行iframe页的方法iframeWin.method();
iframeWin.submit();
},
btn2: function (index) {
content: ['/flowInstances/Verification?id=' + data[0].Id, 'no'],
btn: ['关闭'],
yes: function (index) {
layer.close(index);
mainList();
},

View File

@ -5,7 +5,6 @@ layui.config({
var form = layui.form, element = layui.element,
layer = layui.layer,
$ = layui.jquery;
var thiswin = (top == undefined) ? window : top.window;
var table = layui.table;
var openauth = layui.openauth;
@ -108,7 +107,7 @@ layui.config({
btn: ['确定', '取消'],
yes: function (index, layero) {
var body = layer.getChildFrame('body', index);
var iframeWin = thiswin[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象执行iframe页的方法iframeWin.method();
var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象执行iframe页的方法iframeWin.method();
var nodedata = iframeWin.getVal();
flowDesignPanel.SetNodeEx(object.id, nodedata);
layer.close(index);

View File

@ -3,9 +3,8 @@
}).use(['form', 'vue', 'ztree', 'layer', 'utils', 'jquery', 'table', 'droptree', 'openauth', 'element'], function () {
var form = layui.form,
element = layui.element,
layer = (top == undefined || top.layer === undefined )? layui.layer : top.layer,
layer = layui.layer ,
$ = layui.jquery;
var thiswin = (top == undefined) ? window : top.window;
var table = layui.table;
var openauth = layui.openauth;

View File

@ -92,8 +92,9 @@ layui.config({
//登录按钮事件
form.on("submit(login)", function (data) {
$.getJSON("/Login/LoginByDev",
function(data) {
$.getJSON("/Login/Login"
, data.field
,function(data) {
if (data.Code == 200) {
window.location.href = "/Home/Index";
} else {

View File

@ -10,18 +10,12 @@
var id = $.getUrlParam("id"); //ID
$("#FlowInstanceId").val(id);
//标签切换
element.on('tab(tab)', function (data) {
layer.iframeAuto(index);
});
$.getJSON('/FlowInstances/get?id=' + id,
function (data) {
var obj = data.Result;
var schemeContent = JSON.parse(obj.SchemeContent);
var flowDesignPanel = $('#flowPanel').flowdesign({
height: 300,
widht: 300,
haveTool: false
, isprocessing: true
, activityId: obj.ActivityId

View File

@ -30,6 +30,16 @@
</root>
</log4net>
<appSettings>
<add key="version" value="" />
<!--SSO单点登录主域-->
<!--<add key="SSOPassport" value="http://openauthapi.com" />-->
<add key="SSOPassport" value="http://localhost:52789" />
<!--AppKey唯一标识-->
<add key="SSOAppKey" value="openauth" />
</appSettings>
<autofac defaultAssembly=" OpenAuth.Repository">
<components>
<component type=" OpenAuth.Repository.UserRepository" service=" OpenAuth.Domain.Interface.IUserRepository,OpenAuth.Domain" />

View File

@ -22,7 +22,7 @@ namespace OpenAuth.UnitTest
[TestMethod]
public void TestMethod1()
{
var service= app.Create("System");
var service= app.Create("admin");
var modules = service.Modules;

View File

@ -12,11 +12,13 @@ namespace OpenAuth.UnitTest
{
private FlowSchemeApp _app;
private FlowInstanceApp _runApp;
private AuthorizeApp authenApp;
public TestWorkflow()
{
_app = AutofacExt.GetFromFac<FlowSchemeApp>();
_runApp = AutofacExt.GetFromFac<FlowInstanceApp>();
authenApp = AutofacExt.GetFromFac<AuthorizeApp>();
}
/// <summary>
@ -26,9 +28,10 @@ namespace OpenAuth.UnitTest
[TestMethod]
public void Verify()
{
authenApp.Create("System");
_runApp.Verification(new VerificationReq
{
FlowInstanceId = "132333fe-d8db-4373-b101-b0ac574d3b1a",
FlowInstanceId = "7335d82f-5c3d-43e5-a53b-7d51a7cb1f59",
VerificationFinally = "3"
});
}

View File

@ -65,7 +65,7 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
var user = _objCacheProvider.GetCache(token);
if (user != null)
{
result.Result = _app.GetAccessedControls(user.UserName);
result.Result = _app.GetAccessedControls(user.Account);
}
}
catch (Exception ex)
@ -92,7 +92,7 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
var user = _objCacheProvider.GetCache(token);
if (user != null)
{
result.Result = user.UserName;
result.Result = user.Account;
}
}
catch (Exception ex)

View File

@ -23,7 +23,7 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
var viewModel = new PassportLoginRequest
{
AppKey = appKey,
UserName = username,
Account = username,
};
return View(viewModel);
@ -37,7 +37,7 @@ namespace OpenAuth.WebApi.Areas.SSO.Controllers
if (result.Code ==200)
{
var redirectUrl = string.Format("{0}?token={1}&sessionusername={2}", result.ReturnUrl, result.Token, model.UserName);
var redirectUrl = string.Format("{0}?token={1}&sessionusername={2}", result.ReturnUrl, result.Token, model.Account);
//跳转默认回调页面
return Redirect(redirectUrl);

View File

@ -36,7 +36,7 @@
<div class="form-group">
<label class="col-md-3 control-label" for="UserName">用户名</label>
<div class="col-md-9">
@Html.TextBoxFor(model => model.UserName, new { @class = "form-control input-lg", style = "width: 280px" })
@Html.TextBoxFor(model => model.Account, new { @class = "form-control input-lg", style = "width: 280px" })
@Html.HiddenFor(model => model.AppKey)
</div>
</div>

Binary file not shown.