private void SaveReport()
        {
            if (currentREPORT == null)
            {
                return;
            }

            // Save the report to a stream.
            MemoryStream ms = new MemoryStream();

            currentREPORT.SaveLayout(ms);

            // Prepare the stream for reading.
            ms.Position = 0;
            // Insert the report to a database.
            using (StreamReader sr = new StreamReader(ms))
            {
                // Read the report from the stream to a string variable.
                string reportString = sr.ReadToEnd();
                if (currentPROJECT_REPORT == null)
                {
                    currentPROJECT_REPORT = new PROJECT_REPORT();
                    currentPROJECT_REPORT.GUID_PROJECT = currentPROJECT.GUID;
                    currentPROJECT_REPORT.REPORT_TYPE  = currentReportType.ToString();
                    currentPROJECT_REPORT.REPORT       = reportString;
                }
                else
                {
                    currentPROJECT_REPORT.REPORT = reportString;
                }

                collectionViewModel.Save(currentPROJECT_REPORT);
            }
        }
Exemplo n.º 2
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.º 3
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);
        }
Exemplo n.º 4
0
        bool MainEntityPreSave(PROGRESS_ITEMProjection projectionEntity)
        {
            CollectionViewModel <PROGRESS_ITEM, PROGRESS_ITEM, Guid, IBluePrintsEntitiesUnitOfWork> PROGRESS_ITEMSCollectionViewModel = (CollectionViewModel <PROGRESS_ITEM, PROGRESS_ITEM, Guid, IBluePrintsEntitiesUnitOfWork>)loaderCollection.GetViewModel <PROGRESS_ITEM>();
            PROGRESS_ITEM savePROGRESS_ITEM = projectionEntity.PROGRESS_ITEMCurrent;

            savePROGRESS_ITEM.EARNED_DATE      = loadPROGRESS.DATA_DATE;
            savePROGRESS_ITEM.GUID_PROGRESS    = loadPROGRESS.GUID;
            savePROGRESS_ITEM.GUID_ORIBASEITEM = projectionEntity.BASELINE_ITEMJoinRATE.BASELINE_ITEM.GUID_ORIGINAL;
            //workaround for created because Save() only sets the projection primary key, this is used for property redo where the interceptor only tampers with UPDATED and CREATED is left as null
            if (savePROGRESS_ITEM.CREATED.Date.Year == 1)
            {
                savePROGRESS_ITEM.CREATED = DateTime.Now;
            }

            savePROGRESS_ITEM = projectionEntity.PROGRESS_ITEMCurrent;
            PROGRESS_ITEMSCollectionViewModel.Save(savePROGRESS_ITEM);
            return(false);
        }
        /// <summary>
        /// Approves an entity.
        /// Since CollectionViewModelBase is a POCO view model, an the instance of this class will also expose the ApproveCommand property that can be used as a binding source in views.
        /// </summary>
        /// <param name="projectionEntity">An entity to approve.</param>
        public void Approve(VARIATION entity)
        {
            string errorMessage = string.Empty;

            if (entity == null)
            {
                errorMessage = "Nothing within variation to approve";
            }
            else if (loadPROJECT == null)
            {
                errorMessage = "Project doesn't exists";
            }
            else if (loadBASELINE == null)
            {
                errorMessage = "Live baseline doesn't exists";
            }
            else if (loadPROGRESS == null)
            {
                errorMessage = "Live progress doesn't exists";
            }

            if (errorMessage != string.Empty)
            {
                MessageBoxService.ShowMessage(errorMessage);
                return;
            }

            IBluePrintsEntitiesUnitOfWork unitOfWork = bluePrintsUnitOfWorkFactory.CreateUnitOfWork();
            BASELINE LiveBASELINE = loadBASELINE;
            IEnumerable <VARIATION_ITEM> editVARIATION_ITEMS = unitOfWork.VARIATION_ITEMS.Where(x => x.GUID_VARIATION == entity.GUID).ToArray().AsEnumerable();
            IEnumerable <BASELINE_ITEM>  addBASELINE_ITEMS   = unitOfWork.BASELINE_ITEMS.Where(x => x.GUID_VARIATION == entity.GUID && x.GUID_BASELINE == null).ToArray().AsEnumerable();
            IQueryable <BASELINE_ITEM>   editBASELINE_ITEMS  = loaderCollection.GetCollection <BASELINE_ITEM>();
            IEnumerable <PROGRESS_ITEM>  livePROGRESS_ITEMS  = loaderCollection.GetCollection <PROGRESS_ITEM>();

            BASELINE newBASELINE = new BASELINE();

            DataUtils.ShallowCopy(newBASELINE, LiveBASELINE);
            newBASELINE.GUID     = Guid.Empty;
            newBASELINE.REVISION = ((char)(LiveBASELINE.REVISION.Last() + 1)).ToString();
            //not saving new baseline as live yet because editBASELINE_ITEMS still depends on the current live baseline for copying BASELINE_ITEMS
            newBASELINE.STATUS = BaselineStatus.Superseded;

            CollectionViewModel <BASELINE, BASELINE, Guid, IBluePrintsEntitiesUnitOfWork>           BASELINECollectionViewModel      = (CollectionViewModel <BASELINE, BASELINE, Guid, IBluePrintsEntitiesUnitOfWork>)loaderCollection.GetViewModel <BASELINE>();
            CollectionViewModel <BASELINE_ITEM, BASELINE_ITEM, Guid, IBluePrintsEntitiesUnitOfWork> BASELINE_ITEMCollectionViewModel = (CollectionViewModel <BASELINE_ITEM, BASELINE_ITEM, Guid, IBluePrintsEntitiesUnitOfWork>)loaderCollection.GetViewModel <BASELINE_ITEM>();

            BASELINECollectionViewModel.Save(newBASELINE);

            entity.APPROVED         = DateTime.Now;
            entity.GUID_ORIBASELINE = LiveBASELINE.GUID;
            entity.GUID_BASELINE    = newBASELINE.GUID;
            MainViewModel.Save(entity);

            ObservableCollection <BASELINE_ITEM> newBASELINE_ITEMS = new ObservableCollection <BASELINE_ITEM>();

            foreach (BASELINE_ITEM editBASELINE_ITEM in editBASELINE_ITEMS)
            {
                BASELINE_ITEM copyBASELINE_ITEM = new BASELINE_ITEM();
                DataUtils.ShallowCopy(copyBASELINE_ITEM, editBASELINE_ITEM);

                VARIATION_ITEM editVARIATION_ITEM = editVARIATION_ITEMS.FirstOrDefault(x => x.GUID_ORIBASEITEM == editBASELINE_ITEM.GUID_ORIGINAL);
                if (editVARIATION_ITEM != null)
                {
                    if (editVARIATION_ITEM.ACTION == VariationAction.Cancel)
                    {
                        decimal progressItemEARNED_UNITS = livePROGRESS_ITEMS.Where(x => x.GUID_ORIBASEITEM == editBASELINE_ITEM.GUID_ORIGINAL).Sum(y => y.EARNED_UNITS);
                        if (progressItemEARNED_UNITS == 0)
                        {
                            copyBASELINE_ITEM.DC_HOURS = -1 * copyBASELINE_ITEM.ESTIMATED_HOURS;
                        }
                        else
                        {
                            copyBASELINE_ITEM.DC_HOURS = -1 * (copyBASELINE_ITEM.TOTAL_HOURS - progressItemEARNED_UNITS);
                        }
                    }
                    else if (editVARIATION_ITEM.ACTION == VariationAction.Append)
                    {
                        copyBASELINE_ITEM.DC_HOURS += editVARIATION_ITEM.VARIATION_UNITS;
                    }

                    if (editVARIATION_ITEM.ACTION != VariationAction.NoAction)
                    {
                        copyBASELINE_ITEM.GUID_VARIATION = entity.GUID;
                    }
                }

                copyBASELINE_ITEM.GUID          = Guid.Empty;
                copyBASELINE_ITEM.GUID_BASELINE = newBASELINE.GUID;
                newBASELINE_ITEMS.Add(copyBASELINE_ITEM);
            }

            foreach (BASELINE_ITEM addBASELINE_ITEM in addBASELINE_ITEMS)
            {
                BASELINE_ITEM newBASELINE_ITEM = new BASELINE_ITEM();
                DataUtils.ShallowCopy(newBASELINE_ITEM, addBASELINE_ITEM);
                newBASELINE_ITEM.GUID          = Guid.Empty;
                newBASELINE_ITEM.GUID_BASELINE = newBASELINE.GUID;
                newBASELINE_ITEM.INTERNAL_NUM  = BluePrintDataUtils.BASELINEITEM_Generate_InternalNumber(this.loadPROJECT, newBASELINE_ITEM, newBASELINE_ITEMS, addBASELINE_ITEM.AREA, addBASELINE_ITEM.DISCIPLINE, addBASELINE_ITEM.DOCTYPE);
                VARIATION_ITEM editVARIATION_ITEM = editVARIATION_ITEMS.First(x => x.GUID_ORIBASEITEM == newBASELINE_ITEM.GUID_ORIGINAL);
                newBASELINE_ITEM.DC_HOURS       = editVARIATION_ITEM.VARIATION_UNITS;
                newBASELINE_ITEM.GUID_VARIATION = entity.GUID;

                newBASELINE_ITEMS.Add(newBASELINE_ITEM);
            }

            foreach (BASELINE_ITEM newBASELINE_ITEM in newBASELINE_ITEMS)
            {
                BASELINE_ITEMCollectionViewModel.Save(newBASELINE_ITEM);
            }

            LiveBASELINE.STATUS = BaselineStatus.Superseded;
            BASELINECollectionViewModel.Save(LiveBASELINE);
            newBASELINE.STATUS = BaselineStatus.Live;
            BASELINECollectionViewModel.Save(newBASELINE);
        }