コード例 #1
0
        //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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        public BindingList<CumulativeInterval> GetCumulativeIntervals()
        {
            BindingList<CumulativeInterval> intervals = new BindingList<CumulativeInterval>();

            CumulativeIntervalData cid = new CumulativeIntervalData();
            intervals = cid.GetCumulativeIntervals();

            return intervals;
        }