Esempio n. 1
0
        private async Task DeleteBulkIndividualEnrollments(List <IndividualEnrollment> individualEnrollments)
        {
            Console.WriteLine("\nDeleting the set of individualEnrollments...");
            BulkEnrollmentOperationResult bulkEnrollmentOperationResult =
                await _provisioningServiceClient.RunBulkEnrollmentOperationAsync(BulkOperationMode.Delete, individualEnrollments).ConfigureAwait(false);

            Console.WriteLine(bulkEnrollmentOperationResult);
        }
        public async Task <List <IndividualEnrollment> > CreateBulkIndividualEnrollmentsAsync()
        {
            Console.WriteLine("\nCreating a new set of individualEnrollments...");
            List <IndividualEnrollment> individualEnrollments = new List <IndividualEnrollment>();

            foreach (var item in _registrationIds)
            {
                Attestation attestation = new TpmAttestation(item.Value);
                individualEnrollments.Add(new IndividualEnrollment(item.Key, attestation));
            }

            Console.WriteLine("\nRunning the bulk operation to create the individualEnrollments...");
            BulkEnrollmentOperationResult bulkEnrollmentOperationResult =
                await _provisioningServiceClient.RunBulkEnrollmentOperationAsync(BulkOperationMode.Create, individualEnrollments).ConfigureAwait(false);

            Console.WriteLine("\nResult of the Create bulk enrollment.");
            Console.WriteLine(bulkEnrollmentOperationResult);

            return(individualEnrollments);
        }
        public void BulkEnrollmentOperationResult_Constructor_Succeed()
        {
            // arrange
            string validJson =
                "{" +
                $"  \"isSuccessful\": true, \"errors\": [ {SampleValidErrorJson}, {SampleValidErrorJson} ]" +
                "}";

            // act
            BulkEnrollmentOperationResult bulkErrors =
                JsonConvert.DeserializeObject <BulkEnrollmentOperationResult>(validJson);

            // assert
            Assert.IsNotNull(bulkErrors);
            Assert.IsTrue(bulkErrors.IsSuccessful);
            Assert.IsNotNull(bulkErrors.Errors);
            foreach (BulkEnrollmentOperationError item in bulkErrors.Errors)
            {
                Assert.AreEqual(SampleRegistrationId, item.RegistrationId);
            }
        }
Esempio n. 4
0
        public static async Task RunSample()
        {
            Console.WriteLine("Starting sample...");

            using (ProvisioningServiceClient provisioningServiceClient =
                       ProvisioningServiceClient.CreateFromConnectionString(_provisioningConnectionString))
            {
                #region Create a new individualEnrollment config
                Console.WriteLine("\nCreating a new set of individualEnrollments...");
                List <IndividualEnrollment> individualEnrollments = new List <IndividualEnrollment>();
                foreach (var item in _registrationIds)
                {
                    Attestation attestation = new TpmAttestation(item.Value);
                    individualEnrollments.Add(new IndividualEnrollment(item.Key, attestation));
                }
                #endregion

                #region Create the individualEnrollment
                Console.WriteLine("\nRunning the bulk operation to create the individualEnrollments...");
                BulkEnrollmentOperationResult bulkEnrollmentOperationResult =
                    await provisioningServiceClient.RunBulkEnrollmentOperationAsync(BulkOperationMode.Create, individualEnrollments).ConfigureAwait(false);

                Console.WriteLine("\nResult of the Create bulk enrollment.");
                Console.WriteLine(bulkEnrollmentOperationResult);
                #endregion

                #region Get info of individualEnrollment
                foreach (IndividualEnrollment individualEnrollment in individualEnrollments)
                {
                    String registrationId = individualEnrollment.RegistrationId;
                    Console.WriteLine($"\nGetting the {nameof(individualEnrollment)} information for {registrationId}...");
                    IndividualEnrollment getResult =
                        await provisioningServiceClient.GetIndividualEnrollmentAsync(registrationId).ConfigureAwait(false);

                    Console.WriteLine(getResult);
                }
                #endregion

                #region Query info of individualEnrollment
                Console.WriteLine("\nCreating a query for enrollments...");
                QuerySpecification querySpecification = new QuerySpecification("SELECT * FROM enrollments");
                using (Query query = provisioningServiceClient.CreateIndividualEnrollmentQuery(querySpecification, QueryPageSize))
                {
                    while (query.HasNext())
                    {
                        Console.WriteLine("\nQuerying the next enrollments...");
                        QueryResult queryResult = await query.NextAsync().ConfigureAwait(false);

                        Console.WriteLine(queryResult);
                    }
                }
                #endregion

                #region Delete info of individualEnrollment
                Console.WriteLine("\nDeleting the set of individualEnrollments...");
                bulkEnrollmentOperationResult =
                    await provisioningServiceClient.RunBulkEnrollmentOperationAsync(BulkOperationMode.Delete, individualEnrollments).ConfigureAwait(false);

                Console.WriteLine(bulkEnrollmentOperationResult);
                #endregion
            }
        }