Example #1
0
        public async Task <IActionResult> ProfilesAsync(string profileId)
        {
            if (manager == null)
            {
                manager = new SdsManager(await GetAccessTokenAsync());
            }

            var manageError = TempData["manageProfileError"];

            if (manageError != null)
            {
                ViewBag.manageProfileError = manageError;
            }

            ViewBag.profileId = profileId;

            var profileRequest = string.IsNullOrWhiteSpace(profileId) ?
                                 await manager.QueryAllProfilesAsync() :
                                 await manager.QueryProfileAsync(profileId);

            var profile = await profileRequest.Content.ReadAsStringAsync();

            var profileDes = JsonConvert.DeserializeObject(profile);
            var profileSer = JsonConvert.SerializeObject(profileDes, Formatting.Indented);

            ViewBag.profile = profileSer;

            if (!string.IsNullOrWhiteSpace(profileId))
            {
                var profileStatusRequest = await manager.QueryProfileStatusAsync(profileId);

                var profileStatus = await profileStatusRequest.Content.ReadAsStringAsync();

                var profileStatusDes = JsonConvert.DeserializeObject(profileStatus);
                var profileStatusSer = JsonConvert.SerializeObject(profileStatusDes, Formatting.Indented);
                ViewBag.profileStatus = profileStatusSer;
            }
            else
            {
                ViewBag.profileStatus = string.Empty;
            }

            return(View("Profiles"));
        }
Example #2
0
        private async Task StartCsvSyncSafely(string profileId)
        {
            var profileIsReady = false;

            do
            {
                var res = await manager.QueryProfileAsync(profileId);

                var responseText = await res.Content.ReadAsStringAsync();

                profileIsReady = (string)JObject.Parse(responseText)["state"] == "provisioned";

                if (!profileIsReady)
                {
                    await Task.Delay(5000);
                }
            } while (!profileIsReady);
            await manager.StartCsvSync(profileId);
        }