feature: pending device enrollment approval
This commit is contained in:
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user