public static async Task <T[]> MoreLikeThisAsync <T>(this IAsyncAdvancedSessionOperations advancedSession, string index, string transformer, MoreLikeThisQuery parameters) { if (string.IsNullOrEmpty(index)) { throw new ArgumentException("Index name cannot be null or empty", "index"); } parameters.IndexName = index; parameters.ResultsTransformer = transformer; // /morelikethis/(index-name)/(ravendb-document-id)?fields=(fields) var cmd = ((AsyncDocumentSession)advancedSession).AsyncDatabaseCommands; var inMemoryDocumentSessionOperations = ((InMemoryDocumentSessionOperations)advancedSession); inMemoryDocumentSessionOperations.IncrementRequestCount(); var multiLoadOperation = new MultiLoadOperation(inMemoryDocumentSessionOperations, cmd.DisableAllCaching, null, null); MultiLoadResult multiLoadResult; do { multiLoadOperation.LogOperation(); using (multiLoadOperation.EnterMultiLoadContext()) { multiLoadResult = await cmd.MoreLikeThisAsync(parameters); } } while (multiLoadOperation.SetResult(multiLoadResult)); return(multiLoadOperation.Complete <T>()); }
public static Task <T[]> MoreLikeThisAsync <T>(this IAsyncAdvancedSessionOperations advancedSession, string index, string transformer, string documentId) { return(MoreLikeThisAsync <T>(advancedSession, index, transformer, new MoreLikeThisQuery { DocumentId = documentId })); }
/// <summary> /// Returns all previous document revisions for specified document (with paging). /// </summary> public static async Task <T[]> GetRevisionsForAsync <T>(this IAsyncAdvancedSessionOperations session, string id, int start = 0, int pageSize = 25) { var getRevisionsOperation = new GetRevisionOperation(); var command = getRevisionsOperation.CreateRequest(id, start, pageSize); await session.RequestExecuter.ExecuteAsync(command, session.Context).ConfigureAwait(false); return(ProcessResults <T>(session, command)); }
/// <summary> /// Returns all revision document keys for specified document (with paging). /// </summary> public static async Task <string[]> GetRevisionIdsForAsync <T>(this IAsyncAdvancedSessionOperations session, string id, int start, int pageSize) { var jsonDocuments = await((AsyncDocumentSession)session).AsyncDatabaseCommands.StartsWithAsync(id + "/revisions/", null, start, pageSize, metadataOnly: true).ConfigureAwait(false); return(jsonDocuments .Select(document => document.Key) .ToArray()); }
/// <summary> /// Returns all previous document revisions for specified document (with paging). /// </summary> public static async Task <T[]> GetRevisionsForAsync <T>(this IAsyncAdvancedSessionOperations session, string id, int start = 0, int pageSize = 25) { var inMemoryDocumentSessionOperations = (InMemoryDocumentSessionOperations)session; var jsonDocuments = await((AsyncDocumentSession)session).AsyncDatabaseCommands.GetRevisionsForAsync(id, start, pageSize).ConfigureAwait(false); return(jsonDocuments .Select(x => (T)inMemoryDocumentSessionOperations.ConvertToEntity(typeof(T), x.Key + "/__revisions", x.DataAsJson, x.Metadata)) .ToArray()); }
public static Task <T[]> MoreLikeThisAsync <TTransformer, T, TIndexCreator>(this IAsyncAdvancedSessionOperations advancedSession, MoreLikeThisQuery parameters) where TIndexCreator : AbstractIndexCreationTask, new() where TTransformer : AbstractTransformerCreationTask, new() { var indexCreator = new TIndexCreator(); var transformer = new TTransformer(); return(MoreLikeThisAsync <T>(advancedSession, indexCreator.IndexName, transformer.TransformerName, parameters)); }
public static Task <T[]> MoreLikeThisAsync <T, TIndexCreator>(this IAsyncAdvancedSessionOperations advancedSession, string documentId) where TIndexCreator : AbstractIndexCreationTask, new() { var indexCreator = new TIndexCreator(); return(MoreLikeThisAsync <T>(advancedSession, indexCreator.IndexName, null, new MoreLikeThisQuery { DocumentId = documentId })); }
/// <summary> /// Returns all previous document revisions for specified document (with paging). /// </summary> public static async Task <T[]> GetRevisionsForAsync <T>(this IAsyncAdvancedSessionOperations session, string id, int start, int pageSize) { var inMemoryDocumentSessionOperations = (InMemoryDocumentSessionOperations)session; var jsonDocuments = await((AsyncDocumentSession)session).AsyncDatabaseCommands.StartsWithAsync(id + "/revisions/", null, start, pageSize).ConfigureAwait(false); return(jsonDocuments .Select(inMemoryDocumentSessionOperations.TrackEntity <T>) .ToArray()); }
public static async Task <IEnumerable <string> > GetChildrenOf(this IAsyncAdvancedSessionOperations asyncAdvancedSessionOperations, Page page, RequestCulture requestCulture) { var site = await((AsyncDocumentSession)asyncAdvancedSessionOperations).LoadAsync <Site>($"sites/{requestCulture.Culture.TwoLetterISOLanguageName}"); return(site.Trie.ChildrenOf("/", true).Select(x => x.Value.PageId)); }
public AuditableAsyncAdvancedSessionOperationsDecorator(IAsyncAdvancedSessionOperations inner, object audit) { _inner = inner; _audit = audit; }
public static Task <T[]> MoreLikeThisAsync <T, TIndexCreator>(this IAsyncAdvancedSessionOperations advancedSession, MoreLikeThisQuery parameters) where TIndexCreator : AbstractIndexCreationTask, new() { var indexCreator = new TIndexCreator(); return(MoreLikeThisAsync <T>(advancedSession, indexCreator.IndexName, null, parameters)); }
public static async Task <OperationAllowedResult[]> IsOperationAllowedOnDocumentAsync(this IAsyncAdvancedSessionOperations session, string userId, string operation, params string[] documentIds) { var serverClient = ((AsyncDocumentSession)session).AsyncDatabaseCommands as AsyncServerClient; if (serverClient == null) { throw new InvalidOperationException("Cannot get whatever operation is allowed on document in embedded mode."); } var url = new StringBuilder("/authorization/IsAllowed/") .Append(Uri.EscapeUriString(userId)) .Append("?operation=") .Append(Uri.EscapeUriString(operation)); foreach (var docId in documentIds) { url.Append("&id=").Append(Uri.EscapeUriString(docId)); } var result = await serverClient.ExecuteGetRequest(url.ToString()).ConfigureAwait(false); return (session.DocumentStore.Conventions.CreateSerializer().Deserialize <OperationAllowedResult[]>( new RavenJTokenReader(result))); }
public static async Task <OperationAllowedResult> IsOperationAllowedOnDocumentAsync(this IAsyncAdvancedSessionOperations session, string userId, string operation, string documentId) { return((await IsOperationAllowedOnDocumentAsync(session, userId, operation, new[] { documentId }).ConfigureAwait(false)).First()); }