/// <summary> /// Counts thermal and fast reactors in database, and adds to BO /// </summary> public StatisticsBO SpectrumCount(List <ReactorBO> reactorBOList, StatisticsBO statisticsBO) { int thermalCount = default(int); int fastCount = default(int); int totalCount = reactorBOList.Count(); if (totalCount > 0) { _logger.LogMessage("Info", "Spectrum Count request", MethodBase.GetCurrentMethod().ToString(), totalCount + " ReactorBOs found in list. Counting thermal and fast reactors in database."); foreach (ReactorBO reactorBO in reactorBOList) { if (reactorBO.IsThermal) { thermalCount++; } else { fastCount++; } } statisticsBO.ThermalCount = thermalCount; statisticsBO.FastCount = fastCount; statisticsBO.ReactorCount = totalCount; } else { _logger.LogMessage("Warning", "Empty list in Spectrum Count", MethodBase.GetCurrentMethod().ToString(), "No ReactorBOs found in list. Did not count thermal and fast reactors."); } return(statisticsBO); }
public StatisticsBO SpectrumPercentage(StatisticsBO statisticsBO) { statisticsBO.PercentThermal = (decimal)statisticsBO.ThermalCount / statisticsBO.ReactorCount * (decimal)100; statisticsBO.PercentFast = (decimal)statisticsBO.FastCount / statisticsBO.ReactorCount * (decimal)100; _logger.LogMessage(statisticsBO.PercentThermal + "% of database reactors operate in thermal spectrum."); _logger.LogMessage(statisticsBO.PercentFast + "% of database reactors operate in fast spectrum."); return(statisticsBO); }
/// <summary> /// Counts number of database reactors in each generation /// </summary> public StatisticsBO GenerationCounter(List <ReactorBO> reactorBOList, StatisticsBO statisticsBO) { int genIcount = default(int); int genIIcount = default(int); int genIIIcount = default(int); int genIVcount = default(int); int genVcount = default(int); int noGenCount = default(int); foreach (ReactorBO reactorBO in reactorBOList) { switch (reactorBO.Generation) { case "I": genIcount++; break; case "II": genIIcount++; break; case "III": genIIIcount++; break; case "IV": genIVcount++; break; case "V": genVcount++; break; default: noGenCount++; break; } } statisticsBO.NoGenCount = noGenCount; statisticsBO.GenIcount = genIcount; statisticsBO.GenIIcount = genIIcount; statisticsBO.GenIIIcount = genIIIcount; statisticsBO.GenIVcount = genIVcount; statisticsBO.GenVcount = genVcount; return(statisticsBO); }
public ActionResult ReactorStatistics() { StatisticsPO dbStats = new StatisticsPO(); StatisticsBO statisticsBO = new StatisticsBO(); List <ReactorBO> reactorBOList = new List <ReactorBO>(); try { List <ReactorDO> reactorDOList = _reactorDAO.ObtainAllReactors(); if (reactorDOList != null) { foreach (ReactorDO reactorDO in reactorDOList) { ReactorBO reactorBO = Mapping.Mapper.ReactorDOtoBO(reactorDO); reactorBOList.Add(reactorBO); } statisticsBO = _reactorBLO.SpectrumCount(reactorBOList, statisticsBO); statisticsBO = _reactorBLO.SpectrumPercentage(statisticsBO); statisticsBO = _reactorBLO.GenerationCounter(reactorBOList, statisticsBO); int[] genCount = new int[6]; genCount[0] = statisticsBO.NoGenCount; genCount[1] = statisticsBO.GenIcount; genCount[2] = statisticsBO.GenIIcount; genCount[3] = statisticsBO.GenIIIcount; genCount[4] = statisticsBO.GenIVcount; genCount[5] = statisticsBO.GenVcount; statisticsBO = _reactorBLO.GenerationPercentage(genCount, statisticsBO); dbStats = Mapping.Mapper.StatisticsBOtoPO(statisticsBO); } } catch (Exception ex) { _logger.LogMessage(ex, "Fatal"); } finally { } return(View(dbStats)); }
public static StatisticsPO StatisticsBOtoPO(StatisticsBO from) { StatisticsPO to = new StatisticsPO(); to.ReactorCount = from.ReactorCount; to.ThermalCount = from.ThermalCount; to.FastCount = from.FastCount; to.PercentThermal = from.PercentThermal; to.PercentFast = from.PercentFast; to.GenIcount = from.GenIcount; to.GenIIcount = from.GenIIcount; to.GenIIIcount = from.GenIIIcount; to.GenIVcount = from.GenIVcount; to.GenVcount = from.GenVcount; to.NoGenCount = from.NoGenCount; to.PercentGenI = from.PercentGenI; to.PercentGenII = from.PercentGenII; to.PercentGenIII = from.PercentGenIII; to.PercentGenIV = from.PercentGenIV; to.PercentGenV = from.PercentGenV; to.PercentNoGen = from.PercentNoGen; return(to); }
/// <summary> /// Calculates percentage of database reactors in each generation /// </summary> public StatisticsBO GenerationPercentage(int[] genCount, StatisticsBO statisticsBO) { decimal[] genPercentArray = new decimal[genCount.Length]; for (int gen = 0; gen < genCount.Length; gen++) { genPercentArray[gen] = (decimal)genCount[gen] / statisticsBO.ReactorCount * 100; if (gen == 0) { _logger.LogMessage(genPercentArray[gen] + "% of database reactors have no generation listed."); } else { _logger.LogMessage(genPercentArray[gen] + "% of database reactors in generation " + gen); } } statisticsBO.PercentNoGen = genPercentArray[0]; statisticsBO.PercentGenI = genPercentArray[1]; statisticsBO.PercentGenII = genPercentArray[2]; statisticsBO.PercentGenIII = genPercentArray[3]; statisticsBO.PercentGenIV = genPercentArray[4]; statisticsBO.PercentGenV = genPercentArray[5]; return(statisticsBO); }