private void GenerateChart(Evaluation evaluation, string pivotCategoryValue) { _currentEvaluation = evaluation; chart1.Visible = false; var dt = PeriodicityState.GetPeriodicityForDataTableForEvaluation(evaluation, pivotCategoryValue, true); if (dt == null) { ClearGraph(); chart1.Visible = true; return; } chart1.DataSource = dt; dataGridView1.DataSource = dt; chart1.Series.Clear(); if (dt.Rows.Count != 0) { _chartLookAndFeelSetter.PopulateYearMonthChart(chart1, dt, "Data Quality"); } chart1.DataBind(); chart1.Visible = true; ReGenerateAnnotations(); }
public void TestGetPeriodicityForDataTableForEvaluation_EmptyEvaluation(bool pivot) { var cata = new Catalogue(CatalogueRepository, "MyCata"); var dqeRepo = new DQERepository(CatalogueRepository); var eval = new Evaluation(dqeRepo, cata); var dt = PeriodicityState.GetPeriodicityForDataTableForEvaluation(eval, "ALL", pivot); Assert.IsNull(dt); }
public Tuple <DateTime?, DateTime?> GetMachineReadableTimespanIfKnownOf(Evaluation evaluation, bool discardOutliers) { var dt = PeriodicityState.GetPeriodicityForDataTableForEvaluation(evaluation, "ALL", false); if (dt == null || dt.Rows.Count < 2) { return(Unknown()); } int discardThreshold = discardOutliers ? GetDiscardThreshold(dt) : -1; DateTime?minMonth = null; for (int i = 0; i < dt.Rows.Count; i++) { if (Convert.ToInt32(dt.Rows[i]["CountOfRecords"]) > discardThreshold) { minMonth = DateTime.Parse(dt.Rows[i][1].ToString()); break; } } DateTime?maxMonth = null; for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (Convert.ToInt32(dt.Rows[i]["CountOfRecords"]) > discardThreshold) { maxMonth = DateTime.Parse(dt.Rows[i][1].ToString()); break; } } if (maxMonth == null || minMonth == null) { return(Unknown()); } return(Tuple.Create(minMonth, maxMonth)); }
public Tuple <DateTime?, DateTime?> GetMachineReadableTimepsanIfKnownOf(Catalogue catalogue, bool discardOutliers, out DateTime?accurateAsOf) { DataTable dt; accurateAsOf = null; Evaluation mostRecentEvaluation = null; try { var repo = new DQERepository(catalogue.CatalogueRepository); mostRecentEvaluation = repo.GetMostRecentEvaluationFor(catalogue); } catch (Exception) { return(Unknown()); } if (mostRecentEvaluation == null) { return(Unknown()); } accurateAsOf = mostRecentEvaluation.DateOfEvaluation; dt = PeriodicityState.GetPeriodicityForDataTableForEvaluation(mostRecentEvaluation, "ALL", false); if (dt == null || dt.Rows.Count < 2) { return(Unknown()); } int discardThreshold = discardOutliers? GetDiscardThreshold(dt):-1; DateTime?minMonth = null; for (int i = 0; i < dt.Rows.Count; i++) { if (Convert.ToInt32(dt.Rows[i]["CountOfRecords"]) > discardThreshold) { minMonth = DateTime.Parse(dt.Rows[i][1].ToString()); break; } } DateTime?maxMonth = null; for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (Convert.ToInt32(dt.Rows[i]["CountOfRecords"]) > discardThreshold) { maxMonth = DateTime.Parse(dt.Rows[i][1].ToString()); break; } } if (maxMonth == null || minMonth == null) { return(Unknown()); } if (maxMonth == minMonth) { return(Tuple.Create(minMonth, minMonth)); } return(Tuple.Create(minMonth, maxMonth)); }
/// <inheritdoc/> public string GetHumanReadableTimepsanIfKnownOf(Catalogue catalogue, bool discardOutliers) { DataTable dt; try { var repo = new DQERepository(catalogue.CatalogueRepository); Evaluation mostRecentEvaluation = repo.GetMostRecentEvaluationFor(catalogue); if (mostRecentEvaluation == null) { return("Unknown"); } dt = PeriodicityState.GetPeriodicityForDataTableForEvaluation(mostRecentEvaluation, "ALL", false); } catch (Exception e) { return("Unknown:" + e.Message); } if (dt == null || dt.Rows.Count < 2) { return("Unknown"); } int discardThreshold = discardOutliers? GetDiscardThreshold(dt):-1; string minMonth = null; for (int i = 0; i < dt.Rows.Count; i++) { if (Convert.ToInt32(dt.Rows[i]["CountOfRecords"]) > discardThreshold) { minMonth = dt.Rows[i][1].ToString(); break; } } string maxMonth = null; for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (Convert.ToInt32(dt.Rows[i]["CountOfRecords"]) > discardThreshold) { maxMonth = dt.Rows[i][1].ToString(); break; } } if (maxMonth == null || minMonth == null) { return("All Values Below Threshold"); } if (maxMonth == minMonth) { return(minMonth); } return(minMonth + " To " + maxMonth); }