internal UserContext() { if (string.IsNullOrEmpty(SpruceSettings.TfsServer)) { throw new ArgumentNullException("The TfsServer settings is empty, please set it in the web.config (full URL, including the port)"); } if (string.IsNullOrEmpty(SpruceSettings.DefaultProjectName)) { throw new ArgumentNullException("The DefaultProjectName settings is empty, please set it in the web.config"); } // Connect to TFS _users = new List <string>(); TfsCollection = new TfsTeamProjectCollection(new Uri(SpruceSettings.TfsServer)); TfsCollection.Authenticate(); WorkItemStore = new WorkItemStore(TfsCollection); VersionControlServer = TfsCollection.GetService <VersionControlServer>(); RegisteredLinkTypes = WorkItemStore.RegisteredLinkTypes; // Get the current username, and load their settings Name = TfsCollection.AuthorizedIdentity.DisplayName; Id = TfsCollection.AuthorizedIdentity.TeamFoundationId; // Load the user settings from the backing store (ravendb) Settings = UserSettings.Load(Id); Settings.Name = Name; // Set the current project, and the view settings if (string.IsNullOrEmpty(Settings.ProjectName) || !WorkItemStore.Projects.Contains(Settings.ProjectName)) { ChangeCurrentProject(SpruceSettings.DefaultProjectName); } else { _projectName = Settings.ProjectName; CurrentProject = new ProjectDetails(WorkItemStore.Projects[_projectName]); } // Populate the list of project names and users - this is done per user rather // than per application, so new project names don't require an app restart. PopulateProjectNames(); PopulateUsers(); }
/// <summary> /// Change's the current project for the logged user, and updates the persisted user settings. /// </summary> public void ChangeCurrentProject(string projectName) { if (string.IsNullOrWhiteSpace(projectName)) { throw new ArgumentNullException("The project name was null or empty"); } if (!WorkItemStore.Projects.Contains(projectName)) { throw new InvalidOperationException(string.Format("The project {0} doesn't exist.", projectName)); } _projectName = projectName; CurrentProject = new ProjectDetails(WorkItemStore.Projects[projectName]); Settings.ProjectName = projectName; Settings.IterationName = CurrentProject.Iterations[0].Name; Settings.IterationPath = CurrentProject.Iterations[0].Path; Settings.AreaName = CurrentProject.Areas[0].Name; Settings.AreaPath = CurrentProject.Areas[0].Path; }
internal UserContext() { if (string.IsNullOrEmpty(SpruceSettings.TfsServer)) throw new ArgumentNullException("The TfsServer settings is empty, please set it in the web.config (full URL, including the port)"); if (string.IsNullOrEmpty(SpruceSettings.DefaultProjectName)) throw new ArgumentNullException("The DefaultProjectName settings is empty, please set it in the web.config"); // Connect to TFS _users = new List<string>(); TfsCollection = new TfsTeamProjectCollection(new Uri(SpruceSettings.TfsServer)); TfsCollection.Authenticate(); WorkItemStore = new WorkItemStore(TfsCollection); VersionControlServer = TfsCollection.GetService<VersionControlServer>(); RegisteredLinkTypes = WorkItemStore.RegisteredLinkTypes; // Get the current username, and load their settings Name = TfsCollection.AuthorizedIdentity.DisplayName; Id = TfsCollection.AuthorizedIdentity.TeamFoundationId; // Load the user settings from the backing store (ravendb) Settings = UserSettings.Load(Id); Settings.Name = Name; // Set the current project, and the view settings if (string.IsNullOrEmpty(Settings.ProjectName) || !WorkItemStore.Projects.Contains(Settings.ProjectName)) { ChangeCurrentProject(SpruceSettings.DefaultProjectName); } else { _projectName = Settings.ProjectName; CurrentProject = new ProjectDetails(WorkItemStore.Projects[_projectName]); } // Populate the list of project names and users - this is done per user rather // than per application, so new project names don't require an app restart. PopulateProjectNames(); PopulateUsers(); }
/// <summary> /// Change's the current project for the logged user, and updates the persisted user settings. /// </summary> public void ChangeCurrentProject(string projectName) { if (string.IsNullOrWhiteSpace(projectName)) throw new ArgumentNullException("The project name was null or empty"); if (!WorkItemStore.Projects.Contains(projectName)) throw new InvalidOperationException(string.Format("The project {0} doesn't exist.", projectName)); _projectName = projectName; CurrentProject = new ProjectDetails(WorkItemStore.Projects[projectName]); Settings.ProjectName = projectName; Settings.IterationName = CurrentProject.Iterations[0].Name; Settings.IterationPath = CurrentProject.Iterations[0].Path; Settings.AreaName = CurrentProject.Areas[0].Name; Settings.AreaPath = CurrentProject.Areas[0].Path; }