Esempio n. 1
0
        private async void CheckAlreadyExists()
        {
            var data = StorageService.Instance.Storage.RetrieveList <PassportDataModel>();

            if (data != null && data.Count > 0)
            {
                var dm = data[0];

                var apis = StorageService.Instance.Storage.RetrieveList <APIKeyDataModel>();
                if (apis != null && apis.Count > 0)
                {
                    apiKey = apis.Where(x => x.Id == dm.APIKeyFKID).FirstOrDefault();
                }

                RequestToken = new OAuthRequestToken()
                {
                    Token = dm.Token, TokenSecret = dm.TokenSecret
                };
                AccessToken = new OAuthAccessToken()
                {
                    Username    = dm.UserName,
                    FullName    = dm.FullName,
                    ScreenName  = dm.ScreenName,
                    Token       = dm.Token,
                    TokenSecret = dm.TokenSecret,
                    UserId      = dm.UserId,
                };
                IsLoggedIn = true;

                _flickr.OAuthAccessToken       = AccessToken.Token;
                _flickr.OAuthAccessTokenSecret = AccessToken.TokenSecret;

                _flickr.ApiKey    = apiKey.APIKey;
                _flickr.ApiSecret = apiKey.APISecret;

                var p = await _flickr.PeopleGetInfoAsync(AccessToken.UserId);

                if (!p.HasError)
                {
                    LoggedInUser = p.Result;
                }

                var favs = await _flickr.FavoritesGetListAsync(AccessToken.UserId);

                if (!favs.HasError)
                {
                    Favourites = favs.Result;
                }
            }
        }
Esempio n. 2
0
        private void GetLoggedInUserDetails(string userid)
        {
            //GET LOGGED IN USER DETAILS
            _flickr.PeopleGetInfoAsync(userid, new Action <FlickrResult <Person> >(p =>
            {
                if (!p.HasError)
                {
                    flickr_Person = p.Result;
                    Dispatcher.RunAsync(
                        Windows.UI.Core.CoreDispatcherPriority.High,
                        new Windows.UI.Core.DispatchedHandler(() =>
                    {
                        //imgUser.Source = new BitmapImage(new Uri(p.Result.BuddyIconUrl));
                        //brdAvatar.Opacity = 1;

                        //lblName.Text = p.Result.UserName;

                        //spLogin.Visibility = Visibility.Collapsed;
                        //spLoggedIn.Visibility = Visibility.Visible;

                        //lblProject.Visibility = Visibility.Visible;
                    })
                        );
                }
            }));


            //GET LOGGED IN USERS PUBLIC PICTURES
            _flickr.PeopleGetPublicPhotosAsync(userid, new Action <FlickrResult <PhotoCollection> >(pc =>
            {
                if (!pc.HasError)
                {
                    PersonPhotos = pc.Result;


                    Dispatcher.RunAsync(
                        Windows.UI.Core.CoreDispatcherPriority.High,
                        new Windows.UI.Core.DispatchedHandler(() =>
                    {
                        //lbPhotos.ItemsSource = PersonPhotos;
                    })
                        );
                }
            }));
        }
Esempio n. 3
0
        private async void PopulatePassportData()
        {
            if (apiKey == null)
            {
                IsLoginVisible = Visibility.Visible; return;
            }

            var data = StorageService.Instance.Storage.RetrieveList <PassportDataModel>();

            if (data != null && data.Count > 0)
            {
                IsLoginVisible = Visibility.Visible;
                IsTabsVisible  = Visibility.Collapsed;

                var dm = data.Where(x => x.PassType == GroupingType).FirstOrDefault();
                if (dm != null)
                {
                    IsLoginVisible = Visibility.Collapsed;
                    IsTabsVisible  = Visibility.Visible;

                    RequestToken = new OAuthRequestToken()
                    {
                        Token = dm.Token, TokenSecret = dm.TokenSecret
                    };
                    AccessToken = new OAuthAccessToken()
                    {
                        Username    = dm.UserName,
                        FullName    = dm.FullName,
                        ScreenName  = dm.ScreenName,
                        Token       = dm.Token,
                        TokenSecret = dm.TokenSecret,
                        UserId      = dm.UserId,
                    };
                    //IsLoggedIn = true;

                    _flickr.OAuthAccessToken       = AccessToken.Token;
                    _flickr.OAuthAccessTokenSecret = AccessToken.TokenSecret;

                    _flickr.ApiKey    = apiKey.APIKey;
                    _flickr.ApiSecret = apiKey.APISecret;

                    var p = await _flickr.PeopleGetInfoAsync(AccessToken.UserId);

                    if (!p.HasError)
                    {
                        LoggedInUser = p.Result;
                    }

                    var favs = await _flickr.FavoritesGetListAsync(AccessToken.UserId);

                    if (!favs.HasError)
                    {
                        var temp = new PhotoCollection();
                        foreach (var fav in favs.Result)
                        {
                            //fav.MachineTags = "https://c1.staticflickr.com/1/523/buddyicons/118877287@N03_l.jpg?1437204284#118877287@N03";
                            fav.MachineTags = $"https://c1.staticflickr.com/{fav.IconFarm}/{fav.IconServer}/buddyicons/{fav.UserId}.jpg?";
                            temp.Add(fav);
                        }
                        FavouritePhotos = temp;
                    }
                }
            }
            else
            {
                //no passport so show login button
                IsLoginVisible = Visibility.Visible;
                IsTabsVisible  = Visibility.Collapsed;
            }
        }