private void CheckAllValues() { IDataCursor cursor = DbContext.PowerPlant.CreateDataCursor(); var columnTypeConverter = DbContext.PowerPlant.CreateColumnTypeConverter(ConversionFileForWrite); ITableDefinition tableDefinition = DbSchema.GetTableDefinition(columnTypeConverter, TestTable); try { IDataReader reader = cursor.ExecuteReader(string.Format("select * from {0}", TestTable)); reader.Read(); tableDefinition.Columns[0].ToString(reader["bool_col"]).Should().Be("1", "because bool was true"); var tmp = reader["bool_col"]; tableDefinition.Columns[1].ToString(reader["char_col"]).Should().Be("'NO'", "because that's the value for char_col"); tableDefinition.Columns[2].ToString(reader["date_col"]).Should().Be("19000223 00:00:00", "because that's the value for date_col"); tableDefinition.Columns[3].ToString(reader["float_col"]).Should().Be("123.12345678", "because that's the value for float_col"); tableDefinition.Columns[4].ToString(reader["guid_col"]).Should().Be(TestGuid, "because that's the value for guid_col"); tableDefinition.Columns[5].ToString(reader["int_col"]).Should().Be("1234567890", "because that's the value for int_col"); tableDefinition.Columns[6].ToString(reader["int8_col"]).Should().Be("150", "because that's the value for int8_col"); tableDefinition.Columns[7].ToString(reader["int16_col"]).Should().Be("12345", "because that's the value for int16_col"); tableDefinition.Columns[8].ToString(reader["int64_col"]).Should().Be("123456789012345", "because that's the value for int64_col"); tableDefinition.Columns[9].ToString(reader["longtext_col"]).Should().Be("'Very long text with æøå'", "because that's the value for longtext_col"); tableDefinition.Columns[10].ToString(reader["money_col"]).Should().Be("123.123", "because that's the value for money_col"); tableDefinition.Columns[12].ToString(reader["nvarchar_col"]).Should().Be("'A unicode ﺽ string'", "because that's the value for string_col"); tableDefinition.Columns[13].ToString(reader["varchar_col"]).Should().Be("'A varchar string'", "because that's the value for varchar_col"); string blob = Encoding.Default.GetString((byte[])reader["blob_col"]); blob.Should().Be("A long blob"); } finally { cursor.Close(); } }
private long WriteTableDataToDataFile(ITableDefinition tableDefinition, string dataFileSuffix) { long rowCounter = 0; using (DataFileTextWriter dataWriter = new DataFileTextWriter(Directory + tableDefinition.Name + "." + dataFileSuffix, UseCompression)) { string selectStmt = CreateSelectStatement(tableDefinition); IDataCursor cursor = _dbContext.PowerPlant.CreateDataCursor(); try { IDataReader reader = cursor.ExecuteReader(selectStmt, tableDefinition.HasBlobColumn); while (reader.Read()) { WriteRow(rowCounter, reader, tableDefinition, dataWriter); dataWriter.WriteLine(); if (rowCounter % 10000 == 0) { _logger.Write($"...... reached row {rowCounter} for {tableDefinition.Name} ......"); } rowCounter++; } } finally { cursor.Close(); } } return(rowCounter); }
private List <IViewDefinition> ReadViewDefinitionsFromDatabase(string selectStatement) { List <IViewDefinition> viewDefinitions = new List <IViewDefinition>(); IDataCursor cursor = null; try { cursor = _dbContext.PowerPlant.CreateDataCursor(); IDataReader reader = cursor.ExecuteReader(selectStatement); while (reader.Read()) { string database = reader.GetString(0); string viewName = reader.GetString(1); string select = reader.GetString(2); viewDefinitions.Add(ViewDefinitionFactory.CreateInstance(ViewDefinition.ConvertFromStringToDbType(database), viewName, select)); } } finally { if (cursor != null) { cursor.Close(); } } return(viewDefinitions); }
protected override List <IIndexColumn> GetIndexColumnsForIndex(IIndexDefinition index) { string selectStmt = ""; selectStmt += "SELECT tc.name as col_name " + "\n"; selectStmt += "FROM sys.index_columns ic, " + "\n"; selectStmt += " sys.columns tc " + "\n"; selectStmt += "WHERE ic.column_id = tc.column_id " + "\n"; selectStmt += " AND ic.object_id = tc.object_id " + "\n"; selectStmt += " AND is_included_column = 0 " + "\n"; selectStmt += string.Format(" AND index_id = {0} ", index.IndexId) + "\n"; selectStmt += string.Format(" AND ic.object_id = Object_id('{0}') ", index.TableName) + "\n"; selectStmt += " AND is_included_column = 0 "; List <IIndexColumn> columns = new List <IIndexColumn>(); IDataCursor cursor = DbContext.PowerPlant.CreateDataCursor(); try { IDataReader reader = cursor.ExecuteReader(selectStmt); while (reader.Read()) { string name = reader.GetString(0); columns.Add(IndexColumnFactory.CreateInstance(name)); } } finally { cursor.Close(); } return(columns); }
private List <IIndexDefinition> ReadIndexDefinitionsFromDatabase(string selectStatement, string tableName) { var indexDefinitions = new List <IIndexDefinition>(); IDataCursor cursor = null; try { cursor = _dbContext.PowerPlant.CreateDataCursor(); var reader = cursor.ExecuteReader(selectStatement); while (reader.Read()) { var indexName = reader.GetString(0); var columnList = reader.GetString(1); var location = reader.GetString(2); var isUnique = Convert.ToBoolean(reader.GetValue(3)); var dbName = reader.GetString(4); var indexDefinition = _dbContext.PowerPlant.CreateIndexDefinition(indexName, tableName, location, isUnique); indexDefinition.Columns = SplitColumns(columnList); indexDefinition.DbSpecific = TableDefinition.ConvertStringToDbType(dbName); indexDefinitions.Add(indexDefinition); } } finally { cursor?.Close(); } return(indexDefinitions); }
public DialogLoader(IRawDataReader reader, IDataCursor cursor, IEventAggregator eventAggregator) { dataReader = reader; dataCursor = cursor; eventAggregator.GetEvent <OpenRawDataFileEvent>().Subscribe(OpenRawData); eventAggregator.GetEvent <ShowAboutBoxEvent>().Subscribe(ShowAboutBox); }
public static Task <bool> MovePrevAsync <T>(this IDataCursor <T> cursor) { if (cursor is null) { throw new ArgumentNullException(nameof(cursor)); } return(cursor.MoveAsync(cursor.CurrentIndex - 1)); }
public static Task <bool> MoveFirstAsync <T>(this IDataCursor <T> cursor) { if (cursor is null) { throw new ArgumentNullException(nameof(cursor)); } return(cursor.MoveAsync(0)); }
public static bool IsFirst <T>(this IDataCursor <T> cursor) { if (cursor is null) { throw new ArgumentNullException(nameof(cursor)); } return(cursor.Count != 0 && cursor.CurrentIndex == 0); }
public PeaksAnalyzer(IDataCursor cursor, IPeaksFinder finder, ISmoother smoother, IPeaksRepository peaksRepository, ILorentzian lorentzianModel) { lorentzian = lorentzianModel; dataCursor = cursor; peaksFinder = finder; dataSmoother = smoother; peaks = peaksRepository; }
public static int RightCount <T>(this IDataCursor <T> cursor) { if (cursor is null) { throw new ArgumentNullException(nameof(cursor)); } return(cursor.Count - cursor.CurrentIndex - 1); }
public static IDataCursor Refine(this IDataCursor initialCursor, params string[] path) { var currentCursor = initialCursor; for (int i = 0; i < path.Length; i++) { currentCursor = currentCursor.Refine(path[i]); } return(currentCursor); }
public MainView(IMainViewModel viewModel, IDataCursor dataCursor, IPeaksRepository peaksRepository, ILorentzian lorentzianModel) { InitializeComponent(); SpectrumQuickView.DataTransform = new Log10YTransform(); SpectrumQuickView.VerticalAxis = new VerticalAxis { LabelProvider = new MyExponentialLabelProvider() }; SpectrumAnalysis.DataTransform = new Log10YTransform(); SpectrumAnalysis.VerticalAxis = new VerticalAxis { LabelProvider = new MyExponentialLabelProvider() }; FWHM.AxisGrid.DrawHorizontalMinorTicks = true; FWHM.AxisGrid.DrawHorizontalTicks = true; FWHM.AxisGrid.DrawVerticalMinorTicks = true; FWHM.AxisGrid.DrawVerticalTicks = true; FWHM.VerticalAxis = new VerticalAxis { LabelProvider = new MyExponentialLabelProvider() }; PeakPosition.AxisGrid.DrawHorizontalMinorTicks = true; PeakPosition.AxisGrid.DrawHorizontalTicks = true; PeakPosition.AxisGrid.DrawVerticalMinorTicks = true; PeakPosition.AxisGrid.DrawVerticalTicks = true; PeakPosition.VerticalAxis = new VerticalAxis { LabelProvider = new MyExponentialLabelProvider() }; PeakValue.AxisGrid.DrawHorizontalMinorTicks = true; PeakValue.AxisGrid.DrawHorizontalTicks = true; PeakValue.AxisGrid.DrawVerticalMinorTicks = true; PeakValue.AxisGrid.DrawVerticalTicks = true; PeakValue.DataTransform = new Log10YTransform(); PeakValue.VerticalAxis = new VerticalAxis { LabelProvider = new MyExponentialLabelProvider() }; ViewModel = viewModel; ViewModel.QuickViewChanged += OnSpectraChanged; ViewModel.AnalysisChanged += OnAnalysisChanged; cursor = dataCursor; dataCursor.SpectraLoaded += OnSpectraChanged; dataCursor.SpectraChanged += OnSpectraChanged; dataCursor.VoltagesLoaded += OnVoltagesChanged; dataCursor.VoltagesChanged += OnVoltagesChanged; peaks = peaksRepository; lorentzian = lorentzianModel; }
public override void GetRawColumnDefinition(string tableName, string colName, out string type, out int length, out int prec, out int scale) { type = ""; length = prec = scale = 0; var selectStmt = ""; selectStmt += "SELECT c.name, " + "\n"; selectStmt += " t.name AS t_name, " + "\n"; selectStmt += " isnull(c.max_length, 0) as length, " + "\n"; selectStmt += " isnull(c.precision, 0) as prec, " + "\n"; selectStmt += " isnull(c.scale, 0) as scale, " + "\n"; selectStmt += " c.is_nullable, " + "\n"; selectStmt += " convert(varchar(256), isnull(c.collation_name, '')) as collation, " + "\n"; selectStmt += " isnull(object_definition(c.default_object_id), '') as def, " + "\n"; selectStmt += " c.is_identity " + "\n"; selectStmt += "FROM sys.columns c " + "\n"; selectStmt += " JOIN sys.types t " + "\n"; selectStmt += " ON c.user_type_id = t.user_type_id " + "\n"; selectStmt += $"WHERE c.object_id = Object_id('{tableName}') " + "\n"; selectStmt += $" AND c.name = '{colName}' " + "\n"; selectStmt += "ORDER BY c.column_id "; IDataCursor cursor = null; try { cursor = DbContext.PowerPlant.CreateDataCursor(); var reader = cursor.ExecuteReader(selectStmt); while (reader.Read()) { var name = reader.GetString(0); type = reader.GetString(1); length = reader.GetInt16(2); if (length != -1 && (type == "nvarchar" || type == "nchar")) { length /= 2; } prec = reader.GetByte(3); scale = reader.GetByte(4); var isNullable = reader.GetBoolean(5); var collation = reader.GetString(6); var def = reader.GetString(7); var isIdentity = reader.GetBoolean(8); var sourceType = type.AddParameters(); } } finally { cursor?.Close(); } }
public static bool IsInRange <T>(this IDataCursor <T> cursor, int index) { if (cursor is null) { throw new ArgumentNullException(nameof(cursor)); } if (cursor.Count == 0) { return(false); } return(index >= 0 && index < cursor.Count); }
private void VerifyColumnType(string expectedType, int?expectedLength, int?expectedPrec, int?expectedScale) { var selectStmt = ""; selectStmt += "SELECT data_type, " + "\n"; selectStmt += " nvl(Decode(char_length, 0, data_length, " + "\n"; selectStmt += " char_length), 0) AS col3, " + "\n"; selectStmt += " nvl(data_precision, 0) as col4, " + "\n"; selectStmt += " nvl(data_scale, 0) as col5 " + "\n"; selectStmt += "FROM user_tab_columns " + "\n"; selectStmt += "WHERE table_name = '" + TableName.ToUpper() + "' \n"; selectStmt += "AND column_name = 'COL1'" + "\n"; IDataCursor cursor = DbContext.PowerPlant.CreateDataCursor(); string type = ""; int length = -99; int prec = -99; int scale = -99; try { IDataReader reader = cursor.ExecuteReader(selectStmt); reader.Read(); type = reader.GetString(0); length = reader.GetInt16(1); prec = reader.GetInt16(2); scale = reader.GetInt32(3); } catch (Exception) { false.Should().BeTrue("because we want to fail when we cant read type from database."); } finally { cursor.Close(); } type.Should().Be(expectedType); if (expectedLength != null) { length.Should().Be(expectedLength, "because that's the expected length"); } if (expectedPrec != null) { prec.Should().Be(expectedPrec, "because that's the expected precision"); } if (expectedScale != null) { scale.Should().Be(expectedScale, "because that's the expected scale"); } }
public void TestExecuteReader_When_ErrorInStatement() { Initialize(_msContext); IDataCursor cursor = _msContext.PowerPlant.CreateDataCursor(); string errorMsg = ""; try { cursor.ExecuteReader("select * from some_table_that_doesnt_exist"); } catch (Exception ex) { errorMsg = ex.Message; } errorMsg.Should().Contain("some_table_that_doesnt_exist", "because it's an illegal table"); }
private static bool seek(IDataCursor ic, int position) { int curPos = 0; if (ic.first()) { while (curPos < position) { if (!ic.next()) { return(false); } curPos++; } return(true); } return(false); }
public static void append(IData src, IData dst) { if ((src == null) || (dst == null) || (src == dst)) { return; } IDataCursor srcC = src.getCursor(); IDataCursor dstC = dst.getCursor(); dstC.last(); while (srcC.next()) { dstC.insertAfter(srcC.getKey(), srcC.getValue()); } srcC.destroy(); dstC.destroy(); }
public async Task Move_MovedEventMustBeFired() { var cur = new NullDataCursor(new object[] { new object() }); IDataCursor <object> sender = null; int index = -1; cur.Moved += (o, e) => { sender = o; index = e; }; await cur.MoveAsync(0); Assert.AreEqual(cur, sender); Assert.AreEqual(0, index); sender = null; index = -1; await cur.MoveAsync(0); }
protected override List <IIndexDefinition> GetIndexesForTable(string tableName) { string selectStmt = ""; selectStmt += "SELECT DISTINCT i.name, " + "\n"; selectStmt += " s.name loc_name, " + "\n"; selectStmt += " i.index_id indid, " + "\n"; selectStmt += " i.is_unique unique_flag, " + "\n"; selectStmt += " i.type_desc " + "\n"; selectStmt += "FROM sys.indexes i, " + "\n"; selectStmt += " sys.filegroups s " + "\n"; selectStmt += "WHERE i.index_id BETWEEN 1 AND 254 " + "\n"; selectStmt += " AND i.data_space_id = s.data_space_id " + "\n"; selectStmt += " AND i.is_primary_key = 0 " + "\n"; selectStmt += " AND i.is_unique_constraint = 0 " + "\n"; selectStmt += " AND i.is_hypothetical = 0 " + "\n"; selectStmt += string.Format(" AND i.object_id = Object_id('{0}') ", tableName) + "\n"; selectStmt += "ORDER BY i.name "; List <IIndexDefinition> indexes = new List <IIndexDefinition>(); IDataCursor cursor = DbContext.PowerPlant.CreateDataCursor(); try { IDataReader reader = cursor.ExecuteReader(selectStmt); while (reader.Read()) { string name = reader.GetString(0); string location = reader.GetString(1); int id = reader.GetInt32(2); bool isUnique = reader.GetBoolean(3); bool isClustered = reader.GetString(4) == "CLUSTERED"; indexes.Add(DbContext.PowerPlant.CreateIndexDefinition(name, tableName, location, isUnique, id, isClustered)); } } finally { cursor.Close(); } return(indexes); }
public MainViewModel(IDataCursor cursor, IPeaksAnalyzer analyzer, IEventAggregator eventAggregator) { mainPeakAnalysis.DoWork += StartMainPeakAnalysis; mainPeakAnalysis.RunWorkerCompleted += MainPeakAnalysisCompleted; mainPeakAnalysis.WorkerReportsProgress = true; mainPeakAnalysis.ProgressChanged += MainPeakAnalysisProgressChanged; allPeaksAnalysis.DoWork += StartAllPeaksAnalysis; allPeaksAnalysis.RunWorkerCompleted += AllPeaksAnalysisCompleted; allPeaksAnalysis.WorkerReportsProgress = true; allPeaksAnalysis.ProgressChanged += AllPeaksAnalysisProgressChanged; peaksAnalyzer = analyzer; dataCursor = cursor; dataCursor.SpectraLoaded += OnSpectrumLoaded; dataCursor.SpectraChanged += OnSpectrumChanged; eventAggregator.GetEvent <NewProjectEvent>().Subscribe(NewProject); eventAggregator.GetEvent <CleanDataEvent>().Subscribe(CleanData); eventAggregator.GetEvent <RunAnalysisEvent>().Subscribe(RunAnalysis); }
public override ITableDefinition GetTableDefinition(IColumnTypeConverter columnTypeConverter, string tableName) { string selectStmt = ""; selectStmt += "SELECT c.name, " + "\n"; selectStmt += " t.name AS t_name, " + "\n"; selectStmt += " isnull(c.max_length, 0) as length, " + "\n"; selectStmt += " isnull(c.precision, 0) as prec, " + "\n"; selectStmt += " isnull(c.scale, 0) as scale, " + "\n"; selectStmt += " c.is_nullable, " + "\n"; selectStmt += " convert(varchar(256), isnull(c.collation_name, '')) as collation, " + "\n"; selectStmt += " isnull(object_definition(c.default_object_id), '') as def, " + "\n"; selectStmt += " c.is_identity " + "\n"; selectStmt += "FROM sys.columns c " + "\n"; selectStmt += " JOIN sys.types t " + "\n"; selectStmt += " ON c.user_type_id = t.user_type_id " + "\n"; selectStmt += string.Format("WHERE c.object_id = Object_id('{0}') ", tableName) + "\n"; selectStmt += "ORDER BY c.column_id "; IColumnFactory columnFactory = DbContext.PowerPlant.CreateColumnFactory(); List <IColumn> columns = new List <IColumn>(); bool tableHasBlobColumn = false; IDataCursor cursor = null; try { cursor = DbContext.PowerPlant.CreateDataCursor(); IDataReader reader = cursor.ExecuteReader(selectStmt); while (reader.Read()) { string name = reader.GetString(0); string type = reader.GetString(1); int length = reader.GetInt16(2); if (length != -1 && (type == "nvarchar" || type == "nchar")) { length /= 2; } int prec = reader.GetByte(3); int scale = reader.GetByte(4); if (scale != 0 && type == "datetime2") { prec = 0; } bool isNullable = reader.GetBoolean(5); string collation = reader.GetString(6); string def = reader.GetString(7); bool isIdentity = reader.GetBoolean(8); string sourceType = type.AddParameters(); ColumnTypeName colType = columnTypeConverter.GetDestinationType(sourceType, ref length, ref prec, ref scale).ColumnTypeName(length); if (colType == ColumnTypeName.Blob || colType == ColumnTypeName.OldBlob) { tableHasBlobColumn = true; } columns.Add( columnFactory.CreateInstance( colType, name, length, prec, scale, isNullable, isIdentity, def, collation) ); } } catch (Exception ex) { throw new ADatabaseException("ERROR when Get TableDefinition: " + selectStmt, ex); } finally { if (cursor != null) { cursor.Close(); } } ITableDefinition tableDefinition = DbContext.PowerPlant.CreateTableDefinition(tableName, columns, GetSegmentName(tableName)); tableDefinition.HasBlobColumn = tableHasBlobColumn; tableDefinition.Columns.RemoveAll(c => c.Name == "agrtid"); return(tableDefinition); }
private void VerifyColumnType(string expectedType, int?expectedLength, int?expectedPrec, int?expectedScale) { var selectStmt = ""; selectStmt += "SELECT c.name, " + "\n"; selectStmt += " t.name AS t_name, " + "\n"; selectStmt += " isnull(c.max_length, 0) as length, " + "\n"; selectStmt += " isnull(c.precision, 0) as prec, " + "\n"; selectStmt += " isnull(c.scale, 0) as scale, " + "\n"; selectStmt += " c.is_nullable, " + "\n"; selectStmt += " convert(varchar(256), isnull(c.collation_name, '')) as collation, " + "\n"; selectStmt += " isnull(object_definition(c.default_object_id), '') as def, " + "\n"; selectStmt += " c.is_identity " + "\n"; selectStmt += "FROM sys.columns c " + "\n"; selectStmt += " JOIN sys.types t " + "\n"; selectStmt += " ON c.user_type_id = t.user_type_id " + "\n"; selectStmt += $"WHERE c.object_id = Object_id('{TableName}') " + "\n"; selectStmt += "ORDER BY c.column_id "; IDataCursor cursor = DbContext.PowerPlant.CreateDataCursor(); string type = ""; int length = -99; int prec = -99; int scale = -99; try { IDataReader reader = cursor.ExecuteReader(selectStmt); reader.Read(); type = reader.GetString(1).ToLower(); length = reader.GetInt16(2); if (length != -1 && (type == "nvarchar" || type == "nchar")) { length /= 2; } prec = reader.GetByte(3); scale = reader.GetByte(4); if (reader.GetBoolean(8)) { type = "identity"; } } catch (Exception) { false.Should().BeTrue("because we want to fail when we cant read type from database."); } finally { cursor.Close(); } type.Should().Be(expectedType); if (expectedLength != null) { length.Should().Be(expectedLength, "because that's the expected length"); } if (expectedPrec != null) { prec.Should().Be(expectedPrec, "because that's the expected precision"); } if (expectedScale != null) { scale.Should().Be(expectedScale, "because that's the expected scale"); } }
public static void Update(this IDataCursor cursor, string key, object data) { cursor.Refine(key).Update(data); }
public static void Update(this IDataCursor cursor, string[] path, object data) { cursor.Refine(path).Update(data); }
/*protected bool validateMessage(FlowState state, IData pipeline, bool inOpt) * { * NSService svc = getService(state.getNamespace(), NSName.create(getNSName())); * * int vo = inOpt ? svc.getInputValidatorOptions() : svc.getOutputValidatorOptions(); * if (vo == 2) * { * IData val = null; * * NSRecord nsr = inOpt ? svc.getSignature().getInput() : svc.getSignature().getOutput(); * * ValidatorOptions vtorOpts = Validator.getDefaultOptions(); * * Validator vtor = Validator.create(pipeline, nsr, vtorOpts); * boolean valid = false; * Exception ex = null; * try * { * val = vtor.validate(); * IDataCursor ic = val.getCursor(); * if (ic.first("isValid")) * { * valid = IDataUtil.getBoolean(ic); * } * ic.destroy(); * } * catch (Exception e) * { * ex = e; * } * if ((!valid) || (ex != null)) * { * Object[] subs = { svc.getNSName().getFullName(), FlowInvoke.getValidationMsgs(val) }; * if (ex == null) * { * ex = new FlowException(FlowExceptionBundle.class, inOpt? FlowExceptionBundle.FAILED_INPUT_VALIDATION : FlowExceptionBundle.FAILED_OUTPUT_VALIDATION, "", subs); * } * handleError(state, ex); * } * return valid; * } * return true; * }*/ public override void invoke(FlowState flowState) { bool isRoot = FlowState.isRoot(this); bool disabled = false; FlowElement last = flowState.last; if ((last != null) && (!last.enabled)) { disabled = true; } if (flowState.shouldExit(this) || (flowState.error == null && exitOn == SUCCESS && !start && !map && !disabled) || (flowState.error != null && exitOn == FAILURE)) { flowState.done = true; flowState.willExit(); return; } if (flowState.error != null) { FlowExceptionHandler fex = flowState.flowExHandler; if (fex != null) { fex.resetException(); } flowState.error = null; IData pipe = flowState.pipeline; IDataCursor cursor = pipe.getCursor(); while (cursor.first() && cursor.delete()) { } cursor.destroy(); IDataUtil.append(save_pipeline, pipe); } else { save_pipeline = IDataUtil.clone(flowState.pipeline); } if (flowState.pushNextNode() == null) { flowState.done = true; if (isRoot && flowState.incremental) { if (flowState.shouldExit(this) || (flowState.error == null && exitOn == SUCCESS && !start && !map && !disabled) || (flowState.error != null && exitOn == FAILURE)) { flowState.done = true; flowState.willExit(); } } } else { map = flowState.current().type.Equals(TYPE_MAP); } if (start) { start = false; } }
public static object get(IData parent, WmPathItem pathItem, bool bestEffort, IData origPipe) { if ((parent == null) || (pathItem == null)) { return(null); } Object value = null; if (pathItem.pathType == 0) { IDataCursor cursor = parent.getCursor(); String name = pathItem.name; if (cursor.first(name)) { value = cursor.getValue(); } cursor.destroy(); } else if (pathItem.pathType == 1) { if (pathItem.position < 0) { return(null); } IDataCursor cursor = parent.getCursor(); if (seek(cursor, pathItem.position)) { value = cursor.getValue(); } cursor.destroy(); } else if (pathItem.pathType == 2) { if (pathItem.position < 0) { return(null); } IDataCursor cursor = parent.getCursor(); String name = pathItem.name; int position = pathItem.position; bool find = true; for (int i = 0; i <= position; i++) { if (!cursor.next(name)) { find = false; break; } } if (find) { value = cursor.getValue(); } cursor.destroy(); } else if (pathItem.pathType == 3) { return(null); } if ((!bestEffort) && (!dataCheck(value, pathItem))) { value = null; } if ((value is WmIDataList)) { value = ((WmIDataList)value).getItems(); } if (pathItem.arrayIndex == -1) { return(value); } return(getByArrayIndex(value, pathItem, origPipe)); }
private static bool seek(IDataCursor ic, int position) { int curPos = 0; if (ic.first()) { while (curPos < position) { if (!ic.next()) { return false; } curPos++; } return true; } return false; }
public static TData Get <TData>(this IDataCursor cursor, string key) { return(cursor.Refine(key).Get <TData>()); }
public static TData Get <TData>(this IDataCursor cursor, params string[] path) { return(cursor.Refine(path).Get <TData>()); }