Ejemplo n.º 1
0
        internal void Fill(ExcelWorksheet worksheet, SimulationModel simulationModel, int simulationYearsCount, ParametersModel parametersModel)
        {
            var simulationId            = simulationModel.simulationId;
            var investmentPeriod        = analysisData.GetAnySimulationAnalysis(simulationId, db);
            var inflationAndInvestments = getInflationRate.GetAnySimulationInvestmentLibrary(simulationId, db);
            var priorities = getPriorities.GetAnySimulationPriorityLibrary(simulationId, db).Priorities;
            var criterias  = budgetCriteria.GetAnyCriteriaDrivenBudgets(simulationId, db);

            // Simulation Name format
            excelHelper.MergeCells(worksheet, 1, 1, 1, 2);
            excelHelper.MergeCells(worksheet, 1, 3, 1, 10);
            excelHelper.ApplyColor(worksheet.Cells[1, 1, 1, 2], Color.Gray);

            worksheet.Cells["A1:B1"].Value = "Simulation Name";
            worksheet.Cells["C1:J1"].Value = simulationModel.simulationName;
            excelHelper.ApplyColor(worksheet.Cells[1, 3, 1, 10], Color.FromArgb(142, 169, 219));
            excelHelper.ApplyBorder(worksheet.Cells[1, 1, 1, 10]);
            // End of Simulation Name format

            FillData(worksheet, parametersModel);

            FillSimulationDetails(worksheet, investmentPeriod, inflationAndInvestments.InflationRate, simulationYearsCount);
            FillAnalysisDetails(worksheet, investmentPeriod);
            FillJurisdictionCriteria(worksheet, investmentPeriod.Criteria);
            FillPriorities(worksheet, priorities);
            FillInvestmentAndBudgetCriteria(worksheet, inflationAndInvestments, criterias);
            worksheet.Cells.AutoFitColumns(50);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a mapping from user roles to the appropriate methods for getting priority libraries
        /// </summary>
        private Dictionary <string, PriorityLibraryGetMethod> CreateGetMethods()
        {
            PriorityLibraryModel GetAnyLibrary(int id, UserInformationModel userInformation) =>
            repo.GetAnySimulationPriorityLibrary(id, db);
            PriorityLibraryModel GetPermittedLibrary(int id, UserInformationModel userInformation) =>
            repo.GetPermittedSimulationPriorityLibrary(id, db, userInformation.Name);

            return(new Dictionary <string, PriorityLibraryGetMethod>
            {
                [Role.ADMINISTRATOR] = GetAnyLibrary,
                [Role.DISTRICT_ENGINEER] = GetPermittedLibrary,
                [Role.CWOPA] = GetAnyLibrary,
                [Role.PLANNING_PARTNER] = GetPermittedLibrary
            });
        }