From 2bb6da86cf535ee6af9d1086329fb15c0ae5cf34 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Wed, 28 Sep 2016 17:21:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/DefaultParcedProcessCache.cs | 45 +++++++++++++++++++ OpenAuth.Mvc/Models/WorkflowInit.cs | 3 +- OpenAuth.Mvc/OpenAuth.Mvc.csproj | 1 + 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 OpenAuth.Mvc/Models/DefaultParcedProcessCache.cs diff --git a/OpenAuth.Mvc/Models/DefaultParcedProcessCache.cs b/OpenAuth.Mvc/Models/DefaultParcedProcessCache.cs new file mode 100644 index 00000000..4535ec1d --- /dev/null +++ b/OpenAuth.Mvc/Models/DefaultParcedProcessCache.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using OptimaJet.Workflow.Core.Cache; +using OptimaJet.Workflow.Core.Model; + +namespace OpenAuth.Mvc.Models +{ + /// + /// 流程定义的缓存 + /// 李玉宝新增于2016-09-28 17:15:45 + /// + public sealed class DefaultParcedProcessCache : IParsedProcessCache + { + private Dictionary _cache; + + public void Clear() + { + _cache.Clear(); + } + + public ProcessDefinition GetProcessDefinitionBySchemeId(Guid schemeId) + { + if (_cache == null) + return null; + if (_cache.ContainsKey(schemeId)) + return _cache[schemeId]; + return null; + } + + public void AddProcessDefinition(Guid schemeId, ProcessDefinition processDefinition) + { + if (_cache == null) + { + _cache = new Dictionary {{schemeId, processDefinition}}; + } + else + { + if (_cache.ContainsKey(schemeId)) + _cache[schemeId] = processDefinition; + else + _cache.Add(schemeId, processDefinition); + } + } + } +} diff --git a/OpenAuth.Mvc/Models/WorkflowInit.cs b/OpenAuth.Mvc/Models/WorkflowInit.cs index 819ad16c..0bdb73d7 100644 --- a/OpenAuth.Mvc/Models/WorkflowInit.cs +++ b/OpenAuth.Mvc/Models/WorkflowInit.cs @@ -31,7 +31,8 @@ namespace OpenAuth.Mvc.Models new MSSQLProvider(connectionString), new OptimaJet.Workflow.Core.Parser.XmlWorkflowParser(), new MSSQLProvider(connectionString) - ).WithDefaultCache(); + ); + builder.SetCache(new DefaultParcedProcessCache()); _runtime = new WorkflowRuntime(new Guid("{8D38DB8F-F3D5-4F26-A989-4FDD40F32D9D}")) .WithBuilder(builder) diff --git a/OpenAuth.Mvc/OpenAuth.Mvc.csproj b/OpenAuth.Mvc/OpenAuth.Mvc.csproj index bbd2f77f..21522c42 100644 --- a/OpenAuth.Mvc/OpenAuth.Mvc.csproj +++ b/OpenAuth.Mvc/OpenAuth.Mvc.csproj @@ -167,6 +167,7 @@ +