完成流程模板列表

This commit is contained in:
yubaolee 2016-09-14 16:11:46 +08:00
parent 0269a4f194
commit bf1121f24b
19 changed files with 497 additions and 60 deletions

View File

@ -113,6 +113,7 @@
<Compile Include="ViewModel\ModuleView.cs" />
<Compile Include="ViewModel\RoleVM.cs" />
<Compile Include="ViewModel\UserView.cs" />
<Compile Include="WorkflowSchemasManagerApp.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj">

View File

@ -0,0 +1,37 @@
using System.Linq;
using Infrastructure;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
namespace OpenAuth.App
{
/// <summary>
/// 工作流模板
/// </summary>
public class WorkflowSchemasManagerApp
{
private IWorkflowSchemeRepository _repository;
public WorkflowSchemasManagerApp(IWorkflowSchemeRepository repository)
{
_repository = repository;
}
public GridData Load(int pageCurrent, int pageSize)
{
var result = new GridData
{
pageCurrent = pageCurrent,
total = _repository.GetCount(),
list = _repository.Find(pageCurrent, pageSize, "Code", null).ToList()
};
return result;
}
public void Del(string code)
{
_repository.Delete(u =>u.Code == code);
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.Domain.Interface
{
public interface IWorkflowSchemeRepository : IRepository<WorkflowScheme>
{
}
}

View File

@ -49,6 +49,7 @@
<Compile Include="DicIndex.cs" />
<Compile Include="Entity.cs" />
<Compile Include="CommonApply.cs" />
<Compile Include="Interface\IWorkflowSchemeRepository.cs" />
<Compile Include="Interface\ICategoryRepository.cs" />
<Compile Include="Interface\IModuleRepository.cs" />
<Compile Include="Interface\IOrgRepository.cs" />
@ -73,6 +74,7 @@
<Compile Include="Service\StockManagerService.cs" />
<Compile Include="Stock.cs" />
<Compile Include="User.cs" />
<Compile Include="WorkflowScheme.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -0,0 +1,36 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// Author:Yubao Li
// </autogenerated>
//------------------------------------------------------------------------------
using System;
namespace OpenAuth.Domain
{
/// <summary>
///
/// </summary>
public partial class WorkflowScheme
{
public WorkflowScheme()
{
this.Code= string.Empty;
this.Scheme= string.Empty;
}
/// <summary>
///
/// </summary>
public string Code { get; set; }
/// <summary>
///
/// </summary>
public string Scheme { get; set; }
}
}

View File

@ -0,0 +1,78 @@
//grid列表模块
function MainGrid() {
var url = '/workflowschemas/Load';
this.maingrid = $('#maingrid').datagrid({
showToolbar: false,
filterThead: false,
loadType: 'GET',
target: $(this),
columns: [
{
name: 'Code',
label: '模板名称'
}
],
data:[],
fullGrid: true,
showLinenumber: true,
showCheckboxcol: true,
paging: true,
filterMult: false,
showTfoot: false,
});
this.reload = function (id) {
this.maingrid.datagrid('reload', { dataUrl: url });
};
};
MainGrid.prototype = new Grid();
var list = new MainGrid();
list.reload();
//删除
function del() {
var selected = list.getSelectedObj();
if (selected == null) return;
$.post('/StockManager/Delete?Id=' + selected.Id, function (data) {
if (data.statusCode == "200") {
list.reload();
ztree.reload();
}
else {
$(this).alertmsg('warn', data.message);
}
}, "json");
}
//自定义的编辑按钮
function edit() {
var selected = list.getSelectedObj();
if (selected == null) {
return;
}
window.location = '/designer/index?schemeName=' + selected.Code;
}
function add() {
window.location = '/designer/index?schemeName=';
}
//删除
function del() {
var selected = list.getSelectedObj();
if (selected == null) return;
$.post('/WorkflowSchemas/Del?code=' +selected.Code, function (data) {
if (data.statusCode == "200") {
list.reload();
}
else {
$(this).alertmsg('warn', data.message);
}
}, "json");
}
//@@ sourceURL=workflowSchemaManager.js

View File

@ -0,0 +1,45 @@
using System;
using System.Web.Mvc;
using Infrastructure;
using OpenAuth.App;
namespace OpenAuth.Mvc.Controllers
{
public class WorkflowSchemasController : BaseController
{
private WorkflowSchemasManagerApp _app;
public WorkflowSchemasController()
{
_app = AutofacExt.GetFromFac<WorkflowSchemasManagerApp>();
}
public ActionResult Index()
{
return View();
}
public string Load(int pageCurrent = 1, int pageSize = 30)
{
return JsonHelper.Instance.Serialize(_app.Load(pageCurrent, pageSize));
}
[HttpPost]
public string Del(string code)
{
try
{
_app.Del(code);
}
catch (Exception e)
{
BjuiResponse.statusCode = "300";
BjuiResponse.message = e.Message;
}
return JsonHelper.Instance.Serialize(BjuiResponse);
}
}
}

View File

@ -153,6 +153,7 @@
<Compile Include="AutofacExt.cs" />
<Compile Include="Controllers\BaseController.cs" />
<Compile Include="Controllers\CategoryManagerController.cs" />
<Compile Include="Controllers\WorkflowSchemasController.cs" />
<Compile Include="Controllers\DesignerController.cs" />
<Compile Include="Controllers\ErrorController.cs" />
<Compile Include="Controllers\CommonAppliesController.cs" />
@ -190,6 +191,7 @@
<Content Include="BllScripts\resourceManager.js" />
<Content Include="BllScripts\roleManager.js" />
<Content Include="BllScripts\commonApply.js" />
<Content Include="BllScripts\workflowSchemaManager.js" />
<Content Include="BllScripts\stockManager.js" />
<Content Include="BllScripts\usermanager.js" />
<Content Include="BllScripts\assignRes.js" />
@ -758,6 +760,7 @@
<Content Include="Views\StockManager\Index.cshtml" />
<Content Include="Views\Shared\_BjuiLayout.cshtml" />
<Content Include="Views\CommonApplies\Index.cshtml" />
<Content Include="Views\WorkflowSchemas\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />

View File

@ -11,26 +11,8 @@
<script src="/Scripts/workflowdesigner.min.js"></script>
<script src="/Scripts/ace.js"></script>
<script src="/Scripts/json5.js"></script>
<script src="/BllScripts/queryString.js"></script>
<form action="" id="uploadform" method="post" enctype="multipart/form-data" onsubmit="tmp()">
<table>
<tr>
<td></td>
<td>
<a href='javascript:DownloadScheme()'>下载流程模板</a>
</td>
</tr>
<tr>
<td>
<input type="file" name="uploadFile" id="uploadFile" style="width:350px">
</td>
<td>
<a href='javascript:UploadScheme()'>上传流程模板</a>
</td>
</tr>
</table>
</form>
<table>
<tr>
<td>大小:</td>
@ -39,16 +21,24 @@
<td>
|
</td>
<td><button onclick="OnNew()">新建</button></td>
<td><button onclick="OnSave()">保存</button></td>
<td><label class="msg-wrap">*模板名称</label></td>
<td><input value="" id="schemeName" /></td>
<td><button class="btn btn-primary" onclick="OnSave()">保存</button></td>
<td><button class="btn btn-red" onclick="javascript: window.history.go(-1)">返回</button></td>
</tr>
</table>
<br />
<div id="wfdesigner"></div>
<script>
var schemecode = 'SimpleWF';
var schemecode = QueryString["schemeName"];
var inputScheme = $("#schemeName");
var add = schemecode == "" ? true : false;
if (!add) {
inputScheme.val(schemecode);
inputScheme.attr("readonly", "readonly");
}
var wfdesigner = undefined;
function wfdesignerRedraw() {
@ -68,52 +58,37 @@
graphheight: $('#graphheight').val()
});
if (data == undefined) {
var isreadonly = false;
var p = { schemecode: schemecode, readonly: isreadonly };
if (wfdesigner.exists(p))
wfdesigner.load(p);
else
wfdesigner.create();
if (add) {
wfdesigner.create();
} else {
wfdesigner.data = data;
wfdesigner.render();
if (data == undefined) {
var isreadonly = false;
var p = { schemecode: schemecode, readonly: isreadonly };
if (wfdesigner.exists(p)) //如果已经存在
wfdesigner.load(p);
} else {
wfdesigner.data = data;
wfdesigner.render();
}
}
}
wfdesignerRedraw();
function DownloadScheme() {
wfdesigner.downloadscheme({ schemecode: schemecode });
}
function UploadScheme() {
var file = $('#uploadFile');
if (file == undefined || file.val().length == 0) {
alert('You did not select a file to upload!');
return false;
}
wfdesigner.uploadscheme($('#uploadform')[0],
function() {
alert('The file is uploaded!');
});
}
function OnSave() {
wfdesigner.schemecode = schemecode;
if (inputScheme.val().length == 0) {
alert("请输入模板名称");
return;
}
wfdesigner.schemecode = inputScheme.val();
var err = wfdesigner.validate();
if (err != undefined && err.length > 0) {
alert(err);
} else {
wfdesigner.save(function() {
alert('The scheme is saved!');
wfdesigner.save(function () {
alert('保存成功');
});
}
}
function OnNew() {
wfdesigner.create();
}
</script>

View File

@ -8,7 +8,7 @@
清空查询
</a></li>*@
<div class="pull-right">
@{
@if(ViewBag.Module != null){
var sb = new StringBuilder();
foreach (var element in ViewBag.Module.Elements)
{

View File

@ -0,0 +1,16 @@
@{
Layout = "~/Views/Shared/_BjuiLayout.cshtml";
}
@{ Html.RenderAction("MenuHeader", "Home");}
<div class="bjui-pageContent tableContent" style="position: relative">
<div class="clearfix">
<div id="detail">
<table id="maingrid" class="table table-bordered"></table>
</div>
</div>
</div>
<script src="~/BllScripts/grid.js"></script>
<script src="~/BllScripts/workflowSchemaManager.js"></script>

View File

@ -53,6 +53,8 @@
<component type=" OpenAuth.Repository.CategoryRepository" service="OpenAuth.Domain.Interface.ICategoryRepository,OpenAuth.Domain" />
<component type=" OpenAuth.Repository.ResourceRepository" service="OpenAuth.Domain.Interface.IResourceRepository,OpenAuth.Domain" />
<component type=" OpenAuth.Repository.StockRepository" service="OpenAuth.Domain.Interface.IStockRepository,OpenAuth.Domain" />
<component type=" OpenAuth.Repository.Workflow.WorkflowSchemeRepository"
service="OpenAuth.Domain.Interface.IWorkflowSchemeRepository,OpenAuth.Domain" />
</components>
</autofac>
@ -65,7 +67,6 @@
<add key="version" value="" />
<!--SSO单点登录主域-->
<!--<add key="SSOPassport" value="http://sso.com"/>-->
<!--<add key="SSOPassport" value="http://openauthapi.com" />-->
<add key="SSOPassport" value="http://localhost:52789" />
<!--AppKey唯一标识-->

View File

@ -10,6 +10,7 @@
using System.Data.Entity;
using OpenAuth.Domain;
using OpenAuth.Repository.Models.Mapping;
using OpenAuth.Repository.Workflow.Mapping;
namespace OpenAuth.Repository.Models
{
@ -42,6 +43,8 @@ namespace OpenAuth.Repository.Models
public DbSet<ApplyTransitionHistory> ApplyTransitionHistories { get; set; }
public System.Data.Entity.DbSet<WorkflowScheme> WorkflowSchemes { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new CategoryMap());
@ -57,6 +60,7 @@ namespace OpenAuth.Repository.Models
modelBuilder.Configurations.Add(new StockMap());
modelBuilder.Configurations.Add(new UserMap());
modelBuilder.Configurations.Add(new ApplyTransitionHistoryMap());
modelBuilder.Configurations.Add(new WorkflowSchemeMap());
}
}

View File

@ -57,6 +57,7 @@
<ItemGroup>
<Compile Include="Models\Mapping\ApplyTransitionHistoryMap.cs" />
<Compile Include="Models\Mapping\CommonApplyMap.cs" />
<Compile Include="Workflow\Mapping\WorkflowSchemeMap.cs" />
<Compile Include="UnitWork.cs" />
<Compile Include="BaseRepository.cs" />
<Compile Include="Models\Mapping\CategoryMap.cs" />
@ -80,6 +81,9 @@
<Compile Include="StockRepository.cs" />
<Compile Include="UserRepository.cs" />
<Compile Include="RelevanceRepository.cs" />
<Compile Include="Workflow\WorkflowSchemeRepository.cs" />
<Compile Include="Workflow\WorkflowBaseRepository.cs" />
<Compile Include="Workflow\WorkflowContext.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj">

View File

@ -0,0 +1,37 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
using OpenAuth.Domain;
namespace OpenAuth.Repository.Workflow.Mapping
{
public partial class WorkflowSchemeMap
: System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<WorkflowScheme>
{
public WorkflowSchemeMap()
{
// table
ToTable("WorkflowScheme", "dbo");
// keys
HasKey(t => t.Code);
// Properties
Property(t => t.Code)
.HasColumnName("Code")
.HasMaxLength(256)
.IsRequired();
Property(t => t.Scheme)
.HasColumnName("Scheme")
.IsRequired();
// Relationships
}
}
}

View File

@ -0,0 +1,134 @@
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Linq.Expressions;
using EntityFramework.Extensions;
using Infrastructure;
using OpenAuth.Domain.Interface;
namespace OpenAuth.Repository.Workflow
{
public class WorkflowBaseRepository<T> :IRepository<T> where T:class
{
protected WorkflowContext Context = new WorkflowContext();
/// <summary>
/// 根据过滤条件,获取记录
/// </summary>
/// <param name="exp">The exp.</param>
public IQueryable<T> Find(Expression<Func<T, bool>> exp = null)
{
return Filter(exp);
}
public bool IsExist(Expression<Func<T, bool>> exp)
{
return Context.Set<T>().Any(exp);
}
/// <summary>
/// 查找单个
/// </summary>
public T FindSingle(Expression<Func<T, bool>> exp)
{
return Context.Set<T>().AsNoTracking().FirstOrDefault(exp);
}
/// <summary>
/// 得到分页记录
/// </summary>
/// <param name="pageindex">The pageindex.</param>
/// <param name="pagesize">The pagesize.</param>
/// <param name="orderby">排序,格式如:"Id"/"Id descending"</param>
public IQueryable<T> Find(int pageindex, int pagesize, string orderby = "", Expression<Func<T, bool>> exp = null)
{
if (pageindex < 1) pageindex = 1;
if (string.IsNullOrEmpty(orderby))
orderby = "Id descending";
return Filter(exp).OrderBy(orderby).Skip(pagesize * (pageindex - 1)).Take(pagesize);
}
/// <summary>
/// 根据过滤条件获取记录数
/// </summary>
public int GetCount(Expression<Func<T, bool>> exp = null)
{
return Filter(exp).Count();
}
public void Add(T entity)
{
Context.Set<T>().Add(entity);
Save();
}
/// <summary>
/// 批量添加
/// </summary>
/// <param name="entities">The entities.</param>
public void BatchAdd(T[] entities)
{
Context.Set<T>().AddRange(entities);
Save();
}
public void Update(T entity)
{
var entry = this.Context.Entry(entity);
//todo:如果状态没有任何更改,会报错
entry.State = EntityState.Modified;
Save();
}
public void Delete(T entity)
{
Context.Set<T>().Remove(entity);
Save();
}
/// <summary>
/// 按指定id更新实体,会更新整个实体
/// </summary>
/// <param name="identityExp">The identity exp.</param>
/// <param name="entity">The entity.</param>
public void Update(Expression<Func<T, object>> identityExp, T entity)
{
Context.Set<T>().AddOrUpdate(identityExp, entity);
Save();
}
/// <summary>
/// 实现按需要只更新部分更新
/// <para>如Update(u =>u.Id==1,u =>new User{Name="ok"});</para>
/// </summary>
/// <param name="where">The where.</param>
/// <param name="entity">The entity.</param>
public void Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> entity)
{
Context.Set<T>().Where(where).Update(entity);
}
public virtual void Delete(Expression<Func<T, bool>> exp)
{
Context.Set<T>().Where(exp).Delete();
}
public void Save()
{
Context.SaveChanges();
}
private IQueryable<T> Filter(Expression<Func<T, bool>> exp)
{
var dbSet = Context.Set<T>().AsQueryable();
if (exp != null)
dbSet = dbSet.Where(exp);
return dbSet;
}
}
}

View File

@ -0,0 +1,41 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a CodeSmith Template.
//
// DO NOT MODIFY contents of this file. Changes to this
// file will be lost if the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
using System.Data.Entity;
using OpenAuth.Domain;
using OpenAuth.Repository.Models;
using OpenAuth.Repository.Models.Mapping;
using OpenAuth.Repository.Workflow.Mapping;
namespace OpenAuth.Repository.Workflow
{
public partial class WorkflowContext: DbContext
{
static WorkflowContext()
{
Database.SetInitializer< OpenAuthDBContext>(null);
}
public WorkflowContext()
:base("Name=WorkFlow")
{ }
public WorkflowContext(string nameOrConnectionString)
: base(nameOrConnectionString)
{ }
public System.Data.Entity.DbSet<WorkflowScheme> WorkflowSchemes { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Configurations.Add(new WorkflowSchemeMap());
}
}
}

View File

@ -0,0 +1,11 @@
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
namespace OpenAuth.Repository.Workflow
{
public class WorkflowSchemeRepository:WorkflowBaseRepository<WorkflowScheme>,IWorkflowSchemeRepository
{
}
}

View File

@ -32,7 +32,7 @@
{
<h2>可访问的机构</h2>
<ul>
@foreach (var org in ViewBag.CurrentUser.AccessedOrgs)
@foreach (var org in ViewBag.CurrentUser.Orgs)
{
<li>@org.Name</li>
}