Beispiel #1
0
        public virtual ActionResult ChangeState(string operationNumber, string opNum, string state)
        {
            var operation = _operationRepository.GetOne(x => x.OperationNumber == opNum);
            var cmb       = CMBusiness.Get(operation);

            cmb
            .Context
            .ActivityPlanItems
            .Where(x => x.Code.ToLower() != CMConstants.DefaultActivityItems.ON)
            .ToList()
            .ForEach(x => x.StatusId = CMConstants.ActivityItemStatus.NotStarted.MasterId);
            var activityItemAppr = cmb.Context.APPRMilestone;

            switch (state)
            {
            case "draft":
                var draftCode = _enumMappingService.GetMappingCode(CSOverallStageEnum.DRAFT);
                operation.OperationData.OperationStageId = draftCode;
                break;

            case "preparation":
                var preparationCode = _enumMappingService.GetMappingCode(CSOverallStageEnum.PREP);
                operation.OperationData.OperationStageId = preparationCode;
                break;

            case "approved":
                var approvedCode = _enumMappingService.GetMappingCode(CSOverallStageEnum.APPR);
                activityItemAppr.SetAsCompleted();
                operation.OperationData.OperationStageId = approvedCode;
                break;

            case "expired":
                var expiredCode = _enumMappingService.GetMappingCode(CSOverallStageEnum.OVSTGEXP);
                activityItemAppr.SetAsCompleted();
                operation.OperationData.OperationStageId = expiredCode;
                break;

            case "closed":
                var closedCode = _enumMappingService.GetMappingCode(CSOverallStageEnum.CL);
                activityItemAppr.SetAsCompleted();
                operation.OperationData.OperationStageId = closedCode;
                break;

            case "cancelled":
                var cancelledCode = _enumMappingService.GetMappingCode(CSOverallStageEnum.CA);
                activityItemAppr.SetAsCompleted();
                operation.OperationData.OperationStageId = cancelledCode;
                break;

            default:
                break;
            }

            cmb.UpdateActivityItem(activityItemAppr);
            _operationRepository.Update(operation);
            var message = "Operation State changed to " + state;

            return(View(viewName: "ChangeOperationState", model: message));
        }
Beispiel #2
0
        private string ChangeStatePCRMilestone(
            bool published,
            Operation operation,
            ActivityItem activityItemInter,
            ActivityItem activityItemIntra)
        {
            var result = string.Empty;

            // PCRINTER
            if (activityItemInter != null)
            {
                if (activityItemInter.StatusId == CMConstants.ActivityItemStatus.Completed.MasterId && !published)
                {
                    activityItemInter.StatusId = CMConstants.ActivityItemStatus.NotStarted.MasterId;
                }
                else if (activityItemInter.StatusId != CMConstants.ActivityItemStatus.Completed.MasterId && published)
                {
                    activityItemInter.StatusId = CMConstants.ActivityItemStatus.Completed.MasterId;
                }

                if (published)
                {
                    result = "1- PCR Published: Operation PCRINTER - Complete";
                }
                else
                {
                    result = "1- PCR Published: Operation PCRINTER - NotStarted";
                }

                CMBusiness.Get(operation).UpdateActivityItem(activityItemInter);
            }

            // PCRINTRA
            if (activityItemIntra != null && activityItemInter != null)
            {
                if (activityItemInter.StatusId == CMConstants.ActivityItemStatus.Completed.MasterId && !published)
                {
                    activityItemIntra.StatusId = CMConstants.ActivityItemStatus.NotStarted.MasterId;
                }
                else if (activityItemInter.StatusId != CMConstants.ActivityItemStatus.Completed.MasterId && published)
                {
                    activityItemIntra.StatusId = CMConstants.ActivityItemStatus.Completed.MasterId;
                }

                if (published)
                {
                    result = "1- PCR Published: Operation PCRINTRA - Complete";
                }
                else
                {
                    result = "1- PCR Published: Operation PCRINTRA - NotStarted";
                }

                CMBusiness.Get(operation).UpdateActivityItem(activityItemInter);
            }

            return(result);
        }
        public virtual ActionResult Index(string operationNumber)
        {
            var typeResponse = _operationDataService.GetOperationType(operationNumber);

            ViewBag.TypeOperation = typeResponse.OperationType;

            if (!TestMode)
            {
                GlobalCommonLogic.SetLastOperation(operationNumber);
            }

            var modelOverview = _operationOverviewModelRepository.GetOverviews(operationNumber, Localization.CurrentLanguage);

            modelOverview.Objetive = _operationOverviewModelRepository.GetObjetive(operationNumber, Localization.CurrentLanguage);
            modelOverview.BasicData.Responsible = _operationOverviewModelRepository.GetResponsible(operationNumber);
            ViewBag.OperationNumber             = operationNumber;
            ViewBag.showLoader = true;

            string[] masterTypeList = new string[]
            {
                MasterType.SECTOR
            };

            var masterDataListByTypeCode = _catalogService
                                           .GetMasterDataListByTypeCode(typeCodes: masterTypeList);

            var operationSectorList = _catalogService.GetListMasterData(
                MasterType.SECTOR, listRepository: masterDataListByTypeCode);

            modelOverview.BasicData.Sector = GetSectorOverview(modelOverview.BasicData.SectorID, operationSectorList);

            try
            {
                modelOverview.EventsData.PartialEligibilityDate = _clientLoan.GetMinElegibilityDateByLoans(operationNumber);
            }
            catch
            {
                modelOverview.EventsData.PartialEligibilityDate = new DateTime();
            }

            var attributes = _operationDataService.GetAttributesBasicResponse(operationNumber);

            if (!TestMode)
            {
                ViewBag.IsAppr = CMBusiness.Get().Context.APPRMilestone.IsCompleted(false);
            }

            ViewBag.FormBasicAttributes = attributes.IsValid ? attributes.Attributes.FormAttributes : new FormDataViewModel();

            ViewBag.operationRelated = _overviewService.GetRelation(operationNumber);
            ViewBag.EventData        = _overviewService.GetEventData(operationNumber);

            return(View(modelOverview));
        }
Beispiel #4
0
        public virtual ActionResult SetExpiredStage(string operationNumber)
        {
            var message     = string.Empty;
            var operation   = _operationRepository.GetOne(x => x.OperationNumber == operationNumber);
            var cmNotStared = _enumMappingService.GetMasterData <CSMilestoneStateEnum>(CSMilestoneStateEnum.NotStarted);
            var cmComplete  = _enumMappingService.GetMasterData <CSMilestoneStateEnum>(CSMilestoneStateEnum.Completed);

            var cmNotStaredModel = new MasterDataModel()
            {
                Code = cmNotStared.Code, MasterId = cmNotStared.MasterDataId, MasterTypeId = cmNotStared.MasterType.MasterTypeId, Name = cmNotStared.NameEn, TypeName = cmNotStared.MasterType.Type
            };
            var cmCompleteModel = new MasterDataModel()
            {
                Code = cmComplete.Code, MasterId = cmComplete.MasterDataId, MasterTypeId = cmComplete.MasterType.MasterTypeId, Name = cmComplete.NameEn, TypeName = cmComplete.MasterType.Type
            };

            if (operation != null)
            {
                var cmb = CMBusiness.Get(operation);

                var activityItems = cmb.Context.ActivityPlanItems;

                foreach (var activityItem in activityItems)
                {
                    activityItem.EndDate   = null;
                    activityItem.StartDate = null;
                    activityItem.StatusId  = CMConstants.ActivityItemStatus.NotStarted.MasterId;
                    cmb.UpdateActivityItem(activityItem);
                }

                var transMilestone = cmb.Context.GetActivityItem("CSCW");
                transMilestone.EndDate   = null;
                transMilestone.StartDate = null;
                transMilestone.StatusId  = CMConstants.ActivityItemStatus.Completed.MasterId;
                cmb.UpdateActivityItem(transMilestone);

                transMilestone           = cmb.Context.GetActivityItem("CSVP");
                transMilestone.EndDate   = null;
                transMilestone.StartDate = null;
                transMilestone.StatusId  = CMConstants.ActivityItemStatus.Completed.MasterId;
                cmb.UpdateActivityItem(transMilestone);

                message = "Operation " + operationNumber + " is in Expired Stage.";
            }
            else
            {
                message = "Operation " + operationNumber + " doesn´t exist.";
            }

            return(View("FakeLifeCycle", model: message));
        }
        public virtual ActionResult IndexOperationBudget(string operationNumber, string year)
        {
            var stageCode = CMBusiness.Get(IDBContext.Current.Operation).Context.APPRMilestone
                            .IsCompleted(false)
                ? OperationBudgetValues.OPERATION_PHASE_EXECUTION
                : OperationBudgetValues.OPERATION_PHASE_PREPARATION;

            string stage = stageCode == OperationBudgetValues.OPERATION_PHASE_EXECUTION
                ? Localization.GetText("TCP.FirmProcurement.Tabs.Execution")
                : Localization.GetText("TCP.FirmProcurement.Tabs.Preparation");

            var service = Globals.Resolve <ISPOperationBudget>();

            var responseYears = service.GetSpYearsByOperationNumber(
                new GetSPYearsByOperationNumberRequest
            {
                OperationNumber = operationNumber
            });

            if (!responseYears.IsValid)
            {
                throw new Exception(responseYears.ErrorMessage);
            }
            var responseConvert = service.ConvertListItems(responseYears.Years);
            var selectYear      = string.IsNullOrEmpty(year)
                ? responseYears.Years.FirstOrDefault()
                : Convert.ToInt32(year);
            var response = service.GetBudget(new PSPBudgetRequest
            {
                Year            = selectYear,
                OperationNumber = operationNumber,
                Stage           = stage,
                StageCode       = stageCode
            });

            if (!response.IsValid)
            {
                throw new Exception(response.ErrorMessage);
            }
            var result = new SPOperationBudgetViewModel
            {
                SpOperationBudgetDto = response.PreparationOperationBudget,
                SpTotalValuesDto     = response.SpTotalValuesDto,
                SelectedYear         = selectYear.ToString(),
                Years = responseConvert,
                SupervisionPlanDashboardRoute = ConfigurationServiceFactory
                                                .Current.GetApplicationSettings().SupervisionPlanDashboardRoute
            };

            return(PartialView(result));
        }
Beispiel #6
0
        public virtual ActionResult EditPCR(string opNum, bool published, bool required)
        {
            var message = string.Empty;

            if (opNum == null || opNum == string.Empty)
            {
                message = "Operation Number is Empty";
                return(View(viewName: "TestPCR", model: message));
            }

            var operation = _operationRepository.GetOne(x => x.OperationNumber == opNum);

            if (operation == null)
            {
                message = "Operation Null";
                return(View(viewName: "TestPCR", model: message));
            }

            if (!OperationTypeHelper.GetOperationTypes(operation.OperationId).Contains(OperationType.LON) &&
                !OperationTypeHelper.GetOperationTypes(operation.OperationId).Contains(OperationType.GUA) &&
                !OperationTypeHelper.GetOperationTypes(operation.OperationId).Contains(OperationType.IGR))
            {
                message = "Operation Not SG";
                return(View(viewName: "TestPCR", model: message));
            }

            var cmb = CMBusiness.Get(operation);
            var activityItemInter = cmb.GetActivityItem(CMConstants.DefaultActivityItems.PCRINTER);
            var activityItemIntra = cmb.GetActivityItem(CMConstants.DefaultActivityItems.PCRINTRA);

            if (activityItemInter == null && activityItemIntra == null)
            {
                message = "Operation Not Have PCRINTRA/PCRINTER";
                return(View(viewName: "TestPCR", model: message));
            }

            var message1 = ChangeStatePCRMilestone(published, operation, activityItemInter, activityItemIntra);
            var message2 = ChangeWorkflowRequired(operation, required);

            if (published && required)
            {
                var message3 = CreateAverageScore(operation);
            }

            //Test
            message = TestPCRForDebugg(operation);
            return(View(viewName: "TestPCR", model: "Result Value: " + message));
        }
Beispiel #7
0
        public virtual ActionResult CreateActivityPlan(int selectedTemplate)
        {
            var cmb = CMBusiness.Get(IDBContext.Current.Operation);

            var items = cmb.Context.ActivityPlanItems;

            int activityPlanId = cmb.Context.ActiveActivityPlan.Id;

            var cofinancingService = Globals.Resolve <ICofinancingService>();

            var cofinCounterpartFundDetailIds =
                GetCofinCounterpartFundDetail(cofinancingService, activityPlanId);

            if (cofinCounterpartFundDetailIds.Any())
            {
                cofinancingService.UpdateActivityPlan(cofinCounterpartFundDetailIds, null);
            }

            cmb.DeleteCurrentActivityPlan();

            int newActivityPlanId = cmb.CreateActivityPlan(selectedTemplate, items, true).Id;

            if (cofinCounterpartFundDetailIds.Any())
            {
                cofinancingService
                .UpdateActivityPlan(cofinCounterpartFundDetailIds, newActivityPlanId);
            }

            cmb = CMBusiness.Get(IDBContext.Current.Operation);

            if (cmb.Context.LastCompletedActivityItem != null)
            {
                cmb.UpdateActivityItem(cmb.Context.LastCompletedActivityItem, true);
            }

            UpdateActivityPlanCompAppr(cmb);

            UpdateReferencesToNewActivityPlan(
                cmb.Context.ActiveActivityPlan.OperationId,
                newActivityPlanId,
                activityPlanId);

            return(Content("ok"));
        }