private void Application_NewProject(MSProject.Project pj) { OnProjectLoaded(pj); }
void Application_NewProject(MSProject.Project pj) { _project = pj; //ConnectToJiraServer(); }
private void GetPredecessorActivitiesRecursively(MSProject.Task task, ref Dictionary<string, Activity> predecessorActivities) { if (task.Name.Contains(Constants.START_NAME) || task.Name.Contains(Constants.BUFFER_NAME)) return; if (predecessorActivities.ContainsKey(task.ID.ToString())) return; predecessorActivities.Add(task.ID.ToString(), new Activity { Id = task.ID.ToString(), Description = task.Name, Duration = task.Duration, }); foreach (MSProject.Task predecessorTask in task.PredecessorTasks) { GetPredecessorActivitiesRecursively(predecessorTask, ref predecessorActivities); } }
private void CreateSubtasks(MSProject.Task selectedTask, Issue jiraIssue) { var nextTaskID = selectedTask.ID + 1; var outlineLevel = selectedTask.OutlineLevel; while (true) { if (_project.Tasks.Count < nextTaskID) break; var childTask = _project.Tasks[nextTaskID]; if (childTask == null || childTask.OutlineLevel != outlineLevel + 1) break; nextTaskID++; if (!string.IsNullOrEmpty(childTask.Text3)) { continue; } var subTask = _jira.CreateIssue(JiraProjectName, jiraIssue.Key.Value); subTask.Type = "Sub-task"; // the id of the sub-task issue type subTask.Summary = jiraIssue.Summary + " - " + childTask.Name; subTask.Assignee = GetAssignee(childTask.ResourceNames)?.Username; foreach (var component in childTask.ResourceGroup.Split(',')) subTask.Components.Add(component); subTask.SaveChanges(); childTask.SetField(MSProject.PjField.pjTaskText2, JiraProjectURL + "/browse/" + subTask.Key.Value); childTask.SetField(MSProject.PjField.pjTaskText3, subTask.Key.Value); } }
private List<Activity> GetCriticalPath(MSProject.Task task) { var predecessorActivities = new Dictionary<string, Activity>(); // Get all task predecessors, up to where START another BUFFER is reached foreach (MSProject.Task predecessorTask in task.PredecessorTasks) { GetPredecessorActivitiesRecursively(predecessorTask, ref predecessorActivities); } // Fill predecessors for all activities foreach (Activity activity in predecessorActivities.Values) { MSProject.Task activityTask = project.Tasks.Find(int.Parse(activity.Id)); foreach (MSProject.Task taskPredecessor in activityTask.PredecessorTasks) { if (predecessorActivities.ContainsKey(taskPredecessor.ID.ToString())) { predecessorActivities[activity.Id].Predecessors.Add(predecessorActivities[taskPredecessor.ID.ToString()]); } } } // End of: Get all task predecessors // Calc critical path var criticalPathActivities = predecessorActivities.Values.CriticalPath(p => p.Predecessors, l => (long)l.Duration); // Ensure return is sorted first to last // Return return criticalPathActivities.ToList(); }