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;
        }
Esempio n. 2
0
        public TaskInformation(Issue issue, ResourceInformation assignedTo)
        {
            TaskName = issue.Subject;
            ID       = issue.Id;
            Tracker  = issue.Tracker.Name;

            double est = 0, spent = 0;

            if (issue.EstimatedHours.HasValue)
            {
                est = issue.EstimatedHours.Value;
            }
            if (issue.SpentHours.HasValue)
            {
                spent = issue.SpentHours.Value;
            }
            Duration           = new WorkDuration(est, spent);
            CompletePercentage = int.Parse(issue.DoneRatio.Value.ToString());
            if (CompletePercentage == 100 && Duration.Spent == 0)
            {
                Duration.Spent = Duration.Estimated;
                Duration.ReCalculateOvertime();
            }
            Dates = new ProjectDates(issue.StartDate, issue.DueDate);

            Dates.SetCreatedDate(issue.CreatedOn);

            //Costs
            double costPerHour = assignedTo.CostPerTimeUnit;

            Cost       = (int)(costPerHour * Duration.TotalDuration());
            ActualCost = (int)(costPerHour * Duration.Spent);
            if (CompletePercentage == 100)
            {
                RemainingCost = 0;
            }
            else
            {
                RemainingCost = (int)(costPerHour * (Duration.Estimated - Duration.Spent));
            }
            OverCost = (int)(costPerHour * Duration.Overtime);

            //TODO: issue status
            if (CompletePercentage == 100)
            {
                Status = TaskStatus.Closed;
            }
            else
            {
                Status = TaskStatus.InWork;
            }


            ChildTasks = new List <TaskInformation>();
            SetAnomaly();
            SetDeviation();
        }
Esempio n. 3
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();
        }
 //TODO: groups
 public ResourceInformation(Project project, User user, WorkDuration duration)
 {
     ResourceName = user.Login;
     ID           = user.Id;
     Duration     = duration;
     foreach (var cfield in user.CustomFields)
     {
         if (cfield.Name.ToLower() == "ставка" || cfield.Name.ToLower() == "salary")
         {
             try
             {
                 CostPerTimeUnit = int.Parse(cfield.Values[0].Info);
             }
             catch
             {
                 CostPerTimeUnit = 0;
             }
         }
     }
     Cost             = CostPerTimeUnit * Duration.TotalDuration();
     OvertimeWorkCost = CostPerTimeUnit * Duration.Overtime;
 }