Beispiel #1
0
        public DeficientResult GetData(SimulationModel data, int[] totalYears)
        {
            // Deficient and DeficientResults are models. Deficient gets data
            // from the database. DeficientResult gets the processed data
            IQueryable <DeficientReportModel> deficients = null;
            DeficientResult result = null;

            var select =
                "SELECT TargetID, Years, TargetMet, IsDeficient " +
                " FROM Target_" + data.NetworkId
                + "_" + data.SimulationId;

            try
            {
                var rawDeficientList = db.Database.SqlQuery <DeficientReportModel>(select).AsQueryable();

                deficients = rawDeficientList.Where(_ => _.IsDeficient == true);

                var targetAndYear = this.deficients.GetData(deficients);
                result = GetDeficientInformation(data, targetAndYear, totalYears);
            }
            catch (SqlException ex)
            {
                HandleException.SqlError(ex, "Target");
            }
            catch (OutOfMemoryException ex)
            {
                HandleException.OutOfMemoryError(ex);
            }
            catch (Exception ex)
            {
                HandleException.GeneralError(ex);
            }
            return(result);
        }
Beispiel #2
0
        private DeficientResult GetDeficientInformation(SimulationModel data, Hashtable yearsIDValues, int[] totalYears)
        {
            var       deficientTableData = db.Deficients.AsNoTracking().Where(_ => _.SIMULATIONID == data.simulationId);
            var       totalYearCount     = totalYears.Count();
            DataTable DeficientTable     = new DataTable();

            DeficientTable.Columns.Add("Attribute");
            DeficientTable.Columns.Add("Group");
            for (int i = 0; i < totalYearCount; i++)
            {
                DeficientTable.Columns.Add(totalYears[i].ToString());
            }
            FillData(deficientTableData, yearsIDValues, DeficientTable, totalYears);
            var forDeficient = new DeficientResult
            {
                Deficients = DeficientTable,
                Address    = address
            };

            return(forDeficient);
        }