public ResourceInformation(Resource resource, List <Task> tasks)
        {
            this.resource = resource;
            ID            = resource.getID().intValue();
            ResourceName  = resource.getName() ?? "Undefined";
            this.tasks    = tasks ?? new List <Task>();
            Cost          = resource.getCost().floatValue();
            GroupName     = resource.getGroup();

            Duration baselineWork = resource.getBaselineWork();
            double   duration     = 0;

            if (baselineWork != null)
            {
                if (resource.getType().toString() == "Work")
                {
                    foreach (Task t in tasks)
                    {
                        //Sometimes there is a null task
                        if (t != null && t.getBaselineDuration() != null)
                        {
                            duration += t.getDuration().getDuration() - t.getBaselineDuration().getDuration();
                        }
                    }
                }
            }
            Duration         = new WorkDuration(TimeUnitStringConverter.ConvertTime(resource.getBaselineWork().toString()), duration);
            CostPerTimeUnit  = Convert.ToSingle(Cost / Duration.TotalDuration());
            OvertimeWorkCost = Duration.Overtime * CostPerTimeUnit;
        }
Beispiel #2
0
        public TaskInformation(Task task, List <Resource> resources)
        {
            Resources = new List <ResourceInformation>();
            this.task = task;
            foreach (Resource res in resources)
            {
                this.Resources.Add(new ResourceInformation(res));
            }
            ChildTasks = new List <TaskInformation>();

            //Dates
            Dates = new ProjectDates(task.getStart(), task.getFinish());
            if (task.getBaselineStart() != null && task.getBaselineFinish() != null)
            {
                Dates.SetBaseline(task.getBaselineStart(), task.getBaselineFinish());
            }
            else
            {
                //TODO: ERR_MSG_NOT_NIN_BASELINE
            }

            if (task.getBaselineDuration() != null && task.getDuration() != null)
            {
                Duration = new WorkDuration(
                    TimeUnitStringConverter.ConvertTime(task.getBaselineDuration().toString()),
                    TimeUnitStringConverter.ConvertTime(task.getDuration().toString()));
            }
            else
            {
                Duration = new WorkDuration();
            }


            OverCost           = task.getCost().doubleValue() - task.getBaselineCost().doubleValue();
            TaskName           = task.getName();
            Cost               = task.getCost().intValue();
            ActualCost         = task.getActualCost().intValue();
            RemainingCost      = task.getRemainingCost().intValue();
            CompletePercentage = task.getPercentageComplete().intValue();
            if (CompletePercentage == 100)
            {
                Status = TaskStatus.Closed;
            }
            else
            {
                Status = TaskStatus.InWork;
            }
            Tracker = "Undefined";
            Dates.SetCreatedDate(task.getCreateDate());
            SetAnomaly();
            SetDeviation();
        }