FromMetadata() 정적인 개인적인 메소드

Convert a MobileServiceFileMetadata into a MobileServiceFile
static private FromMetadata ( MobileServiceFileMetadata metadata ) : MobileServiceFile
metadata Microsoft.WindowsAzure.MobileServices.Files.Metadata.MobileServiceFileMetadata The instance
리턴 MobileServiceFile
        public async static Task <IEnumerable <MobileServiceFile> > GetFilesAsync <T>(this IMobileServiceSyncTable <T> table, T dataItem)
        {
            IFileSyncContext context = table.MobileServiceClient.GetFileSyncContext();

            var fileMetadata = await context.MetadataStore.GetMetadataAsync(table.TableName, GetDataItemId(dataItem));

            return(fileMetadata.Where(m => !m.PendingDeletion).Select(m => MobileServiceFile.FromMetadata(m)));
        }
예제 #2
0
        public async Task PullFilesAsync(string tableName, string itemId)
        {
            IEnumerable <MobileServiceFile> files = await this.mobileServiceFilesClient.GetFilesAsync(tableName, itemId);

            foreach (var file in files)
            {
                FileSynchronizationAction syncAction = FileSynchronizationAction.Update;

                MobileServiceFileMetadata metadata = await this.metadataStore.GetFileMetadataAsync(file.Id);

                if (metadata == null)
                {
                    syncAction = FileSynchronizationAction.Create;

                    metadata = MobileServiceFileMetadata.FromFile(file);

                    metadata.ContentMD5   = null;
                    metadata.LastModified = null;
                }

                if (string.Compare(metadata.ContentMD5, file.ContentMD5, StringComparison.Ordinal) != 0 ||
                    (metadata.LastModified == null || metadata.LastModified.Value.ToUniversalTime() != file.LastModified.Value.ToUniversalTime()))
                {
                    metadata.LastModified = file.LastModified;
                    metadata.ContentMD5   = file.ContentMD5;

                    await this.metadataStore.CreateOrUpdateAsync(metadata);

                    await this.syncHandler.ProcessFileSynchronizationAction(file, syncAction);

                    NotifyFileOperationCompletion(file, syncAction.ToFileOperationKind(), FileOperationSource.ServerPull);
                }
            }

            var fileMetadata = await this.metadataStore.GetMetadataAsync(tableName, itemId);

            var deletedItemsMetadata = fileMetadata.Where(m => !files.Any(f => string.Compare(f.Id, m.FileId) == 0));

            foreach (var metadata in deletedItemsMetadata)
            {
                IMobileServiceFileOperation pendingOperation = await this.operationsQueue.GetOperationByFileIdAsync(metadata.FileId);

                // TODO: Need to call into the sync handler for conflict resolution here...
                if (pendingOperation == null || pendingOperation is DeleteMobileServiceFileOperation)
                {
                    await metadataStore.DeleteAsync(metadata);

                    await this.syncHandler.ProcessFileSynchronizationAction(MobileServiceFile.FromMetadata(metadata), FileSynchronizationAction.Delete);

                    NotifyFileOperationCompletion(MobileServiceFile.FromMetadata(metadata), FileOperationKind.Delete, FileOperationSource.ServerPull);
                }
            }
        }
        public async Task UploadFileAsync(MobileServiceFileMetadata metadata, IMobileServiceFileDataSource dataSource)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource");
            }

            StorageToken token = await GetStorageToken(this.client, MobileServiceFile.FromMetadata(metadata), StoragePermissions.Write);

            await this.storageProvider.UploadFileAsync(metadata, dataSource, token);
        }
 private async Task <StorageToken> GetStorageToken(IMobileServiceClient client, MobileServiceFileMetadata metadata, StoragePermissions permissions)
 {
     return(await GetStorageToken(client, MobileServiceFile.FromMetadata(metadata), permissions));
 }