public override async Task StartAsync(PerformContext performContext) { await ExecuteAsync(performContext, async() => { Console.WriteLine(Environment.NewLine); Logger.Info(performContext, "Acquiring the upload details from the api."); var managedServer = PortalService.GetManagedServer(); if (managedServer == null) { Logger.Info(performContext, "It appears this device hasn't logged in before. Generating the upload details."); try { var upload = ManagedSupport.Create( SettingManagerHelper.ClientVersion, AuthService.GetDevice(), AuthService.GetAccount()); await PortalService.AddManagedServerAsync(upload); managedServer = PortalService.GetManagedServer(); if (managedServer == null) { throw new UserFriendlyException("There was a problem creating the upload, please try again. If the problem persists, please raise a bug report."); } } catch (Exception ex) when(!(ex is UserFriendlyException)) { throw new UserFriendlyException(ex.Message); } } else { managedServer.ClientVersion = SettingManagerHelper.ClientVersion; } Logger.Info(performContext, "Upload details acquired!"); Console.WriteLine(Environment.NewLine); Logger.Info(performContext, "---------- Uploading groups begin ----------"); await ComputeGroups(performContext); Logger.Info(performContext, "---------- Uploading groups end ----------"); Console.WriteLine(Environment.NewLine); Logger.Info(performContext, "---------- Uploading users begin ----------"); await ComputeUsers(performContext, managedServer.Id); Logger.Info(performContext, "---------- Uploading users end ----------"); Console.WriteLine(Environment.NewLine); Logger.Info(performContext, "Calculating group memberships. This could take some time..."); await ComputeGroupMembershipAsync(performContext); Logger.Info(performContext, "Group memberships are up to date."); Console.WriteLine(Environment.NewLine); Logger.Info(performContext, "Completing the upload."); await PortalService.UpdateManagedServerAsync(managedServer); }); }