Click here to Skip to main content
15,886,519 members
Articles / Desktop Programming / Win32

Host and Workflow: Two Worlds to Communicate. Part V

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
4 Oct 2008CPOL7 min read 36.8K   408   23  
Part V: Intercommunications with a Workflow instance using Correlation parameter
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CommunicationManager
{
    public class MailCommunication:IMailCommunication, IMailCommunication2
    {
        #region Workflow to Host Communication
        /// <summary>
        /// Internal event to communicate with the host by events
        /// </summary>
        public event EventHandler<RequestMailEventArgs> SendInfoToHost;

        /// <summary>
        /// External Method that is called by the workflow.
        /// </summary>
        /// <param name="wfId"></param>
        /// <param name="typo"></param>
        /// <param name="orderNumber"></param>
        public void GetEmailAddress(Guid wfId, string typo, string orderNumber)
        {
            //Create a Event to receive the info en host async.
            RequestMailEventArgs args = new RequestMailEventArgs(wfId, typo, orderNumber);
            if (SendInfoToHost != null)
            {
                SendInfoToHost(null, args);
            }
        }

        //.. Send to host the information about the sended email...........
        //public event EventHandler<NotificationEventArgs> ReceiveEmailNotification; 

        public void SendEmailNotification(Guid wfId, string notification)
        {
            Console.WriteLine(notification);
         //........................    
        }
        #endregion

        #region Host To Workflow Communication
        
        public event EventHandler<MailEventArgs> SendEmailToWorkflow;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="instanceId"></param>
        /// <param name="typo"></param>
        /// <param name="email"></param>
        public void RaiseSendEmailToWorkflow(Guid instanceId, string typo, string email)
        {
            //Raise the events
            MailEventArgs args = new MailEventArgs(instanceId, typo, email);
            if (SendEmailToWorkflow != null)
            {
                SendEmailToWorkflow(null, args);
            }
        }
        #endregion

    }
}

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