using System;
using System.Collections.Generic;
using System.Data;
using System.Web.Mvc;
using System.Web.UI.WebControls;
using Infrastructure;
using LeaRun.Util.WebControl;
using OpenAuth.App;
using OpenAuth.App.SSO;
using OpenAuth.Domain;
using OpenAuth.Domain.Service;
using OpenAuth.Mvc.Controllers;
namespace OpenAuth.Mvc.Areas.FlowManage.Controllers
{
///
/// 流程设计
/// 李玉宝新增于2017-01-12 19:41:56
///
public class FlowDesignController :BaseController
{
private WFSchemeService wfFlowInfoBLL;
private UserManagerApp userBLL;
public FlowDesignController()
{
wfFlowInfoBLL = AutofacExt.GetFromFac();
userBLL = AutofacExt.GetFromFac();
}
#region 视图功能
///
/// 管理
///
///
[HttpGet]
public ActionResult Index()
{
return View();
}
///
/// 预览
///
///
[HttpGet]
public ActionResult PreviewIndex()
{
return View();
}
///
/// 表单
///
///
[HttpGet]
public ActionResult Form()
{
return View();
}
///
/// 节点设置
///
///
[HttpGet]
public ActionResult FlowNodeForm()
{
return View();
}
///
/// 连接线设置
///
///
[HttpGet]
public ActionResult FlowLineForm()
{
return View();
}
///
/// 流程创建
///
///
[HttpGet]
public ActionResult FlowSchemeBuider()
{
return View();
}
#endregion
#region 获取数据
///
/// 设置流程
///
/// 主键
///
[HttpGet]
public ActionResult GetFormJson(Guid keyValue)
{
var schemeinfo = wfFlowInfoBLL.GetEntity(keyValue);
var schemecontent = wfFlowInfoBLL.GetSchemeEntity(schemeinfo.Id, schemeinfo.SchemeVersion);
var JsonData = new
{
schemeinfo = schemeinfo,
schemecontent = schemecontent
};
return Content(JsonData.ToJson());
}
///
/// 获取工作流流程模板内容
///
///
///
///
[HttpGet]
public ActionResult GetSchemeContentJson(Guid keyValue, string SchemeVersion)
{
var schemecontent = wfFlowInfoBLL.GetSchemeEntity(keyValue, SchemeVersion);
return Content(schemecontent.ToJson());
}
#endregion
#region 提交数据
///
/// 删除表单模板
///
/// 主键值
///
[HttpPost]
public string RemoveForm(Guid[] ids)
{
wfFlowInfoBLL.RemoveForm(ids);
return Result.ToJson();
}
///
/// 保存用户表单(新增、修改)
///
/// 主键值
/// 用户实体
///
[HttpPost]
public string SaveForm(string keyValue, string InfoEntity, string ContentEntity, string shcemeAuthorizeData)
{
WFSchemeInfo entyity = InfoEntity.ToObject();
WFSchemeContent contententity = ContentEntity.ToObject();
wfFlowInfoBLL.SaveForm(keyValue, entyity, contententity);
return Result.ToJson();
}
///
/// (启用、禁用)
///
/// 主键值
/// 状态:1-启动;0-禁用
///
[HttpPost]
public ActionResult SubmitUpdateState(string keyValue, int State)
{
wfFlowInfoBLL.UpdateState(keyValue, State);
return Content("操作成功。");
}
public string Load(int pageCurrent = 1, int pageSize = 30)
{
return JsonHelper.Instance.Serialize(wfFlowInfoBLL.Load(pageCurrent, pageSize));
}
#endregion
#region 获取权限数据
///
/// 用户列表树
///
/// 返回树形Json
[HttpGet]
public ActionResult GetUserCheckTreeJson()
{
var data = userBLL.Load(Guid.Empty, 1, 10);
var treeList = new List();
string companyid = "";
string departmentid = "";
foreach (DataRow item in data.rows)
{
TreeEntity tree = new TreeEntity();
if (companyid != item["OrganizeId"].ToString())
{
TreeEntity tree1 = new TreeEntity();
companyid = item["OrganizeId"].ToString();
tree1.id = item["OrganizeId"].ToString();
tree1.text = item["OrganizeName"].ToString();
tree1.value = item["OrganizeId"].ToString();
tree1.isexpand = true;
tree1.complete = true;
tree1.hasChildren = true;
tree1.Attribute = "Sort";
tree1.AttributeValue = "Organize";
tree1.parentId = "0";
tree1.img = "fa fa-home";
treeList.Add(tree1);
}
if (departmentid != item["DepartmentId"].ToString() && !string.IsNullOrEmpty(item["DepartmentId"].ToString()))
{
TreeEntity tree1 = new TreeEntity();
departmentid = item["DepartmentId"].ToString();
tree1.id = item["DepartmentId"].ToString();
tree1.text = item["DepartmentName"].ToString();
tree1.value = item["DepartmentId"].ToString();
tree1.isexpand = false;
tree1.complete = true;
tree1.hasChildren = true;
tree1.Attribute = "Sort";
tree1.AttributeValue = "Department";
tree1.parentId = item["OrganizeId"].ToString();
tree1.img = "fa fa-umbrella";
treeList.Add(tree1);
}
tree.id = item["UserId"].ToString();
tree.text = item["RealName"].ToString();
tree.value = item["UserId"].ToString();
tree.isexpand = true;
tree.complete = true;
tree.hasChildren = false;
tree.parentId = string.IsNullOrEmpty(item["DepartmentId"].ToString()) ? item["OrganizeId"].ToString() : item["DepartmentId"].ToString();
tree.showcheck = true;
tree.img = "fa fa-user";
tree.Attribute = "mytype";
tree.AttributeValue = "User";
treeList.Add(tree);
}
return Content(treeList.TreeToJson());
}
#endregion
}
}