public bool UpdateCumulativeIntervalsAddToTotals(string dbConnectionString, BindingList<PacketInterval> intervalCounts, CaptureState marked) { // NOTE: don't use this method - just add the intervals (see UpdateCumulativeIntervals(...) above). bool success = false; //BindingList<BatchIntervalMarked> markedBatchIntervals = new BindingList<BatchIntervalMarked>(); BindingList<CumulativeInterval> cumulativeIntervals = new BindingList<CumulativeInterval>(); BatchIntervalData bid = new BatchIntervalData(); CumulativeIntervalData cid = new CumulativeIntervalData(); cumulativeIntervals = cid.GetCumulativeIntervals(); if (cumulativeIntervals.Count == 0) { // No cumulative intervals yet - use the last batch intervals foreach (PacketInterval ic in intervalCounts) { CumulativeInterval ci = new CumulativeInterval(); ci.CumulativeIntervalNumber = ic.Interval; ci.PacketCount = ic.PacketCount; ci.Marked = ic.PacketState == CaptureState.Marked ? true : false; cumulativeIntervals.Add(ci); } } else { // Add the new batch intervals to the cumulative intervals // Make sure they are for the correct marked set! // Get the cumulative intervals for the marked type cumulativeIntervals = cid.GetMarkedCumulativeIntervals(marked); for (int i = 0; i < cumulativeIntervals.Count; i++) { cumulativeIntervals[i].PacketCount += intervalCounts[i].PacketCount; } if (intervalCounts.Count >= cumulativeIntervals.Count) { int lastIntervalNumber = cid.LastIntervalNumber; // There are additional intervals in this batch // Add them to the cumulative intervals foreach (PacketInterval pi in intervalCounts) { if (pi.Interval >= cumulativeIntervals.Count) { CumulativeInterval newci = new CumulativeInterval(); // Get the last cumulative interval number //var cin = (from c in cumulativeIntervals select c.CumulativeIntervalNumber).Max(); //newci.CumulativeIntervalNumber = pi.Interval; //newci.CumulativeIntervalNumber = cin + 1; newci.CumulativeIntervalNumber = lastIntervalNumber++; newci.PacketCount = pi.PacketCount; newci.Marked = pi.PacketState == CaptureState.Marked ? true : false; cumulativeIntervals.Add(newci); } } } } // Save the cumulative interval counts // Delete the old counts first cid.DeleteCumulativeIntervals(marked); cid.DbConnectionString = dbConnectionString; // Create a DataTable to hold the cumulative intervals DataTable CumulativeIntervalsDataTable = null; // Create a data table for bulk-loading the data DataTable dt = CreateCumulativeIntervalDataTable(); try { // Load the cumulative interval counts into the data table CumulativeIntervalsDataTable = new DataTable(); CumulativeIntervalsDataTable = LoadCumulativeIntervalDataTable(dt, cumulativeIntervals); success = true; } catch (Exception ex) { throw new Exception("Error loading cumulative intervals into DataTable: " + ex.Message); } if (success) { try { // Load the cumulative interval counts into the database success = cid.LoadCumulativeIntervals(CumulativeIntervalsDataTable); } catch (Exception ex) { throw new Exception("Error loading cumulative intervals into database: " + ex.Message); } } return success; }
//public bool UpdateCumulativeIntervals(string dbConnectionString, BindingList<PacketInterval> intervalCounts, CaptureState marked) public bool UpdateCumulativeIntervals(string dbConnectionString, BindingList<PacketInterval> intervalCounts) { // Add the intervals to the cumulative intervals collection bool success = false; //BindingList<BatchIntervalMarked> markedBatchIntervals = new BindingList<BatchIntervalMarked>(); BindingList<CumulativeInterval> cumulativeIntervals = new BindingList<CumulativeInterval>(); BatchIntervalData bid = new BatchIntervalData(); CumulativeIntervalData cid = new CumulativeIntervalData(dbConnectionString); //cumulativeIntervals = cid.GetCumulativeIntervals(); int ciNumber = cid.LastIntervalNumber; foreach (PacketInterval ic in intervalCounts) { ciNumber++; CumulativeInterval ci = new CumulativeInterval(); ci.CumulativeIntervalNumber = ciNumber; ci.PacketCount = ic.PacketCount; ci.Marked = ic.PacketState == CaptureState.Marked ? true : false; cumulativeIntervals.Add(ci); } // Save the cumulative interval counts //// Delete the old counts first //cid.DeleteCumulativeIntervals(marked); //cid.DbConnectionString = dbConnectionString; // Create a DataTable to hold the cumulative intervals DataTable CumulativeIntervalsDataTable = null; // Create a data table for bulk-loading the data DataTable dt = CreateCumulativeIntervalDataTable(); try { // Load the cumulative interval counts into the data table CumulativeIntervalsDataTable = new DataTable(); CumulativeIntervalsDataTable = LoadCumulativeIntervalDataTable(dt, cumulativeIntervals); success = true; } catch (Exception ex) { throw new Exception("Error loading cumulative intervals into DataTable: " + ex.Message); } if (success) { try { // Load the cumulative interval counts into the database success = cid.LoadCumulativeIntervals(CumulativeIntervalsDataTable); } catch (Exception ex) { throw new Exception("Error loading cumulative intervals into database: " + ex.Message); } } return success; }
public void TruncateAllIntervalStatisticAndTestTables() { BatchIntervalData bid = new BatchIntervalData(); bid.TruncateAllIntervalStatisticAndTestTables(); }
//public bool SaveBatchIntervals(string dbConnectionString, BindingList<PacketInterval> intervals, string fileName, int captureBatchId, CaptureState marked) public bool SaveBatchIntervals(string dbConnectionString, BindingList<PacketInterval> intervals) { bool success = false; DataTable BatchIntervalsDataTable = null; // Create a data table for bulk-loading the data DataTable dt = CreateBatchIntervalDataTable(); try { // Load the interval counts into the data table BatchIntervalsDataTable = new DataTable(); //BatchIntervalsDataTable = LoadBatchIntervalDataTable(dt, intervals, captureBatchId); BatchIntervalsDataTable = LoadBatchIntervalDataTable(dt, intervals); success = true; } catch (Exception ex) { throw new Exception("Error loading batch intervals into DataTable: " + ex.Message); } try { if (success) { // Save the batch intervals to the database BatchIntervalData bid = new BatchIntervalData(dbConnectionString); bid.LoadBatchIntervals(BatchIntervalsDataTable); } } catch(Exception ex) { throw new Exception("Error bulk-loading batch intervals into database: " + ex.Message); } return success; }
public BindingList<BatchIntervalMarked> GetMarkedBatchIntervals(int captureBatchId) { BindingList<BatchIntervalMarked> markedIntervals = new BindingList<BatchIntervalMarked>(); BatchIntervalData bid = new BatchIntervalData(); markedIntervals = bid.GetMarkedBatchIntervals(captureBatchId); return markedIntervals; }
public void RecalculateBatchIntervals() { // Recalculate intervals for all existing batch data using a new interval size // First delete all existing batch intervals and cumulative intervals BatchIntervalData bid = new BatchIntervalData(); //bid.RemoveAllBatchIntervals(); bid.TruncateAllIntervalStatisticAndTestTables(); // Get a list of all capture files CaptureFileData cfd = new CaptureFileData(); BindingList<CurrentCaptureFile> captureFiles = new BindingList<CurrentCaptureFile>(); captureFiles = cfd.GetBatchIds(); // Create new intervals for each capture file and update the cumulative intervals foreach (CurrentCaptureFile file in captureFiles) { BindingList<PacketInterval> intervals = new BindingList<PacketInterval>(); intervals = CreateBatchIntervals(file.FileName); UpdateCumulativeIntervals(intervals); UpdateCaptureBatchParseStatusForRecalculation(file.CaptureBatchId); } }