GetBasicPropertiesAsync() public method

public GetBasicPropertiesAsync ( ) : IAsyncOperation
return IAsyncOperation
コード例 #1
0
        async Task UpdateFolder(StorageFolder storageFolder)
        {
            var folder = await databaseConnection.Table<Folder>().Where(p => p.Path == storageFolder.Path).FirstOrDefaultAsync();

            if (folder == null)
            {
                folder = new Folder() { LastUpdateTime = DateTime.Now, CheckedToday = true, Path = storageFolder.Path };
                await databaseConnection.InsertAsync(folder);

                await UpdateFilesInFolder(folder.Id, storageFolder);
            }
            else
            {
                var dateChanged = (await storageFolder.GetBasicPropertiesAsync()).DateModified;
                if (dateChanged > folder.LastUpdateTime)
                {
                    await UpdateFilesInFolder(folder.Id, storageFolder);
                    folder.LastUpdateTime = DateTime.Now;
                }

                folder.CheckedToday = true;
                await databaseConnection.UpdateAsync(folder);
            }

            foreach (var subFolder in await storageFolder.GetFoldersAsync())
                await UpdateFolder(subFolder);
        }
コード例 #2
0
        private async Task UpdateFilesInFolder(int folderId, StorageFolder storageFolder)
        {
            var files = await databaseConnection.Table<File>().Where(p => p.FolderId == folderId).ToListAsync();

            foreach (var storageFile in await storageFolder.GetFilesAsync())
            {
                var file = files.Where(p => p.Path == storageFile.Path).FirstOrDefault();

                if (file == null)
                {
                    await databaseConnection.InsertAsync(new File() { LastUpdateTime = DateTime.Now, FolderId = folderId, Path = storageFile.Path });

                    await AddSong(storageFile);
                }
                else
                {
                    files.Remove(file);

                    var dateChanged = (await storageFolder.GetBasicPropertiesAsync()).DateModified;
                    if (dateChanged > file.LastUpdateTime)
                    {
                        await RemoveSong(storageFile.Path);
                        await AddSong(storageFile);

                        file.LastUpdateTime = DateTime.Now;
                        await databaseConnection.UpdateAsync(file);
                    }

                }
            }
        }