feature: pending device enrollment approval

This commit is contained in:
Gary Sharp
2024-01-21 14:06:11 +11:00
parent 6af83cbdb2
commit 37e2e5a08c
33 changed files with 1379 additions and 344 deletions
@@ -41,6 +41,9 @@ namespace Disco.Client.Extensions
if (!string.IsNullOrEmpty(enrolResponse.ErrorMessage))
throw new ClientServiceException("Enrolment", enrolResponse.ErrorMessage);
if (enrolResponse.IsPending)
return;
// Offline Domain Join
bool requireReboot = enrolResponse.ApplyOfflineDomainJoin();
+30 -7
View File
@@ -122,17 +122,40 @@ namespace Disco.Client
EnrolResponse response = null;
// Build Request
Presentation.UpdateStatus("Enrolling Device", "Building enrolment request and preparing to send data to the server.", true, -1);
Presentation.UpdateStatus("Enrolling Device", "Building enrollment request and preparing to send data to the server.", true, -1);
request = new Enrol();
request.Build();
// Send Request
Presentation.UpdateStatus("Enrolling Device", "Sending the enrolment request to the server.", true, -1);
response = request.Post(Program.IsAuthenticated);
var startTime = DateTimeOffset.Now;
do
{
// Send Request
Presentation.UpdateStatus("Enrolling Device", "Sending the enrollment request to the server.", true, -1);
response = request.Post(Program.IsAuthenticated);
// Process Response
Presentation.UpdateStatus("Enrolling Device", "Processing the enrolment response from the server.", true, -1);
response.Process();
// Process Response
Presentation.UpdateStatus("Enrolling Device", "Processing the enrollment response from the server.", true, -1);
response.Process();
if (response.IsPending)
{
request.PendingSessionId = response.SessionId;
request.PendingAuthorization = response.PendingAuthorization;
// Session Pending
var totalSeconds = (response.PendingTimeout - startTime).TotalSeconds;
var secondsConsumed = (DateTimeOffset.Now - startTime).TotalSeconds;
var progress = (int)((secondsConsumed / totalSeconds) * 100);
Presentation.UpdateStatus("Pending Device Enrollment Approval", $"Waiting for enrollment session to be approved.{Environment.NewLine}Reason: {response.PendingReason}", true, progress);
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10));
}
else
{
// Session Complete
break;
}
} while (true);
// Complete
return true;