public void OnSelectedEntityChanged(IEnumerable <TProjection> entities)
        {
            if (entities.Count() == 0)
            {
                return;
            }

            if (entities.Count() == 1)
            {
                SummaryEntity = entities.First();
            }
            else
            {
                TProjection newEntity            = ViewModelSource.Create(() => new TProjection());
                DateTime    earliestDataDate     = entities.Min(x => x.ReportingDataDate);
                var         earliestLiveProgress = entities.First(x => x.LivePROGRESS.DATA_DATE == earliestDataDate).LivePROGRESS;
                newEntity.LivePROGRESS         = earliestLiveProgress;
                newEntity.IntervalPeriod       = ISupportProgressReportingExtensions.ConvertProgressIntervalToPeriod(earliestLiveProgress);
                newEntity.ReportableObjects    = entities.SelectMany(x => x.ReportableObjects);
                newEntity.FirstAlignedDataDate = entities.Min(x => x.FirstAlignedDataDate);
                newEntity.ReportingDataDate    = earliestLiveProgress.DATA_DATE;
                newEntity.NonCumulative_VariationAdjustments       = new ObservableCollection <VariationAdjustment>(entities.SelectMany(x => x.NonCumulative_VariationAdjustments));
                newEntity.NonCumulative_ActualDataPoints           = new ObservableCollection <ProgressInfo>(entities.SelectMany(x => x.NonCumulative_ActualDataPoints));
                newEntity.NonCumulative_BurnedDataPoints           = new ObservableCollection <ProgressInfo>(entities.SelectMany(x => x.NonCumulative_BurnedDataPoints));
                newEntity.NonCumulative_EarnedDataPoints           = new ObservableCollection <ProgressInfo>(entities.SelectMany(x => x.NonCumulative_EarnedDataPoints));
                newEntity.NonCumulative_OriginalDataPoints         = new ObservableCollection <ProgressInfo>(entities.SelectMany(x => x.NonCumulative_OriginalDataPoints));
                newEntity.NonCumulative_PlannedDataPoints          = new ObservableCollection <ProgressInfo>(entities.SelectMany(x => x.NonCumulative_PlannedDataPoints));
                newEntity.NonCumulative_RemainingPlannedDataPoints = new ObservableCollection <ProgressInfo>(entities.SelectMany(x => x.NonCumulative_RemainingPlannedDataPoints));
                ISupportProgressReportingExtensions.GenerateCumulativeSummaryDataPoints(newEntity);
                SummaryEntity = newEntity;
            }

            this.RaisePropertyChanged(x => x.SummaryEntity);
        }
        public PROJECTSummaryBuilder(SummarizableObject summaryObject, IBluePrintsEntitiesUnitOfWork BluePrintsUOW = null, IP6EntitiesUnitOfWork P6UOW = null)
        {
            if (summaryObject.LivePROGRESS == null || summaryObject.LiveBASELINE == null)
            {
                return;
            }

            this.CurrencyConversion = summaryObject.LiveBASELINE.PROJECT.CURRENCYCONVERSION;
            this.SummaryObject      = summaryObject;
            this.SummaryObject.ReportingDataDate = this.SummaryObject.LivePROGRESS.DATA_DATE;

            if (BluePrintsUOW == null)
            {
                BluePrintsUOW = BluePrintsEntitiesUnitOfWorkSource.GetUnitOfWorkFactory().CreateUnitOfWork();
            }
            else
            {
                this.BluePrintsUnitOfWork = BluePrintsUOW;
            }

            if (P6UOW == null)
            {
                this.P6UnitOfWork = P6EntitiesUnitOfWorkSource.GetUnitOfWorkFactory().CreateUnitOfWork();
            }
            else
            {
                this.P6UnitOfWork = P6UOW;
            }

            this.SummaryObject.IntervalPeriod       = ISupportProgressReportingExtensions.ConvertProgressIntervalToPeriod(SummaryObject.LivePROGRESS);
            this.SummaryObject.FirstAlignedDataDate = ISupportProgressReportingExtensions.GenerateFirstAlignedDataDate(SummaryObject.LivePROGRESS);
        }
Exemplo n.º 3
0
        void OnPROJECTWORKPACKSMappingViewModelLoaded(IEnumerable <WORKPACK_Dashboard> entities)
        {
            IEnumerable <TASK>         PROJECTTASK = WORKPACK_DashboardViewModel.P6TASKCollection;
            IEnumerable <ProgressInfo> cumulativeEarnedDataPoints = WORKPACK_DashboardViewModel.MainViewModel.Entities.Where(x => x.Summary_CumulativeEarnedDataPoints != null).SelectMany(x => x.Summary_CumulativeEarnedDataPoints);

            cumulativeEarnedDataPoints = cumulativeEarnedDataPoints.OrderBy(x => x.ProgressDate).ToList();
            TimeSpan intervalTimeSpan = ISupportProgressReportingExtensions.ConvertProgressIntervalToPeriod(loadPROGRESS);
            CollectionViewModel <TASK, int, IP6EntitiesUnitOfWork> P6TASKCollectionViewModel = WORKPACK_DashboardViewModel.P6TASKCollectionViewModel;

            foreach (WORKPACK_Dashboard workpack in WORKPACK_DashboardViewModel.MainViewModel.Entities)
            {
                ProgressInfo fWorkpackEarnedDataPoint = cumulativeEarnedDataPoints.FirstOrDefault(dataPoint => dataPoint.WorkpackGuid == workpack.WORKPACK.GUID && dataPoint.Units > 0);
                if (fWorkpackEarnedDataPoint != null)
                {
                    ProgressInfo lWorkpackEarnedDataPoint          = cumulativeEarnedDataPoints.LastOrDefault(dataPoint => dataPoint.WorkpackGuid == workpack.WORKPACK.GUID && dataPoint.ProgressDate <= loadPROGRESS.DATA_DATE);
                    List <WORKPACK_ASSIGNMENT> workpackAssignments = workpack.WORKPACK.WORKPACK_ASSIGNMENT.Where(assignment => assignment.LOW_VALUE <= lWorkpackEarnedDataPoint.Units).OrderBy(assignment => assignment.LOW_VALUE).ToList();
                    for (int i = 0; i < workpackAssignments.Count; i++)
                    {
                        WORKPACK_ASSIGNMENT workpackAssignment = workpackAssignments[i];
                        TASK P6TASK = PROJECTTASK.FirstOrDefault(P6Task => P6Task.task_code == workpackAssignment.P6_ACTIVITYID);
                        if (P6TASK != null)
                        {
                            DateTime proposedStartDate = fWorkpackEarnedDataPoint.ProgressDate.AddDays(-1 * intervalTimeSpan.Days).AddSeconds(1);
                            if (P6TASK.act_start_date == null || P6TASK.act_start_date > proposedStartDate)
                            {
                                P6TASK.act_start_date = proposedStartDate;
                            }

                            decimal actUnits             = lWorkpackEarnedDataPoint.Units < workpackAssignment.HIGH_VALUE ? lWorkpackEarnedDataPoint.Units : workpackAssignment.HIGH_VALUE;
                            decimal actWorkUnitNormalize = i == 0 ? actUnits : (actUnits - workpackAssignments[i - 1].HIGH_VALUE);
                            P6TASK.act_work_qty = actWorkUnitNormalize;
                            if (P6TASK.remain_work_qty >= 0)
                            {
                                P6TASK.remain_work_qty = P6TASK.target_work_qty - P6TASK.act_work_qty;
                            }
                            P6TASK.remain_drtn_hr_cnt = P6TASK.target_drtn_hr_cnt * (P6TASK.remain_work_qty / P6TASK.target_work_qty);

                            if (P6TASK.remain_work_qty == 0)
                            {
                                P6TASK.status_code  = P6TASKSTATUS.TK_Complete.ToString();
                                P6TASK.act_end_date = lWorkpackEarnedDataPoint.ProgressDate;
                            }
                            else if (P6TASK.remain_work_qty > 0)
                            {
                                P6TASK.status_code  = P6TASKSTATUS.TK_Active.ToString();
                                P6TASK.act_end_date = null;
                            }
                            else if (P6TASK.status_code == P6TASKSTATUS.TK_NotStart.ToString())
                            {
                                P6TASK.status_code = P6TASKSTATUS.TK_Active.ToString();
                            }

                            P6TASKCollectionViewModel.Save(P6TASK);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void DateChange(bool isForward)
        {
            var interval   = ISupportProgressReportingExtensions.ConvertProgressIntervalToPeriod(loadPROGRESS);
            int multiplier = isForward == true ? 1 : -1;

            loadPROGRESS.DATA_DATE = loadPROGRESS.DATA_DATE.AddDays(multiplier * interval.Days);
            CollectionViewModel <PROGRESS, PROGRESS, Guid, IBluePrintsEntitiesUnitOfWork> PROGRESSCollectionViewModel = (CollectionViewModel <PROGRESS, PROGRESS, Guid, IBluePrintsEntitiesUnitOfWork>)loaderCollection.GetViewModel <PROGRESS>();

            PROGRESSCollectionViewModel.Save(loadPROGRESS);
            this.RaisePropertyChanged(x => x.DataDate);
        }