示例#1
0
        private void CreateDocument(DocumentHistory history)
        {
            _logger.LogDebug("create document: {0}", history.Path);

            if (_documentsByPath.TryGetValue(history.Path, out var _))
            {
                _logger.LogWarning($"invalid created log found: {history.Id}");
                UpdateDocument(history);
            }

            var document = new MaintainanceDocument()
            {
                DocumentId   = _documentId++,
                Path         = history.Path,
                StorageKey   = history.StorageKey,
                ContentType  = history.ContentType,
                FileSize     = history.FileSize,
                Hash         = history.Hash,
                Created      = history.Created,
                LastModified = history.LastModified,
                Histories    = new List <DocumentHistory>()
                {
                    history
                }
            };

            _documentStore.Add(document.DocumentId, document);
            _documentsByPath.Add(document.Path, document);
        }
示例#2
0
 private async Task FixHistoryIfNeededAsync(IConfiguration configuration, Document document, MaintainanceDocument doc)
 {
     using (var context = CreateContext(configuration))
     {
         doc.Histories.ForEach(h => h.DocumentId = document.Id);
         await context.SaveChangesAsync().ConfigureAwait(false);
     }
 }