public int CreateBatchInterval(string fileName, CaptureState marked) { //bool success = false; int newCaptureBatchId = 0; //using (var context = new PacketCaptureContext()) using (var context = new PacketAnalysisEntity()) { // Check to see if the batch already exists (it shouldn't - but we will use this for testing) var captureBatchId = (from c in context.CaptureBatches where c.FileName == fileName select c.CaptureBatchId).FirstOrDefault(); if (captureBatchId > 0) { // CaptureBatch already exists - just use the current CaptureBatchId newCaptureBatchId = captureBatchId; } else { // We need to add a new capture batch and get the CaptureBatchId var newBatch = context.CaptureBatches.Add(new CaptureBatch()); newBatch.FileName = fileName; newBatch.Marked = marked == CaptureState.Marked? true : false; //newCaptureBatchId = context.SaveChanges(); context.SaveChanges(); newCaptureBatchId = context.CaptureBatches.Select(c => c.CaptureBatchId).Max(); } } // success; return newCaptureBatchId; }
public void InsertCumulativeProbabilityDistribution(BindingList<CumulativeProbabilityDistribution> cumulativeProbabilityDistribution) { using (var context = new PacketAnalysisEntity()) { foreach (CumulativeProbabilityDistribution cpd in cumulativeProbabilityDistribution) { context.CumulativeProbabilityDistributions.Add(cpd); } context.SaveChanges(); } }
public void InsertCumulativeHistogramData() { using (var context = new PacketAnalysisEntity()) { foreach (CumulativeHistogram h in this._CumulativeHistogram) { context.CumulativeHistograms.Add(h); //context.SaveChanges(); } context.SaveChanges(); } }
public void InsertSingleHistogramData() { using (var context = new PacketAnalysisEntity()) { foreach (SingleHistogram h in this._SingleHistograms) { context.SingleHistograms.Add(h); //context.SaveChanges(); } context.SaveChanges(); } }
public void DeleteCumulativeProbabilityDistribution(CaptureState captureState) { using (var context = new PacketAnalysisEntity()) { var distribution = from d in context.CumulativeProbabilityDistributions where d.CaptureState == (int)captureState select d; foreach (CumulativeProbabilityDistribution cpd in distribution) { context.CumulativeProbabilityDistributions.Remove(cpd); } context.SaveChanges(); } }
public void DeleteCumulativeHistogramData() { int captureState = Convert.ToInt32(this._CaptureState); using (var context = new PacketAnalysisEntity()) { var deleteHistogram = (from h in context.CumulativeHistograms where h.CaptureState == captureState select h).ToList(); foreach (CumulativeHistogram h in deleteHistogram) { context.CumulativeHistograms.Remove(h); } context.SaveChanges(); } }
public void DeleteHypothesisTestResults() { using (var context = new PacketAnalysisEntity()) { // Check to see if the table is empty var isEmpty = (from e in context.HypothesisTests select e).Count(); // If not empty delete any rows if (isEmpty > 0) { var deleteResults = (from t in context.HypothesisTests select t).ToList(); foreach (HypothesisTest ht in deleteResults) { context.HypothesisTests.Remove(ht); } context.SaveChanges(); } } }
public void UpdateDisplayStatsSavedFlag(int captureBatchId, BatchType batchType, bool saveData) { using (var context = new PacketAnalysisEntity()) { var captureBatch = (from b in context.CaptureBatches where b.CaptureBatchId == captureBatchId select b).Single(); if (batchType == BatchType.Single) { captureBatch.SingleStatistics = saveData; } else if(batchType == BatchType.Cumulative) { captureBatch.CumulativeStatistics = saveData; } else { // no op - unknown batch type } context.SaveChanges(); } }
public void InsertSingleUnarkedDisplayStatitics(BatchStatistics batchStatistics) { using (var context = new PacketAnalysisEntity()) { context.DisplayStatisticsInsert( batchStatistics.IntervalCount, batchStatistics.IntervalCountTrimmed, batchStatistics.PacketCountMean, batchStatistics.PacketCountStandardDeviation, batchStatistics.PacketCountMinimum, batchStatistics.PacketCountMaximum, batchStatistics.MeanOfMeans, batchStatistics.MeanOfMeansStandardDeviation, false, // Marked Convert.ToInt32(BatchType.Single) ); context.SaveChanges(); } }
public void InsertHypothesisTestResults(HypothesisTest testResults) { using (var context = new PacketAnalysisEntity()) { context.HypothesisTests.Add(testResults); context.SaveChanges(); } }