Пример #1
0
        private async Task AuthenticateAsync()
        {
            while (MobileServiceClientProvider.MobileClient.CurrentUser == null)
            {
                var aadAuthority           = ConfigurationHub.ReadConfigurationValue("AadAuthority");
                var aadRedirectResourceUri = ConfigurationHub.ReadConfigurationValue("AadRedirectResourceURI");
                var aadClientId            = ConfigurationHub.ReadConfigurationValue("AadClientID");
                await this.LoginAdalAsync(aadAuthority, aadRedirectResourceUri, aadClientId);
            }

            if (MobileServiceClientProvider.MobileClient.CurrentUser != null)
            {
                this.GridVisibility = Visibility.Visible;
            }
        }
        public override void FinishedLaunching(UIApplication application)
        {
            CurrentPlatform.Init();

            UINavigationBar.Appearance.BarTintColor = new UIColor(red: 0, green: 173.0f / 255.0f, blue: 240.0f / 255.0f, alpha: 1);
            UINavigationBar.Appearance.BarTintColor.SetColor();

            UINavigationBar.Appearance.TintColor = UIColor.White;

            UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false);

            UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes()
            {
                TextColor = UIColor.White
            });

            MobileServiceClientProvider.InitializeClient(ConfigurationHub.ReadConfigurationValue("MobSvcUri"), ConfigurationHub.ReadConfigurationValue("AppKey"));
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var refreshControl = new UIRefreshControl();

            this.RefreshControl = refreshControl;
            this.RefreshControl.ValueChanged += this.OnRefreshControlValueChanged;
            this.progressHud = new MTMBProgressHUD(View)
            {
                LabelText = "Loading...",
                RemoveFromSuperViewOnHide = true
            };

            View.AddSubview(this.progressHud);
            this.progressHud.Show(animated: true);

            this.facilityService.LoginCompletedAction = this.RetrieveRequests;
            this.facilityService.LoginAsync(true, ConfigurationHub.ReadConfigurationValue("AadAuthority"), ConfigurationHub.ReadConfigurationValue("AppRedirectLocation"), ConfigurationHub.ReadConfigurationValue("AadRedirectResourceURI"), ConfigurationHub.ReadConfigurationValue("AadClientID"));
        }
        public InspectionDetailsView()
        {
            this.InitializeComponent();

            this.DefaultViewModel = new InspectionDetailsViewModel();
            this.DataContext      = this;

            this.MapImage.Source = new BitmapImage(new Uri(ConfigurationHub.ReadConfigurationValue("MapImageLarge")));

            // Setup the navigation helper
            this.navigationHelper            = new NavigationHelper(this);
            this.navigationHelper.LoadState += this.NavigationHelperLoadState;

            // Setup the logical page navigation components that allow
            // the page to only show one pane at a time.
            this.navigationHelper.GoBackCommand = new RelayCommand(this.GoBack, this.CanGoBack);

            // Start listening for Window size changes
            // to change from showing two panes to showing a single pane
            Window.Current.SizeChanged += this.WindowSizeChanged;
            this.InvalidateVisualState();
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelperLoadState(object sender, LoadStateEventArgs e)
        {
            await this.DefaultViewModel.InitPageAsync();

            var request = e.NavigationParameter as FacilityRequestViewModel;

            this.DefaultViewModel.CurrentJob = request ?? new FacilityRequestViewModel()
            {
                User           = ConfigurationHub.ReadConfigurationValue("UserName") + " " + ConfigurationHub.ReadConfigurationValue("UserSurname"),
                Building       = ConfigurationHub.ReadConfigurationValue("BuildingFRVM"),
                Room           = ConfigurationHub.ReadConfigurationValue("RoomFRVM"),
                RoomType       = RoomType.Auditorium,
                RequestedDate  = DateTime.Now,
                BeforeImageUrl = ConfigurationHub.ReadConfigurationValue("CameraThumbnail"),
                AfterImageUrl  = ConfigurationHub.ReadConfigurationValue("CameraThumbnail"),
                DocId          = new Random((int)DateTime.Now.Ticks & 0x0000FFFF).Next(100000).ToString(),
                Street         = ConfigurationHub.ReadConfigurationValue("StreetFRVM"),
                City           = ConfigurationHub.ReadConfigurationValue("CityFRVM"),
                State          = ConfigurationHub.ReadConfigurationValue("StateFRVM"),
                Zip            = ConfigurationHub.ReadConfigurationValue("ZipFRVM")
            };
        }
Пример #6
0
        public override async Task <string> LoginAsync(bool clearCache, string authorityId, string redirectUri, string resourceId, string clientId)
        {
            var context = new AuthenticationContext(authorityId);
            var result  = await context.AcquireTokenAsync(resourceId, clientId);

            // Build our token
            var token = JObject.FromObject(new
            {
                access_token = result.AccessToken,
            });

            // Request access to Azure Mobile Services
            await MobileServiceClientProvider.MobileClient.LoginAsync(MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory, token);

            var authContext = new AuthenticationContext(ConfigurationHub.ReadConfigurationValue("AadAuthority"), false);

            // Get the sharepoint token
            var authenticationResult = await authContext.AcquireTokenByRefreshTokenAsync(result.RefreshToken, ConfigurationHub.ReadConfigurationValue("AadClientID"), ConfigurationHub.ReadConfigurationValue("SharePointResource"));

            State.SharePointToken = authenticationResult.AccessToken;

            return(result.AccessToken);
        }
Пример #7
0
        protected async Task GetUserImage()
        {
            var user           = ConfigurationHub.ReadConfigurationValue("SharePointUser");
            var sharePointUser = user.Replace(".", "_").Replace("@", "_");

            var imageStream = await MobileClient.Util.SharePointProvider.GetUserPhoto(ConfigurationHub.ReadConfigurationValue("SharePointResource"), State.SharePointToken, sharePointUser);

            if (imageStream != null)
            {
                var memStream = new MemoryStream();
                var bitmap    = new BitmapImage();

                await imageStream.CopyToAsync(memStream);

                memStream.Position = 0;
                bitmap.SetSource(memStream.AsRandomAccessStream());

                this.UserImage = bitmap;
            }
            else
            {
                this.UserImage = new BitmapImage(new System.Uri("ms-appx:///Assets/UserImage.png"));
            }
        }
 public FacilityRequest GetFacilityRequest()
 {
     return(new FacilityRequest {
         Id = this.Id,
         User = this.User,
         RoomType = this.RoomType,
         Building = this.Building,
         Room = this.Room,
         GeoLocation = this.GeoLocation,
         Zip = this.Zip,
         Street = this.Street,
         State = this.State,
         City = this.City,
         BTLEId = this.BTLEId,
         BeforeImageUrl = this.BeforeImageUrl ?? ConfigurationHub.ReadConfigurationValue("CameraThumbnail"),
         AfterImageUrl = this.AfterImageUrl ?? ConfigurationHub.ReadConfigurationValue("CameraThumbnail"),
         ProblemDescription = this.ProblemDescription,
         ServiceNotes = this.ServiceNotes,
         DocId = this.DocId,
         RequestedDate = this.RequestedDate,
         CompletedDate = this.CompletedDate,
         Version = this.Version,
     });
 }
Пример #9
0
 protected async Task InitUserInfo()
 {
     this.UserName    = ConfigurationHub.ReadConfigurationValue("UserName");
     this.UserSurname = ConfigurationHub.ReadConfigurationValue("UserSurname");
     await this.GetUserImage();
 }
Пример #10
0
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     MobileServiceClientProvider.InitializeClient(ConfigurationHub.ReadConfigurationValue("MobSvcUri"), ConfigurationHub.ReadConfigurationValue("AppKey"));
 }