/// <summary> /// Get a list containing all transactions that meet the specified criteria. /// </summary> /// <param name="accessParams"></param> /// <param name="itemIDs"></param> /// <param name="stationIDs"></param> /// <param name="startDate"></param> /// <param name="endDate"></param> /// <returns></returns> public static TransactionList LoadTransactions(List<FinanceAccessParams> accessParams, List<int> itemIDs, List<long> stationIDs, DateTime startDate, DateTime endDate, string type) { TransactionList retVal = new TransactionList(); //--------------------------------------------------------------------------------------------------- EMMADataSet.TransactionsDataTable table = new EMMADataSet.TransactionsDataTable(); table = GetTransData(accessParams, itemIDs, new List<long>(), stationIDs, startDate, endDate, type); foreach (EMMADataSet.TransactionsRow row in table) { Transaction trans = new Transaction(row); retVal.Add(trans); } //--------------------------------------------------------------------------------------------------- // This was an attempt to speed up loading of data by only loading IDs initally and // then retrieving other information as required. // It was not much faster on the inital load and gave worse stuttering during operation // so it's no longer used. Instead we simply limit the inital data retrieval on // the view form to the last week's worth of data. //--------------------------------------------------------------------------------------------------- /*string itemString = ""; string stationString = ""; foreach (int item in itemIDs) { itemString = itemString + (itemString.Length == 0 ? "" : ",") + item; } foreach (int station in stationIDs) { stationString = stationString + (stationString.Length == 0 ? "" : ",") + station; } SqlConnection connection = new SqlConnection(Properties.Settings.Default.EMMA_DatabaseConnectionString); SqlDataAdapter adapter = null; SqlCommand command = null; connection.Open(); command = new SqlCommand("TransCountByItemAndLoc", connection); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add(new SqlParameter("@accessParams", FinanceAccessParams.BuildAccessList(accessParams))); command.Parameters.Add(new SqlParameter("@itemIDs", itemString)); command.Parameters.Add(new SqlParameter("@stationIDs", stationString)); command.Parameters.Add(new SqlParameter("@regionIDs", "")); command.Parameters.Add(new SqlParameter("@startDate", SqlDateTime.MinValue.Value)); command.Parameters.Add(new SqlParameter("@endDate", SqlDateTime.MaxValue.Value)); command.Parameters.Add(new SqlParameter("@transType", "")); adapter = new SqlDataAdapter(command); // lock on the transactions table adapter, even though we're not actually using it, we're still // accessing the same database table. lock (tableAdapter) { SqlDataReader reader = adapter.SelectCommand.ExecuteReader(); try { while (reader.Read()) { Transaction trans = new Transaction(reader.GetInt64(0)); retVal.Add(trans); } } finally { reader.Close(); } }*/ //--------------------------------------------------------------------------------------------------- return retVal; }
public static bool GetResultsPage(int startPos, int pageSize, ref TransactionList transactions) { if (startPos <= 0) startPos = 1; EMMADataSet.TransactionsDataTable table = new EMMADataSet.TransactionsDataTable(); lock (tableAdapter) { tableAdapter.FillByResultsPage(table, startPos, pageSize); } foreach (EMMADataSet.TransactionsRow transaction in table) { transactions.Add(new Transaction(transaction)); } return table.Count == pageSize; }