Exemple #1
0
        private void RefreshFileSystemTree()
        {
            var uiRequest = new DispatchThreadServerRequest {
                Request = new RefreshFileSystemTreeRequest(),
                Id      = "RefreshFileSystemTreeRequest",
                Delay   = TimeSpan.FromSeconds(0.0),
            };

            _dispatchThreadServerRequestExecutor.Post(uiRequest);
        }
Exemple #2
0
        public void RefreshFileSystemTree()
        {
            var uiRequest = new DispatchThreadServerRequest {
                Request          = new RefreshFileSystemTreeRequest(),
                Id               = "RefreshFileSystemTreeRequest",
                Delay            = TimeSpan.FromSeconds(0.0),
                OnThreadPoolSend = () => {
                    _performSearchOnNextRefresh = true;
                }
            };

            _dispatchThreadServerRequestExecutor.Post(uiRequest);
        }
        private void SearchFilesPaths(string searchPattern, bool immediate)
        {
            var processedSearchPattern = PreproccessFilePathSearchString(searchPattern);

            // Cancel all previously running tasks
            _taskCancellation.CancelAll();
            var cancellationToken = _taskCancellation.GetNewToken();

            var id         = Interlocked.Increment(ref _operationSequenceId);
            var progressId = string.Format("{0}-{1}", OperationsIds.SearchFilePaths, id);
            var sw         = new Stopwatch();
            var request    = new DispatchThreadServerRequest {
                // Note: Having a single ID for all searches ensures previous search
                // requests are superseeded.
                Id      = "MetaSearch",
                Request = new SearchFilePathsRequest {
                    SearchParams = new SearchParams {
                        SearchString    = processedSearchPattern,
                        MaxResults      = 200, // TM_TODO
                        MatchCase       = false,
                        MatchWholeWord  = false,
                        IncludeSymLinks = true,
                        UseRe2Engine    = true,
                        Regex           = false,
                    }
                },
                Delay = TimeSpan.FromMilliseconds(immediate ? 0 : GlobalSettings.AutoSearchDelayMsec), OnThreadPoolSend = () => { sw.Start(); }, OnThreadPoolReceive = () => { sw.Stop(); }, OnDispatchThreadSuccess = typedResponse => {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }
                    var response = ((SearchFilePathsResponse)typedResponse);
                    var msg      = string.Format("Found {0:n0} path(s) among {1:n0} ({2:0.00} seconds) matching pattern \"{3}\"",
                                                 response.HitCount,
                                                 response.TotalCount,
                                                 sw.Elapsed.TotalSeconds,
                                                 processedSearchPattern);
                    var viewModel = CreateSearchFilePathsResult(response.SearchResult, msg, "", true);
                    ViewModel.UpdateFileList(viewModel);
                    _control.UpdateSelection();
                }, OnDispatchThreadError = errorResponse => {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }
                }
            };

            _dispatchThreadServerRequestExecutor.Post(request);
        }
Exemple #4
0
        private void SendUnregisterFileRequest(string path)
        {
            if (!IsValidPath(path))
            {
                return;
            }

            var request = new DispatchThreadServerRequest {
                Id      = "UnregisterFileRequest-" + path,
                Request = new UnregisterFileRequest {
                    FileName = path
                }
            };

            _dispatchThreadServerRequestExecutor.Post(request);
        }
Exemple #5
0
        private void SendRegisterFileRequest(string path)
        {
            if (!IsPhysicalFile(path))
            {
                return;
            }

            var request = new DispatchThreadServerRequest {
                Id      = "RegisterFileRequest-" + path,
                Request = new RegisterFileRequest {
                    FileName = path
                }
            };

            _dispatchThreadServerRequestExecutor.Post(request);
        }
Exemple #6
0
        private void SearchWorker(SearchWorkerParams workerParams)
        {
            // Cancel all previously running tasks
            _taskCancellation.CancelAll();
            var cancellationToken = _taskCancellation.GetNewToken();

            var id         = Interlocked.Increment(ref _operationSequenceId);
            var progressId = string.Format("{0}-{1}", workerParams.OperationName, id);
            var sw         = new Stopwatch();
            var request    = new DispatchThreadServerRequest {
                // Note: Having a single ID for all searches ensures previous search
                // requests are superseeded.
                Id               = "MetaSearch",
                Request          = workerParams.TypedRequest,
                Delay            = workerParams.Delay,
                OnThreadPoolSend = () => {
                    sw.Start();
                    _progressBarTracker.Start(progressId, workerParams.HintText);
                },
                OnThreadPoolReceive = () => {
                    sw.Stop();
                    _progressBarTracker.Stop(progressId);
                },
                OnDispatchThreadSuccess = typedResponse => {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }
                    workerParams.ProcessResponse(typedResponse, sw);
                },
                OnDispatchThreadError = errorResponse => {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        return;
                    }
                    workerParams.ProcessError(errorResponse, sw);
                }
            };

            _dispatchThreadServerRequestExecutor.Post(request);
        }
Exemple #7
0
        public static void LoadFileExtracts(ICodeSearchController host, string path, IEnumerable <FlatFilePositionViewModel> filePositions)
        {
            var positions = filePositions.ToList();

            if (!positions.Any())
            {
                return;
            }

            var request = new GetFileExtractsRequest
            {
                FileName         = path,
                MaxExtractLength = host.GlobalSettings.MaxTextExtractLength,
                Positions        = positions
                                   .Select(x => new FilePositionSpan
                {
                    Position = x.Position,
                    Length   = x.Length
                })
                                   .ToList()
            };

            var uiRequest = new DispatchThreadServerRequest
            {
                Request = request,
                Id      = "FlatFilePositionViewModel-" + path,
                Delay   = TimeSpan.FromSeconds(0.0),
                OnDispatchThreadSuccess = (typedResponse) => {
                    var response = (GetFileExtractsResponse)typedResponse;
                    positions
                    .Zip(response.FileExtracts, (x, y) => new {
                        FilePositionViewModel = x,
                        FileExtract           = y
                    })
                    .Where(x => x.FileExtract != null)
                    .ForAll(x => x.FilePositionViewModel.SetTextExtract(x.FileExtract));
                }
            };

            host.DispatchThreadServerRequestExecutor.Post(uiRequest);
        }
Exemple #8
0
        public void FetchDatabaseStatisticsImpl(string requestId, TimeSpan?delay, bool forceGarbageCollect,
                                                Action <GetDatabaseStatisticsResponse> callback)
        {
            var request = new DispatchThreadServerRequest {
                Id      = requestId,
                Request = new GetDatabaseStatisticsRequest {
                    ForceGabageCollection = forceGarbageCollect
                },
                OnDispatchThreadSuccess = typedResponse => {
                    var response = (GetDatabaseStatisticsResponse)typedResponse;
                    callback(response);
                }
            };

            if (delay != null)
            {
                request.Delay = delay.Value;
            }

            _dispatchThreadServerRequestExecutor.Post(request);
        }
        private void LoadFileExtracts()
        {
            var positions = GetChildren()
                            .OfType <FilePositionViewModel>()
                            .ToList();

            if (!positions.Any())
            {
                return;
            }

            var request = new GetFileExtractsRequest {
                FileName         = Path,
                MaxExtractLength = Controller.GlobalSettings.MaxTextExtractLength,
                Positions        = positions
                                   .Select(x => new FilePositionSpan {
                    Position = x.Position,
                    Length   = x.Length
                })
                                   .ToList()
            };

            var uiRequest = new DispatchThreadServerRequest {
                Request = request,
                Id      = "FileEntryViewModel-" + Path,
                Delay   = TimeSpan.FromSeconds(0.0),
                OnDispatchThreadSuccess = (typedResponse) => {
                    var response = (GetFileExtractsResponse)typedResponse;
                    positions
                    .Zip(response.FileExtracts, (x, y) => new {
                        FilePositionViewModel = x,
                        FileExtract           = y
                    })
                    .Where(x => x.FileExtract != null)
                    .ForAll(x => x.FilePositionViewModel.SetTextExtract(x.FileExtract));
                }
            };

            this.Controller.DispatchThreadServerRequestExecutor.Post(uiRequest);
        }