Beispiel #1
0
        public static async Task <BitmapImage> GetImageAsync(string uri)
        {
            var folder = await ImageCacheHelper.GetFolderAsync(ImageType.Captcha);

            var file = await folder.CreateFileAsync(GetMD5(uri));

            return(await DownloadImageAsync(new Uri(uri), file));
        }
Beispiel #2
0
        public static async Task <BitmapImage> GetImageAsync(string uri)
        {
            var folder = await ImageCacheHelper.GetFolderAsync(ImageType.Captcha);

            var file = await folder.CreateFileAsync(Utils.GetMD5(uri));

            var s = await GetStreamAsync(new Uri(uri), GetCoolapkCookies());

            using (var ss = await file.OpenStreamForWriteAsync())
            {
                await s.CopyToAsync(ss);
            }

            return(new BitmapImage(new Uri(file.Path)));
        }
Beispiel #3
0
        public static async Task <bool> CheckLoginInfo()
        {
            try
            {
                using (var filter = new Windows.Web.Http.Filters.HttpBaseProtocolFilter())
                {
                    var    cookieManager = filter.CookieManager;
                    string uid = string.Empty, token = string.Empty, userName = string.Empty;
                    foreach (var item in cookieManager.GetCookies(new Uri("http://coolapk.com")))
                    {
                        switch (item.Name)
                        {
                        case "uid":
                            uid = item.Value;
                            break;

                        case "username":
                            userName = item.Value;
                            break;

                        case "token":
                            token = item.Value;
                            break;
                        }
                    }
                    if (!string.IsNullOrEmpty(uid) && !string.IsNullOrEmpty(token) && !string.IsNullOrEmpty(userName))
                    {
                        Set(Uid, uid);
                        Set(UserName, userName);
                        var o = (JObject)await DataHelper.GetDataAsync(DataUriType.CheckLoginInfo);

                        UIHelper.NotificationNums.Initial((JObject)o["notifyCount"]);
                        UIHelper.RaiseUserAvatarChangedEvent(await ImageCacheHelper.GetImageAsync(ImageType.BigAvatar, o.Value <string>("userAvatar")));
                        var uri = ((JObject)await DataHelper.GetDataAsync(DataUriType.GetUserProfile, uid)).Value <string>("userAvatar");
                        Set(UserAvatar, uri);
                        UIHelper.RaiseUserAvatarChangedEvent(await ImageCacheHelper.GetImageAsync(ImageType.BigAvatar, uri));
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch { throw; }
        }