示例#1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            //int port;
            //try
            //{
            //    port = int.Parse(txtPort.Text);
            //}
            //catch (System.FormatException)
            //{
            //    MessageBox.Show("Invalid name for 'Port' field.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return;
            //}

            connection = new GConnection();
            //config.Host = connection.Host = txtHost.Text;
            //config.Port = connection.Port = port;
            config.Username = connection.Username = txtUsername.Text;
            config.Password = connection.Password = txtPassword.Text;
            if (config.EndPointConfig == null)
            {
                config.EndPointConfig = new EndPointConfiguration();
            }
            ucEndPointConfig.WriteEndPointConfiguration(config.EndPointConfig);
            connection.RemoteEP = config.EndPointConfig.GetEndPoint();
            config.Write(Role);

            IManager          mgr;
            EndPointReference mgrEpr = null;

            try
            {
                mgrEpr = GNode.GetRemoteManagerRef(connection.RemoteEP);
                mgr    = (IManager)mgrEpr.Instance;
            }
            catch (RemotingException)
            {
                MessageBox.Show("Could not connect to grid at " + connection.Host + ":" + connection.Port + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                mgr.AuthenticateUser(new SecurityCredentials(config.Username, config.Password));
            }
            catch (AuthenticationException)
            {
                MessageBox.Show("Access denied.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (mgrEpr != null)
            {
                mgrEpr.Dispose();
                mgrEpr = null;
            }

            DialogResult = DialogResult.OK;
        }
示例#2
0
        /// <summary>
        /// Constructor that takes the given connection and the thread buffer capacity.
        /// </summary>
        /// <param name="oConnection"></param>
        /// <param name="nThreadBufferCapacity"></param>
        public GApplicationBuffered(GConnection oConnection, int nThreadBufferCapacity) : this(nThreadBufferCapacity)
        {
            if (oConnection == null)
            {
                throw new ArgumentNullException("oConnection");
            }

            Connection = oConnection;
        }
示例#3
0
        /// <summary>
        /// Constructor that takes the given connection and the thread buffer capacity.
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="threadBufferCapacity"></param>
        public GApplicationBuffered(GConnection connection, int threadBufferCapacity)
            : this(threadBufferCapacity)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            Connection = connection;
        }
示例#4
0
        /// <summary>
        /// Constructor that takes the given connection.
        /// </summary>
        /// <param name="connection">connection to alchemi manager</param>
        public GApplicationBuffered(GConnection connection)
            : this(DefaultThreadBufferCapacity)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection may not be null");
            }

            Connection = connection;
        }
        /// <summary>
        /// Constructor that takes the given connection and the thread buffer capacity.
        /// </summary>
        /// <param name="oConnection"></param>
        /// <param name="nThreadBufferCapacity"></param>
        public GApplicationBuffered(GConnection oConnection, int nThreadBufferCapacity)
            : this(nThreadBufferCapacity)
        {
            if (oConnection == null)
            {
                throw new ArgumentNullException("oConnection");
            }

            Connection = oConnection;
        }
        /// <summary>
        /// Constructor that takes the given connection and the thread buffer capacity.
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="threadBufferCapacity"></param>
        public GApplicationBuffered(GConnection connection, int threadBufferCapacity)
            : this(threadBufferCapacity)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            Connection = connection;
        }
        /// <summary>
        /// Constructor that takes the given connection.
        /// </summary>
        /// <param name="connection">connection to alchemi manager</param>
        public GApplicationBuffered(GConnection connection)
            : this(DefaultThreadBufferCapacity)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection may not be null");
            }

            Connection = connection;
        }
示例#8
0
        static void Main(string[] args)
        {
            Console.WriteLine("[enter] to start grid application ...");
            Console.ReadLine();

            // create standard grid connection
            GConnection gc = new GConnection("localhost", 9000, "user", "user");

            // create multi-use grid application
            ga = new GApplication(true);
            ga.ApplicationName = "Tutorial OTF - Alchemi sample";

            // use standard grid connection
            ga.Connection = gc;

            // add GridThread module (this executable) as a dependency
            ga.Manifest.Add(new ModuleDependency(typeof(MultiplierThread).Module));

            // set the thread finish callback method
            ga.ThreadFinish += new GThreadFinish(ThreadFinished);

            // start application
            ga.Start();

            int i = -1;
            string input = "";

            while (input != "x")
            {
                i++;
                // create thread
                MultiplierThread thread = new MultiplierThread(i, i + 1);

                // add thread to application
                ga.StartThread(thread);

                Console.WriteLine("[enter] to start a new thread, [x] + [enter] to stop");
                input = Console.ReadLine();
            }

            ga.Stop();

            ApplicationStopped();
            Console.ReadLine();
        }
示例#9
0
 public ConsoleNode(GConnection gc)
     : base(gc)
 {
 }
        private void btnOK_Click(object sender, EventArgs e)
        {
            //int port;
            //try
            //{
            //    port = int.Parse(txtPort.Text);
            //}
            //catch (System.FormatException)
            //{
            //    MessageBox.Show("Invalid name for 'Port' field.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return;
            //}

            connection = new GConnection();
            //config.Host = connection.Host = txtHost.Text;
            //config.Port = connection.Port = port;
            config.Username = connection.Username = txtUsername.Text;
            config.Password = connection.Password = txtPassword.Text;
            if(config.EndPointConfig == null) config.EndPointConfig = new EndPointConfiguration();
            ucEndPointConfig.WriteEndPointConfiguration(config.EndPointConfig);
            connection.RemoteEP = config.EndPointConfig.GetEndPoint();
            config.Write(Role);

            IManager mgr;
            EndPointReference mgrEpr = null;

            try
            {
                mgrEpr = GNode.GetRemoteManagerRef(connection.RemoteEP);
                mgr = (IManager)mgrEpr.Instance;
            }
            catch (RemotingException)
            {
                MessageBox.Show("Could not connect to grid at " + connection.Host + ":" + connection.Port + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                mgr.AuthenticateUser(new SecurityCredentials(config.Username, config.Password));
            }
            catch (AuthenticationException)
            {
                MessageBox.Show("Access denied.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (mgrEpr != null)
            {
                mgrEpr.Dispose();
                mgrEpr = null;
            }

            DialogResult = DialogResult.OK;
        }
示例#11
0
 /// <summary>
 /// Creates an instance of the GApplication
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="multiUse">specifies if the GApplication instance is re-usable</param>
 public GApplication(GConnection connection, bool multiUse) : this(connection)
 {
     InitializeComponent();
     _MultiUse = multiUse;
 }
示例#12
0
 /// <summary>
 /// Creates an instance of the GApplication
 /// </summary>
 /// <param name="connection"></param>
 public GApplication(GConnection connection) : base(connection)
 {
     InitializeComponent();
 }
示例#13
0
 /// <summary>
 /// Creates an instance of the GApplication
 /// </summary>
 /// <param name="connection"></param>
 public GApplication(GConnection connection)
     : base(connection)
 {
     InitializeComponent();
 }
示例#14
0
 /// <summary>
 /// Creates an instance of the GApplication
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="multiUse">specifies if the GApplication instance is re-usable</param>
 public GApplication(GConnection connection, bool multiUse)
     : this(connection)
 {
     InitializeComponent();
     _MultiUse = multiUse;
 }
        private void btOk_Click(object sender, System.EventArgs e)
        {
            int port;
                try
                {
                    port = int.Parse(txPort.Text);
                }
                catch (System.FormatException)
                {
                    MessageBox.Show("Invalid value for 'Port' field.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                connection = new GConnection();
                config.Host = connection.Host = txHost.Text;
                config.Port = connection.Port = port;
                config.Username = connection.Username = txUsername.Text;
                config.Password = connection.Password = txPassword.Text;
                config.Write();

                IManager mgr;

                try
                {
                    mgr = GNode.GetRemoteManagerRef(new RemoteEndPoint(connection.Host, connection.Port, RemotingMechanism.TcpBinary));
                }
                catch (RemotingException)
                {
                    MessageBox.Show("Could not connect to grid at " + connection.Host + ":" + connection.Port + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                try
                {
                    mgr.AuthenticateUser(new SecurityCredentials(config.Username, config.Password));
                }
                catch (AuthenticationException)
                {
                    MessageBox.Show("Access denied.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DialogResult = DialogResult.OK;
        }
示例#16
0
 /// <summary>
 /// Creates a new instance of the GConnection class
 /// </summary>
 /// <param name="connection"></param>
 public GNode(GConnection connection)
 {
     Connection = connection;
     Init();
 }