示例#1
0
        /// <summary>
        ///     异步获得实例
        /// </summary>
        /// <returns></returns>
        public async Task <ImageFolderList> GetInstanceAsync(FolderModel folderModel)
        {
            var imageFolderList = new ImageFolderList(folderModel);
            // 初始化list
            var query = imageFolderList.DatabaseHelper.ImageDatabase.GetQuery(folderModel.KeyNo);

            while (query.Read())
            {
                var imagePath   = query.GetString(2);
                var accessToken = query.GetString(3);
                var imageModel  =
                    await _imageModelService.GetInstanceAsync(query.GetInt32(1), imagePath, accessToken);

                // 查下这个图片还在不在
                if (imageModel != null)
                {
                    imageModel.KeyNo = query.GetInt32(0);
                    imageFolderList.ImageModels.Add(imageModel);
                }
                else
                {
                    // 从数据库里删掉这个图片
                    imageFolderList.DatabaseHelper.ImageDatabase.Delete(imagePath);
                    // 从使用list里删掉这个文件夹
                    StorageApplicationPermissions.FutureAccessList.Remove(accessToken);
                }
            }
            return(imageFolderList);
        }
示例#2
0
        /// <summary>
        ///     异步获取实例
        /// </summary>
        /// <returns>回忆列表</returns>
        public async Task <MemoryList> GetInstanceAsync()
        {
            var memoryList = new MemoryList();
            // 初始化list
            var query = memoryList.DatabaseHelper.MemoryListDatabase.GetQuery();

            while (query.Read())
            {
                var memoryKeyNo = query.GetInt32(0);
                // 初始化图片list
                var imageModels = new List <ImageModel>();
                var imageQuery  = memoryList.DatabaseHelper.MemoryImageDatabase.GetQuery(memoryKeyNo);
                while (imageQuery.Read())
                {
                    var imagePath   = imageQuery.GetString(2);
                    var accessToken = imageQuery.GetString(3);
                    var imageModel  = await _imageModelService.GetInstanceAsync(imageQuery.GetInt32(1), imagePath, accessToken);

                    // 查下这个图片还在不在
                    if (imageModel != null)
                    {
                        imageModel.KeyNo = imageQuery.GetInt32(0);
                        imageModel       = await _imageModelService.GetThumbnailImageAsync(400, imageModel);

                        imageModels.Add(imageModel);
                    }
                    else
                    {
                        // 从数据库里删掉这个图片
                        memoryList.DatabaseHelper.ImageDatabase.Delete(imagePath);
                        // 从使用list里删掉这个文件夹
                        StorageApplicationPermissions.FutureAccessList.Remove(accessToken);
                    }
                }
                // 初始化回忆model
                var memoryModel = new MemoryModel
                {
                    KeyNo       = memoryKeyNo,
                    MemoryName  = query.GetString(1),
                    ImageModels = imageModels
                };
                memoryModel.CoverImage = memoryModel.ImageModels[0].ThumbnailImage;
                memoryList.MemoryModels.Add(memoryModel);
            }
            return(memoryList);
        }