示例#1
0
        public Task ExecuteAsync(DbConnection connection, DbTransaction transaction, ISqlDialect dialect, ILogger logger)
        {
            var command = "delete from " + dialect.QuoteForTableName(_tablePrefix + IndexType.Name) + " where " + dialect.QuoteForColumnName("DocumentId") + " = @Id";

            logger.LogTrace(command);
            return(connection.ExecuteAsync(command, DocumentIds.Select(x => new { Id = x }), transaction));
        }
示例#2
0
        private async Task <ProjectStateChecksums> ComputeChecksumsAsync(CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.ProjectState_ComputeChecksumsAsync, FilePath, cancellationToken))
            {
                // get states by id order to have deterministic checksum
                var documentChecksumsTasks          = DocumentIds.Select(id => DocumentStates[id].GetChecksumAsync(cancellationToken));
                var additionalDocumentChecksumTasks = AdditionalDocumentIds.Select(id => AdditionalDocumentStates[id].GetChecksumAsync(cancellationToken));

                var serializer = new Serializer(_solutionServices.Workspace);

                var infoChecksum = serializer.CreateChecksum(ProjectInfo.Attributes, cancellationToken);

                // these compiler objects doesn't have good place to cache checksum. but rarely ever get changed.
                var compilationOptionsChecksum = SupportsCompilation ? ChecksumCache.GetOrCreate(CompilationOptions, _ => serializer.CreateChecksum(CompilationOptions, cancellationToken)) : Checksum.Null;
                var parseOptionsChecksum       = SupportsCompilation ? ChecksumCache.GetOrCreate(ParseOptions, _ => serializer.CreateChecksum(ParseOptions, cancellationToken)) : Checksum.Null;

                var projectReferenceChecksums  = ChecksumCache.GetOrCreate <ProjectReferenceChecksumCollection>(ProjectReferences, _ => new ProjectReferenceChecksumCollection(ProjectReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray()));
                var metadataReferenceChecksums = ChecksumCache.GetOrCreate <MetadataReferenceChecksumCollection>(MetadataReferences, _ => new MetadataReferenceChecksumCollection(MetadataReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray()));
                var analyzerReferenceChecksums = ChecksumCache.GetOrCreate <AnalyzerReferenceChecksumCollection>(AnalyzerReferences, _ => new AnalyzerReferenceChecksumCollection(AnalyzerReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray()));

                var documentChecksums = await Task.WhenAll(documentChecksumsTasks).ConfigureAwait(false);

                var additionalChecksums = await Task.WhenAll(additionalDocumentChecksumTasks).ConfigureAwait(false);

                return(new ProjectStateChecksums(
                           infoChecksum,
                           compilationOptionsChecksum,
                           parseOptionsChecksum,
                           new DocumentChecksumCollection(documentChecksums),
                           projectReferenceChecksums,
                           metadataReferenceChecksums,
                           analyzerReferenceChecksums,
                           new TextDocumentChecksumCollection(additionalChecksums)));
            }
        }
        public virtual Task <IList <IndexDocument> > GetDocumentsAsync(IList <string> documentIds)
        {
            var validDocumentIds         = DocumentIds?.Intersect(documentIds) ?? documentIds;
            IList <IndexDocument> result = validDocumentIds.Select(id => CreateDocument(id, Name)).ToArray();

            return(Task.FromResult(result));
        }
示例#4
0
        public Task <IReadOnlyCollection <IndexDocumentChange> > GetNextBatch()
        {
            IReadOnlyCollection <IndexDocumentChange> result = null;

            if (Skip < TotalCount)
            {
                var changes = DocumentIds
                              .Skip((int)Skip)
                              .Take((int)Take)
                              .Select(x => new IndexDocumentChange
                {
                    DocumentId = x,
                    ChangeDate = DateTime.UtcNow,
                    ChangeType = ChangeType
                })
                              .ToList();

                if (changes.Any())
                {
                    result = new ReadOnlyCollection <IndexDocumentChange>(changes);
                    Skip  += changes.Count;
                }
            }

            return(Task.FromResult(result));
        }
示例#5
0
        private async Task <ProjectStateChecksums> ComputeChecksumsAsync(CancellationToken cancellationToken)
        {
            using (Logger.LogBlock(FunctionId.ProjectState_ComputeChecksumsAsync, FilePath, cancellationToken))
            {
                // get states by id order to have deterministic checksum
                var documentChecksumsTasks          = DocumentIds.Select(id => DocumentStates[id].GetChecksumAsync(cancellationToken));
                var additionalDocumentChecksumTasks = AdditionalDocumentIds.Select(id => AdditionalDocumentStates[id].GetChecksumAsync(cancellationToken));

                var serializer = new Serializer(_solutionServices.Workspace.Services);

                var infoChecksum = serializer.CreateChecksum(new SerializedProjectInfo(Id, Version, Name, AssemblyName, Language, FilePath, OutputFilePath, IsSubmission), cancellationToken);

                var compilationOptionsChecksum = SupportsCompilation ? serializer.CreateChecksum(CompilationOptions, cancellationToken) : Checksum.Null;
                var parseOptionsChecksum       = SupportsCompilation ? serializer.CreateChecksum(ParseOptions, cancellationToken) : Checksum.Null;

                var projectReferenceChecksums  = new ProjectReferenceChecksumCollection(ProjectReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray());
                var metadataReferenceChecksums = new MetadataReferenceChecksumCollection(MetadataReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray());
                var analyzerReferenceChecksums = new AnalyzerReferenceChecksumCollection(AnalyzerReferences.Select(r => serializer.CreateChecksum(r, cancellationToken)).ToArray());

                var documentChecksums = await Task.WhenAll(documentChecksumsTasks).ConfigureAwait(false);

                var additionalChecksums = await Task.WhenAll(additionalDocumentChecksumTasks).ConfigureAwait(false);

                return(new ProjectStateChecksums(
                           infoChecksum,
                           compilationOptionsChecksum,
                           parseOptionsChecksum,
                           new DocumentChecksumCollection(documentChecksums),
                           projectReferenceChecksums,
                           metadataReferenceChecksums,
                           analyzerReferenceChecksums,
                           new TextDocumentChecksumCollection(additionalChecksums)));
            }
        }
示例#6
0
        /// <inheritdoc/>
        public void Visit(DocumentIds documentIds)
        {
            Ensure.IsNotNull(documentIds, nameof(documentIds));
            Ensure.IsNotNull(documentIds.Id, nameof(documentIds.Id));
            Ensure.ConditionIsMet(documentIds.Id.Length == 1, $"{nameof(documentIds.Id)} must have exactly one document id");

            documentIds.KustoQL = $"{IdColumnName} {KustoQLOperators.Equal} \"{documentIds.Id[0]}\"";
        }
示例#7
0
        public GetDocumentsOperation(Alachisoft.NosDB.Common.Protobuf.Command command) : base(command.ToBuilder())
        {
            _getDocumentsCommand = command.GetDocumentsCommand.ToBuilder();
            _documentId          = new List <IJSONDocument>();

            foreach (string document in _getDocumentsCommand.DocumentIdsList)
            {
                DocumentIds.Add(JSONDocument.Parse(document));
            }

            base.Message = this;
        }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // It is up to your application's business logic to determine which documents will compose the batch
                DocumentIds = Enumerable.Range(1, 10).ToList();                 // from 1 to 30

                // Populate the DocumentsListView with the batch documents
                DocumentsListView.DataSource = DocumentIds.ConvertAll(i => new DocumentItem()
                {
                    Id = i
                });
                DocumentsListView.DataBind();
            }
        }
示例#9
0
        public async Task <SerializableConflictResolution> DehydrateAsync(CancellationToken cancellationToken)
        {
            if (ErrorMessage != null)
            {
                return new SerializableConflictResolution {
                           ErrorMessage = ErrorMessage
                }
            }
            ;

            var documentTextChanges = await RemoteUtilities.GetDocumentTextChangesAsync(OldSolution, _newSolutionWithoutRenamedDocument, cancellationToken).ConfigureAwait(false);

            return(new SerializableConflictResolution
            {
                ReplacementTextValid = ReplacementTextValid,
                RenamedDocument = _renamedDocument,
                DocumentIds = DocumentIds.ToArray(),
                RelatedLocations = RelatedLocations.Select(loc => SerializableRelatedLocation.Dehydrate(loc)).ToArray(),
                DocumentTextChanges = documentTextChanges,
                DocumentToModifiedSpansMap = _documentToModifiedSpansMap.Select(kvp => (kvp.Key, kvp.Value)).ToArray(),
                DocumentToComplexifiedSpansMap = _documentToComplexifiedSpansMap.Select(kvp => (kvp.Key, kvp.Value.SelectAsArray(s => SerializableComplexifiedSpan.Dehydrate(s)))).ToArray(),
                DocumentToRelatedLocationsMap = _documentToRelatedLocationsMap.Select(kvp => (kvp.Key, kvp.Value.SelectAsArray(s => SerializableRelatedLocation.Dehydrate(s)))).ToArray(),
            });
        public virtual Task <IList <IndexDocumentChange> > GetChangesAsync(DateTime?startDate, DateTime?endDate, long skip, long take)
        {
            IList <IndexDocumentChange> result;

            if (startDate == null && endDate == null)
            {
                result = DocumentIds.Select(id => new IndexDocumentChange
                {
                    DocumentId = id,
                    ChangeType = IndexDocumentChangeType.Modified,
                    ChangeDate = DateTime.UtcNow
                })
                         .Skip((int)skip)
                         .Take((int)take)
                         .ToArray();
            }
            else
            {
                var changes = GetChangesQuery(startDate, endDate);
                result = changes.Skip((int)skip).Take((int)take).ToArray();
            }
            return(Task.FromResult(result));
        }
        public Task <IReadOnlyCollection <IndexDocumentChange> > GetNextBatch()
        {
            if (Skip >= TotalCount)
            {
                return(Task.FromResult <IReadOnlyCollection <IndexDocumentChange> >(null));
            }

            var changes = DocumentIds
                          .Skip((int)Skip)
                          .Take((int)Take)
                          .Select(x => new IndexDocumentChange
            {
                DocumentId = x,
                ChangeDate = DateTime.UtcNow,
                ChangeType = ChangeType
            })
                          .ToList();

            Skip += changes.Count;

            return(Task.FromResult((IReadOnlyCollection <IndexDocumentChange>)
                                   new ReadOnlyCollection <IndexDocumentChange>(changes)));
        }
 public void AddDocumentId(object documentId)
 {
     DocumentIds.Add((DocumentId)documentId);
 }