/// <summary> /// Gets the next results and add the rows to the current RowSet queue /// </summary> protected virtual void PageNext() { if (IsFullyFetched) { return; } if (FetchNextPage == null) { //There is no handler, clear the paging state this.PagingState = null; return; } lock (_pageLock) { var pageState = this.PagingState; if (pageState == null) { return; } bool value; bool alreadyPresent = _pagers.TryGetValue(pageState, out value); if (alreadyPresent) { return; } var rs = FetchNextPage(pageState); foreach (var newRow in rs.RowQueue) { RowQueue.Enqueue(newRow); } PagingState = rs.PagingState; _pagers.AddOrUpdate(pageState, true, (k, v) => v); } }
/// <summary> /// Adds a row to the inner row list /// </summary> internal virtual void AddRow(Row row) { if (RowQueue == null) { throw new InvalidOperationException("Can not append a Row to a RowSet instance created for VOID results"); } RowQueue.Enqueue(row); }
/// <summary> /// Adds a row to the inner row list /// </summary> internal virtual void AddRow(Row row) { RowQueue.Enqueue(row); }
// --- Higer Level Functions --- public DataSet GetDataset(int MaxRows) { bool OldColumnHeaders = ColumnHeaders; ColumnHeaders = false; if (!InitRead()) { return(null); } ColumnHeaders = OldColumnHeaders; m_MaxRows = MaxRows; int i; DataSet DS = new DataSet(); DataTable DT = new DataTable(); bCancel = false; string strColumnName; if (ColumnHeaders) { for (i = 0; i <= m_ColumnCount - 1; i++) { strColumnName = ColumnValues[i].Trim(); if (strColumnName == "") { strColumnName = "Column" + i.ToString(); } try { DT.Columns.Add(strColumnName, Type.GetType("System.String")); } catch { strColumnName = "Column" + i.ToString(); DT.Columns.Add(strColumnName, Type.GetType("System.String")); } } if (!EOF) { if (!MoveNext()) { return(null); } } m_RecordCount = 1; } else { for (i = 0; i <= m_ColumnCount - 1; i++) { DT.Columns.Add("Column" + i.ToString(), Type.GetType("System.String")); } } DataRow Row; int Percent; if (!EOF) { if (ProgressChangeEvent != null) { ProgressChangeEvent(0); } while (!EOF && !bCancel) { Row = DT.NewRow(); for (i = 0; i <= m_ColumnCount - 1; i++) { try { Row[i] = Strings.ConvertNull(ColumnValues[i]); } catch (Exception) { } } if (Queued) { RowQueue.Enqueue(Row); } else { DT.Rows.Add(Row); } if (!MoveNext()) { return(null); } Percent = PercentDone; if (ProgressChangeEvent != null) { ProgressChangeEvent(Percent); } if (MaxRows > 0 && m_RecordCount > MaxRows) { break; } } if (ProgressChangeEvent != null) { ProgressChangeEvent(100); } } //if (Queued) // RowQueue.Quit(); DS.Tables.Add(DT); return(DS); }