private void button_Click_2(object sender, RoutedEventArgs e) { try { string locazioneFile = String.Empty; if (lstFiles.SelectedItem != null) { locazioneFile = ((SearchResult)(lstFiles.SelectedItem)).Indirizzo; } if (filesList.SelectedItem != null) { locazioneFile = ((FileHeader)(filesList.SelectedItem)).FullPath; } using (IDocumentSession session = RavenConnection.DocumentStore.OpenSession()) { Documento documento = session.Query <Documento>().Where(x => x.Indirizzo == locazioneFile.TrimStart(new[] { '/' })).FirstOrDefault(); if (documento != null) { session.Delete <Documento>(documento); } var command = new AsyncShardedFilesServerClient(FileStore.ShardStrategy); if (documento != null) { command.DeleteAsync(documento.Indirizzo); } else { command.DeleteAsync(locazioneFile); } session.SaveChanges(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } ReloadFiles(); }
public async Task Foo() { #region sharding_1 var shards = new Dictionary<string, IAsyncFilesCommands> { {"europe", new AsyncFilesServerClient("http://localhost:8080", "NorthwindFS")}, {"asia", new AsyncFilesServerClient("http://localhost:8081", "NorthwindFS")}, }; var shardStrategy = new ShardStrategy(shards) { /* ShardAccessStrategy = ... ShardResolutionStrategy = ... ModifyFileName = ... */ }; var shardedCommands = new AsyncShardedFilesServerClient(shardStrategy); #endregion #region file_operations string fileName = await shardedCommands.UploadAsync("test.bin", new RavenJObject() { { "Owner", "Admin" } }, new MemoryStream()); // will return either /europe/test.bin or /asia/test.bin name // you need to pass the returned file name here to let the client know on which shard the file exists using (var content = await shardedCommands.DownloadAsync(fileName)) { } string renamed = await shardedCommands.RenameAsync(fileName, "new.bin"); await shardedCommands.DeleteAsync(renamed); #endregion #region search_browse_operations FileHeader[] fileHeaders = await shardedCommands.BrowseAsync(); SearchResults searchResults = await shardedCommands.SearchAsync("__fileName:test*"); #endregion #region custom_shard_res_strategy_2 var strategy = new ShardStrategy(shards); strategy.ShardResolutionStrategy = new RegionMetadataBasedResolutionStrategy(shards.Keys.ToList(), strategy.ModifyFileName, strategy.Conventions); var client = new AsyncShardedFilesServerClient(strategy); #endregion }
public async Task Foo() { #region sharding_1 var shards = new Dictionary <string, IAsyncFilesCommands> { { "europe", new AsyncFilesServerClient("http://localhost:8080", "NorthwindFS") }, { "asia", new AsyncFilesServerClient("http://localhost:8081", "NorthwindFS") }, }; var shardStrategy = new ShardStrategy(shards) { /* * ShardAccessStrategy = ... * ShardResolutionStrategy = ... * ModifyFileName = ... */ }; var shardedCommands = new AsyncShardedFilesServerClient(shardStrategy); #endregion #region file_operations string fileName = await shardedCommands.UploadAsync("test.bin", new RavenJObject() { { "Owner", "Admin" } }, new MemoryStream()); // will return either /europe/test.bin or /asia/test.bin name // you need to pass the returned file name here to let the client know on which shard the file exists using (var content = await shardedCommands.DownloadAsync(fileName)) { } string renamed = await shardedCommands.RenameAsync(fileName, "new.bin"); await shardedCommands.DeleteAsync(renamed); #endregion #region search_browse_operations FileHeader[] fileHeaders = await shardedCommands.BrowseAsync(); SearchResults searchResults = await shardedCommands.SearchAsync("__fileName:test*"); #endregion #region custom_shard_res_strategy_2 var strategy = new ShardStrategy(shards); strategy.ShardResolutionStrategy = new RegionMetadataBasedResolutionStrategy(shards.Keys.ToList(), strategy.ModifyFileName, strategy.Conventions); var client = new AsyncShardedFilesServerClient(strategy); #endregion }