async void Delete() { if ( MessageBox.Show(string.Format("You're about to delete {0} workspaces, and {1} shelvesets\n** Caution: There’s no way to recover a shelveset or workspace once it is deleted. **\nClick OK to continue.", Workspaces.Count, Shelvesets.Count), "Delete Confirmation", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.Cancel) { return; } TotalItemToDelete = Workspaces.Count + Shelvesets.Count; CompletedItems = 0; Working = true; await Task.Run(() => { foreach (var ws in Workspaces) { ws.Delete(); CompletedItems++; } foreach (var sh in Shelvesets) { TfsShared.Instance.Vcs.DeleteShelveset(sh); CompletedItems++; } }); Workspaces.Clear(); Shelvesets.Clear(); Working = false; }
async void Search() { Working = true; DisplayIsIndeterminate = true; Workspaces.Clear(); Shelvesets.Clear(); if (SearchWorkspaces) { List <Workspace> workspacesFilterByDays = new List <Workspace>(); await Task.Run(() => { var allWorkspacesForUser = TfsShared.Instance.Vcs.QueryWorkspaces(null, Owner.UserName, null); workspacesFilterByDays.AddRange(allWorkspacesForUser.Where(w => w.LastAccessDate < DateTime.Now.AddDays(-this.MaxDays)) .Where(w => w.Folders.Any(s => s.ServerItem.StartsWith(string.Format("$/{0}", TfsShared.Instance.ProjectInfo.Name))))); }); if (workspacesFilterByDays != null) { foreach (var ws in workspacesFilterByDays) { Workspaces.AddOnUi(ws); } } } if (SearchShelvesets) { IEnumerable <Shelveset> shelvsetesFilterByDays = null; await Task.Run(() => { var allShelvsetes = TfsShared.Instance.Vcs.QueryShelvesets(null, Owner.UserName); shelvsetesFilterByDays = allShelvsetes.Where(w => w.CreationDate < DateTime.Now.AddDays(-this.MaxDays)); }); if (shelvsetesFilterByDays != null) { foreach (var sh in shelvsetesFilterByDays) { Shelvesets.AddOnUi(sh); } } } Working = false; DisplayIsIndeterminate = false; }