Click here to Skip to main content
15,892,005 members
Articles / Programming Languages / C#

The Application Automation Layer - Using XML to generate Menus

Rate me:
Please Sign up or sign in to vote.
4.81/5 (56 votes)
5 May 200313 min read 238.7K   2.6K   194  
Exploring the issues of menu management as specified externally via an XML file, in the context of status bars, toolbars, and events.
using System;
using System.Collections;

/*
	Manages the execution of workflow processes.  A workflow:
	1. consists of a sequence of one or more actions;
	2. may include conditionals to control which actions are performed;
	3. may include iteration to repeat a series of actions;
	4. may invoke sub-processes.
	
	Additionally:
	1. Workflows are initiated via events and/or direct calls;
	2. Workflows are script based
		a. Simple <component>.<function> implementation
		b. Parameters are defined in a parameter definition section
		c. Parameters are packaged based on parameter sequence and the parameter definition section
		d. Iteration and conditionals are supported through the workflow component (2a)
	3. Workflows can be graphically represented in Visio
		a. Each component provides:
			1) a component level icon (as a stencil reference)
			2) an optional icon for each function (as a stencil reference)
			3) icons are stored in Visio stencils
	4. Individual actions can be executed directly or initiated in a separate thread
		a. Execution continues when started as a separate thread
		
Do we need a tool to build scripts visually/graphically?

*/

namespace AAL
{
	public sealed class WorkflowManager
	{
		private static WorkflowManager workflowManager;
		private static ICore.IComponentManager icm;

		private IWM iwm;
		private ICore.IDataHub idh;

		/// <summary>
		/// Phase 1 initialization.
		/// </summary>
		/// <param name="icm">The Component Manager interface.</param>
		/// <returns></returns>
		public static ICore.IWorkflowManager Init1(ICore.IComponentManager icm)
		{
			WorkflowManager.icm=icm;
			workflowManager=new WorkflowManager();
			return workflowManager.iwm;
		}

		/// <summary>
		/// Phase 2 initialization.
		/// </summary>
		public static void Init2()
		{
			workflowManager.idh=icm.GetInterface("DataHub") as ICore.IDataHub;
		}

		/// <summary>
		/// Constructor.
		/// </summary>
		public WorkflowManager()
		{
			iwm=new IWM(this);										// instantiate interface
			icm.RegisterInterfacePoint("WorkflowManager", "Run", new InterfacePoint(Run));
		}

		/// <summary>
		/// The Workflow Manager is responsible for interfacing with the Data Hub to
		/// create a workflow.  A workflow combines both data and task information.  By
		/// using the Workflow Manager, it can pass on the workflow data initialization to
		/// the Data Hub while performing necessary workflow task initialization here.
		/// This is currently a stub function.
		/// </summary>
		/// <param name="name">The workflow domain name.</param>
		public void CreateWorkflowDomain(string name)
		{
			idh.CreateWorkflowDomain(name);
		}

		/// <summary>
		/// The Workflow Manager is responsible for interfacing with the Component Manager
		/// to invoke component service.  This gives the Workflow Manager the opportunity
		/// to create invoke a service as a separate thread, measure performance, etc. 
		/// This is currently a stub function.
		/// </summary>
		/// <param name="eventName">The event name.</param>
		/// <param name="eventData">The associated event data.</param>
		public void FireEvent(string eventName, EventData eventData)
		{
			Dbg.WriteLine("Event: "+eventName);
			icm.Invoke(eventName, eventData);
		}

		/// <summary>
		/// Begin a workflow process, as defined by a script.
		/// </summary>
		/// <param name="eventData"></param>
		/// <returns></returns>
		private object Run(EventData eventData)
		{

			string fnc;
			eventData.UnMarshal("Function", out fnc);
			if (fnc != "")
			{
				icm.Invoke(fnc, eventData);
			}
			
			return null;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect Interacx
United States United States
Blog: https://marcclifton.wordpress.com/
Home Page: http://www.marcclifton.com
Research: http://www.higherorderprogramming.com/
GitHub: https://github.com/cliftonm

All my life I have been passionate about architecture / software design, as this is the cornerstone to a maintainable and extensible application. As such, I have enjoyed exploring some crazy ideas and discovering that they are not so crazy after all. I also love writing about my ideas and seeing the community response. As a consultant, I've enjoyed working in a wide range of industries such as aerospace, boatyard management, remote sensing, emergency services / data management, and casino operations. I've done a variety of pro-bono work non-profit organizations related to nature conservancy, drug recovery and women's health.

Comments and Discussions