/// <summary> /// Implements the functionality of IExecutant::GetPagedData /// </summary> /// <param name="fields">Comma-separated list of fields</param> /// <param name="fields">Array of fields to get</param> /// <param name="orderByField">Field for sorting</param> /// <param name="orderByASc">true if sort is ASCending</param> /// <param name="where">WHERE clausule</param> /// <param name="rowstart">1st register to fetch</param> /// <param name="rowend">Last register to fetch</param> /// <param name="tableBD">Table of the DataBase to SELECT</param> /// <param name="tableDT">Name of the DataTable returned</param> /// <param name="pk">Array of strings with the primary keys (CANNOT be null)</param> /// <returns>DataTable with the data</returns> protected DataTable DoGetPagedData(string fields, string orderByField, bool orderByAsc, string where, int rowstart, int rowend, string tableBD, string tableDT, string[] pk) { // Converts possible null or "" values if (pk == null) { throw new ArgumentNullException("pk", "PK cannot be null when paging!"); } if (orderByField == string.Empty) { orderByField = null; } if (!orderByAsc && orderByField != null) { orderByField = orderByField + " DESC"; } // if (tableBD == "OPERATIONS") // { // if (where == "OPE_VALID=1 AND OPE_DELETED=0") // { // where = "OPE_VALID=1 AND OPE_DELETED=0 AND OPE_RANK >= " + rowstart + " AND OPE_RANK <= " + rowend; // orderByField = "OPE_RANK ASC"; // } // } // else if ((tableBD == "ALARMS_HIS") && (where == "")) // { // where = "HALA_RANK >= " + rowstart + " AND HALA_RANK <= " + rowend; // orderByField = "HALA_RANK ASC"; // } // else if ((tableBD == "FINES_HIS") && (where == "")) // { // where = "HFIN_RANK >= " + rowstart + " AND HFIN_RANK <= " + rowend; // orderByField = "HFIN_RANK ASC"; // } // else if ((tableBD == "MSGS_HIS") && (where == "")) // { // where = "HMSG_RANK >= " + rowstart + " AND HMSG_RANK <= " + rowend; // orderByField = "HMSG_RANK ASC"; // } // else if ((tableBD == "OPERATIONS_HIS") && (where == "")) // { // where = "HOPE_RANK >= " + rowstart + " AND HOPE_RANK <= " + rowend; // orderByField = "HOPE_RANK ASC"; // } Database d = DatabaseFactory.GetDatabase(); DataTable dt = null; if (rowend == -1) { dt = d.FillDataTable(fields, tableBD, orderByField, where, tableDT, -1); DataColumn [] dtPK = new DataColumn[pk.Length]; for (int i = 0; i < pk.Length; i++) { dtPK[i] = dt.Columns[pk[i]]; } dt.PrimaryKey = dtPK; } else { dt = d.FillPagedDataTable(fields, tableDT, orderByField, where, tableDT, rowstart, rowend, pk); } return(dt); }