private void SelectObject(object obj) { if (obj is VsProject) { SelectProject((VsProject)obj); } else if (obj is VsProjectReference) { SelectProjectReference((VsProjectReference)obj); } else if (obj is NuGetPackageReference) { var nuGetReference = (NuGetPackageReference)obj; var nuGetProject = AllProjects.FirstOrDefault(p => p.NuGetPackageId == nuGetReference.Name); if (nuGetProject != null) { SelectProject(nuGetProject); } else { var msg = new TextMessage("The Project with this NuGet Package ID could not be found in your collection.\n\n" + "Do you want to show the Package on NuGet.org?", "Show on on NuGet.org?", MessageButton.YesNo); msg.SuccessCallback = result => { if (result == MessageResult.Yes) { OpenNuGetWebsite(nuGetReference); } }; Messenger.Default.Send(msg); } } }
public static string GetProjectIdByName(string projectName) { BimProject result = null; result = AllProjects.FirstOrDefault(p => p.name.Equals(projectName)); return(result != null ? result.id : null); }
internal static void HandleUpdateProjectResponse(IRestResponse response, BimProject project, int rowIndex = -1) { LogResponse(response); ResponseContent content = null; if (response.StatusCode == System.Net.HttpStatusCode.OK) { BimProject projectResponse = JsonConvert.DeserializeObject <BimProject>(response.Content); BimProject updatedProject = AllProjects.FirstOrDefault(p => p.id == projectResponse.id); _AllProjects.Remove(updatedProject); _AllProjects.Add(projectResponse); if (rowIndex > -1) { _projectTable.Rows[rowIndex]["id"] = projectResponse.id; _projectTable.Rows[rowIndex]["result"] = ResultCodes.ProjectUpdated; } Log.Info($"- project {projectResponse.name} updated. (original Name: {updatedProject.name})"); } else { content = JsonConvert.DeserializeObject <ResponseContent>(response.Content); string msg = ((content != null && content.message != null) ? content.message : null); if (rowIndex > -1) { _projectTable.Rows[rowIndex]["result"] = ResultCodes.Error; _projectTable.Rows[rowIndex]["result_message"] = msg; } Log.Warn($"Status Code: {response.StatusCode.ToString()}\t Message: {msg}"); } }
/// <exception cref="WebException">There was a connection exception. </exception> private async Task AddNuGetPackagesToGraphAsync(object parent, IEnumerable <NuGetPackageReference> packages, Color edgeColor, BidirectionalGraph <object, IEdge <object> > graph, List <NuGetPackageReference> packagesInGraph) { foreach (var package in packages) { var existingPackage = TryGetExistingPackage(package, packagesInGraph); if (existingPackage == null) { AddNuGetPackageVertext(graph, package, packagesInGraph); AddEdge(parent, package, edgeColor, graph); var referencedProject = AllProjects.FirstOrDefault(p => p.NuGetPackageId == package.Name); if (referencedProject != null) { await AddNuGetPackagesToGraphAsync(package, referencedProject.NuGetReferences, edgeColor, graph, packagesInGraph); } else { //var externalDependencies = await package.GetDependenciesAsync(); //await AddNuGetPackagesToGraphAsync(package, externalDependencies, Colors.DeepSkyBlue, graph, packagesInGraph); } } else { AddEdge(parent, existingPackage, Colors.DarkBlue, graph); } } }
public static BimProject GetProjectById(string projectId) { BimProject result = null; result = AllProjects.FirstOrDefault(p => p.id.Equals(projectId)); return(result != null ? result : null); }
public AllProjectsViewModel(ProjectData projectData, TaskData taskData) { if (projectData == null) { throw new ArgumentNullException("projectData"); } base.DisplayName = Properties.Resources.Projects_DisplayName; base.DisplayImage = "pack://application:,,,/TaskConqueror;Component/Assets/Images/project.png"; _projectData = projectData; _taskData = taskData; // Subscribe for notifications of when a new project is saved. _projectData.ProjectAdded += this.OnProjectAdded; _projectData.ProjectUpdated += this.OnProjectUpdated; _projectData.ProjectDeleted += this.OnProjectDeleted; this.AllProjects = new ObservableCollection <ProjectViewModel>(); this.AllProjects.CollectionChanged += this.OnCollectionChanged; this.PageFirst(); SortColumns.Add(new SortableProperty() { Description = "Title", Name = "Title" }); SortColumns.Add(new SortableProperty() { Description = "Status", Name = "StatusId" }); SortColumns.Add(new SortableProperty() { Description = "Est. Cost", Name = "EstimatedCost" }); SortColumns.Add(new SortableProperty() { Description = "Goal", Name = "GoalTitle" }); SortColumns.Add(new SortableProperty() { Description = "Date Created", Name = "CreatedDate" }); SortColumns.Add(new SortableProperty() { Description = "Date Completed", Name = "CompletedDate" }); SelectedSortColumn = SortColumns.FirstOrDefault(); // select the first project ProjectViewModel firstProject = AllProjects.FirstOrDefault(); if (firstProject != null) { firstProject.IsSelected = true; } }
/// <summary> /// Deletes the selected project. /// </summary> public void DeleteProject() { ProjectViewModel selectedProjectVM = AllProjects.FirstOrDefault(p => p.IsSelected == true); if (selectedProjectVM != null && WPFMessageBox.Show(Properties.Resources.Delete_Confirm, Properties.Resources.Projects_Delete_Confirm, WPFMessageBoxButtons.YesNo, WPFMessageBoxImage.Question) == WPFMessageBoxResult.Yes) { _projectData.DeleteProject(_projectData.GetProjectByProjectId(selectedProjectVM.ProjectId), _taskData); selectedProjectVM.Dispose(); } }
/// <summary> /// Launches the edit task window. /// </summary> public void EditProject() { ProjectView window = new ProjectView(); ProjectViewModel selectedProjectVM = AllProjects.FirstOrDefault(p => p.IsSelected == true); using (var viewModel = new ProjectViewModel(_projectData.GetProjectByProjectId(selectedProjectVM.ProjectId), _projectData, _taskData)) { this.ShowWorkspaceAsDialog(window, viewModel); } }
/// <summary> /// Selects project by name, also refreshes the files changes. /// </summary> /// <param name="projectName">The project name.</param> /// <param name="callback">Is this javascript callback?</param> /// <param name="refresh">Refresh the project?</param> public void Select(string projectName, bool callback = false, bool refresh = true) { try { ClientUI.ShowProgress("Loading..."); // select CurrentProject = AllProjects.FirstOrDefault(project => project.ProjectName == projectName); if (CurrentProject == null) { ClientUI.ShowMessage("Failed to select project '" + projectName + "', invalid project name!", true); return; } if (!callback) { Javascript.Run("selectProject('" + projectName + "', false);"); } if (refresh) { CurrentProject.Refresh(delegate { var diff = CurrentProject.BuildDiff(); var filesJs = diff.Aggregate("", (current, file) => current + ("addFileChange('" + file.FileName + "', " + (int)file.DiffType) + ");"); Javascript.Run(filesJs); Javascript.Run("setChangeCount('" + CurrentProject.ProjectName + "', " + diff.Length + ");"); ClientUI.HideProgress(); }); } } catch { if (refresh) { ClientUI.HideProgress(); } ClientUI.ShowMessage("Failed to select project '" + projectName + "'!", true); } }
/// <summary>Removes all filters, shows all projects and selects the given project. </summary> /// <param name="projectReference">The project reference to select. </param> public void SelectProjectReference(VsProjectReference projectReference) { Messenger.Default.Send(new ShowProjectMessage(AllProjects.FirstOrDefault(p => p.IsSameProject(projectReference)))); }
public IProject FindFirstProject(IProjectReference projectReference) { return(AllProjects.FirstOrDefault(p => p.ReferenceEqualTo(projectReference))); }