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 SendRegisterFileRequest(string path) { if (!IsPhysicalFile(path)) { return; } var request = new DispatchThreadServerRequest { Id = "RegisterFileRequest-" + path, Request = new RegisterFileRequest { FileName = path } }; _dispatchThreadServerRequestExecutor.Post(request); }
private void OnShowServerDetailsInvoked() { // Prepare the dialog window var dialog = new ServerDetailsDialog(); dialog.HasMinimizeButton = false; dialog.HasMaximizeButton = false; dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner; // Post async-request to fetch the server details _dispatchThreadServerRequestExecutor.Post( new DispatchThreadServerRequest { Id = Guid.NewGuid().ToString(), Delay = TimeSpan.Zero, Request = new GetDatabaseDetailsRequest { MaxFilesByExtensionDetailsCount = 500, MaxLargeFilesDetailsCount = 4000, }, OnDispatchThreadError = error => { // TODO: Display error message dialog.ViewModel.Waiting = false; }, OnDispatchThreadSuccess = typedResponse => { var response = (GetDatabaseDetailsResponse)typedResponse; var projectDetails = response.Projects.Select(x => new ProjectDetailsViewModel { ProjectDetails = x }).ToList(); foreach (var x in projectDetails) { x.ShowProjectConfigurationInvoked += (sender, args) => { ShowProjectConfiguration(x); }; } dialog.ViewModel.Projects.AddRange(projectDetails); if (dialog.ViewModel.Projects.Count > 0) { dialog.ViewModel.SelectedProject = dialog.ViewModel.Projects[0]; } dialog.ViewModel.Waiting = false; } }); // Show the dialog right away, waiting for a response for the above request // (The dialog shows a "Please wait..." message while waiting) dialog.ShowModal(); }
private void RefreshFileSystemTree() { var uiRequest = new DispatchThreadServerRequest { Request = new RefreshFileSystemTreeRequest(), Id = "RefreshFileSystemTreeRequest", Delay = TimeSpan.FromSeconds(0.0), }; _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); }