Пример #1
0
        public void LoadData()
        {
            if (DataBaseFactory.Instance.IsAvailable)
            {
                Stats = new UsageStats();

                // Calcul des périodes de facturation
                foreach (Period period in DailyUsageDAO.Instance.AllPeriod(Account))
                {
                    BillPeriodList.Add(new BillPeriod()
                    {
                        Start = period.Start,
                        End   = period.End,
                        Text  = String.Format(CIV.strings.AdvancedStats_BillingPeriod,
                                              period.Start.ToShortDateString(),
                                              period.End.ToShortDateString())
                                //period.Start.ToString("d MMMM"),
                                //period.End.ToString("d MMMM yyyy"))
                    });
                }

                // Calcul des statistiques Globale
                List <DailyUsageBO> data = DailyUsageDAO.Instance.All(Account);
                Stats.RecordedDay         = data.Count;
                Stats.GlobalUploadTotal   = 0;
                Stats.GlobalDownloadTotal = 0;
                Stats.GlobalCombinedTotal = 0;
                if (data.Count > 1)
                {
                    Stats.GlobalUploadGreater      = data[0].Upload;
                    Stats.GlobalUploadGreaterDay   = data[0].Day;
                    Stats.GlobalUploadLesser       = data[0].Upload;
                    Stats.GlobalUploadLesserDay    = data[0].Day;
                    Stats.GlobalDownloadGreater    = data[0].Download;
                    Stats.GlobalDownloadGreaterDay = data[0].Day;
                    Stats.GlobalDownloadLesser     = data[0].Download;
                    Stats.GlobalDownloadLesserDay  = data[0].Day;
                    Stats.GlobalCombinedGreater    = data[0].Total;
                    Stats.GlobalCombinedGreaterDay = data[0].Day;
                    Stats.GlobalCombinedLesser     = data[0].Total;
                    Stats.GlobalCombinedLesserDay  = data[0].Day;
                    Stats.MoreOldDay    = data[0].Day;
                    Stats.MoreRecentDay = data[data.Count - 1].Day;
                }

                for (int i = 0; i < data.Count; i++)
                {
                    if (data[i].Upload > Stats.GlobalUploadGreater)
                    {
                        Stats.GlobalUploadGreater    = data[i].Upload;
                        Stats.GlobalUploadGreaterDay = data[i].Day;
                    }
                    if (data[i].Upload < Stats.GlobalUploadLesser)
                    {
                        Stats.GlobalUploadLesser    = data[i].Upload;
                        Stats.GlobalUploadLesserDay = data[i].Day;
                    }
                    Stats.GlobalUploadTotal += data[i].Upload;

                    if (data[i].Download > Stats.GlobalDownloadGreater)
                    {
                        Stats.GlobalDownloadGreater    = data[i].Download;
                        Stats.GlobalDownloadGreaterDay = data[i].Day;
                    }
                    if (data[i].Download < Stats.GlobalDownloadLesser)
                    {
                        Stats.GlobalDownloadLesser    = data[i].Download;
                        Stats.GlobalDownloadLesserDay = data[i].Day;
                    }
                    Stats.GlobalDownloadTotal += data[i].Download;

                    if (data[i].Total > Stats.GlobalCombinedGreater)
                    {
                        Stats.GlobalCombinedGreater    = data[i].Total;
                        Stats.GlobalCombinedGreaterDay = data[i].Day;
                    }
                    if (data[i].Total < Stats.GlobalCombinedLesser)
                    {
                        Stats.GlobalCombinedLesser    = data[i].Total;
                        Stats.GlobalCombinedLesserDay = data[i].Day;
                    }
                    Stats.GlobalCombinedTotal += data[i].Total;
                }

                // Calcul des statistiques Mensuel
                data = DailyUsageDAO.Instance.AllByMonth(Account);
                Stats.RecordedMonth = data.Count;
                if (data.Count > 1)
                {
                    Stats.MonthlyUploadGreater      = data[0].Upload;
                    Stats.MonthlyUploadGreaterDay   = data[0].Day;
                    Stats.MonthlyUploadLesser       = data[0].Upload;
                    Stats.MonthlyUploadLesserDay    = data[0].Day;
                    Stats.MonthlyDownloadGreater    = data[0].Download;
                    Stats.MonthlyDownloadGreaterDay = data[0].Day;
                    Stats.MonthlyDownloadLesser     = data[0].Download;
                    Stats.MonthlyDownloadLesserDay  = data[0].Day;
                    Stats.MonthlyCombinedGreater    = data[0].Total;
                    Stats.MonthlyCombinedGreaterDay = data[0].Day;
                    Stats.MonthlyCombinedLesser     = data[0].Total;
                    Stats.MonthlyCombinedLesserDay  = data[0].Day;
                }

                for (int i = 0; i < data.Count; i++)
                {
                    if (data[i].Upload > Stats.MonthlyUploadGreater)
                    {
                        Stats.MonthlyUploadGreater    = data[i].Upload;
                        Stats.MonthlyUploadGreaterDay = data[i].Day;
                    }
                    if (data[i].Upload < Stats.MonthlyUploadLesser)
                    {
                        Stats.MonthlyUploadLesser    = data[i].Upload;
                        Stats.MonthlyUploadLesserDay = data[i].Day;
                    }

                    if (data[i].Download > Stats.MonthlyDownloadGreater)
                    {
                        Stats.MonthlyDownloadGreater    = data[i].Download;
                        Stats.MonthlyDownloadGreaterDay = data[i].Day;
                    }
                    if (data[i].Download < Stats.MonthlyDownloadLesser)
                    {
                        Stats.MonthlyDownloadLesser    = data[i].Download;
                        Stats.MonthlyDownloadLesserDay = data[i].Day;
                    }

                    if (data[i].Total > Stats.MonthlyCombinedGreater)
                    {
                        Stats.MonthlyCombinedGreater    = data[i].Total;
                        Stats.MonthlyCombinedGreaterDay = data[i].Day;
                    }
                    if (data[i].Total < Stats.MonthlyCombinedLesser)
                    {
                        Stats.MonthlyCombinedLesser    = data[i].Total;
                        Stats.MonthlyCombinedLesserDay = data[i].Day;
                    }
                }
                Stats.MonthlyUploadAverage   = Stats.GlobalUploadTotal / data.Count;
                Stats.MonthlyDownloadAverage = Stats.GlobalDownloadTotal / data.Count;
                Stats.MonthlyCombinedAverage = Stats.GlobalCombinedTotal / data.Count;
            }
        }
Пример #2
0
        public void LoadData()
        {
            if (DataBaseFactory.Instance.IsAvailable)
            {
                Stats = new UsageStats();

                // Calcul des périodes de facturation
                foreach (Period period in DailyUsageDAO.Instance.AllPeriod(Account))
                {
                    BillPeriodList.Add(new BillPeriod()
                    {
                        Start = period.Start,
                        End = period.End,
                        Text = String.Format(CIV.strings.AdvancedStats_BillingPeriod,
                                             period.Start.ToShortDateString(),
                                             period.End.ToShortDateString())
                        //period.Start.ToString("d MMMM"),
                        //period.End.ToString("d MMMM yyyy"))
                    });
                }

                // Calcul des statistiques Globale
                List<DailyUsageBO> data = DailyUsageDAO.Instance.All(Account);
                Stats.RecordedDay = data.Count;
                Stats.GlobalUploadTotal = 0;
                Stats.GlobalDownloadTotal = 0;
                Stats.GlobalCombinedTotal = 0;
                if (data.Count > 1)
                {
                    Stats.GlobalUploadGreater = data[0].Upload;
                    Stats.GlobalUploadGreaterDay = data[0].Day;
                    Stats.GlobalUploadLesser = data[0].Upload;
                    Stats.GlobalUploadLesserDay = data[0].Day;
                    Stats.GlobalDownloadGreater = data[0].Download;
                    Stats.GlobalDownloadGreaterDay = data[0].Day;
                    Stats.GlobalDownloadLesser = data[0].Download;
                    Stats.GlobalDownloadLesserDay = data[0].Day;
                    Stats.GlobalCombinedGreater = data[0].Total;
                    Stats.GlobalCombinedGreaterDay = data[0].Day;
                    Stats.GlobalCombinedLesser = data[0].Total;
                    Stats.GlobalCombinedLesserDay = data[0].Day;
                    Stats.MoreOldDay = data[0].Day;
                    Stats.MoreRecentDay = data[data.Count - 1].Day;
                }

                for (int i = 0; i < data.Count; i++)
                {
                    if (data[i].Upload > Stats.GlobalUploadGreater)
                    {
                        Stats.GlobalUploadGreater = data[i].Upload;
                        Stats.GlobalUploadGreaterDay = data[i].Day;
                    }
                    if (data[i].Upload < Stats.GlobalUploadLesser)
                    {
                        Stats.GlobalUploadLesser = data[i].Upload;
                        Stats.GlobalUploadLesserDay = data[i].Day;
                    }
                    Stats.GlobalUploadTotal += data[i].Upload;

                    if (data[i].Download > Stats.GlobalDownloadGreater)
                    {
                        Stats.GlobalDownloadGreater = data[i].Download;
                        Stats.GlobalDownloadGreaterDay = data[i].Day;
                    }
                    if (data[i].Download < Stats.GlobalDownloadLesser)
                    {
                        Stats.GlobalDownloadLesser = data[i].Download;
                        Stats.GlobalDownloadLesserDay = data[i].Day;
                    }
                    Stats.GlobalDownloadTotal += data[i].Download;

                    if (data[i].Total > Stats.GlobalCombinedGreater)
                    {
                        Stats.GlobalCombinedGreater = data[i].Total;
                        Stats.GlobalCombinedGreaterDay = data[i].Day;
                    }
                    if (data[i].Total < Stats.GlobalCombinedLesser)
                    {
                        Stats.GlobalCombinedLesser = data[i].Total;
                        Stats.GlobalCombinedLesserDay = data[i].Day;
                    }
                    Stats.GlobalCombinedTotal += data[i].Total;
                }

                // Calcul des statistiques Mensuel
                data = DailyUsageDAO.Instance.AllByMonth(Account);
                Stats.RecordedMonth = data.Count;
                if (data.Count > 1)
                {
                    Stats.MonthlyUploadGreater = data[0].Upload;
                    Stats.MonthlyUploadGreaterDay = data[0].Day;
                    Stats.MonthlyUploadLesser = data[0].Upload;
                    Stats.MonthlyUploadLesserDay = data[0].Day;
                    Stats.MonthlyDownloadGreater = data[0].Download;
                    Stats.MonthlyDownloadGreaterDay = data[0].Day;
                    Stats.MonthlyDownloadLesser = data[0].Download;
                    Stats.MonthlyDownloadLesserDay = data[0].Day;
                    Stats.MonthlyCombinedGreater = data[0].Total;
                    Stats.MonthlyCombinedGreaterDay = data[0].Day;
                    Stats.MonthlyCombinedLesser = data[0].Total;
                    Stats.MonthlyCombinedLesserDay = data[0].Day;
                }

                for (int i = 0; i < data.Count; i++)
                {
                    if (data[i].Upload > Stats.MonthlyUploadGreater)
                    {
                        Stats.MonthlyUploadGreater = data[i].Upload;
                        Stats.MonthlyUploadGreaterDay = data[i].Day;
                    }
                    if (data[i].Upload < Stats.MonthlyUploadLesser)
                    {
                        Stats.MonthlyUploadLesser = data[i].Upload;
                        Stats.MonthlyUploadLesserDay = data[i].Day;
                    }

                    if (data[i].Download > Stats.MonthlyDownloadGreater)
                    {
                        Stats.MonthlyDownloadGreater = data[i].Download;
                        Stats.MonthlyDownloadGreaterDay = data[i].Day;
                    }
                    if (data[i].Download < Stats.MonthlyDownloadLesser)
                    {
                        Stats.MonthlyDownloadLesser = data[i].Download;
                        Stats.MonthlyDownloadLesserDay = data[i].Day;
                    }

                    if (data[i].Total > Stats.MonthlyCombinedGreater)
                    {
                        Stats.MonthlyCombinedGreater = data[i].Total;
                        Stats.MonthlyCombinedGreaterDay = data[i].Day;
                    }
                    if (data[i].Total < Stats.MonthlyCombinedLesser)
                    {
                        Stats.MonthlyCombinedLesser = data[i].Total;
                        Stats.MonthlyCombinedLesserDay = data[i].Day;
                    }
                }
                Stats.MonthlyUploadAverage = Stats.GlobalUploadTotal / data.Count;
                Stats.MonthlyDownloadAverage = Stats.GlobalDownloadTotal / data.Count;
                Stats.MonthlyCombinedAverage = Stats.GlobalCombinedTotal / data.Count;
            }
        }