/// <summary>A method that can be called by other models to perform a line of output.</summary>
        public new void DoOutput()
        {
            object[] valuesToWrite = new object[columns.Count];
            for (int i = 0; i < columns.Count; i++)
            {
                // if contains Pools[ then get the value
                if (columns[i].Name.Contains("-"))
                {
                    string[] values = columns[i].Name.Split('-');
                    double   value  = grazeStore.GetValueByPoolAge(Convert.ToInt32(values[1]), values[2]);
                    if (value != 0)
                    {
                        valuesToWrite[i] = Math.Round(value, 2);
                    }
                }
                else
                {
                    // otherwise normal approach
                    valuesToWrite[i] = columns[i].GetValue();
                }
            }

            if (dataToWriteToDb == null)
            {
                dataToWriteToDb = new ReportData()
                {
                    SimulationName = simulation.Name,
                    TableName      = Name,
                    ColumnNames    = columns.Select(c => c.Name).ToList(),
                    ColumnUnits    = columns.Select(c => c.Units).ToList()
                }
            }
            ;

            // Add row to our table that will be written to the db file
            dataToWriteToDb.Rows.Add(valuesToWrite.ToList());

            // Write the table if we reach our threshold number of rows.
            if (dataToWriteToDb.Rows.Count == 100)
            {
                storage.Writer.WriteTable(dataToWriteToDb);
                dataToWriteToDb = null;
            }
        }
Esempio n. 2
0
 /// <summary>A method that can be called by other models to perform a line of output.</summary>
 public new void DoOutput()
 {
     object[] valuesToWrite = new object[columns.Count];
     for (int i = 0; i < columns.Count; i++)
     {
         // if contains Pools[ then get the value
         if (columns[i].Name.Contains("-"))
         {
             string[] values = columns[i].Name.Split('-');
             double   value  = grazeStore.GetValueByPoolAge(Convert.ToInt32(values[1]), values[2]);
             if (value != 0)
             {
                 valuesToWrite[i] = Math.Round(value, 2);
             }
         }
         else
         {
             // otherwise normal approach
             valuesToWrite[i] = columns[i].GetValue();
         }
     }
     storage.WriteRow(simulation.Name, Name, columnNames, columnUnits, valuesToWrite);
 }