This commit is contained in:
yubaolee
2016-12-21 15:03:37 +08:00
4 changed files with 156 additions and 109 deletions

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using OptimaJet.Workflow.Core.Cache;
using OptimaJet.Workflow.Core.Model;
namespace OpenAuth.Mvc.Models
{
/// <summary>
/// 流程定义的缓存
/// <para>李玉宝新增于2016-09-28 17:15:45</para>
/// </summary>
public sealed class DefaultParcedProcessCache : IParsedProcessCache
{
private Dictionary<Guid, ProcessDefinition> _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<Guid, ProcessDefinition> {{schemeId, processDefinition}};
}
else
{
if (_cache.ContainsKey(schemeId))
_cache[schemeId] = processDefinition;
else
_cache.Add(schemeId, processDefinition);
}
}
}
}

View File

@@ -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)