Beispiel #1
0
        private void Button_Connect_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder sb = new StringBuilder(1024);

            try
            {
                // read account settings, dump
                AccountSettings accountSettings = SampleHelpers.LoadAccountSettings();
                sb.AppendLine("--- accountSettings ---");
                sb.AppendLine(accountSettings.ToString());

                // read job settings, dump
                JobSettings jobSettings = SampleHelpers.LoadJobSettings();
                sb.AppendLine("--- jobSettings ---");
                sb.AppendLine(jobSettings.ToString());

                // connect to batch, dump status
                BatchSharedKeyCredentials cred = new BatchSharedKeyCredentials(
                    accountSettings.BatchServiceUrl,
                    accountSettings.BatchAccountName,
                    accountSettings.BatchAccountKey
                    );

                sb.AppendLine($"credentials created: {cred.AccountName},{cred.BaseUrl}");

                using (BatchClient client = BatchClient.Open(cred))
                {
                    sb.AppendLine($"batchclient opened successfully");
                    // enumerate pools
                    sb.AppendLine("--- pools ---");
                    foreach (var pool in client.PoolOperations.ListPools())
                    {
                        sb.AppendLine($"pool found: id:{pool.Id} vmsize:{pool.VirtualMachineSize} state:{pool.State.ToString()}");
                    }
                    sb.AppendLine("--- applications ---");
                    foreach (var app in client.ApplicationOperations.ListApplicationSummaries())
                    {
                        sb.AppendLine($"application found: {app.Id} {app.Versions[0]}");
                    }
                } // batchclient
            }
            catch (AggregateException ae)
            {
                sb.AppendLine("aggregate exception caught");
                sb.AppendLine(SampleHelpers.AggregateExceptionDump(ae.Flatten()));
                System.Diagnostics.Trace.Write(sb.ToString(), "ERROR");
            }
            catch (Exception ex)
            {
                sb.AppendLine("exception caught");
                sb.AppendLine(ex.ToString());
                System.Diagnostics.Trace.Write(sb.ToString(), "ERROR");
            }

            TextBlock_Out.Text = sb.ToString();
        }
Beispiel #2
0
        public void Setting()
        {
            var settings = new AccountSettings();

            settings.Set(Option.ApplyBloom, 1);
            settings.Set(Option.JoypadVibration, 1);
            settings.Set(Option.UiMode, 2);

            Assert.Equal("23 1 46 1 43 2", settings.ToString());
        }
Beispiel #3
0
        public void Setting()
        {
            var settings = new AccountSettings();

            settings.Set(Option.EnableBloom, 1);
            settings.Set(Option.JoyPadVibration, 1);
            settings.Set(Option.ControlMode, 2);

            Assert.Equal("23 1 46 1 43 2", settings.ToString());
        }
Beispiel #4
0
        /// <summary>
        /// Submits a job to the Azure Batch service, and waits for it to complete
        /// </summary>
        private static async Task HelloWorldAsync(AccountSettings accountSettings, Settings helloWorldConfigurationSettings)
        {
            Console.WriteLine("Running with the following settings: ");
            Console.WriteLine("-------------------------------------");
            Console.WriteLine(helloWorldConfigurationSettings.ToString());
            Console.WriteLine(accountSettings.ToString());

            // Set up the Batch Service credentials used to authenticate with the Batch Service.
            BatchSharedKeyCredentials credentials = new BatchSharedKeyCredentials(
                accountSettings.BatchServiceUrl,
                accountSettings.BatchAccountName,
                accountSettings.BatchAccountKey);

            // Get an instance of the BatchClient for a given Azure Batch account.
            using (BatchClient batchClient = await BatchClient.OpenAsync(credentials))
            {
                // add a retry policy. The built-in policies are No Retry (default), Linear Retry, and Exponential Retry
                batchClient.CustomBehaviors.Add(RetryPolicyProvider.LinearRetryProvider(TimeSpan.FromSeconds(10), 3));

                string jobId = GettingStartedCommon.CreateJobId("HelloWorldJob");

                try
                {
                    // Submit the job
                    await SubmitJobAsync(batchClient, helloWorldConfigurationSettings, jobId);

                    // Wait for the job to complete
                    await WaitForJobAndPrintOutputAsync(batchClient, jobId);
                }
                finally
                {
                    // Delete the job to ensure the tasks are cleaned up
                    if (!string.IsNullOrEmpty(jobId) && helloWorldConfigurationSettings.ShouldDeleteJob)
                    {
                        Console.WriteLine("Deleting job: {0}", jobId);
                        batchClient.JobOperations.DeleteJob(jobId);
                    }
                }
            }
        }
Beispiel #5
0
        public void Parsing()
        {
            var settings = new AccountSettings("23 1 46 1 43 2");

            Assert.Equal("23 1 46 1 43 2", settings.ToString());
        }