private async void OnLoaded(object sender, RoutedEventArgs e)
        {
            try
            {
                var client    = new RobotClient();
                var processes = await client.GetProcesses();

                foreach (var process in processes.OrderBy(p => p.Name))
                {
                    processNameListBox.Items.Add(process.Name);
                }
                if (processNameListBox.Items.Count > 0)
                {
                    processNameListBox.IsEnabled = true;
                    if (SelectedProcessName != null)
                    {
                        var selected = SelectedProcessName;
                        SelectedProcessName = null;
                        foreach (string name in processNameListBox.Items)
                        {
                            if (name == selected)
                            {
                                processNameListBox.SelectedValue = SelectedProcessName = name;
                                okButton.IsEnabled = true;
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Unable to get process names.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 2
0
        private IReadOnlyDictionary <string, object> RunProcess(string processName, IDictionary <string, object> inputValues)
        {
            var client = new RobotClient();
            var task1  = client.GetProcesses();

            task1.Wait();
            var processes = task1.Result;
            var myProcess = processes.Single(process => process.Name == processName);
            var job       = myProcess.ToJob();

            job.InputArguments = inputValues;
            var task2 = client.RunJob(job);

            task2.Wait();
            return(task2.Result.Arguments);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Runs the designated process asynchronously.
        /// </summary>
        /// <param name="processName">Name of the process to run</param>
        /// <returns>Task with JobOutput</returns>
        private static async Task <JobOutput> RunAsync(string processName)
        {
            try
            {
                var client    = new RobotClient();
                var processes = await client.GetProcesses();

                var myProcess = processes.Single(process => process.Name == processName);
                var job       = myProcess.ToJob();
                return(await client.RunJob(job));
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("{0}", ex.ToString());
                return(null);
            }
        }