mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 02:29:24 +08:00
workflowengine.net 结构调整
This commit is contained in:
91
OpenAuth.Mvc/Controllers/DesignerController.cs
Normal file
91
OpenAuth.Mvc/Controllers/DesignerController.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using OptimaJet.Workflow;
|
||||
using OptimaJet.Workflow.Core.Builder;
|
||||
using OptimaJet.Workflow.Core.Bus;
|
||||
using OptimaJet.Workflow.Core.Runtime;
|
||||
using OptimaJet.Workflow.Core.Parser;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Mvc;
|
||||
using System.Xml.Linq;
|
||||
using WorkflowRuntime = OptimaJet.Workflow.Core.Runtime.WorkflowRuntime;
|
||||
|
||||
namespace WF.Sample.Controllers
|
||||
{
|
||||
public class DesignerController : Controller
|
||||
{
|
||||
public ActionResult Index(string schemeName)
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult API()
|
||||
{
|
||||
Stream filestream = null;
|
||||
if (Request.Files.Count > 0)
|
||||
filestream = Request.Files[0].InputStream;
|
||||
|
||||
var pars = new NameValueCollection();
|
||||
pars.Add(Request.Params);
|
||||
|
||||
if(Request.HttpMethod.Equals("POST", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
var parsKeys = pars.AllKeys;
|
||||
foreach (var key in Request.Form.AllKeys)
|
||||
{
|
||||
if (!parsKeys.Contains(key))
|
||||
{
|
||||
pars.Add(Request.Form);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var res = getRuntime.DesignerAPI(pars, filestream, true);
|
||||
if (pars["operation"].ToLower() == "downloadscheme")
|
||||
return File(Encoding.UTF8.GetBytes(res), "text/xml", "scheme.xml");
|
||||
return Content(res);
|
||||
}
|
||||
|
||||
private static volatile WorkflowRuntime _runtime;
|
||||
private static readonly object _sync = new object();
|
||||
|
||||
private WorkflowRuntime getRuntime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_runtime == null)
|
||||
{
|
||||
lock (_sync)
|
||||
{
|
||||
if (_runtime == null)
|
||||
{
|
||||
var connectionString = ConfigurationManager.ConnectionStrings["WorkFlow"].ConnectionString;
|
||||
var builder = new WorkflowBuilder<XElement>(
|
||||
new OptimaJet.Workflow.DbPersistence.DbXmlWorkflowGenerator(connectionString),
|
||||
new OptimaJet.Workflow.Core.Parser.XmlWorkflowParser(),
|
||||
new OptimaJet.Workflow.DbPersistence.DbSchemePersistenceProvider(connectionString)
|
||||
).WithDefaultCache();
|
||||
|
||||
_runtime = new WorkflowRuntime(new Guid("{8D38DB8F-F3D5-4F26-A989-4FDD40F32D9D}"))
|
||||
.WithBuilder(builder)
|
||||
.WithPersistenceProvider(new OptimaJet.Workflow.DbPersistence.DbPersistenceProvider(connectionString))
|
||||
.WithTimerManager(new TimerManager())
|
||||
.WithBus(new NullBus())
|
||||
.SwitchAutoUpdateSchemeBeforeGetAvailableCommandsOn()
|
||||
.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _runtime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user