public static void DoClean(IWin32Window Owner, PerforceConnection PerforceClient, string LocalRootPath, string ClientRootPath, IReadOnlyList <string> SyncPaths, string[] ExtraSafeToDeleteFolders, string[] ExtraSafeToDeleteExtensions, TextWriter Log) { // Figure out which folders to clean FolderToClean RootFolderToClean = new FolderToClean(new DirectoryInfo(LocalRootPath)); using (FindFoldersToCleanTask QueryWorkspace = new FindFoldersToCleanTask(PerforceClient, RootFolderToClean, ClientRootPath, SyncPaths, Log)) { string ErrorMessage; if (ModalTask.Execute(Owner, QueryWorkspace, "Clean Workspace", "Querying files in Perforce, please wait...", out ErrorMessage) != ModalTaskResult.Succeeded) { if (!String.IsNullOrEmpty(ErrorMessage)) { MessageBox.Show(ErrorMessage); } return; } } // If there's nothing to delete, don't bother displaying the dialog at all if (RootFolderToClean.FilesToDelete.Count == 0 && RootFolderToClean.NameToSubFolder.Count == 0) { MessageBox.Show("You have no local files which are not in Perforce.", "Workspace Clean", MessageBoxButtons.OK); return; } // Populate the tree CleanWorkspaceWindow CleanWorkspace = new CleanWorkspaceWindow(PerforceClient, RootFolderToClean, ExtraSafeToDeleteFolders, ExtraSafeToDeleteExtensions); CleanWorkspace.ShowDialog(); }
int TryOpenProject(UserSelectedProjectSettings Project, int ReplaceTabIdx, OpenProjectOptions Options = OpenProjectOptions.None) { Log.WriteLine("Detecting settings for {0}", Project); using (DetectProjectSettingsTask DetectProjectSettings = new DetectProjectSettingsTask(Project, DataFolder, CacheFolder, new PrefixedTextWriter(" ", Log))) { string ErrorMessage; ModalTaskResult Result; if ((Options & OpenProjectOptions.Quiet) != 0) { Result = ModalTask.Execute(this, DetectProjectSettings, "Opening Project", "Opening project, please wait...", out ErrorMessage); } else { Result = PerforceModalTask.Execute(this, Project.LocalPath, Project.ServerAndPort, Project.UserName, DetectProjectSettings, "Opening Project", "Opening project, please wait...", Log, out ErrorMessage); } if (Result != ModalTaskResult.Succeeded) { CreateErrorPanel(ReplaceTabIdx, Project, ErrorMessage); return(-1); } return(TryOpenProject(DetectProjectSettings, ReplaceTabIdx, Options)); } }
private void FetchMoreResults() { int NewMaxResults = MaxResults + 100; QueryIssuesTask Task = new QueryIssuesTask(IssueMonitor.ApiUrl, NewMaxResults); // Execute the task string ErrorMessage; ModalTaskResult Result = ModalTask.Execute(this, Task, "Querying issues", "Fetching data, please wait...", out ErrorMessage); if (Result != ModalTaskResult.Succeeded) { if (Result != ModalTaskResult.Aborted) { StatusLabel.Text = "Unable to fetch issues."; MessageBox.Show(ErrorMessage); } return; } // Update the list of project names Issues = Task.Issues; ProjectNames = Task.Issues.Select(x => x.Project).Distinct().OrderBy(x => x).ToList(); // Populate the list control UpdateIssueList(); MaxResults = NewMaxResults; }
public static ModalTaskResult Execute(IWin32Window Owner, string ProjectFileName, string ServerAndPort, string UserName, IPerforceModalTask PerforceTask, string Title, string Message, TextWriter Log, out string ErrorMessage) { PerforceModalTask Task = new PerforceModalTask(ProjectFileName, ServerAndPort, UserName, PerforceTask, Log); for (;;) { string TaskErrorMessage; ModalTaskResult TaskResult = ModalTask.Execute(Owner, Task, Title, Message, out TaskErrorMessage); if (Task.LoginResult == LoginResult.Succeded) { ErrorMessage = TaskErrorMessage; return(TaskResult); } else if (Task.LoginResult == LoginResult.MissingPassword) { PasswordWindow PasswordWindow = new PasswordWindow(String.Format("Enter the password for user '{0}' on server '{1}'.", Task.UserName, Task.ServerAndPort), Task.Password); if (Owner == null) { PasswordWindow.StartPosition = FormStartPosition.CenterScreen; } if (PasswordWindow.ShowDialog() != DialogResult.OK) { ErrorMessage = null; return(ModalTaskResult.Aborted); } Task.Password = PasswordWindow.Password; } else if (Task.LoginResult == LoginResult.IncorrectPassword) { PasswordWindow PasswordWindow = new PasswordWindow(String.Format("Authentication failed. Enter the password for user '{0}' on server '{1}'.", Task.UserName, Task.ServerAndPort), Task.Password); if (Owner == null) { PasswordWindow.StartPosition = FormStartPosition.CenterScreen; } if (PasswordWindow.ShowDialog() != DialogResult.OK) { ErrorMessage = null; return(ModalTaskResult.Aborted); } Task.Password = PasswordWindow.Password; } else { ErrorMessage = TaskErrorMessage; return(ModalTaskResult.Failed); } } }
int TryOpenProject(UserSelectedProjectSettings Project, int ReplaceTabIdx, OpenProjectOptions Options = OpenProjectOptions.None) { using (DetectProjectSettingsTask DetectProjectSettings = new DetectProjectSettingsTask(Project, DataFolder, Log)) { string ErrorMessage; if (ModalTask.Execute(this, DetectProjectSettings, "Opening Project", "Opening project, please wait...", out ErrorMessage) != ModalTaskResult.Succeeded) { if (!String.IsNullOrEmpty(ErrorMessage) && (Options & OpenProjectOptions.Quiet) == 0) { CreateErrorPanel(ReplaceTabIdx, Project, ErrorMessage); } return(-1); } return(TryOpenProject(DetectProjectSettings, ReplaceTabIdx, Options)); } }
public static bool?ShowModal(IWin32Window Owner, bool bUnstable, string OriginalExecutableFileName, UserSettings Settings, TextWriter Log) { GetDefaultSettingsTask DefaultSettings = new GetDefaultSettingsTask(Log); string ErrorMessage; ModalTask.Execute(Owner, DefaultSettings, "Checking Settings", "Checking settings, please wait...", out ErrorMessage); ApplicationSettingsWindow ApplicationSettings = new ApplicationSettingsWindow(DefaultSettings.ServerAndPort, DefaultSettings.UserName, bUnstable, OriginalExecutableFileName, Settings, Log); if (ApplicationSettings.ShowDialog() == DialogResult.OK) { return(ApplicationSettings.bRestartUnstable); } else { return(null); } }
private void CleanBtn_Click(object sender, EventArgs e) { List <FileInfo> FilesToSync = new List <FileInfo>(); List <FileInfo> FilesToDelete = new List <FileInfo>(); List <DirectoryInfo> DirectoriesToDelete = new List <DirectoryInfo>(); foreach (TreeNode RootNode in TreeView.Nodes) { FindSelection(RootNode, FilesToSync, FilesToDelete, DirectoriesToDelete); } string ErrorMessage; if (ModalTask.Execute(this, new DeleteFilesTask(PerforceClient, FilesToSync, FilesToDelete, DirectoriesToDelete), "Clean Workspace", "Cleaning files, please wait...", out ErrorMessage) != ModalTaskResult.Succeeded && !String.IsNullOrEmpty(ErrorMessage)) { FailedToDeleteWindow FailedToDelete = new FailedToDeleteWindow(); FailedToDelete.FileList.Text = ErrorMessage; FailedToDelete.FileList.SelectionStart = 0; FailedToDelete.FileList.SelectionLength = 0; FailedToDelete.ShowDialog(); } }