mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 10:37:55 +08:00
流程跳转
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.App.SSO;
|
||||
using OpenAuth.App.ViewModel;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Mvc.Models;
|
||||
using OptimaJet.Workflow.Core.Runtime;
|
||||
@@ -50,8 +52,9 @@ namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var apply = _app.Get(id);
|
||||
GoodsApplyVM apply = _app.Get(id);
|
||||
CreateWorkflowIfNotExists(id);
|
||||
apply.Commands = GetCommands(id);
|
||||
return View(apply);
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -62,6 +65,39 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public string Delete(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.Del(id);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = ex.Message;
|
||||
throw;
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public string ExeCmd(Guid id, string cmd)
|
||||
{
|
||||
try
|
||||
{
|
||||
ExecuteCommand(id, cmd, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BjuiResponse.statusCode = "300";
|
||||
BjuiResponse.message = ex.Message;
|
||||
throw;
|
||||
}
|
||||
|
||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||
}
|
||||
|
||||
|
||||
private void CreateWorkflowIfNotExists(Guid id)
|
||||
{
|
||||
@@ -77,5 +113,43 @@ namespace OpenAuth.Mvc.Controllers
|
||||
sync.Wait(new TimeSpan(0, 0, 10));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前登陆用户可执行的命令
|
||||
/// </summary>
|
||||
/// <param name="id">流程实体ID</param>
|
||||
private CommandModel[] GetCommands(Guid id)
|
||||
{
|
||||
var result = new List<CommandModel>();
|
||||
var commands = WorkflowInit.Runtime.GetAvailableCommands(id, AuthUtil.GetCurrentUser().User.Id.ToString());
|
||||
foreach (var workflowCommand in commands) //去除相同的
|
||||
{
|
||||
if (result.Count(c => c.Key == workflowCommand.CommandName) == 0)
|
||||
result.Add(new CommandModel() { Key = workflowCommand.CommandName, Value = workflowCommand.LocalizedName, Classifier = workflowCommand.Classifier });
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行指令
|
||||
/// </summary>
|
||||
/// <param name="id">流程实例ID</param>
|
||||
/// <param name="commandName">命令名称</param>
|
||||
/// <param name="goodsApply">申请实体</param>
|
||||
private void ExecuteCommand(Guid id, string commandName, GoodsApply goodsApply)
|
||||
{
|
||||
var currentUser =AuthUtil.GetCurrentUser().User.Id.ToString();
|
||||
|
||||
var commands = WorkflowInit.Runtime.GetAvailableCommands(id, currentUser);
|
||||
|
||||
var command =
|
||||
commands.FirstOrDefault(
|
||||
c => c.CommandName.Equals(commandName, StringComparison.CurrentCultureIgnoreCase));
|
||||
|
||||
if (command == null)
|
||||
return;
|
||||
|
||||
WorkflowInit.Runtime.ExecuteCommand(id, currentUser, currentUser, command);
|
||||
}
|
||||
}
|
||||
}
|
@@ -33,7 +33,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
|
||||
public string LoadOrg()
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(AuthUtil.GetCurrentUser().AccessedOrgs);
|
||||
return JsonHelper.Instance.Serialize(AuthUtil.GetCurrentUser().Orgs);
|
||||
}
|
||||
|
||||
public string LoadForUser(Guid firstId)
|
||||
|
Reference in New Issue
Block a user