From 5996d6b5f794948f74c96a60defdb208a8be24b4 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Fri, 16 Sep 2016 18:05:57 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=8F=AF=E4=BB=A5=E9=80=89=E6=8B=A9=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/CommonApplyApp.cs | 3 ++- OpenAuth.App/ViewModel/CommonApplyVM.cs | 2 ++ OpenAuth.Domain/CommonApply.cs | 2 ++ OpenAuth.Mvc/BllScripts/commonApply.js | 17 +++++++++++++++++ OpenAuth.Mvc/BllScripts/processDetail.js | 3 ++- .../Controllers/CommonAppliesController.cs | 6 +++--- OpenAuth.Mvc/Views/CommonApplies/Detail.cshtml | 3 ++- OpenAuth.Mvc/Views/CommonApplies/Index.cshtml | 12 +++++++++--- .../Models/Mapping/CommonApplyMap.cs | 4 ++++ 9 files changed, 43 insertions(+), 9 deletions(-) diff --git a/OpenAuth.App/CommonApplyApp.cs b/OpenAuth.App/CommonApplyApp.cs index c28077f0..4b914241 100644 --- a/OpenAuth.App/CommonApplyApp.cs +++ b/OpenAuth.App/CommonApplyApp.cs @@ -31,7 +31,8 @@ namespace OpenAuth.App { UserId = model.UserId, Name = model.Name, - Comment = model.Comment + Comment = model.Comment, + WorkflowName = model.WorkflowName }); } diff --git a/OpenAuth.App/ViewModel/CommonApplyVM.cs b/OpenAuth.App/ViewModel/CommonApplyVM.cs index 965dc1fb..705fef37 100644 --- a/OpenAuth.App/ViewModel/CommonApplyVM.cs +++ b/OpenAuth.App/ViewModel/CommonApplyVM.cs @@ -52,6 +52,8 @@ namespace OpenAuth.App.ViewModel /// public System.Guid? ControllerUserId { get; set; } + public string WorkflowName { get; set; } + /// /// 可用命令 /// diff --git a/OpenAuth.Domain/CommonApply.cs b/OpenAuth.Domain/CommonApply.cs index ece75ae7..7b7e52c2 100644 --- a/OpenAuth.Domain/CommonApply.cs +++ b/OpenAuth.Domain/CommonApply.cs @@ -60,5 +60,7 @@ namespace OpenAuth.Domain /// public System.Guid? ControllerUserId { get; set; } + + public string WorkflowName { get; set; } } } \ No newline at end of file diff --git a/OpenAuth.Mvc/BllScripts/commonApply.js b/OpenAuth.Mvc/BllScripts/commonApply.js index 56e16402..72622952 100644 --- a/OpenAuth.Mvc/BllScripts/commonApply.js +++ b/OpenAuth.Mvc/BllScripts/commonApply.js @@ -72,11 +72,26 @@ function MainGrid() { MainGrid.prototype = new Grid(); var list = new MainGrid(); +var selectScheme = function(val) { + $("#WorkflowName").empty(); + $.getJSON('/workflowschemas/Load', + function (data) { + $.each(data.list, function (i, n) { + $("#WorkflowName").append(""); + }); + + if (val != undefined) { + $('#WorkflowName').val(val); + } + }); +} + //添加(编辑)对话框 var editDlg = function () { var show = function () { BJUI.dialog({ id: 'editDlg', title: '编辑对话框', target: '#editDlg' }); + $("#btnSave").on("click", function () { editDlg.save(); }); @@ -84,6 +99,7 @@ var editDlg = function () { return { add: function () { //弹出添加 show(); + selectScheme(); $.CurrentDialog.find("form")[0].reset(); //reset方法只能通过dom调用 $("#Id").val('00000000-0000-0000-0000-000000000000'); }, @@ -92,6 +108,7 @@ var editDlg = function () { $('#Id').val(ret.Id); $('#Name').val(ret.Name); $('#Comment').val(ret.Comment); + selectScheme(ret.WorkflowName); }, save: function () { //编辑-->保存 $('#editForm').isValid(function (v) { diff --git a/OpenAuth.Mvc/BllScripts/processDetail.js b/OpenAuth.Mvc/BllScripts/processDetail.js index ac8f285b..bb74e7c3 100644 --- a/OpenAuth.Mvc/BllScripts/processDetail.js +++ b/OpenAuth.Mvc/BllScripts/processDetail.js @@ -1,4 +1,4 @@ -var schemecode = 'SimpleWF'; + var wfdesigner = undefined; function wfdesignerRedraw() { @@ -9,6 +9,7 @@ function wfdesignerRedraw() { wfdesigner.destroy(); } var processid = $("#processId").val(); + var schemecode = $("#schemeCode").val(); wfdesigner = new WorkflowDesigner({ name: 'simpledesigner', diff --git a/OpenAuth.Mvc/Controllers/CommonAppliesController.cs b/OpenAuth.Mvc/Controllers/CommonAppliesController.cs index a5b544f1..216ba541 100644 --- a/OpenAuth.Mvc/Controllers/CommonAppliesController.cs +++ b/OpenAuth.Mvc/Controllers/CommonAppliesController.cs @@ -43,7 +43,7 @@ namespace OpenAuth.Mvc.Controllers { apply.UserId = AuthUtil.GetCurrentUser().User.Id; _app.AddOrUpdate(apply); - CreateWorkflowIfNotExists(apply.Id); + CreateWorkflowIfNotExists(apply.Id,apply.WorkflowName); } catch (Exception ex) @@ -110,14 +110,14 @@ namespace OpenAuth.Mvc.Controllers } - private void CreateWorkflowIfNotExists(Guid id) + private void CreateWorkflowIfNotExists(Guid id, string schemecode) { if (WorkflowInit.Runtime.IsProcessExists(id)) return; using (var sync = new WorkflowSync(WorkflowInit.Runtime, id)) { - WorkflowInit.Runtime.CreateInstance("SimpleWF", id); + WorkflowInit.Runtime.CreateInstance(schemecode, id); sync.StatrtWaitingFor(new List { ProcessStatus.Initialized, ProcessStatus.Initialized }); diff --git a/OpenAuth.Mvc/Views/CommonApplies/Detail.cshtml b/OpenAuth.Mvc/Views/CommonApplies/Detail.cshtml index 929aa764..207b3eb2 100644 --- a/OpenAuth.Mvc/Views/CommonApplies/Detail.cshtml +++ b/OpenAuth.Mvc/Views/CommonApplies/Detail.cshtml @@ -16,7 +16,8 @@
- + +

@Model.Name

diff --git a/OpenAuth.Mvc/Views/CommonApplies/Index.cshtml b/OpenAuth.Mvc/Views/CommonApplies/Index.cshtml index b04ed607..543c5612 100644 --- a/OpenAuth.Mvc/Views/CommonApplies/Index.cshtml +++ b/OpenAuth.Mvc/Views/CommonApplies/Index.cshtml @@ -29,11 +29,17 @@ + + + + + + - - - + + + diff --git a/OpenAuth.Repository/Models/Mapping/CommonApplyMap.cs b/OpenAuth.Repository/Models/Mapping/CommonApplyMap.cs index 65884027..b64f34ac 100644 --- a/OpenAuth.Repository/Models/Mapping/CommonApplyMap.cs +++ b/OpenAuth.Repository/Models/Mapping/CommonApplyMap.cs @@ -45,6 +45,10 @@ namespace OpenAuth.Repository.Models.Mapping .HasColumnName("State") .HasMaxLength(1024) .IsRequired(); + Property(t => t.WorkflowName) + .HasColumnName("WorkflowName") + .HasMaxLength(1024) + .IsRequired(); Property(t => t.StateName) .HasColumnName("StateName") .HasMaxLength(1024) From 5412c8b7bd7b63a9663420bc2c1b32ab431fdec0 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Fri, 16 Sep 2016 18:13:13 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E6=A8=A1=E6=9D=BF=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 建表&初始化数据.sql | Bin 184948 -> 185148 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/建表&初始化数据.sql b/建表&初始化数据.sql index 6173cf7ee6fad5dd67aa02a65dfd281fe6d8a3d8..63124a0244db0aeed15d3fe077ad083ca7a20076 100644 GIT binary patch delta 180 zcmeyegnQ32?hQTylNT_t@P{+xGZZmoGo&%(09oae?fH}^E2znB_7RW?megTTV2EZw zQ^MfKkhnQ9xs`GHgBy$-{J{*F47m&iK<%kOm2Q(KPSTw$ka`EV-pPr{@|#)G!XWwu d(DXA*wu^I{?2shWyeqwZS32YNUFl4_vH&9~GH3t* delta 62 zcmV-E0KxyfrVI3>3$RQOv!D Date: Mon, 19 Sep 2016 20:47:06 +0800 Subject: [PATCH 3/4] check issue #17 --- OpenAuth.Mvc/Views/Shared/_BjuiLayout.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenAuth.Mvc/Views/Shared/_BjuiLayout.cshtml b/OpenAuth.Mvc/Views/Shared/_BjuiLayout.cshtml index 15f0a23c..6cdc89de 100644 --- a/OpenAuth.Mvc/Views/Shared/_BjuiLayout.cshtml +++ b/OpenAuth.Mvc/Views/Shared/_BjuiLayout.cshtml @@ -70,7 +70,7 @@ loginInfo: { url: 'Login', title: '登录', width: 400, height: 200 }, // 会话超时后弹出登录对话框 statusCode: { ok: 200, error: 300, timeout: 301 }, //[可选] ajaxTimeout: 50000, //[可选]全局Ajax请求超时时间(毫秒) - pageInfo: { total: 'total', list:'rows', pageCurrent: 'page', pageSize: 'pageSize', orderField: 'orderField', orderDirection: 'orderDirection' }, //[可选]分页参数 + pageInfo: { total: 'total', list:'rows', pageCurrent: 'pageCurrent', pageSize: 'pageSize', orderField: 'orderField', orderDirection: 'orderDirection' }, //[可选]分页参数 alertMsg: { displayPosition: 'topcenter', displayMode: 'slide', alertTimeout: 3000 }, //[可选]信息提示的显示位置,显隐方式,及[info/correct]方式时自动关闭延时(毫秒) keys: { statusCode: 'statusCode', message: 'message' }, //[可选] ui: { From f001e83c33f8ec2410a99ed107a8ef3113d47655 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Thu, 22 Sep 2016 15:38:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.Mvc/AutofacExt.cs | 11 ++-- OpenAuth.Mvc/BllScripts/queryString.js | 10 +++- OpenAuth.Mvc/Views/Designer/Index.cshtml | 2 +- OpenAuth.UnitTest/App.config | 30 +++++++++- OpenAuth.UnitTest/AutofacExt.cs | 44 ++++++++++++++ OpenAuth.UnitTest/OpenAuth.UnitTest.csproj | 67 ++++++++++++++++++++-- OpenAuth.UnitTest/TestBase.cs | 10 ++++ OpenAuth.UnitTest/TestCommonApply.cs | 59 +++++++++++++++++++ OpenAuth.UnitTest/TestUser.cs | 53 +++++++++++++++++ OpenAuth.UnitTest/packages.config | 11 +++- 10 files changed, 284 insertions(+), 13 deletions(-) create mode 100644 OpenAuth.UnitTest/AutofacExt.cs create mode 100644 OpenAuth.UnitTest/TestBase.cs create mode 100644 OpenAuth.UnitTest/TestCommonApply.cs create mode 100644 OpenAuth.UnitTest/TestUser.cs diff --git a/OpenAuth.Mvc/AutofacExt.cs b/OpenAuth.Mvc/AutofacExt.cs index b3ab8cfd..5818281b 100644 --- a/OpenAuth.Mvc/AutofacExt.cs +++ b/OpenAuth.Mvc/AutofacExt.cs @@ -24,8 +24,10 @@ using OpenAuth.Repository; namespace OpenAuth.Mvc { - internal static class AutofacExt + public static class AutofacExt { + private static IContainer _container; + public static void InitAutofac() { var builder = new ContainerBuilder(); @@ -61,8 +63,8 @@ namespace OpenAuth.Mvc builder.RegisterFilterProvider(); // Set the dependency resolver to be Autofac. - var container = builder.Build(); - DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); + _container = builder.Build(); + DependencyResolver.SetResolver(new AutofacDependencyResolver(_container)); } /// @@ -71,7 +73,8 @@ namespace OpenAuth.Mvc /// public static T GetFromFac() { - return (T)DependencyResolver.Current.GetService(typeof(T)); + return _container.Resolve(); + // return (T)DependencyResolver.Current.GetService(typeof(T)); } } } \ No newline at end of file diff --git a/OpenAuth.Mvc/BllScripts/queryString.js b/OpenAuth.Mvc/BllScripts/queryString.js index 07626ae6..d9bf17e1 100644 --- a/OpenAuth.Mvc/BllScripts/queryString.js +++ b/OpenAuth.Mvc/BllScripts/queryString.js @@ -33,4 +33,12 @@ var QueryString = function () { } } return query_string; -}(); \ No newline at end of file +}(); + +(function ($) { + $.getUrlParam = function (name) { + var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); + var r = window.location.search.substr(1).match(reg); + if (r != null) return unescape(r[2]); return null; + } +})(jQuery); diff --git a/OpenAuth.Mvc/Views/Designer/Index.cshtml b/OpenAuth.Mvc/Views/Designer/Index.cshtml index c251b108..198fdcbe 100644 --- a/OpenAuth.Mvc/Views/Designer/Index.cshtml +++ b/OpenAuth.Mvc/Views/Designer/Index.cshtml @@ -31,7 +31,7 @@