public StoreDocument AddExtractedText(Guid id, string extractedText) { var c = NewConnection(); const string textExtractedState = "text-extracted"; StoreDocument document = this.documentTable.Get(id).Pluck("state").Run<StoreDocument>(c); string[] states = new string[] { }; if (!document.State.Contains(textExtractedState)) { var state = document.State.ToList(); state.Add(textExtractedState); states = state.ToArray(); } var update = new { extractedText = extractedText, updated = DateTime.UtcNow, state = states }; var result = this.documentTable.Get(id).Update(update).Run(c); return GetDocument(id); }
public DocumentAddResult AddDocument(Document document) { var storeInstance = this.store.Value; var toSave = new StoreDocument(document) { Inserted = DateTime.UtcNow, Updated = DateTime.UtcNow, State = new[] { "persisted" }, Version = 1, DocumentSequenceId = document.Id }; //first check if the document maybe already exists - right now we will jusBt override var existingDoc = store.Value.GetDocument("client_name_user", store.Value.R.Array(toSave.Client, toSave.Name, toSave.User)); if (existingDoc != null) { toSave.Version = existingDoc.Version + 1; toSave.DocumentSequenceId = existingDoc.DocumentSequenceId; } this.store.Value.InsertDocument(toSave); this.logger.LogInformation($"saved document '{document.Id}/{document.Name}' in db"); return(new DocumentAddResult() { Result = Result.Success, DocumentId = document.Id }); }
public StoreDocument GetDocument(Guid id) { //todo: is it smart to open the connection every time?? var c = NewConnection(); StoreDocument doc = this.documentTable.Get(id).Run<StoreDocument>(c); return doc; }
public static Document Convert(this StoreDocument input) { return(new Store.Document() { Client = input.Client, Content = input.Content, DocumentSequenceId = input.DocumentSequenceId, ExtractedText = input.ExtractedText, Id = input.Id, Name = input.Name, State = input.State, User = input.User, Version = input.Version }); }