public IList <ResourceViewModel> ReadResources(string path) { ProjectReader reader = new UniversalProjectReader(); var resources = new List <ResourceViewModel>(); try { ProjectFile project = reader.read(path); foreach (Resource res in project.Resources) { var name = res.Name; if (name == null) { continue; } resources.Add(new ResourceViewModel() { ID = res.UniqueID.ToNullableInt().GetValueOrDefault(), Name = res.Name }); } return(resources); } catch { return(resources); } }
public IList <ResourceViewModel> ReadResources(string path) { // Initialize an MPXJ Project reader which is universal (will open any supported file) ProjectReader reader = new UniversalProjectReader(); var resources = new List <ResourceViewModel>(); try { // Read the file at the specified path ProjectFile project = reader.read(path); // Create a ResourceViewModel for each defined in the Project resource foreach (Resource res in project.Resources) { var name = res.Name; if (name == null) { continue; } resources.Add(new ResourceViewModel() { ID = res.UniqueID.ToNullableInt().GetValueOrDefault(), Name = res.Name }); } return(resources); } catch { return(resources); } }
public IList <ResourceAssignmentViewModel> ReadAssignments(string path) { var assignments = new List <ResourceAssignmentViewModel>(); ProjectReader reader = new UniversalProjectReader(); try { ProjectFile project = reader.read(path); foreach (ResourceAssignment assignment in project.ResourceAssignments) { var resourceId = assignment.ResourceUniqueID.ToNullableInt().GetValueOrDefault(); if (resourceId < 0) { continue; } assignments.Add(new ResourceAssignmentViewModel() { ID = assignment.UniqueID.ToNullableInt().GetValueOrDefault(), TaskID = assignment.TaskUniqueID.ToNullableInt().GetValueOrDefault(), ResourceID = resourceId, Units = assignment.Units.ToNullableDouble().GetValueOrDefault() / 100 }); } return(assignments); } catch { return(assignments); } }
public IList <TaskViewModel> ReadTasks(string path) { // Initialize an MPXJ Project reader which is universal (will open any supported file) ProjectReader reader = new UniversalProjectReader(); var modelTasks = new List <TaskViewModel>(); try { // Read the file at the specified path ProjectFile project = reader.read(path); var index = 0; foreach (Task task in project.Tasks) { // Create a TaskViewModel for each task in the file var modelTask = new TaskViewModel() { TaskID = task.UniqueID.ToNullableInt().GetValueOrDefault(), Start = task.Start.ToDateTime(), End = task.Finish.ToDateTime(), PlannedStart = task.BaselineStart.ToDateTime(), PlannedEnd = task.BaselineFinish.ToDateTime(), Expanded = task.Expanded, PercentComplete = task.PercentageComplete.ToNullableDecimal().GetValueOrDefault() / 100, Summary = task.Summary, Title = task.Name }; // Create parent-child relations and specify the appropriate OrderId for each task var parent = task.ParentTask; if (parent != null) { var parentId = task.ParentTask.UniqueID.ToNullableInt(); modelTask.OrderId = modelTasks.Where(t => t.ParentID == parentId).Count(); modelTask.ParentID = parentId; } else { modelTask.OrderId = index; index++; } modelTasks.Add(modelTask); } return(modelTasks); } catch { // If an error occurs while reading file, return an empty list of Tasks return(modelTasks); } }
public IList <TaskViewModel> ReadTasks(string path) { ProjectReader reader = new UniversalProjectReader(); var modelTasks = new List <TaskViewModel>(); try { ProjectFile project = reader.read(path); var index = 0; foreach (Task task in project.Tasks) { var modelTask = new TaskViewModel() { TaskID = task.UniqueID.ToNullableInt().GetValueOrDefault(), Start = task.Start.ToDateTime(), End = task.Finish.ToDateTime(), PlannedStart = task.BaselineStart.ToDateTime(), PlannedEnd = task.BaselineFinish.ToDateTime(), // expanded is always true upon reading Expanded = task.Expanded, PercentComplete = task.PercentageComplete.ToNullableDecimal().GetValueOrDefault() / 100, Summary = task.Summary, Title = task.Name }; var parent = task.ParentTask; if (parent != null) { var parentId = task.ParentTask.UniqueID.ToNullableInt(); modelTask.OrderId = modelTasks.Where(t => t.ParentID == parentId).Count(); modelTask.ParentID = parentId; } else { modelTask.OrderId = index; index++; } modelTasks.Add(modelTask); } return(modelTasks); } catch { return(modelTasks); } }
bool Reset(string path, int year) { if (Year == year) { return(true); } Year = year; XptDays = new List <ExceptDays>(); if (YearIsNotOK()) { return(false); } if (string.IsNullOrEmpty(path)) { return(false); } if (!Directory.Exists(path)) { return(false); } string FileN = $@"{path}\{Year}.calendar.mpp"; if (!File.Exists(FileN)) { return(false); } UniversalProjectReader reader = new UniversalProjectReader(); ProjectFile project = reader.read(FileN); var RootTasks = project.GetChildTasks(); var Clds = project.getCalendars(); var Xps = Clds.GetExceptions(); foreach (var X in Xps) { XptDays.Add(new ExceptDays { From = ToDayBegin(X.From), To = ToDayEnd(X.To), IsWorking = X.IsWorking }); } WDaysInM = CountWDays(Day1, DayN); return(true); }
public IList <DependencyViewModel> ReadDependencies(string path) { // Initialize an MPXJ Project reader which is universal (will open any supported file) ProjectReader reader = new UniversalProjectReader(); var dependencies = new List <DependencyViewModel>(); try { // Read the file at the specified path ProjectFile project = reader.read(path); var index = 0; // Iterate over all tasks foreach (Task task in project.Tasks) { var successors = task.Successors; Iterator iterator = successors.iterator(); // Create DependencyViewModel for each relation present in the Project Tasks while (iterator.hasNext()) { index++; var succ = (Relation)iterator.next(); var dep = new DependencyViewModel() { DependencyID = index, PredecessorID = task.UniqueID.ToNullableInt().GetValueOrDefault(), SuccessorID = succ.TargetTask.UniqueID.ToNullableInt().GetValueOrDefault(), Type = (DependencyType)succ.Type.Value }; dependencies.Add(dep); } } return(dependencies); } catch { return(dependencies); } }
public IList <DependencyViewModel> ReadDependencies(string path) { ProjectReader reader = new UniversalProjectReader(); var dependencies = new List <DependencyViewModel>(); try { ProjectFile project = reader.read(path); var index = 0; foreach (Task task in project.Tasks) { var successors = task.Successors; Iterator iterator = successors.iterator(); while (iterator.hasNext()) { index++; var succ = (Relation)iterator.next(); var dep = new DependencyViewModel() { DependencyID = index, PredecessorID = task.UniqueID.ToNullableInt().GetValueOrDefault(), SuccessorID = succ.TargetTask.UniqueID.ToNullableInt().GetValueOrDefault(), Type = (DependencyType)succ.Type.Value }; dependencies.Add(dep); } } return(dependencies); } catch { return(dependencies); } }
public IList <ResourceAssignmentViewModel> ReadAssignments(string path) { // Initialize an MPXJ Project reader which is universal (will open any supported file) var assignments = new List <ResourceAssignmentViewModel>(); ProjectReader reader = new UniversalProjectReader(); try { // Read the file at the specified path ProjectFile project = reader.read(path); // Create a ResourceAssignmentViewModel for each defined resource assignment in the Project foreach (ResourceAssignment assignment in project.ResourceAssignments) { var resourceId = assignment.ResourceUniqueID.ToNullableInt().GetValueOrDefault(); if (resourceId < 0) { continue; } assignments.Add(new ResourceAssignmentViewModel() { ID = assignment.UniqueID.ToNullableInt().GetValueOrDefault(), TaskID = assignment.TaskUniqueID.ToNullableInt().GetValueOrDefault(), ResourceID = resourceId, Units = assignment.Units.ToNullableDouble().GetValueOrDefault() / 100 }); } return(assignments); } catch { return(assignments); } }