コード例 #1
0
        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;
        }
コード例 #2
0
        void CopyToClipboard()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(string.Format("List of Workspaces & Shelvesets older than {0}", DateTime.Now.AddDays(-this.MaxDays)));

            if (Workspaces.Count > 0)
            {
                sb.AppendLine("Workspaces:");
                TableBuilder table = new TableBuilder();
                table.AddHeaders(new Header("Name"), new Header("Computer"), new Header("Last Access Date"), new Header("Comment", 35));
                foreach (var ws in Workspaces.OrderBy(o => o.OwnerName))
                {
                    table.AddValues(ws.DisplayName, ws.Computer, ws.LastAccessDate.ToString(), ws.Comment);
                }

                sb.Append(table.ToString());
            }

            if (Shelvesets.Count > 0)
            {
                sb.AppendLine("Shelvesets:");
                TableBuilder table = new TableBuilder();
                table.AddHeaders(new Header("Name"), new Header("Creation Date"), new Header("Comment", 35));
                foreach (var ws in Shelvesets.OrderBy(o => o.OwnerName))
                {
                    table.AddValues(ws.DisplayName, ws.CreationDate.ToString(), ws.Comment);
                }
                sb.Append(table.ToString());
            }

            Clipboard.SetText(sb.ToString());
        }
コード例 #3
0
        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;
        }