예제 #1
0
            public bool CanInvokeRename(out TrackingSession trackingSession, bool isSmartTagCheck = false, bool waitForResult = false, CancellationToken cancellationToken = default(CancellationToken))
            {
                // This needs to be able to run on a background thread for the diagnostic.

                trackingSession = this.TrackingSession;
                if (trackingSession == null)
                {
                    return(false);
                }

                ISyntaxFactsService syntaxFactsService;
                IRenameTrackingLanguageHeuristicsService languageHeuristicsService;

                return(TryGetSyntaxFactsService(out syntaxFactsService) && TryGetLanguageHeuristicsService(out languageHeuristicsService) &&
                       trackingSession.CanInvokeRename(syntaxFactsService, languageHeuristicsService, isSmartTagCheck, waitForResult, cancellationToken));
            }
예제 #2
0
            private void StartTrackingSession(TextContentChangedEventArgs eventArgs)
            {
                AssertIsForeground();
                ClearTrackingSession();

                if (_inlineRenameService.ActiveSession != null)
                {
                    return;
                }

                // Synchronously find the tracking span in the old document.

                var change     = eventArgs.Changes.Single();
                var beforeText = eventArgs.Before.AsText();

                if (!TryGetSyntaxFactsService(out var syntaxFactsService))
                {
                    return;
                }

                var leftSidePosition  = change.OldPosition;
                var rightSidePosition = change.OldPosition + change.OldText.Length;

                while (
                    leftSidePosition > 0 &&
                    IsTrackableCharacter(syntaxFactsService, beforeText[leftSidePosition - 1])
                    )
                {
                    leftSidePosition--;
                }

                while (
                    rightSidePosition < beforeText.Length &&
                    IsTrackableCharacter(syntaxFactsService, beforeText[rightSidePosition])
                    )
                {
                    rightSidePosition++;
                }

                var originalSpan = new Span(leftSidePosition, rightSidePosition - leftSidePosition);

                this.TrackingSession = new TrackingSession(
                    this,
                    new SnapshotSpan(eventArgs.Before, originalSpan),
                    _asyncListener
                    );
            }
        public async Task UpdateLocation(VehicleLocationRequest model)
        {
            var vehicle = _vehicleRepository.FindOneByCondition(x => x.VehicleNumber == model.VehicleNumber && x.IsActive);

            if (vehicle == null)
            {
                throw new VehicleNotFoundException(ErrorCode.E102, model.VehicleNumber);
            }

            //Check session was created or not
            var session = _trackingSessionRepository.FindOneByCondition(x =>
                                                                        x.CreatedDate >= DateTime.UtcNow.Date &&
                                                                        x.VehicleId == vehicle.Id);

            if (session == null)
            {
                session = new TrackingSession()
                {
                    VehicleId      = vehicle.Id,
                    CreatedDate    = DateTime.UtcNow,
                    TrackingRemark = DateTime.UtcNow.ToString("d")
                };
                _trackingSessionRepository.Create(session);
                await _trackingSessionRepository.SaveAsync();
            }

            //Update Location with this session
            var location = new TrackingHistory()
            {
                TrackingSessionId = session.Id,
                CreatedDate       = DateTime.UtcNow,
                Lat = model.Latitude,
                Lon = model.Longitude
            };

            _trackingHistoryRepository.Create(location);
            await _trackingHistoryRepository.SaveAsync();
        }
예제 #4
0
            public bool ClearTrackingSession()
            {
                ThreadingContext.ThrowIfNotOnUIThread();

                if (this.TrackingSession != null)
                {
                    // Disallow the existing TrackingSession from triggering IdentifierFound.
                    var previousTrackingSession = this.TrackingSession;
                    this.TrackingSession = null;

                    previousTrackingSession.Cancel();

                    // If there may have been a tag showing, then actually clear the tags.
                    if (previousTrackingSession.IsDefinitelyRenamableIdentifier())
                    {
                        TrackingSessionCleared(previousTrackingSession.TrackingSpan);
                    }

                    return(true);
                }

                return(false);
            }
예제 #5
0
            public bool ClearVisibleTrackingSession()
            {
                AssertIsForeground();

                if (
                    this.TrackingSession != null &&
                    this.TrackingSession.IsDefinitelyRenamableIdentifier()
                    )
                {
                    var document =
                        _buffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
                    if (document != null)
                    {
                        // When rename tracking is dismissed via escape, we no longer wish to
                        // provide a diagnostic/codefix, but nothing has changed in the workspace
                        // to trigger the diagnostic system to reanalyze, so we trigger it
                        // manually.

                        _diagnosticAnalyzerService?.Reanalyze(
                            document.Project.Solution.Workspace,
                            documentIds: SpecializedCollections.SingletonEnumerable(document.Id),
                            highPriority: true
                            );
                    }

                    // Disallow the existing TrackingSession from triggering IdentifierFound.
                    var previousTrackingSession = this.TrackingSession;
                    this.TrackingSession = null;

                    previousTrackingSession.Cancel();
                    TrackingSessionCleared(previousTrackingSession.TrackingSpan);
                    return(true);
                }

                return(false);
            }
            public void OnTrackingSessionUpdated(TrackingSession trackingSession)
            {
                AssertIsForeground();

                if (this.TrackingSession == trackingSession)
                {
                    TrackingSessionUpdated();
                }
            }
            public bool CanInvokeRename(out TrackingSession trackingSession, bool isSmartTagCheck = false, bool waitForResult = false, CancellationToken cancellationToken = default(CancellationToken))
            {
                // This needs to be able to run on a background thread for the diagnostic.

                trackingSession = this.TrackingSession;
                if (trackingSession == null)
                {
                    return false;
                }

                ISyntaxFactsService syntaxFactsService;
                IRenameTrackingLanguageHeuristicsService languageHeuristicsService;
                return TryGetSyntaxFactsService(out syntaxFactsService) && TryGetLanguageHeuristicsService(out languageHeuristicsService) &&
                    trackingSession.CanInvokeRename(syntaxFactsService, languageHeuristicsService, isSmartTagCheck, waitForResult, cancellationToken);
            }
예제 #8
0
 /// <summary>
 /// Update the database with the provided tracking session entity.
 /// </summary>
 /// <param name="trackingSession"></param>
 public void Update(TrackingSession trackingSession)
 {
     _dataStore.Save(trackingSession);
 }
예제 #9
0
 /// <summary>
 /// Delete the provided tracking session from the database.
 /// </summary>
 /// <param name="trackingSession"></param>
 public void Delete(TrackingSession trackingSession)
 {
     _dataStore.Delete(trackingSession);
 }
 public UndoPrimitive(StateMachine stateMachine, bool shouldRestoreStateOnUndo)
 {
     _stateMachine = stateMachine;
     _trackingSession = shouldRestoreStateOnUndo ? stateMachine.TrackingSession : null;
 }
            public void RestoreTrackingSession(TrackingSession trackingSession)
            {
                AssertIsForeground();
                ClearTrackingSession();

                this.TrackingSession = trackingSession;
                TrackingSessionUpdated();
            }
 public UndoPrimitive(StateMachine stateMachine, bool shouldRestoreStateOnUndo)
 {
     _stateMachine    = stateMachine;
     _trackingSession = shouldRestoreStateOnUndo ? stateMachine.TrackingSession : null;
 }