protected async override Task ExecuteOperation(IFileMetadataStore metadataStore, IFileSyncContext context) { MobileServiceFileMetadata metadata = await metadataStore.GetFileMetadataAsync(FileId); if (metadata != null) { var dataSource = await context.SyncHandler.GetDataSource(metadata); await context.MobileServiceFilesClient.UploadFileAsync(metadata, dataSource); } }
protected async override Task ExecuteOperation(IFileMetadataStore metadataStore, IFileSyncContext context) { MobileServiceFileMetadata metadata = await metadataStore.GetFileMetadataAsync(FileId); if (metadata != null) { await metadataStore.DeleteAsync(metadata); await context.MobileServiceFilesClient.DeleteFileAsync(metadata); } }
/// <summary> /// Initializes the file synchronization capabilities of the <see cref="IMobileServiceClient"/>. Offline sync must also be initialized by calling /// IMobileServiceClient.SyncContext.InitializeAsync. /// </summary> /// <param name="client">IMobileServiceClient instance</param> /// <param name="context"></param> /// <returns>An instance of <see cref="IFileSyncContext"/></returns> public static IFileSyncContext InitializeFileSyncContext(this IMobileServiceClient client, IFileSyncContext context) { lock (contextsSyncRoot) { if (contexts.ContainsKey(client)) { throw new InvalidOperationException("The file sync context has already been initialized."); } contexts.Add(client, context); return context; } }
public async Task Execute(IFileMetadataStore metadataStore, IFileSyncContext context) { try { this.State = FileOperationState.InProcess; await ExecuteOperation(metadataStore, context); } catch { this.State = FileOperationState.Failed; throw; } this.State = FileOperationState.Succeeded; }
public CustomFileSyncTrigger(IFileSyncContext fileSyncContext, IMobileServiceClient mobileServiceClient, bool autoUpdateParentRecords) { if (fileSyncContext == null) { throw new ArgumentNullException("fileSyncContext"); } if (mobileServiceClient == null) { throw new ArgumentNullException("mobileServiceClient"); } this.fileSyncContext = fileSyncContext; this.mobileServiceClient = mobileServiceClient; this.dataChangeNotificationSubscription = mobileServiceClient.EventManager.Subscribe<StoreOperationCompletedEvent>(OnStoreOperationCompleted); if (autoUpdateParentRecords) { this.fileChangeNotificationSubscription = mobileServiceClient.EventManager.Subscribe<FileOperationCompletedEvent>(OnFileOperationCompleted); } }
public IList <IFileSyncTrigger> CreateTriggers(IFileSyncContext fileSyncContext) { return(new List <IFileSyncTrigger> { new EntityDataFileSyncTrigger(fileSyncContext, this.mobileServiceClient, this.autoUpdateRecords) }); }
protected async override Task ExecuteOperation(IFileMetadataStore metadataStore, IFileSyncContext context) { MobileServiceFileMetadata metadata = await metadataStore.GetFileMetadataAsync(FileId); if (metadata != null) { IMobileServiceFileDataSource dataSource = await context.SyncHandler.GetDataSource(metadata); await context.MobileServiceFilesClient.UploadFileAsync(metadata, dataSource); await metadataStore.CreateOrUpdateAsync(metadata); } }
protected abstract Task ExecuteOperation(IFileMetadataStore metadataStore, IFileSyncContext context);
public async static Task AddFileAsync <T>(this IMobileServiceSyncTable <T> table, MobileServiceFile file) { IFileSyncContext context = table.MobileServiceClient.GetFileSyncContext(); await context.AddFileAsync(file); }
public async static Task PullFilesAsync <T>(this IMobileServiceSyncTable <T> table, T dataItem) { IFileSyncContext context = table.MobileServiceClient.GetFileSyncContext(); await context.PullFilesAsync(table.TableName, GetDataItemId(dataItem)); }
public async static Task PushFileChangesAsync <T>(this IMobileServiceSyncTable <T> table) { IFileSyncContext context = table.MobileServiceClient.GetFileSyncContext(); await context.PushChangesAsync(CancellationToken.None); }
public async static Task PurgeFilesAsync <T>(this IMobileServiceSyncTable <T> table) { IFileSyncContext context = table.MobileServiceClient.GetFileSyncContext(); await context.MetadataStore.PurgeAsync(table.TableName); }
public IList<IFileSyncTrigger> CreateTriggers(IFileSyncContext fileSyncContext) { return new List<IFileSyncTrigger> { new CustomFileSyncTrigger(fileSyncContext, this.mobileServiceClient, this.autoUpdateRecords) }; }
public IList <IFileSyncTrigger> CreateTriggers(IFileSyncContext fileSyncContext) { return(new List <IFileSyncTrigger> { new CustomFileSyncTrigger(fileSyncContext, this._mobileServiceClient, this._autoUpdateRecords) }); }