コード例 #1
0
        private void BuildReportableObjectProductivity(ReportableObject reportableObject, List <Period> exceptionPeriods)
        {
            decimal remainingUnitsAfterDataDate = reportableObject.BASELINE_ITEMJoinRATE.BASELINE_ITEM.TOTAL_HOURS - reportableObject.TOTAL_EARNED_UNITS;
            //When productivity is below this threshold, escalate to workpack or project
            decimal minimumProductivityBeforeEscalating = 0.001M;

            //establish dates for productivity assessment
            DateTime workpackStart         = reportableObject.BASELINE_ITEMJoinRATE.BASELINE_ITEM.WORKPACK.STARTDATE;
            DateTime workpackEnd           = reportableObject.BASELINE_ITEMJoinRATE.BASELINE_ITEM.WORKPACK.ENDDATE;
            DateTime?workpackForecastStart = reportableObject.BASELINE_ITEMJoinRATE.BASELINE_ITEM.WORKPACK.FORECASTSTARTDATE;
            DateTime?workpackForecastEnd   = reportableObject.BASELINE_ITEMJoinRATE.BASELINE_ITEM.WORKPACK.FORECASTENDDATE;

            DateTime assessmentStartDate;
            DateTime assessmentEndDate;

            if (workpackForecastStart != null)
            {
                assessmentStartDate = (DateTime)workpackForecastStart;
            }
            else
            {
                assessmentStartDate = workpackStart;
            }

            if (workpackForecastEnd != null)
            {
                assessmentEndDate = (DateTime)workpackForecastEnd;
            }
            else
            {
                assessmentEndDate = workpackEnd;
            }

            if (reportableObject.ReportingDataDate > assessmentStartDate)
            {
                assessmentStartDate = reportableObject.ReportingDataDate;
            }
            if (reportableObject.ReportingDataDate > assessmentEndDate)
            {
                assessmentEndDate = reportableObject.ReportingDataDate;
            }

            Period assessmentPeriod = new Period(assessmentStartDate.Date, assessmentEndDate.Date);

            //establish workpack productivity to be used when deliverable productivity is too low
            WORKPACK currentWORKPACK = reportableObject.BASELINE_ITEMJoinRATE.BASELINE_ITEM.WORKPACK;

            //calculate deliverable productivity
            reportableObject.VariationProductivity = ISupportProgressReportingExtensions.CalculatePlannedProductivity(assessmentPeriod, exceptionPeriods, reportableObject.BASELINE_ITEMJoinRATE.BASELINE_ITEM.TOTAL_HOURS);
            //progressItem.ProgressItem_CurrentProductivity = UnifiedCalculationMethods.CalculateProductivity(assessmentPeriod)

            decimal workpackVarProductivity = 0;

            if (reportableObject.VariationProductivity < minimumProductivityBeforeEscalating)
            {
                IEnumerable <BASELINE_ITEMProjection> WorkpackBASELINE_ITEMJoinRATES = SummaryObject.ReportableObjects.Where(x => x.BASELINE_ITEMJoinRATE.BASELINE_ITEM.GUID_WORKPACK == currentWORKPACK.GUID).Select(x => x.BASELINE_ITEMJoinRATE);

                //not checking for progressItemWorkpack null because all progress item should have workpacks assigned if the user
                decimal totalWorkpackUnits = WorkpackBASELINE_ITEMJoinRATES.Sum(x => x.BASELINE_ITEM.TOTAL_HOURS);

                workpackVarProductivity = ISupportProgressReportingExtensions.CalculatePlannedProductivity(assessmentPeriod, exceptionPeriods, totalWorkpackUnits);
                if (workpackVarProductivity > 0)
                {
                    reportableObject.VariationProductivity = workpackVarProductivity;
                }
            }

            decimal workpackBaseProductivity = 0;
            //not checking for progressItemWorkpack null because all progress item should have workpacks assigned if the user
            decimal totalWorkpackBudgetedUnits = (currentWORKPACK == null || currentWORKPACK.BASELINE_ITEM == null) ? 0 : currentWORKPACK.BASELINE_ITEM.Sum(pItem => pItem.ESTIMATED_HOURS);

            workpackBaseProductivity = ISupportProgressReportingExtensions.CalculatePlannedProductivity(assessmentPeriod, exceptionPeriods, remainingUnitsAfterDataDate);

            if (reportableObject.BASELINE_ITEMJoinRATE.BASELINE_ITEM.ESTIMATED_HOURS == 0)
            {
                reportableObject.BaselineProductivity = workpackBaseProductivity;
            }
            else
            {
                reportableObject.BaselineProductivity = ISupportProgressReportingExtensions.CalculatePlannedProductivity(assessmentPeriod, exceptionPeriods, remainingUnitsAfterDataDate);
                //apply normalized productivity for unusually low calculated productivity
                if (reportableObject.BaselineProductivity < minimumProductivityBeforeEscalating)
                {
                    if (workpackBaseProductivity > 0)
                    {
                        reportableObject.BaselineProductivity = workpackBaseProductivity;
                    }
                }
            }

            List <ProgressInfo> deliverablePlannedDataPointsOnOrBeforeDataDate = reportableObject.NonCumulative_PlannedDataPoints.Where(dataPoint => dataPoint.ProgressDate <= SummaryObject.LivePROGRESS.DATA_DATE).ToList();
            decimal             currentEfficiency = 0;

            if (reportableObject.TOTAL_EARNED_UNITS != 0 && deliverablePlannedDataPointsOnOrBeforeDataDate.Count() > 0)
            {
                decimal deliverablePlannedUnitsOnOrBeforeDataDate = deliverablePlannedDataPointsOnOrBeforeDataDate.Sum(dataPoint => dataPoint.Units);
                if (deliverablePlannedUnitsOnOrBeforeDataDate > 0)
                {
                    currentEfficiency = reportableObject.TOTAL_EARNED_UNITS / deliverablePlannedUnitsOnOrBeforeDataDate;
                }

                reportableObject.ActualProductivity = reportableObject.BaselineProductivity * currentEfficiency;
            }
            else
            {
                reportableObject.ActualProductivity = reportableObject.BaselineProductivity; //assume productivity of 1 because there are no units to measure against
            }
            if (reportableObject.ActualProductivity < minimumProductivityBeforeEscalating)
            {
                reportableObject.ActualProductivity = reportableObject.BaselineProductivity;
            }
        }
コード例 #2
0
        /// <summary>
        /// Try to generate non-cumulative data points from P6 TASKs repository
        /// </summary>
        /// <param name="progressItem">current progress item to generate against, also populate progressItem nonCumulative datapoints collection</param>
        /// <param name="p6ScheduleTasks">context P6 tasks</param>
        /// <param name="firstAlignedDataDate">universal chart first aligned data date</param>
        /// <param name="progressInterval">period iteration interval</param>
        /// <param name="this.CurrencyConversion">currency conversion factor</param>
        /// <param name="nonCumulativeP6DataPoints">current progress item non cumulative data points</param>
        /// <returns>is generation success</returns>
        private bool TryBuildP6DataPoints(P6Data.PROJECT P6PROJECT, IEnumerable <TASK> P6TASKS, ReportableObject reportableObject, DataPointsType processingType, WorkpackAssignmentLoadType assignmentLoadType, out List <ProgressInfo> nonCumulativeP6DataPoints)
        {
            nonCumulativeP6DataPoints = new List <ProgressInfo>();
            if (reportableObject.BASELINE_ITEMJoinRATE.BASELINE_ITEM.WORKPACK == null)
            {
                return(false);
            }

            IEnumerable <WORKPACK_ASSIGNMENT> FilteredWORKPACK_ASSIGNMENTS;

            if (assignmentLoadType == WorkpackAssignmentLoadType.Modified)
            {
                FilteredWORKPACK_ASSIGNMENTS = reportableObject.BASELINE_ITEMJoinRATE.BASELINE_ITEM.WORKPACK.WORKPACK_ASSIGNMENT.Where(assignment => assignment.ISMODIFIEDBASELINE == true);
                if (FilteredWORKPACK_ASSIGNMENTS.Count() == 0)
                {
                    FilteredWORKPACK_ASSIGNMENTS = reportableObject.BASELINE_ITEMJoinRATE.BASELINE_ITEM.WORKPACK.WORKPACK_ASSIGNMENT; //try to get original if modified is empty
                }
            }
            else
            {
                FilteredWORKPACK_ASSIGNMENTS = reportableObject.BASELINE_ITEMJoinRATE.BASELINE_ITEM.WORKPACK.WORKPACK_ASSIGNMENT.Where(assignment => assignment.ISMODIFIEDBASELINE == false);
            }

            if (P6PROJECT != null && FilteredWORKPACK_ASSIGNMENTS != null && P6TASKS != null && FilteredWORKPACK_ASSIGNMENTS.Count() != 0 && P6TASKS.Count() != 0)
            {
                DateTime?lastRecalcDate = P6PROJECT.last_recalc_date;
                BASELINE_ITEMProjection currentBASELINE_ITEM = reportableObject.BASELINE_ITEMJoinRATE;
                decimal progressItemTotalHours = currentBASELINE_ITEM.BASELINE_ITEM.TOTAL_HOURS;
                decimal progressItemTotalCosts = currentBASELINE_ITEM.TOTAL_COSTS;

                foreach (var WORKPACK_ASSIGNMENTS in FilteredWORKPACK_ASSIGNMENTS)
                {
                    decimal  CurrentAssignmentUnits;
                    decimal  CurrentAssignmentCosts;
                    decimal  CurrentAssignmentMaxUnits;
                    decimal  CurrentAssignmentMinUnits;
                    DateTime CurrentAssignmentStartDate;
                    TimeSpan CurrentAssignmentWorkingPeriod;
                    TASK     currentAssignmentTASK = P6TASKS.FirstOrDefault(task => task.task_code == WORKPACK_ASSIGNMENTS.P6_ACTIVITYID);

                    if (processingType == DataPointsType.Planned)
                    {
                        //routine failed so report to revert to workpack dates calculation
                        if (currentAssignmentTASK == null || currentAssignmentTASK.target_start_date == null)
                        {
                            return(false);
                        }

                        CurrentAssignmentStartDate     = (DateTime)currentAssignmentTASK.target_start_date;
                        CurrentAssignmentWorkingPeriod = (DateTime)currentAssignmentTASK.target_end_date - (DateTime)currentAssignmentTASK.target_start_date;
                        CurrentAssignmentMaxUnits      = progressItemTotalHours;
                        CurrentAssignmentMinUnits      = WORKPACK_ASSIGNMENTS.LOW_VALUE;
                    }
                    else if (processingType == DataPointsType.Earned)
                    {
                        CurrentAssignmentMaxUnits = reportableObject.TOTAL_EARNED_UNITS;
                        CurrentAssignmentMinUnits = WORKPACK_ASSIGNMENTS.LOW_VALUE;
                        if (WORKPACK_ASSIGNMENTS.LOW_VALUE > CurrentAssignmentMaxUnits)
                        {
                            continue;
                        }

                        if (currentAssignmentTASK.act_work_qty == null || currentAssignmentTASK.act_start_date == null || (currentAssignmentTASK.act_end_date == null && lastRecalcDate == null))
                        {
                            return(false);
                        }

                        CurrentAssignmentStartDate = (DateTime)currentAssignmentTASK.act_start_date;
                        if (currentAssignmentTASK.act_end_date == null)
                        {
                            CurrentAssignmentWorkingPeriod = (DateTime)lastRecalcDate - (DateTime)currentAssignmentTASK.act_start_date;
                        }
                        else
                        {
                            CurrentAssignmentWorkingPeriod = (DateTime)currentAssignmentTASK.act_end_date - (DateTime)currentAssignmentTASK.act_start_date;
                        }
                    }
                    else
                    {
                        if (currentAssignmentTASK.early_start_date == null || currentAssignmentTASK.early_end_date == null)
                        {
                            return(false);
                        }

                        if (WORKPACK_ASSIGNMENTS.HIGH_VALUE < reportableObject.TOTAL_EARNED_UNITS)
                        {
                            continue;
                        }

                        CurrentAssignmentMaxUnits = progressItemTotalHours;
                        decimal earnedUnits = reportableObject.TOTAL_EARNED_UNITS;
                        if (earnedUnits > WORKPACK_ASSIGNMENTS.LOW_VALUE)
                        {
                            CurrentAssignmentMinUnits = earnedUnits + 1;
                        }
                        else
                        {
                            CurrentAssignmentMinUnits = WORKPACK_ASSIGNMENTS.LOW_VALUE;
                        }

                        CurrentAssignmentStartDate     = (DateTime)currentAssignmentTASK.early_start_date;
                        CurrentAssignmentWorkingPeriod = (DateTime)currentAssignmentTASK.early_end_date - (DateTime)currentAssignmentTASK.early_start_date;
                    }

                    if (WORKPACK_ASSIGNMENTS.HIGH_VALUE > CurrentAssignmentMaxUnits)
                    {
                        CurrentAssignmentUnits = (CurrentAssignmentMaxUnits - CurrentAssignmentMinUnits) + 1;
                    }
                    else
                    {
                        CurrentAssignmentUnits = (WORKPACK_ASSIGNMENTS.HIGH_VALUE - CurrentAssignmentMinUnits) + 1;
                    }

                    //use assignment units instead of estimated units because we are working on a subset of total units, also, this cost will be processed by conversion later
                    CurrentAssignmentCosts = CurrentAssignmentUnits * reportableObject.BASELINE_ITEMJoinRATE.ITEMRATE;
                    nonCumulativeP6DataPoints.AddRange(ISupportProgressReportingExtensions.DataPointsGenerator(SummaryObject, CurrentAssignmentWorkingPeriod, CurrentAssignmentUnits, CurrentAssignmentCosts, CurrentAssignmentStartDate, currentBASELINE_ITEM.BASELINE_ITEM.GUID_ORIGINAL, this.CurrencyConversion, null, null, null));
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }