diff --git a/Infrastructure/ObjectHelper.cs b/Infrastructure/ObjectHelper.cs index ce708af6..cb7f304f 100644 --- a/Infrastructure/ObjectHelper.cs +++ b/Infrastructure/ObjectHelper.cs @@ -25,6 +25,12 @@ namespace Infrastructure { public static class ObjectHelper { + public static T CopyTo(this object source) where T:class, new() + { + var result = new T(); + source.CopyTo(result); + return result; + } public static void CopyTo(this object source, T target) where T : class,new() diff --git a/OpenAuth.App/CommonApplyApp.cs b/OpenAuth.App/CommonApplyApp.cs new file mode 100644 index 00000000..d72ea88b --- /dev/null +++ b/OpenAuth.App/CommonApplyApp.cs @@ -0,0 +1,104 @@ +using System; +using System.Linq; +using Infrastructure; +using OpenAuth.App.ViewModel; +using OpenAuth.Domain; +using OpenAuth.Domain.Interface; + +namespace OpenAuth.App +{ + public class CommonApplyApp + { + private IRepository _repository; + private IUnitWork _unitWork; + + public CommonApplyApp(IRepository repository, IUnitWork unitWork) + { + _repository = repository; + _unitWork = unitWork; + } + + public void AddOrUpdate(CommonApply model) + { + if (model.Id == Guid.Empty) + { + var obj = model.CopyTo(); + _repository.Add(obj); + } + else + { + _repository.Update(u => u.Id == model.Id, u => new CommonApply + { + UserId = model.UserId, + Name = model.Name, + }); + } + + } + + /// + /// 更改流程状态 + /// + public void ChangeState(Guid id,string state, string statename) + { + _repository.Update(u =>u.Id == id, u =>new CommonApply + { + State = state, + StateName = statename + }); + } + + public CommonApply Get(Guid value) + { + return _repository.FindSingle(u =>u.Id == value); + } + + /// + /// 加载流程处理 + /// + /// 用户ID + /// inbox:待办事项/outbox:已办事项 + public GridData Load(Guid userid, string type, int pageCurrent, int pageSize) + { + var result = new GridData + { + pageCurrent = pageCurrent + }; + + if (type == "inbox") //待办事项 + { + var inboxes = GetInboxProcessIds(userid); + result.total = _unitWork.Find(u => inboxes.Contains(u.Id)).Count(); + result.list = _unitWork.Find(pageCurrent, pageSize, "Sort descending",u => inboxes.Contains(u.Id)).ToList(); + } + else if (type == "outbox") //已办事项 + { + IQueryable outboxes = GetOutboxProcessIds(userid); + result.total = _unitWork.Find(u => outboxes.Contains(u.Id)).Count(); + result.list = _unitWork.Find(pageCurrent, pageSize, "Sort descending", u => outboxes.Contains(u.Id)).ToList(); + } + else //我的流程 + { + result.total = _unitWork.Find(u => u.UserId == userid).Count(); + result.list = _unitWork.Find(pageCurrent, pageSize, "Sort descending", u => u.UserId == userid).ToList(); + } + + return result; + } + + private IQueryable GetOutboxProcessIds(Guid userid) + { + return _unitWork.Find(u => u.UserId == userid).Select(u => u.ApplyId); + } + + private IQueryable GetInboxProcessIds(Guid userid) + { + return _unitWork.Find(u =>u.Key =="ProcessUser" &&(userid == Guid.Empty || u.SecondId == userid)).Select(u =>u.FirstId); + } + + public void Del(Guid id) + { + _repository.Delete(u =>u.Id == id); + } + } +} \ No newline at end of file diff --git a/OpenAuth.App/GoodsApplyApp.cs b/OpenAuth.App/GoodsApplyApp.cs deleted file mode 100644 index 2de70c1a..00000000 --- a/OpenAuth.App/GoodsApplyApp.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using OpenAuth.App.ViewModel; -using OpenAuth.Domain; -using OpenAuth.Domain.Interface; - -namespace OpenAuth.App -{ - public class GoodsApplyApp - { - private IRepository _repository; - - public GoodsApplyApp(IRepository repository) - { - _repository = repository; - } - - public void AddOrUpdate(GoodsApply model) - { - if (model.Id == Guid.Empty) - { - _repository.Add(model); - } - else - { - _repository.Update(u => u.Id == model.Id, u => new GoodsApply - { - UserId = model.UserId, - Name = model.Name, - Number = model.Number - }); - } - - } - - /// - /// 更改流程状态 - /// - public void ChangeState(Guid id,string state, string statename) - { - _repository.Update(u =>u.Id == id, u =>new GoodsApply - { - State = state, - StateName = statename - }); - } - - public GoodsApply Get(Guid value) - { - return _repository.FindSingle(u =>u.Id == value); - } - - public GridData Load(Guid userid, Guid parentId, int pageCurrent, int pageSize) - { - var result = new GridData - { - pageCurrent = pageCurrent - }; - - result.list= _repository.Find( pageCurrent, pageSize); - result.total = _repository.GetCount(null); - - return result; - } - - public void Del(Guid id) - { - _repository.Delete(u =>u.Id == id); - } - } -} \ No newline at end of file diff --git a/OpenAuth.App/OpenAuth.App.csproj b/OpenAuth.App/OpenAuth.App.csproj index c4551478..823ca174 100644 --- a/OpenAuth.App/OpenAuth.App.csproj +++ b/OpenAuth.App/OpenAuth.App.csproj @@ -100,13 +100,13 @@ - + - + diff --git a/OpenAuth.App/ViewModel/GoodsApplyVM.cs b/OpenAuth.App/ViewModel/CommonApplyVM.cs similarity index 85% rename from OpenAuth.App/ViewModel/GoodsApplyVM.cs rename to OpenAuth.App/ViewModel/CommonApplyVM.cs index c9ee8b55..965dc1fb 100644 --- a/OpenAuth.App/ViewModel/GoodsApplyVM.cs +++ b/OpenAuth.App/ViewModel/CommonApplyVM.cs @@ -17,7 +17,7 @@ namespace OpenAuth.App.ViewModel /// /// /// - public class GoodsApplyVM :Entity + public class CommonApplyVM :Entity { /// /// @@ -59,14 +59,14 @@ namespace OpenAuth.App.ViewModel public Dictionary AvailiableStates { get; set; } - public static implicit operator GoodsApplyVM(GoodsApply obj) + public static implicit operator CommonApplyVM(CommonApply obj) { - return obj.MapTo(); + return obj.MapTo(); } - public static implicit operator GoodsApply(GoodsApplyVM obj) + public static implicit operator CommonApply(CommonApplyVM obj) { - return obj.MapTo(); + return obj.MapTo(); } } diff --git a/OpenAuth.App/WorkflowInboxApp.cs b/OpenAuth.App/WorkflowInboxApp.cs index 62122576..37025a3a 100644 --- a/OpenAuth.App/WorkflowInboxApp.cs +++ b/OpenAuth.App/WorkflowInboxApp.cs @@ -7,9 +7,9 @@ namespace OpenAuth.App { public class WorkflowInboxApp { - private IRepository _repository; + private IRepository _repository; - public WorkflowInboxApp(IRepository repository) + public WorkflowInboxApp(IRepository repository) { _repository = repository; } @@ -17,10 +17,10 @@ namespace OpenAuth.App public void DeleteAllByProcess(Guid processId) { - _repository.Delete(u =>u.ProcessId == processId); + _repository.Delete(u =>u.FirstId == processId && u.Key=="ProcessUser"); } - public void Add(WorkflowInbox newInboxItem) + public void Add(Relevance newInboxItem) { _repository.Add(newInboxItem); } diff --git a/OpenAuth.Domain/ApplyTransitionHistory.cs b/OpenAuth.Domain/ApplyTransitionHistory.cs index fac480e7..b258c9b0 100644 --- a/OpenAuth.Domain/ApplyTransitionHistory.cs +++ b/OpenAuth.Domain/ApplyTransitionHistory.cs @@ -20,7 +20,6 @@ namespace OpenAuth.Domain public ApplyTransitionHistory() { this.AllowedToUserNames= string.Empty; - this.TransitionTime= DateTime.Now; this.InitialState= string.Empty; this.DestinationState= string.Empty; this.Command= string.Empty; diff --git a/OpenAuth.Domain/GoodsApply.cs b/OpenAuth.Domain/CommonApply.cs similarity index 87% rename from OpenAuth.Domain/GoodsApply.cs rename to OpenAuth.Domain/CommonApply.cs index 0b9c5da7..ece75ae7 100644 --- a/OpenAuth.Domain/GoodsApply.cs +++ b/OpenAuth.Domain/CommonApply.cs @@ -13,18 +13,18 @@ using System; namespace OpenAuth.Domain { /// - /// + /// 同意申请单 /// - public partial class GoodsApply : Entity + public partial class CommonApply : Entity { - public GoodsApply() + public CommonApply() { - this.Sort= 0; - this.Number= 0; + this.Sort= 0; this.Name= string.Empty; this.Comment= string.Empty; this.State= string.Empty; this.StateName= string.Empty; + this.ApplyTime = DateTime.Now; } /// @@ -34,7 +34,7 @@ namespace OpenAuth.Domain /// /// /// - public int Number { get; set; } + public DateTime ApplyTime { get; set; } /// /// /// diff --git a/OpenAuth.Domain/OpenAuth.Domain.csproj b/OpenAuth.Domain/OpenAuth.Domain.csproj index b336de46..4cfdf300 100644 --- a/OpenAuth.Domain/OpenAuth.Domain.csproj +++ b/OpenAuth.Domain/OpenAuth.Domain.csproj @@ -48,7 +48,7 @@ - + @@ -73,7 +73,6 @@ - 保存 $('#editForm').isValid(function (v) { @@ -123,7 +103,6 @@ var editDlg = function () { return; } list.reload(); - ztree.reload(); } }); }); @@ -136,7 +115,7 @@ function del() { var selected = list.getSelectedObj(); if (selected == null) return; - $.getJSON('/GoodsApplies/Delete?Id=' + selected.Id, function (data) { + $.getJSON('/CommonApplies/Delete?Id=' + selected.Id, function (data) { if (data.statusCode == "200") { list.reload(); } @@ -163,10 +142,10 @@ function detail() { } BJUI.dialog({ id: 'detailDlg', - url: '/GoodsApplies/Detail?id=' + selected.Id, + url: '/CommonApplies/Detail?id=' + selected.Id, title: '进度详情', width: 900, - height: 700, + height: 600, mask:true }); $(document).on('bjui.beforeCloseDialog',function(e) { diff --git a/OpenAuth.Mvc/BllScripts/processDetail.js b/OpenAuth.Mvc/BllScripts/processDetail.js index 948c2a98..3838492c 100644 --- a/OpenAuth.Mvc/BllScripts/processDetail.js +++ b/OpenAuth.Mvc/BllScripts/processDetail.js @@ -15,8 +15,8 @@ function wfdesignerRedraw() { apiurl: '/Designer/API', renderTo: 'wfdesigner', imagefolder: '/images/', - graphwidth: 800, - graphheight: 500 + graphwidth: 850, + graphheight: 450 }); if (data == undefined) { @@ -36,7 +36,7 @@ wfdesignerRedraw(); $(function () { $(".btn-cmd") .on("click", function () { //执行命令 - $.post("/GoodsApplies/ExeCmd?id=" +$("#processId").val() +"&cmd=" +$(this).val() , + $.post("/CommonApplies/ExeCmd?id=" +$("#processId").val() +"&cmd=" +$(this).val() , function (data) { BJUI.dialog('refresh', 'detailDlg'); }); diff --git a/OpenAuth.Mvc/Controllers/GoodsAppliesController.cs b/OpenAuth.Mvc/Controllers/CommonAppliesController.cs similarity index 90% rename from OpenAuth.Mvc/Controllers/GoodsAppliesController.cs rename to OpenAuth.Mvc/Controllers/CommonAppliesController.cs index 7df8434b..711a146d 100644 --- a/OpenAuth.Mvc/Controllers/GoodsAppliesController.cs +++ b/OpenAuth.Mvc/Controllers/CommonAppliesController.cs @@ -13,13 +13,13 @@ using ProcessStatus = OptimaJet.Workflow.Core.Persistence.ProcessStatus; namespace OpenAuth.Mvc.Controllers { - public class GoodsAppliesController : BaseController + public class CommonAppliesController : BaseController { - private GoodsApplyApp _app; + private CommonApplyApp _app; - public GoodsAppliesController() + public CommonAppliesController() { - _app = AutofacExt.GetFromFac(); + _app = AutofacExt.GetFromFac(); } public ActionResult Index() @@ -27,13 +27,13 @@ namespace OpenAuth.Mvc.Controllers return View(); } - public string Load(Guid parentId, int pageCurrent = 1, int pageSize = 30) + public string Load(string type, int pageCurrent = 1, int pageSize = 30) { - return JsonHelper.Instance.Serialize(_app.Load(AuthUtil.GetCurrentUser().User.Id, parentId, pageCurrent, pageSize)); + return JsonHelper.Instance.Serialize(_app.Load(AuthUtil.GetCurrentUser().User.Id, type, pageCurrent, pageSize)); } [HttpPost] - public string Edit(GoodsApply apply) + public string Edit(CommonApply apply) { try { @@ -54,7 +54,7 @@ namespace OpenAuth.Mvc.Controllers { try { - GoodsApplyVM apply = _app.Get(id); + CommonApplyVM apply = _app.Get(id); apply.Commands = GetCommands(id); return View(apply); } @@ -146,7 +146,7 @@ namespace OpenAuth.Mvc.Controllers /// 流程实例ID /// 命令名称 /// 申请实体 - private void ExecuteCommand(Guid id, string commandName, GoodsApply goodsApply) + private void ExecuteCommand(Guid id, string commandName, CommonApply goodsApply) { var currentUser =AuthUtil.GetCurrentUser().User.Id.ToString(); diff --git a/OpenAuth.Mvc/Models/WorkflowInit.cs b/OpenAuth.Mvc/Models/WorkflowInit.cs index 92b837d6..819ad16c 100644 --- a/OpenAuth.Mvc/Models/WorkflowInit.cs +++ b/OpenAuth.Mvc/Models/WorkflowInit.cs @@ -77,7 +77,7 @@ namespace OpenAuth.Mvc.Models { var nextState = WorkflowInit.Runtime.GetLocalizedStateName(e.ProcessId, e.ProcessInstance.CurrentState); - var _app = AutofacExt.GetFromFac(); + var _app = AutofacExt.GetFromFac(); _app.ChangeState(e.ProcessId, e.ProcessInstance.CurrentState, nextState); } @@ -94,11 +94,12 @@ namespace OpenAuth.Mvc.Models var newActors = Runtime.GetAllActorsForDirectCommandTransitions(e.ProcessId); foreach (var newActor in newActors) { - var newInboxItem = new WorkflowInbox() + var newInboxItem = new Relevance() { Id = Guid.NewGuid(), - IdentityId = new Guid(newActor), - ProcessId = e.ProcessId + SecondId = new Guid(newActor), + FirstId = e.ProcessId, + Key = "ProcessUser" }; inboxApp.Add(newInboxItem); diff --git a/OpenAuth.Mvc/Models/WorkflowRuleProvider.cs b/OpenAuth.Mvc/Models/WorkflowRuleProvider.cs index 6df62d30..38d5d9d5 100644 --- a/OpenAuth.Mvc/Models/WorkflowRuleProvider.cs +++ b/OpenAuth.Mvc/Models/WorkflowRuleProvider.cs @@ -8,7 +8,7 @@ using OptimaJet.Workflow.Core.Runtime; namespace OpenAuth.Mvc.Models { /// - /// 判断角色 + /// 流程角色处理 /// public class WorkflowRuleProvider : IWorkflowRuleProvider { @@ -59,13 +59,7 @@ namespace OpenAuth.Mvc.Models { var userids = _app.GetUsersInRole(ruleName); if (userids == null) return null; - var userstrs = new List(); - foreach (var userid in userids) - { - userstrs.Add(userid.ToString()); - } - - return userstrs; + return userids.Select(u => u.ToString()); } } } \ No newline at end of file diff --git a/OpenAuth.Mvc/OpenAuth.Mvc.csproj b/OpenAuth.Mvc/OpenAuth.Mvc.csproj index 83a46b67..a451910e 100644 --- a/OpenAuth.Mvc/OpenAuth.Mvc.csproj +++ b/OpenAuth.Mvc/OpenAuth.Mvc.csproj @@ -155,7 +155,7 @@ - + @@ -189,7 +189,7 @@ - + @@ -736,7 +736,7 @@ - + @@ -757,7 +757,7 @@ - + diff --git a/OpenAuth.Mvc/Views/GoodsApplies/Detail.cshtml b/OpenAuth.Mvc/Views/CommonApplies/Detail.cshtml similarity index 87% rename from OpenAuth.Mvc/Views/GoodsApplies/Detail.cshtml rename to OpenAuth.Mvc/Views/CommonApplies/Detail.cshtml index 3b76891a..929aa764 100644 --- a/OpenAuth.Mvc/Views/GoodsApplies/Detail.cshtml +++ b/OpenAuth.Mvc/Views/CommonApplies/Detail.cshtml @@ -2,7 +2,7 @@ Layout = null; } @using OptimaJet.Workflow.Core.Model -@model OpenAuth.App.ViewModel.GoodsApplyVM +@model OpenAuth.App.ViewModel.CommonApplyVM @@ -25,7 +25,7 @@ @if (Model.Commands.Length > 0) {
- 你可以执行: + 下图蓝色为当前状态,你可以执行: @foreach (var cmd in Model.Commands) { if (cmd.Classifier == TransitionClassifier.Reverse) @@ -39,9 +39,7 @@ }
} -
-
-
+
diff --git a/OpenAuth.Mvc/Views/GoodsApplies/Index.cshtml b/OpenAuth.Mvc/Views/CommonApplies/Index.cshtml similarity index 80% rename from OpenAuth.Mvc/Views/GoodsApplies/Index.cshtml rename to OpenAuth.Mvc/Views/CommonApplies/Index.cshtml index 8498aabd..1c8128bd 100644 --- a/OpenAuth.Mvc/Views/GoodsApplies/Index.cshtml +++ b/OpenAuth.Mvc/Views/CommonApplies/Index.cshtml @@ -18,21 +18,21 @@