Exemple #1
0
        private YearsData AddYearsData(DataRow simulationRow, ReportProjectCost projectCostEntry, int year, BudgetsPerBRKey budgetPerBrKey)
        {
            var yearsData = new YearsData
            {
                Deck   = simulationRow["DECK_SEEDED_" + year].ToString(),
                Super  = simulationRow["SUP_SEEDED_" + year].ToString(),
                Sub    = simulationRow["SUB_SEEDED_" + year].ToString(),
                Culv   = simulationRow["CULV_SEEDED_" + year].ToString(),
                DeckD  = simulationRow["DECK_DURATION_N_" + year].ToString(),
                SuperD = simulationRow["SUP_DURATION_N_" + year].ToString(),
                SubD   = simulationRow["SUB_DURATION_N_" + year].ToString(),
                CulvD  = simulationRow["CULV_DURATION_N_" + year].ToString(),
                Year   = year
            };
            var isDeckConverted  = double.TryParse(yearsData.Deck, out var deck);
            var isCulvConverted  = double.TryParse(yearsData.Culv, out var culv);
            var isSuperConverted = double.TryParse(yearsData.Super, out var super);
            var isSubConverted   = double.TryParse(yearsData.Sub, out var sub);

            if (isDeckConverted && isCulvConverted && isSuperConverted && isSubConverted)
            {
                yearsData.MinC = Math.Min(deck, Math.Min(culv, Math.Min(super, sub)));
            }
            yearsData.SD = yearsData.MinC < 5 ? "Y" : "N";

            yearsData.Project = year != 0 ? projectCostEntry?.TREATMENT : string.Empty;

            double roundedCost = 0;

            if (projectCostEntry != null)
            {
                var amount = projectCostEntry.COST_;
                if (amount >= 500)
                {
                    roundedCost = amount % 1000 >= 500 ? amount + 1000 - amount % 1000 : amount - amount % 1000;
                }
                else
                {
                    roundedCost = 1000;
                }
            }

            yearsData.Cost        = year != 0 ? roundedCost : 0;
            yearsData.Project     = yearsData.Project == null ? "No Treatment" : yearsData.Project;
            yearsData.Budget      = budgetPerBrKey != null ? budgetPerBrKey.Budget : "";
            yearsData.ProjectPick = budgetPerBrKey != null ?
                                    (budgetPerBrKey.ProjectType == 0 ? "BAMs Pick" :
                                     (budgetPerBrKey.ProjectType == 1 ? "Committed Pick" :
                                      (budgetPerBrKey.ProjectType == 2 ? "Cash Flow" : "Scheduled")
                                     )) :
                                    "BAMs Pick";
            yearsData.ProjectPickType = budgetPerBrKey != null ? budgetPerBrKey.ProjectType : 0;
            yearsData.Treatment       = budgetPerBrKey != null ? budgetPerBrKey.Treatment : "";
            return(yearsData);
        }
Exemple #2
0
        private SimulationDataModel CreatePrevYearSimulationMdel(DataRow simulationRow)
        {
            YearsData yearsData = AddYearsData(simulationRow, null, 0);

            return(new SimulationDataModel
            {
                YearsData = new List <YearsData>()
                {
                    yearsData
                },
                SectionId = Convert.ToInt32(simulationRow["SECTIONID"])
            });
        }
Exemple #3
0
        private SimulationDataModel CreatePrevYearSimulationMdel(DataRow simulationRow)
        {
            var blankBudgetForPreviousYear = new BudgetsPerBRKey {
                Budget = "", IsCommitted = false, Treatment = ""
            };
            YearsData yearsData = AddYearsData(simulationRow, null, 0, blankBudgetForPreviousYear);

            return(new SimulationDataModel
            {
                YearsData = new List <YearsData>()
                {
                    yearsData
                },
                SectionId = Convert.ToInt32(simulationRow["SECTIONID"])
            });
        }
Exemple #4
0
        private YearsData AddYearsData(DataRow simulationRow, ReportProjectCost projectCostEntry, int year)
        {
            var yearsData = new YearsData
            {
                Deck   = simulationRow["DECK_SEEDED_" + year].ToString(),
                Super  = simulationRow["SUP_SEEDED_" + year].ToString(),
                Sub    = simulationRow["SUB_SEEDED_" + year].ToString(),
                Culv   = simulationRow["CULV_SEEDED_" + year].ToString(),
                DeckD  = simulationRow["DECK_DURATION_N_" + year].ToString(),
                SuperD = simulationRow["SUP_DURATION_N_" + year].ToString(),
                SubD   = simulationRow["SUB_DURATION_N_" + year].ToString(),
                CulvD  = simulationRow["CULV_DURATION_N_" + year].ToString(),
                Year   = year
            };

            yearsData.MinC = Math.Min(Convert.ToDouble(yearsData.Deck), Convert.ToDouble(yearsData.Culv)).ToString();
            yearsData.SD   = Convert.ToDouble(yearsData.DeckD) < 5 ? "Y" : "N";

            yearsData.Project = year != 0 ? projectCostEntry?.TREATMENT : string.Empty;
            yearsData.Cost    = year != 0 ? (projectCostEntry == null ? 0 : projectCostEntry.COST_) : 0;
            yearsData.Project = yearsData.Cost == 0 ? "No Treatment" : yearsData.Project;
            return(yearsData);
        }
        private int AddSimulationYearData(ExcelWorksheet worksheet, int row, int column, YearsData yearData, string familyId)
        {
            var familyIdLessThanEleven = Convert.ToInt32(familyId) < 11;

            worksheet.Cells[row, ++column].Value = Convert.ToInt32(familyId) > 10 ? "N" : yearData.Deck;
            worksheet.Cells[row, ++column].Value = Convert.ToInt32(familyId) > 10 ? "N" : yearData.Super;
            worksheet.Cells[row, ++column].Value = Convert.ToInt32(familyId) > 10 ? "N" : yearData.Sub;
            worksheet.Cells[row, ++column].Value = familyIdLessThanEleven ? "N" : yearData.Culv;
            yearData.Culv = familyIdLessThanEleven ? "N" : yearData.Culv;
            worksheet.Cells[row, ++column].Value = Convert.ToInt32(familyId) > 10 ? "N" : yearData.DeckD;
            worksheet.Cells[row, ++column].Value = Convert.ToInt32(familyId) > 10 ? "N" : yearData.SuperD;
            worksheet.Cells[row, ++column].Value = Convert.ToInt32(familyId) > 10 ? "N" : yearData.SubD;
            worksheet.Cells[row, ++column].Value = familyIdLessThanEleven ? "N" : yearData.CulvD;
            yearData.CulvD = familyIdLessThanEleven ? "N" : yearData.CulvD;
            worksheet.Cells[row, ++column].Value = yearData.MinC;
            worksheet.Cells[row, ++column].Value = yearData.SD;
            if (yearData.Year != 0)
            {
                worksheet.Cells[row, ++column].Value = yearData.Project;
                worksheet.Cells[row, ++column].Value = yearData.Cost;
                excelHelper.SetCurrencyFormat(worksheet.Cells[row, column]);
            }
            // Empty column
            column++;
            return(column);
        }
Exemple #6
0
 private int EnterMinDeckSuperSubCulv(ExcelWorksheet worksheet, int row, int column, YearsData yearData)
 {
     worksheet.Cells[row, ++column].Value = yearData.MinC;
     if (yearData.MinC <= 3.5)
     {
         excelHelper.ApplyColor(worksheet.Cells[row, column], Color.FromArgb(112, 48, 160));
         excelHelper.SetTextColor(worksheet.Cells[row, column], Color.White);
     }
     return(column);
 }
Exemple #7
0
        private int EnterMinDeckSuperSub(ExcelWorksheet worksheet, int row, int column, YearsData yearData)
        {
            var minValue = Math.Min(Convert.ToDouble(yearData.Deck), Math.Min(Convert.ToDouble(yearData.Super), Convert.ToDouble(yearData.Sub)));

            worksheet.Cells[row, ++column].Value = minValue;
            yearData.MinC = minValue;
            if (yearData.MinC <= 3.5)
            {
                excelHelper.ApplyColor(worksheet.Cells[row, column], Color.FromArgb(112, 48, 160));
                excelHelper.SetTextColor(worksheet.Cells[row, column], Color.White);
            }
            return(column);
        }
Exemple #8
0
 private int EnterValueEqualsCulv(ExcelWorksheet worksheet, int row, int column, YearsData yearData)
 {
     yearData.MinC = Convert.ToDouble(yearData.Culv);
     worksheet.Cells[row, ++column].Value = yearData.MinC;
     if (yearData.MinC <= 3.5)
     {
         excelHelper.ApplyColor(worksheet.Cells[row, column], Color.FromArgb(112, 48, 160));
         excelHelper.SetTextColor(worksheet.Cells[row, column], Color.White);
     }
     return(column);
 }
Exemple #9
0
 private int EnterDefaultMinCValue(ExcelWorksheet worksheet, int row, int column, YearsData yearData)
 {
     worksheet.Cells[row, ++column].Value = "N";
     // It is a dummy value
     yearData.MinC = 100;
     return(column);
 }
Exemple #10
0
        private int AddSimulationYearData(ExcelWorksheet worksheet, int row, int column, YearsData yearData, int familyId,
                                          BridgeDataModel bridgeDataModel, Dictionary <int, int> projectPickByYear)
        {
            var minCActionCallDecider  = MinCValue.minOfCulvDeckSubSuper;
            var familyIdLessThanEleven = familyId < 11;

            if (familyId > 10)
            {
                worksheet.Cells[row, ++column].Value = "N";
                worksheet.Cells[row, ++column].Value = "N";
                worksheet.Cells[row, ++column].Value = "N";

                worksheet.Cells[row, column + 2].Value = "N";
                worksheet.Cells[row, column + 3].Value = "N";
                worksheet.Cells[row, column + 4].Value = "N";
                yearData.Deck         = "N";
                yearData.Super        = "N";
                yearData.Sub          = "N";
                minCActionCallDecider = MinCValue.valueEqualsCulv;
            }
            else
            {
                worksheet.Cells[row, ++column].Value = Convert.ToDouble(yearData.Deck);
                worksheet.Cells[row, ++column].Value = Convert.ToDouble(yearData.Super);
                worksheet.Cells[row, ++column].Value = Convert.ToDouble(yearData.Sub);

                worksheet.Cells[row, column + 2].Value = Convert.ToDouble(yearData.DeckD);
                worksheet.Cells[row, column + 3].Value = Convert.ToDouble(yearData.SuperD);
                worksheet.Cells[row, column + 4].Value = Convert.ToDouble(yearData.SubD);
            }
            if (familyIdLessThanEleven)
            {
                worksheet.Cells[row, ++column].Value   = "N";
                worksheet.Cells[row, column + 4].Value = "N";
                yearData.Culv  = "N";
                yearData.CulvD = "N";
                if (minCActionCallDecider == MinCValue.valueEqualsCulv)
                {
                    minCActionCallDecider = MinCValue.defaultValue;
                }
                else
                {
                    minCActionCallDecider = MinCValue.minOfDeckSubSuper;
                }
            }
            else
            {
                worksheet.Cells[row, ++column].Value = Convert.ToDouble(yearData.Culv);

                worksheet.Cells[row, column + 4].Value = Convert.ToDouble(yearData.CulvD);
            }
            column += 4;

            column = valueForMinC[minCActionCallDecider](worksheet, row, column, yearData); // It returns the column number where MinC value is written

            if (bridgeDataModel.P3 > 0 && yearData.MinC < 5)
            {
                excelHelper.ApplyColor(worksheet.Cells[row, column], Color.Yellow);
                excelHelper.SetTextColor(worksheet.Cells[row, column], Color.Black);
            }
            //worksheet.Cells[row, ++column].Value = yearData.SD;
            //worksheet.Cells[row, ++column].Value = Convert.ToDouble(yearData.MinC) < 5 ? "Y" : "N" ;
            worksheet.Cells[row, ++column].Value = yearData.MinC < 5 ? "Y" : "N"; //poor

            if (yearData.Year != 0)
            {
                //worksheet.Cells[row, ++column].Value = bridgeDataModel.Posted == "Y" ? getPostedType(yearData.Project) : "N"; // Posted
                worksheet.Cells[row, ++column].Value = yearData.ProjectPick; // Project Pick
                worksheet.Cells[row, ++column].Value = yearData.Budget;      // Budget
                worksheet.Cells[row, ++column].Value = yearData.Project;
                if (projectPickByYear[yearData.Year] == 2)
                {
                    excelHelper.ApplyColor(worksheet.Cells[row, column], Color.FromArgb(0, 255, 0));
                    excelHelper.SetTextColor(worksheet.Cells[row, column], Color.Black);
                }
                worksheet.Cells[row, ++column].Value = yearData.Cost;
                excelHelper.SetCurrencyFormat(worksheet.Cells[row, column]);
                worksheet.Cells[row, ++column].Value = ""; // District Remarks
            }
            // Empty column
            column++;
            worksheet.Column(column).Style.Fill.PatternType = ExcelFillStyle.Solid;
            worksheet.Column(column).Style.Fill.BackgroundColor.SetColor(Color.Gray);

            return(column);
        }