Example #1
0
        private static void aliceProgressWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var progressTimer = new Stopwatch();

            progressTimer.Start();

            var taskProgressInfo = new HyperNodeTaskProgressInfo();

            using (var alice = new HyperNodeClient("Alice"))
            {
                var request = (HyperNodeMessageRequest)e.Argument;
                ICommandResponseSerializer serializer = new NetDataContractResponseSerializer <GetCachedTaskProgressInfoResponse>();

                while (!taskProgressInfo.IsComplete && progressTimer.Elapsed <= TimeSpan.FromMinutes(2))
                {
                    var aliceResponse = alice.ProcessMessage(request);

                    var targetResponse = aliceResponse;
                    if (string.IsNullOrWhiteSpace(targetResponse?.CommandResponseString))
                    {
                        break;
                    }

                    var commandResponse = (GetCachedTaskProgressInfoResponse)serializer.Deserialize(targetResponse.CommandResponseString);
                    taskProgressInfo = commandResponse.TaskProgressInfo ?? new HyperNodeTaskProgressInfo();
                    if (!commandResponse.TaskProgressCacheEnabled)
                    {
                        taskProgressInfo.Activity.Add(
                            new HyperNodeActivityItem(ClientAgentName)
                        {
                            EventDescription = "Warning: Task progress cache is not enabled for HyperNode \'Alice\'."
                        }
                            );

                        // Make sure we exit the loop, since we're not going to get anything useful in this case.
                        taskProgressInfo.IsComplete = true;
                    }

                    ((BackgroundWorker)sender).ReportProgress(Convert.ToInt32(taskProgressInfo.ProgressPercentage), taskProgressInfo);

                    Task.Delay(500).Wait();
                }
            }

            progressTimer.Stop();

            e.Result = taskProgressInfo;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var nodeService1 = new HyperNodeClient();

            var requestObject = new ExecuteStoredProcedureRequest();

            var response = nodeService1.ProcessMessage(
                new HyperNodeMessageRequest("NodeClient1")
                {
                    CommandName = SystemCommandName.Echo,
                    CommandRequestString = "Hello, world!"
                }
            );

            MessageBox.Show(response.CommandResponseString);
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            var nodeService1 = new HyperNodeClient();

            var requestObject = new ExecuteStoredProcedureRequest();

            var response = nodeService1.ProcessMessage(
                new HyperNodeMessageRequest("NodeClient1")
            {
                CommandName          = SystemCommandName.Echo,
                CommandRequestString = "Hello, world!"
            }
                );

            MessageBox.Show(response.CommandResponseString);
        }
Example #4
0
        private void btnRunCommand_Click(object sender, EventArgs e)
        {
            try
            {
                // Clear out our data source first
                ClearResponseData();

                // Create our message request
                var serializer           = new NetDataContractRequestSerializer <LongRunningCommandTestRequest>();
                var commandRequestString = serializer.Serialize(
                    new LongRunningCommandTestRequest
                {
                    TotalRunTime         = TimeSpan.FromHours(1),
                    MinimumSleepInterval = TimeSpan.FromSeconds(1),
                    MaximumSleepInterval = TimeSpan.FromSeconds(5)
                }
                    );

                var msg = new HyperNodeMessageRequest(ClientAgentName)
                {
                    CommandName          = cboCommandNames.Text,
                    CommandRequestString = commandRequestString,
                    ProcessOptionFlags   = (chkReturnTaskTrace.Checked ? MessageProcessOptionFlags.ReturnTaskTrace : MessageProcessOptionFlags.None) |
                                           (chkRunConcurrently.Checked ? MessageProcessOptionFlags.RunConcurrently : MessageProcessOptionFlags.None) |
                                           (chkCacheProgressInfo.Checked ? MessageProcessOptionFlags.CacheTaskProgress : MessageProcessOptionFlags.None)
                };

                using (var client = new HyperNodeClient("Alice"))
                {
                    var response = client.ProcessMessage(msg);

                    PopulateResponseSummary(lstRealTimeResponse, response);
                    PopulateTaskTrace(tvwRealTimeTaskTrace, response);

                    if (response.NodeAction != HyperNodeActionType.Rejected && msg.CacheTaskProgress)
                    {
                        StartAliceProgressTracking(response.TaskId);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #5
0
        private void btnBobCancelCurrentTask_Click(object sender, EventArgs e)
        {
            var targetTaskId = txtBobTaskId.Text;

            if (!string.IsNullOrWhiteSpace(targetTaskId))
            {
                // Create our message request
                var msg = new HyperNodeMessageRequest(ClientAgentName)
                {
                    CommandName          = SystemCommandName.CancelTask,
                    CommandRequestString = targetTaskId
                };

                using (var client = new HyperNodeClient("Alice"))
                {
                    client.ProcessMessage(msg);
                }
            }
        }
Example #6
0
        private void btnRefreshCommandList_Click(object sender, EventArgs e)
        {
            try
            {
                cboCommandNames.DataSource = null;

                var serializer = new NetDataContractResponseSerializer <GetNodeStatusResponse>();
                var msg        = new HyperNodeMessageRequest(ClientAgentName)
                {
                    CommandName = SystemCommandName.GetNodeStatus
                };

                using (var client = new HyperNodeClient("Alice"))
                {
                    var response = client.ProcessMessage(msg);

                    // TODO: Recursively find the response we're actually interested in

                    if (!string.IsNullOrWhiteSpace(response.CommandResponseString))
                    {
                        if (((ICommandResponseSerializer)serializer).Deserialize(response.CommandResponseString) is GetNodeStatusResponse commandResponse)
                        {
                            cboCommandNames.DataSource = commandResponse.Commands.Select(c => c.CommandName).OrderBy(cn => cn).ToList();
                        }
                    }
                    else
                    {
                        MessageBox.Show(response.RespondingNodeName + " did not send back a command response string.");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }