예제 #1
0
        internal static async Task <IEnumerable <FavourVolume> > GetUserFavoriteVolumesAsync(bool foreceRefresh = false)
        {
            bool IsSigninError = false;

            try
            {
                var fav = await GetAsync(CacheFolder, "user_fav", LightKindomHtmlClient.GetUserFavoriteVolumesAsync, TimeSpan.FromDays(1), foreceRefresh);

                return(fav);
            }
            catch (NotSignedInException)
            {
                IsSigninError = true;
            }
            catch (Exception excp)
            {
                throw excp;
            }
            if (IsSigninError)
            {
                if (await AppGlobal.SignInAutomaticllyAsync(true))
                {
                    return(await GetAsync(CacheFolder, "user_fav.json", LightKindomHtmlClient.GetUserFavoriteVolumesAsync, TimeSpan.FromDays(1), true));
                }
            }
            return(null);
        }
예제 #2
0
        internal async Task <bool> TryLogInWithStoredCredentialAsync()
        {
            if (!IsOnline)
            {
                return(false);
            }
            var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();

            if (AppGlobal.IsSignedIn)
            {
                IsSignedIn = true;
                UserName   = AppGlobal.User.UserName;
            }
            else
            {
                var userName = AppGlobal.Settings.UserName;
                var password = AppGlobal.Settings.Password;
                if (String.IsNullOrEmpty(password) || String.IsNullOrEmpty(userName))
                {
                    return(false);
                }
                UserName   = resourceLoader.GetString("LoginIndicator");
                IsSignedIn = await AppGlobal.SignInAutomaticllyAsync();

                if (IsSignedIn)
                {
                    UserName = AppGlobal.User.UserName;
                }
                else
                {
                    UserName = resourceLoader.GetString("LoginLabel");
                }
            }
            return(IsSignedIn);
        }