From 0c82f7b8c3445ec5aa872e4b9e359271b391674d Mon Sep 17 00:00:00 2001 From: yubaolee Date: Wed, 7 Sep 2016 11:11:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B5=81=E7=A8=8B=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E8=BD=AC=E6=8D=A2=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/ApplyTransitionHistoryApp.cs | 38 ++++++ OpenAuth.App/OpenAuth.App.csproj | 2 + OpenAuth.App/RoleManagerApp.cs | 9 ++ OpenAuth.App/UserManagerApp.cs | 4 + OpenAuth.App/WorkflowInboxApp.cs | 28 +++++ OpenAuth.Domain/ApplyTransitionHistory.cs | 63 ++++++++++ OpenAuth.Domain/OpenAuth.Domain.csproj | 2 + OpenAuth.Domain/WorkflowInbox.cs | 28 +++++ OpenAuth.Mvc/BllScripts/goodsApply.js | 13 +- OpenAuth.Mvc/BllScripts/processDetail.js | 4 +- .../Controllers/GoodsAppliesController.cs | 4 +- OpenAuth.Mvc/Models/WorkflowActionProvider.cs | 118 +++++++++++++++++- OpenAuth.Mvc/Models/WorkflowInit.cs | 46 ++++++- OpenAuth.Mvc/Models/WorkflowRuleProvider.cs | 10 +- OpenAuth.Mvc/Views/Designer/Index.cshtml | 12 +- OpenAuth.Mvc/Views/GoodsApplies/Detail.cshtml | 46 +++++-- .../Mapping/ApplyTransitionHistoryMap.cs | 62 +++++++++ .../Models/Mapping/WorkflowInboxMap.cs | 39 ++++++ .../Models/OpenAuthDBContext.cs | 7 +- .../OpenAuth.Repository.csproj | 2 + 20 files changed, 499 insertions(+), 38 deletions(-) create mode 100644 OpenAuth.App/ApplyTransitionHistoryApp.cs create mode 100644 OpenAuth.App/WorkflowInboxApp.cs create mode 100644 OpenAuth.Domain/ApplyTransitionHistory.cs create mode 100644 OpenAuth.Domain/WorkflowInbox.cs create mode 100644 OpenAuth.Repository/Models/Mapping/ApplyTransitionHistoryMap.cs create mode 100644 OpenAuth.Repository/Models/Mapping/WorkflowInboxMap.cs diff --git a/OpenAuth.App/ApplyTransitionHistoryApp.cs b/OpenAuth.App/ApplyTransitionHistoryApp.cs new file mode 100644 index 00000000..80bf4976 --- /dev/null +++ b/OpenAuth.App/ApplyTransitionHistoryApp.cs @@ -0,0 +1,38 @@ +using System; +using OpenAuth.Domain; +using OpenAuth.Domain.Interface; + +namespace OpenAuth.App +{ + public class ApplyTransitionHistoryApp + { + private IRepository _repository; + + public ApplyTransitionHistoryApp(IRepository repository) + { + _repository = repository; + } + + public ApplyTransitionHistory Get(Guid processId, string currentstate, string nextState) + { + return _repository.FindSingle(h => h.ApplyId == processId && !h.TransitionTime.HasValue && + h.InitialState == currentstate && h.DestinationState == nextState); + } + + public void Add(ApplyTransitionHistory historyItem) + { + _repository.Add(historyItem); + } + + public void Update(ApplyTransitionHistory historyItem) + { + _repository.Update(historyItem); + } + + public void DeleteByProcess(Guid processId) + { + _repository.Delete(dth => + dth.ApplyId == processId && !dth.TransitionTime.HasValue); + } + } +} \ No newline at end of file diff --git a/OpenAuth.App/OpenAuth.App.csproj b/OpenAuth.App/OpenAuth.App.csproj index 06d12ce7..c4551478 100644 --- a/OpenAuth.App/OpenAuth.App.csproj +++ b/OpenAuth.App/OpenAuth.App.csproj @@ -80,8 +80,10 @@ + + diff --git a/OpenAuth.App/RoleManagerApp.cs b/OpenAuth.App/RoleManagerApp.cs index c9cdda0f..f007e33b 100644 --- a/OpenAuth.App/RoleManagerApp.cs +++ b/OpenAuth.App/RoleManagerApp.cs @@ -147,5 +147,14 @@ namespace OpenAuth.App { _relevanceRepository.DeleteBy("UserRole", roleids.ToLookup(roleId => userId)); } + + public List GetUsersInRole(string ruleName) + { + var role = _repository.FindSingle(u => u.Name == ruleName); + if (role == null) return null; + + return _relevanceRepository.Find(u => u.Key == "UserRole" + && u.SecondId == role.Id).Select(u => u.FirstId).ToList(); + } } } \ No newline at end of file diff --git a/OpenAuth.App/UserManagerApp.cs b/OpenAuth.App/UserManagerApp.cs index 1eb1ebe0..0cc3244b 100644 --- a/OpenAuth.App/UserManagerApp.cs +++ b/OpenAuth.App/UserManagerApp.cs @@ -143,5 +143,9 @@ namespace OpenAuth.App _relevanceRepository.AddRelevance("UserOrg", orgIds.ToLookup(u => user.Id)); } + public IEnumerable GetUsers(IEnumerable userids) + { + return _repository.Find(u => userids.Contains(u.Id)); + } } } \ No newline at end of file diff --git a/OpenAuth.App/WorkflowInboxApp.cs b/OpenAuth.App/WorkflowInboxApp.cs new file mode 100644 index 00000000..62122576 --- /dev/null +++ b/OpenAuth.App/WorkflowInboxApp.cs @@ -0,0 +1,28 @@ +using System; +using OpenAuth.App.ViewModel; +using OpenAuth.Domain; +using OpenAuth.Domain.Interface; + +namespace OpenAuth.App +{ + public class WorkflowInboxApp + { + private IRepository _repository; + + public WorkflowInboxApp(IRepository repository) + { + _repository = repository; + } + + + public void DeleteAllByProcess(Guid processId) + { + _repository.Delete(u =>u.ProcessId == processId); + } + + public void Add(WorkflowInbox newInboxItem) + { + _repository.Add(newInboxItem); + } + } +} \ No newline at end of file diff --git a/OpenAuth.Domain/ApplyTransitionHistory.cs b/OpenAuth.Domain/ApplyTransitionHistory.cs new file mode 100644 index 00000000..fac480e7 --- /dev/null +++ b/OpenAuth.Domain/ApplyTransitionHistory.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// 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 +// +//------------------------------------------------------------------------------ + +using System; + +namespace OpenAuth.Domain +{ + /// + /// + /// + public partial class ApplyTransitionHistory :Entity + { + public ApplyTransitionHistory() + { + this.AllowedToUserNames= string.Empty; + this.TransitionTime= DateTime.Now; + this.InitialState= string.Empty; + this.DestinationState= string.Empty; + this.Command= string.Empty; + } + + /// + /// + /// + public System.Guid ApplyId { get; set; } + /// + /// + /// + public System.Guid? UserId { get; set; } + /// + /// + /// + public string AllowedToUserNames { get; set; } + /// + /// + /// + public System.DateTime? TransitionTime { get; set; } + /// + /// + /// + public long Order { get; set; } + /// + /// + /// + public string InitialState { get; set; } + /// + /// + /// + public string DestinationState { get; set; } + /// + /// + /// + public string Command { get; set; } + + } +} \ No newline at end of file diff --git a/OpenAuth.Domain/OpenAuth.Domain.csproj b/OpenAuth.Domain/OpenAuth.Domain.csproj index c56f7ca1..b336de46 100644 --- a/OpenAuth.Domain/OpenAuth.Domain.csproj +++ b/OpenAuth.Domain/OpenAuth.Domain.csproj @@ -42,6 +42,7 @@ + @@ -72,6 +73,7 @@ +