Click here to Skip to main content
15,891,184 members
Articles / Programming Languages / C#

Host and Workflow: Two Worlds to Communicate IV

Rate me:
Please Sign up or sign in to vote.
4.00/5 (2 votes)
3 Oct 2008CPOL9 min read 32.4K   418   15  
Part IV: Organisation of the communication classes: Communication manager, wca.exe utility and Wwca.exe windows front-end for wca.exe
///////////////////////////////////////////////////////////
//  CommunicationValve.cs
//  Implementation of the Class CommunicationValve
//  Generated by Enterprise Architect
//  Created on:      24-Sep-2008 17:06:18
//  Original author: JAGG
///////////////////////////////////////////////////////////



using System;
using System.Workflow.Activities;
using jagg.ClassCommunication;

namespace jagg.ClassCommunication 
{
	public class CommunicationValve : ICommunicationValve
    {

        #region WF -> Host Communication

        public event EventHandler<ExternalValveEventArgs> EventValveStatus;

      /// <summary>
		/// Used by CallExternalEvent Argument to pass the valve status to Host
		/// </summary>
		/// <param name="status">Valve status OPEN / CLOSE / EXIT</param>
		public void StatusValve(Guid wfGuid, string status)
        {
             
            if (EventValveStatus != null)
            {
              ExternalValveEventArgs e = new ExternalValveEventArgs(wfGuid);
              e.Status = status;
              EventValveStatus(this, e); //Raise the event
            }
		}

        #endregion

        #region Host -> WF

        /// <summary>
		/// Use to pass the valve operation to workflow
		/// </summary>
		public event EventHandler<ExternalDataEventArgs> CloseValve;
  
		/// <summary>
		/// Use to pass the valve operation to workflow
		/// </summary>
		public event EventHandler<ExternalDataEventArgs> Exit;
  
		/// <summary>
		/// Use to pass the valve operation to workflow
		/// </summary>
		public event EventHandler<ExternalDataEventArgs> OpenValve;
         #endregion

        #region Auxiliar procedures
        /// <summary>
        /// Raise the event Exit
        /// </summary>
        /// <param name="instanceId">workflow instance</param>
        public void RaiseExit(Guid instanceId)
        {
            if (Exit != null)
            {
                ExternalDataEventArgs e = new ExternalDataEventArgs(instanceId);
                e.WaitForIdle = true;
                Exit(null, e);
            }
        }
        /// <summary>
        /// Raise the event Open
        /// </summary>
        /// <param name="instanceId">workflow instance</param>
        public void RaiseOpen(Guid instanceId)
        {
            if (OpenValve != null)
            {
                ExternalDataEventArgs e = new ExternalDataEventArgs(instanceId);
                OpenValve(null, e);
             }
        }
        /// <summary>
        /// Raise the event Close
        /// </summary>
        /// <param name="instanceId">workflow instance</param>
        public void RaiseClose(Guid instanceId)
        {
            if (CloseValve != null)
            {
                ExternalDataEventArgs e = new ExternalDataEventArgs(instanceId);
                CloseValve(null, e);
            }
        }
        #endregion

    }//end CommunicationValve

}//end namespace ClassCommunication

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Avalon Development
United States United States
Jose A. Garcia Guirado, Electronic Engineer, graduated in Havana/Cuba 1982, MCTS, MCSD.NET, MCAD.NET, MCSE. Worked in the Institute for Cybernetics and Mathematics of Academy of Science of Cuba for 8 years; since 1995 working as free software architect, developer and adviser, first in Argentina and from 2003 to 2010, in Germany as External consultant in DWS Luxembourg, AIXTRON AG and Shell Deutschland GmbH and from 2010 to 2012 in Mexico working for Twenty Century Fox, and Mexico Stock Exchange (BMV). From 2013 to now in USA, Florida, First in FAME Inc. and now as Senior Software Engineer in Spirit Airlines.

Comments and Discussions