예제 #1
0
        /// <summary>
        /// Generates the charts or lists for the statistical options selected by the user.
        /// </summary>
        private void GenerateStatistics()
        {
            this.agencyList = ConvertToStringArray(this.agencies);

            this.postalCodeList = ConvertToStringArray(this.postalCodes);

            Statistics stats = new Statistics()
            {
                Agencies           = this.agencyList,
                PostalCodes        = this.postalCodeList,
                SerialIds          = this.serialIds.Text,
                StartDate          = Convert.ToDateTime(this.startDate.Text),
                EndDate            = Convert.ToDateTime(this.endDate.Text),
                AfltHitThreshold   = Convert.ToInt32(this.hits.Text.Length > 0 ? this.hits.Text : "-1"),
                DataUsageThreshold = Convert.ToInt32(this.usage.Text.Length > 0 ? this.usage.Text : "-1")
            };

            Enumerators.Period pd = (Enumerators.Period)Enum.Parse(typeof(Enumerators.Period), ((ListBoxItem)this.period.SelectedItem).Content.ToString());

            try
            {
                if (this.afltHits.IsChecked.HasValue && this.afltHits.IsChecked.Value)
                {
                    this.windows.AddRange(Calculate(stats, pd, Enumerators.StatisticsType.AfltHit, this.average.IsChecked,
                                                    this.highest.IsChecked, this.lowest.IsChecked, this.standardDeviation.IsChecked, this.exceedThreshold.IsChecked));
                }

                if (this.dataUsage.IsChecked.HasValue && this.dataUsage.IsChecked.Value)
                {
                    this.windows.AddRange(Calculate(stats, pd, Enumerators.StatisticsType.DataUsage, this.average.IsChecked,
                                                    this.highest.IsChecked, this.lowest.IsChecked, this.standardDeviation.IsChecked, this.exceedThreshold.IsChecked));
                }

                foreach (Window w in this.windows)
                {
                    w.Show();
                }
            }
            finally
            {
                stats.Dispose();
            }
        }
예제 #2
0
        private List <Window> Calculate(Statistics stats, Enumerators.Period pd, Enumerators.StatisticsType type, bool?average, bool?high, bool?low,
                                        bool?stdDev, bool?threshold)
        {
            List <Window> result = new List <Window>();

            //DataTable highTable = null;
            //DataTable lowTable = null;
            //DataTable thresholdTable = null;
            //double standardDeviation = 0;

            //Enumerators.GraphType graphType = Enumerators.GraphType.Average;

            string title = "AFLT Hits";

            if (type == Enumerators.StatisticsType.DataUsage)
            {
                title = "Cell Data Usage";
            }

            //if (average.HasValue && average.Value)
            //    averageTable = stats.GetAverage(type, pd);

            DataTable data = stats.GetData(type);

            if (data != null)
            {
                data.TableName = title;

                Charts charts = new Charts();



                result.Add(charts);

                //if (data.Rows.Count > 1)
                //    result.Add(new Charts());
                //else
                //    result.Add(new Lists(data));
            }

            //if (high.HasValue && high.Value)
            //    highTable = stats.GetHighest(type);

            //if (highTable != null)
            //{
            //    highTable.TableName = title + "Highest";

            //    graphType = Enumerators.GraphType.Highest;

            //    if (highTable.Rows.Count > 1)
            //        result.Add(new Charts(highTable, graphType));
            //    else
            //        result.Add(new Lists(highTable));
            //}

            //if (low.HasValue && low.Value)
            //    lowTable = stats.GetLowest(type);

            //if (lowTable != null)
            //{
            //    lowTable.TableName = title + "Lowest";

            //    graphType = Enumerators.GraphType.Lowest;

            //    if (lowTable.Rows.Count > 1)
            //        result.Add(new Charts(lowTable, graphType));
            //    else
            //        result.Add(new Lists(lowTable));
            //}

            //Figure out where to put this.

            //if (stdDev.HasValue && stdDev.Value)
            //    standardDeviation = stats.GetStandardDeviation(type, pd);

            //if (threshold.HasValue && threshold.Value)
            //    thresholdTable = stats.GetDevicesOverThreshold(type, pd);

            //if (thresholdTable != null)
            //{
            //    thresholdTable.TableName = title + "Threshold";

            //    graphType = Enumerators.GraphType.Threshold;

            //    if (thresholdTable.Rows.Count > 1)
            //        result.Add(new Charts(thresholdTable, graphType));
            //    else
            //        result.Add(new Lists(thresholdTable));
            //}

            return(result);
        }