private void zReadTableResult(DataReaderHelper reader) { TableResultMapping tableResultMapping = (TableResultMapping)m_Step.ResultMapping; ListStateVariable listStateVariable = null; if (tableResultMapping.ObjectSetListName != null && tableResultMapping.ObjectSetClassName != null) { //TODO: there is similar logic in GroupStepExecutor.zCreateElementSetIterator - refactor into common method on DataScope. listStateVariable = (ListStateVariable)CurrentScope.DataScope.GetStateVariable(tableResultMapping.ObjectSetListName); if (listStateVariable == null) { listStateVariable = new ListStateVariable(DataUtils.GetUnscopedVariableName(tableResultMapping.ObjectSetListName), tableResultMapping.PersistenceMode, new List <IStateVariable>()); CurrentScope.DataScope.SetStateVariable(tableResultMapping.ObjectSetListName, listStateVariable); } listStateVariable.IncludeInXML = tableResultMapping.IncludeInXML; } int resultCount = 1; while (reader.Read()) { ObjectStateVariable objectStateVariable = null; if (listStateVariable != null) { string listItemName = String.Format("{0}{1}", tableResultMapping.ObjectSetClassName, resultCount); objectStateVariable = new ObjectStateVariable(listItemName, tableResultMapping.ObjectSetClassName, tableResultMapping.PersistenceMode, new Dictionary <string, IStateVariable>()); listStateVariable.Value.Add(objectStateVariable); } foreach (TableResultMap tableMap in tableResultMapping.TableMapping) { //TODO: for now all data is being converted to string. Once we are doing something with the variable type system, // type the variables appropriately when reading them in. object value = reader.GetNullableValue(tableMap.ColumnName); IStateVariable stateVariable = new StateVariable <string>(DataUtils.GetUnscopedVariableName(tableMap.StateVariable), DataType.String, tableMap.XMLFieldOutputMode, tableMap.PersistenceMode, Convert.ToString(value)); if (objectStateVariable != null && stateVariable.Name == tableMap.StateVariable) { //stateVariable.Name == tableMap.StateVariable checks that tableMap.StateVariable has no explicit scope. //If it has an explicit scope, stateVariable has to be set through CurrentScope.DataScope in the else block. objectStateVariable.Value.Add(tableMap.StateVariable, stateVariable); } else { CurrentScope.DataScope.SetStateVariable(tableMap.StateVariable, stateVariable); } } resultCount++; } }
public override void SetContext(StepEditContext context, TableResultMapping mapping) { base.SetContext(context, mapping); txtObjectClassName.Text = mapping.ObjectSetClassName; cbListName.BindEditableStateVariables(context.StateVariables.Lists(), mapping.ObjectSetListName, true); cbPersistList.Checked = mapping.PersistenceMode == PersistenceMode.Persisted; cbIncludeInXML.Checked = mapping.IncludeInXML; m_TableResultMapping = mapping.TableMapping.Select(trm => trm.Clone()).ToList(); zRefreshTableResults(); }
private void zAddVariablesToScopeFromDatabaseStep(DatabaseStep databaseStep) { foreach (OutputParameterMap parameterMap in databaseStep.OutputParameterMapping) { zAddVariableToScope(m_CurrentScope.ScopeName, new StateVariableInfo(parameterMap.StateVariable, DataType.String, parameterMap.PersistenceMode)); //TODO: get actual datatype } if (databaseStep.ResultMapping is ScalarResultMapping) { ScalarResultMapping scalarResultMapping = (ScalarResultMapping)databaseStep.ResultMapping; zAddVariableToScope(m_CurrentScope.ScopeName, new StateVariableInfo(scalarResultMapping.StateVariable, DataType.String, scalarResultMapping.PersistenceMode)); //TODO: get actual datatype } if (databaseStep.ResultMapping is TableResultMapping) { TableResultMapping tableResultMapping = (TableResultMapping)databaseStep.ResultMapping; StepScope tempScopeForTableResults = null; if (tableResultMapping.ObjectSetClassName != null && tableResultMapping.ObjectSetListName != null) { zAddVariableToScope(m_CurrentScope.ScopeName, new StateVariableInfo(tableResultMapping.ObjectSetListName, DataType.List, tableResultMapping.PersistenceMode)); string tempScopeCacheKey = zGetCacheKey(m_CurrentScope.ScopeName, tableResultMapping.ObjectSetListName); tempScopeForTableResults = new StepScope(Guid.NewGuid().ToString(), tableResultMapping.ObjectSetClassName, tempScopeCacheKey, null); zSetCurrentScope(tempScopeForTableResults); } foreach (TableResultMap tableResultMap in tableResultMapping.TableMapping) { zAddVariableToScope(m_CurrentScope.ScopeName, new StateVariableInfo(tableResultMap.StateVariable, DataType.String, tableResultMapping.PersistenceMode)); //TODO: get actual datatype } if (tempScopeForTableResults != null) { zRemoveCurrentScope(); } } }
public TableResultMappingEditor(StepEditContext context, TableResultMapping mapping) : this() { this.SetContext(context, mapping); }