/// <summary>
        /// Load workspaces for the given Workspace Collection Name
        /// </summary>
        /// <param name="workspaceCollectionName"></param>
        /// <param name="accessKey"></param>
        /// <returns></returns>
        public async Task LoadWorkspacesAsync(string workspaceCollectionName, string accessKey)
        {
            Status    = "Loading...";
            IsLoading = true;
            IsLoaded  = false;

            Workspaces.Clear();

            using (var client = CreateClient(accessKey))
            {
                var response = await client.Workspaces.GetWorkspacesByCollectionNameAsync(workspaceCollectionName);

                if (response.Value != null)
                {
                    foreach (var workspace in response.Value)
                    {
                        Workspaces.Add(new Models.Workspace()
                        {
                            WorkspaceId = workspace.WorkspaceId
                        });
                    }

                    Status   = "Loaded.";
                    IsLoaded = true;
                }
                else
                {
                    Status = "Failed. Cannot get workspaces";
                }
            }

            IsLoading = false;
        }
        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;
        }
Beispiel #3
0
        private void EditLog(object obj)
        {
            Workspaces.Clear();
            EditLogViewModel workspace = new EditLogViewModel(_workspaces);

            Workspaces.Add(workspace);
            SetActiveWorkspace(workspace);
        }
Beispiel #4
0
        private void AddNewLog(object obj)
        {
            Workspaces.Clear();
            AddLogViewModel workspace = new AddLogViewModel(Workspaces);

            Workspaces.Add(workspace);
            SetActiveWorkspace(workspace);
        }
        private void SetProcessCount(int count)
        {
            Workspaces.Clear();
            foreach (var workspace in Enumerable.Range(0, count).Select(index => new ProcessContainerViewModel((uint)index)))
            {
                Workspaces.Add(workspace);
            }

            SetActiveWorkspace(Workspaces.FirstOrDefault());
        }
        /// <summary>
        /// Region that contains a set of UX helpers
        /// </summary>
        #region UX
        private void ClearUX()
        {
            Workspaces.Clear();
            Imports.Clear();
            Reports.Clear();

            WorkspaceResult = "Refresh your workspaces list";
            ImportResult    = "Select a Workspace to load its imports";
            ReportResult    = "Select an Import to load its reports";

            IsWorkspaceResultVisible = true;
            IsImportResultVisible    = true;
            IsReportResultVisible    = true;
        }
        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;
        }
        async Task LoadWorkspacesFromDb()
        {
            var dbWorkspaces = await new StorageService().GetWorkspaces();

            foreach (var asanaWorkspace in dbWorkspaces)
            {
                asanaWorkspace.ProjectsCount =
                    await GetStorageService().GetAsyncConnection().Table <AsanaProject>().Where(
                        x => x.workspaceid == asanaWorkspace.id && x.archived == false).CountAsync();
            }
            AsanaStateService.NeedToSyncData = !dbWorkspaces.Any();

            Dispatcher.RunAsync(() =>
            {
                Workspaces.Clear();
                Workspaces.AddRange(dbWorkspaces);
                // IsAppBarVisible = true;
            });
        }
Beispiel #9
0
        private Task LoadWorkspacesAsync(CancellationToken cancellationToken)
        {
            SelectWorkspaceMenu = null;
            if (Workspaces != null && Workspaces.Any())
            {
                Workspaces.Clear();
            }
            var tfsContext = TfsContext;

            if (IsConnected && tfsContext != null)
            {
                bool   invertRegex = Settings.Get(SettingsKeys.WorkspaceFilterRegexBehavoirKey, WorkspaceFilterRegexBehavoir.Disabled) == WorkspaceFilterRegexBehavoir.Inverted;
                string regex       = Settings.Get(SettingsKeys.WorkspaceFilterRegexBehavoirKey, WorkspaceFilterRegexBehavoir.Disabled) == WorkspaceFilterRegexBehavoir.Disabled ? string.Empty : Settings.Get(SettingsKeys.WorkspaceFilterRegexKey, "^((?!SQL).)*$");

                return(Task.Run(() => tfsContext.GetWorkspaces().Where(w => string.IsNullOrEmpty(regex) || (new Regex(regex).IsMatch(w.Name) != invertRegex)), cancellationToken).IgnoreCancellation(cancellationToken).ContinueWith(task => Workspaces = new ObservableCollection <Workspace>(task.Result), taskSchedulerContext).IgnoreCancellation(cancellationToken));
            }

            return(Task.Delay(0, cancellationToken));
        }