private void GetShuffleResults(ShuffleResultsGraph model) //================================================================================================================ // Get the collection of shuffle results since the last reset // // Parameters // dbCasino: Open connection to the database // model: Reference to the randomness model to populate //================================================================================================================ { model.TotalShuffles = 0; if (SiteHelpers.CombinedShuffleResults != null) { model.TotalShuffles = (SiteHelpers.CombinedShuffleResults.Count / 2); model.ShuffleResultsAggregated = SiteHelpers.CombinedShuffleResults .GroupBy(g => new { g.ShuffleType, g.ShufflePattern }) .Select(e => new ShuffleResultAggregate { ShuffleType = e.Select(x => x.ShuffleType).FirstOrDefault(), ShufflePattern = e.Select(x => x.ShufflePattern).FirstOrDefault(), PatternCount = e.Count() }).ToList(); } }
public ActionResult Randomness_RefreshResultsGraph() //================================================================================================================ // This action is invoked when the shuffling results graph needs to be refreshed. // // Event Arguments // arg_Action: Action to be performed // arg_ResizeWidth: New size of the parent container // // Returns // The sguffling results grasph //================================================================================================================ { // Retrieve the action to be performed string action = !string.IsNullOrEmpty(Request.Params[ARG_ACTION]) ? Request.Params[ARG_ACTION] : ""; // Create the model // Get the current size of the results graph ShuffleResultsGraph model = new ShuffleResultsGraph(); if (Session[SiteHelpers.ResultsGraphWidth] != null) { model.ResizeWidth = (int)Session[SiteHelpers.ResultsGraphWidth]; model.ResizeHeight = (int)Session[SiteHelpers.ResultsGraphHeight]; } // Retrieve the shuffling results SSCasino_DBContext dbCasino = null; try { // Perform the action switch (action) { case ACT_RESIZE_CHART: // Get the resize width and height int resultsGridWidth = !string.IsNullOrEmpty(Request.Params[ARG_RESULTS_GRAPH_WIDTH]) ? int.Parse(Request.Params[ARG_RESULTS_GRAPH_WIDTH]) : 0; int resultsGridHeight = !string.IsNullOrEmpty(Request.Params[ARG_RESULTS_GRAPH_HEIGHT]) ? int.Parse(Request.Params[ARG_RESULTS_GRAPH_HEIGHT]) : 0; // Calculate the new width and height of the shuffling results graph // Store these values in the sesssion object for use on refeshes model.ResizeWidth = ((resultsGridWidth == 0) ? model.DeafultWidth : resultsGridWidth); model.ResizeHeight = ((resultsGridHeight == 0) ? model.DefaultHeight : resultsGridHeight); Session[SiteHelpers.ResultsGraphWidth] = model.ResizeWidth; Session[SiteHelpers.ResultsGraphHeight] = model.ResizeHeight; break; case ACT_CHANGE_SAMPLE_SIZE: // Reset the shuffing results SiteHelpers.ClearCombinedShuffleResults(); break; case ACT_RESET: // Reset the shuffing results SiteHelpers.ClearCombinedShuffleResults(); break; } // Always get the results GetShuffleResults(model); } finally { if (dbCasino != null) { dbCasino.Dispose(); } } return(PartialView("_Randomness_ResultsGraph", model)); }