public WebAppHttpTrigger(IConfiguration config, AzureAdService adService, AzureWebSiteService webAppService, ILogger <WebAppHttpTrigger> log)
 {
     this.config        = config;
     this.adService     = adService;
     this.webAppService = webAppService;
     this.log           = log;
 }
Example #2
0
 public AnalysisServiceHttpTrigger(AzureAdService aadService,
                                   AzureAnalysisService analysisService,
                                   AzureWebSiteService webAppService,
                                   ILogger <AnalysisServiceHttpTrigger> log)
 {
     this.aadService      = aadService;
     this.analysisService = analysisService;
     this.webAppService   = webAppService;
     this.log             = log;
 }
Example #3
0
        private async void ExecuteMyCommand()
        {
            if (AzureAdService.IsLoggedIn())
            {
                AzureAdService.Logout();
                AzureAdLoginButtonContext = "Azure AD Login";
                _navigationService.NavigateTo(ViewModelLocator.HomePageKey);
            }
            else
            {
                await AzureAdService.Login();

                if (AzureAdService.IsLoggedIn())
                {
                    AzureAdLoginButtonContext = "Azure AD Logout";
                }
            }
        }
Example #4
0
        private async void ExecuteLogInOutCommand()
        {
            if (AzureAdService.IsLoggedIn())
            {
                AzureAdService.Logout();
                IsLoggedIn             = false;
                UserProfileName        = "It's pretty alone down here.";
                UserProfilePhotoString = _defaultUserPhoto;
                LogInOutString         = "Login";

                _navigationService.NavigateTo(ViewModelLocator.StartUpPageKey);
                _dialogService.Show(Helpers.DialogType.Success, "Succesfully logged out.");
            }
            else
            {
                NotificationElement wait = null;
                try
                {
                    wait = _dialogService.Show(Helpers.DialogType.BusyWaiting,
                                               "Connecting to Azure Active Directory. Please wait.");
                    await AzureAdService.Login();
                }
                catch (Exception e)
                {
                    AzureAdService.HandleException(e);
                }
                finally
                {
                    wait.Hide();
                }

                if (AzureAdService.IsLoggedIn())
                {
                    IsLoggedIn     = true;
                    LogInOutString = "Logout";

                    User signedInUser = new User();
                    try
                    {
                        signedInUser = (User)await AzureAdService._client.Me.ExecuteAsync();

                        UserProfileName = signedInUser.DisplayName;
                    }
                    catch (Exception e)
                    {
                        _dialogService.Show(Helpers.DialogType.Error,
                                            $"Error getting signed in user {AzureAdService.ExtractErrorMessage(e)}");
                    }

                    if (signedInUser.ObjectId != null)
                    {
                        CouriersTodayActiveOrderList.Clear();
                        CouriersTodayActiveOrderList.Add("Display name: " + signedInUser.DisplayName);
                        CouriersTodayActiveOrderList.Add("Given name: " + signedInUser.GivenName);
                        CouriersTodayActiveOrderList.Add("Country: " + signedInUser.Country);
                        CouriersTodayActiveOrderList.Add("Phone: " + signedInUser.TelephoneNumber);
                        CouriersTodayActiveOrderList.Add("Department: " + signedInUser.Department);
                        CouriersTodayActiveOrderList.Add("Job title: " + signedInUser.JobTitle);
                        CouriersTodayActiveOrderList.Add("Usage location: " + signedInUser.UsageLocation);

                        IUser sUser = (IUser)signedInUser;
                        try
                        {
                            using (var dssr = await sUser.ThumbnailPhoto.DownloadAsync())
                            {
                                BitmapImage bitmapimage = new BitmapImage();
                                bitmapimage.BeginInit();
                                bitmapimage.StreamSource = dssr.Stream;
                                bitmapimage.CacheOption  = BitmapCacheOption.OnLoad;
                                bitmapimage.EndInit();
                                UserProfilePhotoString = bitmapimage;
                            }
                        }
                        catch (Exception e)
                        {
                            if (e.Message.Contains("Request_ResourceNotFound") || (e.InnerException != null && e.InnerException.Message.Contains("Request_ResourceNotFound")))
                            {
                                //User doesn't have profile picture
                                return;
                            }
                            else
                            {
                                _dialogService.Show(Helpers.DialogType.Error,
                                                    $"Error getting signed in user {AzureAdService.ExtractErrorMessage(e)}");
                            }
                        }
                    }
                }
            }
        }