开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 1.8K

码神/OpenAuth.Net

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
4.0
分支 (4)
标签 (4)
4.0
DataPart
bestflow
newui
v4.0
3.0alpha
v2.0beta
v1.2
4.0
分支 (4)
标签 (4)
4.0
DataPart
bestflow
newui
v4.0
3.0alpha
v2.0beta
v1.2
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
4.0
分支 (4)
标签 (4)
4.0
DataPart
bestflow
newui
v4.0
3.0alpha
v2.0beta
v1.2
OpenAuth.Net
/
OpenAuth.App
/
FlowInstanceApp.cs
OpenAuth.Net
/
OpenAuth.App
/
FlowInstanceApp.cs
FlowInstanceApp.cs 20.69 KB
一键复制 编辑 原始数据 按行查看 历史
李玉宝 提交于 2018年05月07日 14:47 +08:00 . check bugs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
using System;
using System.Collections.Generic;
using System.Linq;
using Infrastructure;
using Newtonsoft.Json.Linq;
using OpenAuth.App.Flow;
using OpenAuth.App.Request;
using OpenAuth.App.Response;
using OpenAuth.App.SSO;
using OpenAuth.Repository.Domain;
namespace OpenAuth.App
{
/// <summary>
/// 工作流实例表操作
/// </summary>
public class FlowInstanceApp : BaseApp<FlowInstance>
{
public RevelanceManagerApp RevelanceManagerApp { get; set; }
#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_")))
{
frmdata[property.Name] = property.Value;
}
flowInstance.FrmData = JsonHelper.Instance.Serialize(frmdata);
//创建运行实例
var wfruntime = new FlowRuntime(flowInstance);
var user = AuthUtil.GetCurrentUser();
#region 根据运行实例改变当前节点状态
flowInstance.ActivityId = wfruntime.runtimeModel.nextNodeId;
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.IsFinish = (wfruntime.GetNextNodeType() == 4 ? 1 : 0);
UnitWork.Add(flowInstance);
#endregion
#region 流程操作记录
FlowInstanceOperationHistory processOperationHistoryEntity = new FlowInstanceOperationHistory
{
InstanceId = flowInstance.Id,
CreateUserId = user.User.Id,
CreateUserName = user.User.Name,
CreateDate = DateTime.Now,
Content = "【创建】"
+ user.User.Name
+ "创建了一个流程进程【"
+ flowInstance.Code + "/"
+ flowInstance.CustomName + "】"
};
UnitWork.Add(processOperationHistoryEntity);
#endregion
#region 流转记录
FlowInstanceTransitionHistory processTransitionHistoryEntity = new FlowInstanceTransitionHistory
{
InstanceId = flowInstance.Id,
FromNodeId = wfruntime.runtimeModel.currentNodeId,
FromNodeName = wfruntime.runtimeModel.currentNode.name,
FromNodeType = wfruntime.runtimeModel.currentNodeType,
ToNodeId = wfruntime.runtimeModel.nextNodeId,
ToNodeName = wfruntime.runtimeModel.nextNode.name,
ToNodeType = wfruntime.runtimeModel.nextNodeType,
IsFinish = wfruntime.runtimeModel.nextNodeType == 4?1:0,
TransitionSate = 0,
CreateUserId = user.User.Id,
CreateUserName = user.User.Name
};
#endregion
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,
CreateUserId = user.Id,
CreateUserName = user.Name,
CreateDate = DateTime.Now
};//操作记录
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
var tag = new Tag
{
UserName = user.Name,
UserId = user.Id,
Description = description
};
#region 会签
if (flowInstance.ActivityType == 0)//当前节点是会签节点
{
tag.Taged = 1;
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, tag);//标记会签节点状态
string verificationNodeId = ""; //寻找当前登陆用户可审核的节点Id
List<string> nodelist = wfruntime.GetCountersigningNodeIdList(wfruntime.runtimeModel.currentNodeId);
foreach (string item in nodelist)
{
var makerList = GetMakerList(wfruntime.runtimeModel.nodes[item]
, wfruntime.runtimeModel.flowInstanceId);
if (makerList == "-1") continue;
if (makerList.Split(',').Any(one => user.Id == one))
{
verificationNodeId = item;
}
}
if (verificationNodeId != "")
{
if (flag)
{
tag.Taged = 1;
flowInstanceOperationHistory.Content = "【" + wfruntime.runtimeModel.nodes[verificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】同意,备注:" + description;
}
else
{
tag.Taged = -1;
flowInstanceOperationHistory.Content = "【" + wfruntime.runtimeModel.nodes[verificationNodeId].name + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:" + description;
}
wfruntime.MakeTagNode(verificationNodeId, tag);//标记审核节点状态
string confluenceres = wfruntime.NodeConfluence(verificationNodeId, tag);
switch (confluenceres)
{
case "-1"://不通过
flowInstance.IsFinish = 3;
break;
case "1"://等待,当前节点还是会签开始节点,不跳转
break;
default://通过
flowInstance.PreviousId = flowInstance.ActivityId;
flowInstance.ActivityId = wfruntime.runtimeModel.nextNodeId;
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));//当前节点可执行的人信息
#region 流转记录
UnitWork.Add(new FlowInstanceTransitionHistory
{
InstanceId = flowInstance.Id,
CreateUserId = user.Id,
CreateUserName = user.Name,
FromNodeId = wfruntime.runtimeModel.currentNodeId,
FromNodeName = wfruntime.runtimeModel.currentNode.name,
FromNodeType = wfruntime.runtimeModel.currentNodeType,
ToNodeId = wfruntime.runtimeModel.nextNodeId,
ToNodeName = wfruntime.runtimeModel.nextNode.name,
ToNodeType = wfruntime.runtimeModel.nextNodeType,
IsFinish = wfruntime.runtimeModel.nextNodeType ==4?1:0,
TransitionSate = 0
});
#endregion
break;
}
}
else
{
throw (new Exception("审核异常,找不到审核节点"));
}
}
#endregion
#region 一般审核
else//一般审核
{
if (flag)
{
tag.Taged = 1;
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, tag);
flowInstance.PreviousId = flowInstance.ActivityId;
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.IsFinish = (wfruntime.runtimeModel.nextNodeType == 4 ? 1 : 0);
#region 流转记录
UnitWork.Add(new FlowInstanceTransitionHistory
{
InstanceId = flowInstance.Id,
CreateUserId = user.Id,
CreateUserName = user.Name,
FromNodeId = wfruntime.runtimeModel.currentNodeId,
FromNodeName = wfruntime.runtimeModel.currentNode.name,
FromNodeType = wfruntime.runtimeModel.currentNodeType,
ToNodeId = wfruntime.runtimeModel.nextNodeId,
ToNodeName = wfruntime.runtimeModel.nextNode.name,
ToNodeType = wfruntime.runtimeModel.nextNodeType,
IsFinish = wfruntime.runtimeModel.nextNodeType == 4 ? 1 : 0,
TransitionSate = 0
});
#endregion
flowInstanceOperationHistory.Content = "【" + wfruntime.runtimeModel.currentNode.name
+ "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】同意,备注:" + description;
}
else
{
flowInstance.IsFinish = 3; //表示该节点不同意
tag.Taged = -1;
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, tag);
flowInstanceOperationHistory.Content = "【"
+ wfruntime.runtimeModel.currentNode.name + "】【"
+ DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】不同意,备注:"
+ description;
}
}
#endregion
flowInstance.SchemeContent = JsonHelper.Instance.Serialize(wfruntime.runtimeModel.schemeContentJson);
UnitWork.Update(flowInstance);
UnitWork.Add(flowInstanceOperationHistory);
UnitWork.Save();
return true;
}
/// <summary>
/// 驳回
/// </summary>
/// <returns></returns>
public bool NodeReject(VerificationReq reqest)
{
var user = AuthUtil.GetCurrentUser().User;
FlowInstance flowInstance = Get(reqest.FlowInstanceId);
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
string resnode = "";
if (string.IsNullOrEmpty(reqest.NodeRejectStep))
{
resnode = wfruntime.RejectNode();
}
else
{
resnode = reqest.NodeRejectStep;
}
var tag = new Tag
{
Description = reqest.VerificationOpinion,
Taged = 0,
UserId = user.Id,
UserName = user.Name
};
wfruntime.MakeTagNode(wfruntime.runtimeModel.currentNodeId, tag);
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 流转记录
UnitWork.Add(new FlowInstanceTransitionHistory
{
InstanceId = flowInstance.Id,
CreateUserId = user.Id,
CreateUserName = user.Name,
FromNodeId = wfruntime.runtimeModel.currentNodeId,
FromNodeName = wfruntime.runtimeModel.currentNode.name,
FromNodeType = wfruntime.runtimeModel.currentNodeType,
ToNodeId = wfruntime.runtimeModel.nextNodeId,
ToNodeName = wfruntime.runtimeModel.nextNode.name,
ToNodeType = wfruntime.runtimeModel.nextNodeType,
IsFinish = wfruntime.runtimeModel.nextNodeType == 4 ? 1 : 0,
TransitionSate = 1
});
#endregion
}
UnitWork.Update(flowInstance);
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;
}
#endregion
/// <summary>
/// 寻找该节点执行人
/// </summary>
/// <param name="wfruntime"></param>
/// <returns></returns>
private string GetMakerList(FlowRuntime wfruntime)
{
string makerList = "";
if (wfruntime.runtimeModel.nextNodeId == "-1")
{
throw (new Exception("无法寻找到下一个节点"));
}
if (wfruntime.runtimeModel.nextNodeType == 0)//如果是会签节点
{
List<string> _nodelist = wfruntime.GetCountersigningNodeIdList(wfruntime.runtimeModel.nextNodeId);
string _makerList = "";
foreach (string item in _nodelist)
{
_makerList = GetMakerList(wfruntime.runtimeModel.nodes[item], wfruntime.runtimeModel.flowInstanceId);
if (_makerList == "-1")
{
throw (new Exception("无法寻找到会签节点的审核者,请查看流程设计是否有问题!"));
}
if (_makerList == "1")
{
throw (new Exception("会签节点的审核者不能为所有人,请查看流程设计是否有问题!"));
}
if (makerList != "")
{
makerList += ",";
}
makerList += _makerList;
}
}
else
{
makerList = GetMakerList(wfruntime.runtimeModel.nextNode, wfruntime.runtimeModel.flowInstanceId);
if (makerList == "-1")
{
throw (new Exception("无法寻找到节点的审核者,请查看流程设计是否有问题!"));
}
}
return makerList;
}
/// <summary>
/// 寻找该节点执行人
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
private string GetMakerList(FlowNode node, string processId)
{
string makerList = "";
if (node.setInfo == null)
{
makerList = "-1";
}
else
{
if (node.setInfo.NodeDesignate == Setinfo.ALL_USER)//所有成员
{
makerList = "1";
}
else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_USER)//指定成员
{
makerList = GenericHelpers.ArrayToString(node.setInfo.NodeDesignateData.users, makerList);
if (makerList == "")
{
makerList = "-1";
}
}
else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_ROLE) //指定角色
{
var users = RevelanceManagerApp.Get(Define.USERROLE, false, node.setInfo.NodeDesignateData.roles);
makerList = GenericHelpers.ArrayToString(users, makerList);
if (makerList == "")
{
makerList = "-1";
}
}
}
return makerList;
}
/// <summary>
/// 审核流程
/// <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")//表示不同意
{
NodeVerification(request.FlowInstanceId, false, request.VerificationOpinion);
}
else if (request.VerificationFinally == "1")//表示同意
{
NodeVerification(request.FlowInstanceId, true, request.VerificationOpinion);
}
}
public void Update(FlowInstance flowScheme)
{
Repository.Update(flowScheme);
}
public TableData Load(QueryFlowInstanceListReq request)
{
//todo:待办/已办/我的
var result = new TableData();
var user = AuthUtil.GetCurrentUser();
if (request.type == "wait") //待办事项
{
result.count = UnitWork.Find<FlowInstance>(u => u.MakerList =="1" || u.MakerList.Contains(user.User.Id)).Count();
result.data = UnitWork.Find<FlowInstance>(request.page, request.limit, "CreateDate descending",
u => u.MakerList == "1" || u.MakerList.Contains(user.User.Id)).ToList();
}
else if (request.type == "disposed") //已办事项(即我参与过的流程)
{
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 //我的流程
{
result.count = UnitWork.Find<FlowInstance>(u => u.CreateUserId == user.User.Id).Count();
result.data = UnitWork.Find<FlowInstance>(request.page, request.limit,
"CreateDate descending", u => u.CreateUserId == user.User.Id).ToList();
}
return result;
}
}
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

【已支持.Net Core】基于经典领域驱动设计的权限管理及快速开发框架,基于Martin Fowler企业级应用开发思想及全新技术组合(Asp.Net MVC、EF、AutoFac、WebAPI、Swagger、Json.Net等),核心模块包括:组织机构、角色用户、权限授权、表单设计、工作流等。它的架构精良易于扩展,是中小企业的首选。
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/dotcpp/OpenAuth.Net.git
git@gitee.com:dotcpp/OpenAuth.Net.git
dotcpp
OpenAuth.Net
OpenAuth.Net
4.0
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /