Click here to Skip to main content
15,885,435 members
Articles / Programming Languages / C#

Host and Workflow: Two Worlds to Communicate - Part II

Rate me:
Please Sign up or sign in to vote.
4.83/5 (15 votes)
3 Oct 2008CPOL8 min read 52.1K   394   21  
Part II: Inter-communications: Workflow -> Host through the CallExternalMethod Activity.
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;

namespace CommunicationCallExternalMethod
{
	public sealed partial class Workflow1: SequentialWorkflowActivity
	{
        //Enter the variables that hold the parameters as properties
        string _filepath = string.Empty;
        int _quantity = 0;

        public String _response = default(System.String);

        /// <summary>
        /// The Property name must be the same as the object in the 
        /// input parameter dictionary 
        /// </summary>
        public int Quantity
        {
            get { return _quantity; }
            set { _quantity = value; }
        }
        /// <summary>
        /// The Property name must be the same as the object in the 
        /// input parameter dictionary 
        /// </summary>
        public string FilePath
        {
            get { return _filepath; }
            set { _filepath = value; }
        }


        public Workflow1()
        {
            InitializeComponent();
        }

        private void GetInfoFromFile(object sender, EventArgs e)
        {
            using (System.IO.StreamReader sr = new System.IO.StreamReader(_filepath))
            {
                char[] ac = new char[_quantity + 1];
                sr.Read(ac, 0, _quantity);
                _response = new String(ac);

            }
        }


	}

}

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