/// <summary> /// Create a data view from the specified table and filter. /// </summary> /// <param name="simulationZones">The list of simulation / zone pairs.</param> /// <param name="storage">Storage service</param> private DataTable GetBaseData(IStorageReader storage, List <SimulationZone> simulationZones) { // Get a list of all simulation names in all simulationZones. List <string> simulationNames = new List <string>(); simulationZones.ForEach(sim => simulationNames.AddRange(sim.simulationNames)); string filter = null; foreach (string simulationName in simulationNames.Distinct()) { if (filter != null) { filter += ","; } filter += "'" + simulationName + "'"; } filter = "SimulationName in (" + filter + ")"; if (Filter != string.Empty) { filter = AddToFilter(filter, Filter); } List <string> fieldNames = new List <string>(); if (storage.ColumnNames(TableName).Contains("Zone")) { fieldNames.Add("Zone"); } if (XFieldName != null && !XFieldName.Equals("SimulationName")) { fieldNames.Add(XFieldName); } if (YFieldName != null && !fieldNames.Contains(YFieldName)) { fieldNames.Add(YFieldName); } if (X2FieldName != null && !fieldNames.Contains(X2FieldName)) { fieldNames.Add(X2FieldName); } if (Y2FieldName != null && !fieldNames.Contains(Y2FieldName)) { fieldNames.Add(Y2FieldName); } // Add in column names from annotation series. foreach (EventNamesOnGraph annotation in Apsim.Children(this, typeof(EventNamesOnGraph))) { fieldNames.Add(annotation.ColumnName); } return(storage.GetData(tableName: TableName, fieldNames: fieldNames, filter: filter)); }
/// <summary> /// Create a data view from the specified table and filter. /// </summary> /// <param name="dataStore">The datastore to read from.</param> /// <param name="simulationZones">The list of simulation / zone pairs.</param> private DataTable GetBaseData(DataStore dataStore, List <SimulationZone> simulationZones) { // Get a list of all simulation names in all simulationZones. List <string> simulationNames = new List <string>(); simulationZones.ForEach(sim => simulationNames.AddRange(sim.simulationNames)); string filter = null; foreach (string simulationName in simulationNames.Distinct()) { if (filter != null) { filter += ","; } filter += "'" + simulationName + "'"; } filter = "SimulationName in (" + filter + ")"; if (Filter != string.Empty) { filter = AddToFilter(filter, Filter); } List <string> fieldNames = new List <string>(); if (dataStore.ColumnNames(TableName).Contains("Zone")) { fieldNames.Add("Zone"); } if (XFieldName != null && !XFieldName.Equals("SimulationName")) { fieldNames.Add(XFieldName); } fieldNames.Add(YFieldName); if (X2FieldName != null && !fieldNames.Contains(X2FieldName)) { fieldNames.Add(X2FieldName); } if (Y2FieldName != null && !fieldNames.Contains(Y2FieldName)) { fieldNames.Add(Y2FieldName); } return(dataStore.GetFilteredData(TableName, fieldNames.ToArray(), filter)); }