本文整理汇总了C#中WorkflowRuntime.AddService方法的典型用法代码示例。如果您正苦于以下问题:C# WorkflowRuntime.AddService方法的具体用法?C# WorkflowRuntime.AddService怎么用?C# WorkflowRuntime.AddService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkflowRuntime
的用法示例。
在下文中一共展示了WorkflowRuntime.AddService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
CreateRoles();
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
workflowRuntime.StartRuntime();
// Load the workflow type.
Type type = typeof(PurchaseOrderWorkflow);
ExternalDataExchangeService dataService = new ExternalDataExchangeService();
workflowRuntime.AddService(dataService);
poImpl = new StartPurchaseOrder();
dataService.AddService(poImpl);
workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
WorkflowInstance instance = workflowRuntime.CreateWorkflow(type);
workflowInstanceId = instance.InstanceId;
instance.Start();
SendPORequestMessage();
waitHandle.WaitOne();
workflowRuntime.StopRuntime();
}
}
示例2: Mainform
public Mainform()
{
InitializeComponent();
this.runtime = new WorkflowRuntime();
runtime.WorkflowCompleted += new EventHandler<WorkflowCompletedEventArgs>(runtime_WorkflowCompleted);
// Set up runtime to unload workflow instance from memory to file using FilePersistenceService
FilePersistenceService filePersistence = new FilePersistenceService(true);
runtime.AddService(filePersistence);
// Add document approval service
ExternalDataExchangeService dataService = new ExternalDataExchangeService();
runtime.AddService(dataService);
documentService = new DocumentApprovalService(this);
dataService.AddService(documentService);
// Search for workflows that have previously been persisted to file, and load into the listview control.
// These workflows will be reloaded by the runtime when events are raised against them.
LoadWorkflowData();
// Start the runtime
runtime.StartRuntime();
}
示例3: Main
static void Main()
{
string connectionString = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;";
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
ExternalDataExchangeService dataService = new ExternalDataExchangeService();
workflowRuntime.AddService(dataService);
dataService.AddService(expenseService);
workflowRuntime.AddService(new SqlWorkflowPersistenceService(connectionString));
workflowRuntime.StartRuntime();
workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
workflowRuntime.WorkflowIdled += OnWorkflowIdled;
workflowRuntime.WorkflowAborted += OnWorkflowAborted;
Type type = typeof(Microsoft.Samples.Workflow.CancelWorkflow.SampleWorkflow);
WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(type);
workflowInstance.Start();
waitHandle.WaitOne();
workflowRuntime.StopRuntime();
}
}
示例4: ThereCanBeOnlyOne
public void ThereCanBeOnlyOne () {
CustomPersistenceService cp1 = new CustomPersistenceService ();
CustomPersistenceService cp2 = new CustomPersistenceService ();
WorkflowRuntime wr = new WorkflowRuntime ();
wr.AddService (cp1);
wr.AddService (cp2);
}
示例5: Main
static void Main(string[] args)
{
Console.WriteLine("Starting CRySTAL...");
Console.WriteLine("Linking Workflow Runtime Services...");
CRySTAL.WorkflowInterface.WorkflowInterface.CustomerWF = new CRySTAL.WorkflowInterface.CustomerWorkflowInterface();
WorkflowRuntime workflowRuntime = new WorkflowRuntime();
AppDomain.CurrentDomain.SetData("WorkflowRuntime", workflowRuntime);
ManualWorkflowSchedulerService manualScheduler =
new ManualWorkflowSchedulerService(true);
AppDomain.CurrentDomain.SetData("ManualScheduler", manualScheduler);
workflowRuntime.AddService(manualScheduler);
ExternalDataExchangeService des = new ExternalDataExchangeService();
workflowRuntime.AddService(des);
des.AddService(CRySTAL.WorkflowInterface.WorkflowInterface.CustomerWF);
TimeSpan reloadIntevral = new TimeSpan(0, 0, 0, 20, 0);
TimeSpan ownershipDuration = new TimeSpan(0, 0, 30, 0);
string connectionString = @"Data Source=ETHIELE-LENOVO\SQLEXPRESS;Initial Catalog=WFTrackingAndPersistence;Integrated Security=True";
SqlWorkflowPersistenceService sqlPersistenceService =
new SqlWorkflowPersistenceService(connectionString, true, ownershipDuration, reloadIntevral);
workflowRuntime.AddService(sqlPersistenceService);
SqlTrackingService sts = new SqlTrackingService(connectionString);
workflowRuntime.AddService(sts);
Console.WriteLine("Starting Workflow Runtime...");
workflowRuntime.StartRuntime();
//AppDomain.CurrentDomain.SetData("firstNamestr", "thisisatest");
List<ServiceHost> hosts = new List<ServiceHost>();
hosts.Add(new ServiceHost(typeof(CRySTAL.CookService)));
hosts.Add(new ServiceHost(typeof(CRySTAL.BusBoyService)));
hosts.Add(new ServiceHost(typeof(CRySTAL.HostService)));
hosts.Add(new ServiceHost(typeof(CRySTAL.LoginService)));
hosts.Add(new ServiceHost(typeof(CRySTAL.MenuService)));
hosts.Add(new ServiceHost(typeof(CRySTAL.WaiterService)));
foreach (ServiceHost host in hosts)
{
host.Open();
Console.WriteLine("CRySTAL: Service Running: " + host.BaseAddresses[0].ToString());
}
Console.WriteLine("CRySTAL Ready");
Console.ReadLine();
Console.WriteLine("Shutting down CRySTAL...");
foreach (ServiceHost host in hosts)
{
host.Close();
Console.WriteLine("CRySTAL: Shutingdown Service :" + host.BaseAddresses[0].ToString());
}
Console.WriteLine("Shutting down runtime...");
workflowRuntime.StopRuntime();
Console.WriteLine("CRySTAL shutdown complete");
Console.ReadLine();
}
示例6: Main
static void Main()
{
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
try
{
// engine will unload workflow instance when it is idle
workflowRuntime.AddService(new FilePersistenceService(true));
workflowRuntime.WorkflowCreated += OnWorkflowCreated;
workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
workflowRuntime.WorkflowIdled += OnWorkflowIdle;
workflowRuntime.WorkflowUnloaded += OnWorkflowUnload;
workflowRuntime.WorkflowLoaded += OnWorkflowLoad;
workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
workflowRuntime.ServicesExceptionNotHandled += OnExceptionNotHandled;
workflowRuntime.CreateWorkflow(typeof(PersistenceServiceWorkflow)).Start();
waitHandle.WaitOne();
}
catch (Exception e)
{
Console.WriteLine("Exception \n\t Source: {0} \n\t Message: {1}", e.Source, e.Message);
}
finally
{
workflowRuntime.StopRuntime();
Console.WriteLine("Workflow runtime stopped, program exiting... \n");
}
}
}
示例7: MainForm
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
public MainForm()
{
InitializeComponent();
#region UI define
GenerateButtons();
GenerateAcctions();
#endregion
#region Bankomats Init
currentAccountCulture = CultureInfo.CurrentCulture;
#endregion
#region IniT Workflow
workflowRuntime = new WorkflowRuntime();
ExternalDataExchangeService des = new ExternalDataExchangeService();
workflowRuntime.AddService(des);
des.AddService(this);
workflowRuntime.StartRuntime();
workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
workflowRuntime.WorkflowTerminated += new EventHandler<WorkflowTerminatedEventArgs>(workflowRuntime_WorkflowTerminated);
Type type = typeof(BankomatWorkflowLibrary.BankomatsWorkflow);
workflowInstance = workflowRuntime.CreateWorkflow(type);
workflowInstance.Start();
#endregion
}
示例8: Main
static void Main()
{
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
// Create our local service and add it to the workflow runtime's list of services
ExternalDataExchangeService dataService = new ExternalDataExchangeService();
workflowRuntime.AddService(dataService);
VotingServiceImpl votingService = new VotingServiceImpl();
dataService.AddService(votingService);
// Start up the runtime and hook the creation and completion events
workflowRuntime.StartRuntime();
workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
workflowRuntime.WorkflowStarted += OnWorkflowStarted;
// Create the workflow's parameters collection
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("Alias", "Jim");
// Create and start the workflow
Type type = typeof(HostCommunication.VotingServiceWorkflow);
workflowRuntime.CreateWorkflow(type, parameters).Start();
waitHandle.WaitOne();
// Cleanly stop the runtime and all services
workflowRuntime.StopRuntime();
}
}
示例9: Main
static void Main()
{
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
try
{
const string connectString = "Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;";
workflowRuntime.AddService(new SqlWorkflowPersistenceService(connectString));
workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
workflowRuntime.WorkflowAborted += OnWorkflowAborted;
workflowRuntime.StartRuntime();
Type type = typeof(Compensation.PurchaseOrder);
workflowRuntime.CreateWorkflow(type).Start();
waitHandle.WaitOne();
}
catch (Exception ex)
{
if (ex.InnerException != null)
Console.WriteLine(ex.InnerException.Message);
else
Console.WriteLine(ex.Message);
}
finally
{
workflowRuntime.StopRuntime();
}
}
}
示例10: Main
static void Main()
{
orderService = new OrderServiceImpl();
// Start the workflow runtime engine.
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
ExternalDataExchangeService dataService = new ExternalDataExchangeService();
workflowRuntime.AddService(dataService);
dataService.AddService(orderService);
workflowRuntime.StartRuntime();
// Listen for the workflow events
workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
workflowRuntime.WorkflowIdled += OnWorkflowIdled;
// Start the workflow and wait for it to complete
Type type = typeof(PurchaseOrderWorkflow);
workflowRuntime.CreateWorkflow(type).Start();
waitHandle.WaitOne();
// Stop the workflow runtime engine.
workflowRuntime.StopRuntime();
}
}
示例11: Main
static void Main()
{
try
{
waitHandle = new AutoResetEvent(false);
CreateAndInsertTrackingProfile();
using (WorkflowRuntime runtime = new WorkflowRuntime())
{
SqlTrackingService trackingService = new SqlTrackingService(connectionString);
runtime.AddService(trackingService);
runtime.StartRuntime();
runtime.WorkflowCompleted += OnWorkflowCompleted;
runtime.WorkflowTerminated += OnWorkflowTerminated;
runtime.WorkflowAborted += OnWorkflowAborted;
WorkflowInstance instance = runtime.CreateWorkflow(typeof(BankMachineWorkflow));
instance.Start();
waitHandle.WaitOne();
runtime.StopRuntime();
OutputTrackedData(instance.InstanceId);
}
}
catch (Exception ex)
{
if (ex.InnerException != null)
Console.WriteLine(ex.InnerException.Message);
else
Console.WriteLine(ex.Message);
}
}
示例12: Main
static void Main()
{
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
try
{
// A workflow is always run asychronously; the main thread waits on this event so the program
// doesn't exit before the workflow completes
workflowRuntime.AddService(new SqlWorkflowPersistenceService("Initial Catalog=SqlPersistenceService;Data Source=localhost;Integrated Security=SSPI;"));
// Listen for the workflow events
workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
workflowRuntime.WorkflowAborted += OnWorkflowAborted;
// Create an instance of the workflow
Type type = typeof(NestedExceptionsWorkflow);
workflowRuntime.CreateWorkflow(type).Start();
Console.WriteLine("Workflow Started.\n");
// Wait for the event to be signaled
waitHandle.WaitOne();
}
catch (Exception ex)
{
Console.WriteLine("Source: {0}\nMessage: {1}", ex.Source, ex.Message);
}
finally
{
workflowRuntime.StopRuntime();
Console.WriteLine("\nWorkflow Complete.");
}
}
}
示例13: Main
static void Main(string[] args)
{
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
// Add ChannelManager
ChannelManagerService channelmgr = new ChannelManagerService();
workflowRuntime.AddService(channelmgr);
AutoResetEvent waitHandle = new AutoResetEvent(false);
workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) { Console.WriteLine("WorkflowCompleted: " + e.WorkflowInstance.InstanceId.ToString()); waitHandle.Set(); };
workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { Console.WriteLine("WorkflowTerminated: " + e.Exception.Message); waitHandle.Set(); };
while (true)
{
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(Microsoft.WorkflowServices.Samples.SequentialCalculatorClient));
Console.WriteLine("Start SequentialCalculatorClient.");
instance.Start();
waitHandle.WaitOne();
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Do another calculation? (Y)");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Press <enter> to exit.");
Console.ResetColor();
string input = Console.ReadLine();
if (input.Length == 0 || input[0] != 'Y')
break;
waitHandle.Reset();
}
}
}
示例14: Main
static void Main()
{
// Create WorkflowRuntime
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
// Add ConsoleTrackingService
workflowRuntime.AddService(new ConsoleTrackingService());
// Subscribe to Workflow Completed WorkflowRuntime Event
workflowRuntime.WorkflowCompleted += OnWorkflowCompleted;
// Subscribe to Workflow Terminated WorkflowRuntime Event
workflowRuntime.WorkflowTerminated += OnWorkflowTerminated;
// Start WorkflowRuntime
workflowRuntime.StartRuntime();
// Execute the SampleWorkflow Workflow
Console.WriteLine("Executing the workflow...");
workflowRuntime.CreateWorkflow(typeof(SimplePolicyWorkflow)).Start();
// Wait for the Workflow Completion
waitHandle.WaitOne();
// Stop Runtime
workflowRuntime.StopRuntime();
}
}
示例15: Main
static void Main()
{
try
{
waitHandle = new AutoResetEvent(false);
DataAccess.CreateAndInsertTrackingProfile();
using (WorkflowRuntime runtime = new WorkflowRuntime())
{
SqlTrackingService trackingService = new SqlTrackingService(DataAccess.connectionString);
/*
* Set partitioning settings on Sql Tracking Service and database
*/
//Turn on PartitionOnCompletion setting-- Default is false
trackingService.PartitionOnCompletion = true;
//Set partition interval-- Default is 'm' (monthly)
DataAccess.SetPartitionInterval('d');
runtime.AddService(trackingService);
runtime.StartRuntime();
runtime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
{
waitHandle.Set();
};
runtime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
{
Console.WriteLine(e.Exception.Message);
waitHandle.Set();
};
WorkflowInstance instance = runtime.CreateWorkflow(typeof(SimpleWorkflow));
instance.Start();
waitHandle.WaitOne();
runtime.StopRuntime();
DataAccess.GetWorkflowTrackingEvents(instance.InstanceId);
Console.WriteLine("\nDone running the workflow.");
/*
* Show tracking partition information and tables
*/
DataAccess.ShowTrackingPartitionInformation();
DataAccess.ShowPartitionTableInformation();
}
}
catch (Exception ex)
{
if (ex.InnerException != null)
Console.WriteLine(ex.InnerException.Message);
else
Console.WriteLine(ex.Message);
}
}