示例#1
0
        static void Main(string[] args)
        {
            DashboardManager        manager = new DashboardManager(url, database);
            DashboardService        service = new DashboardService();
            IDictionary <int, long> get     = service.CountSuccessfulLogin(24);
            IDictionary <int, long> get2    = service.CountFailedLogin(12);
            //IList<Double> get3 = manager.GetAverageSuccessfulLogin();
            IDictionary <int, long> get4 = service.CountSuccessfulLogin(1);

            IDictionary <string, long> temp11 = manager.GetSuccessfulLoggedInUsers();

            foreach (var s in temp11)
            {
                Console.WriteLine(s);
            }

            /**
             * Console.WriteLine("succesufl");
             * foreach (var s in get)
             * {
             *  Console.WriteLine(s.Key + "," + s.Value);
             * }
             * Console.WriteLine("failed login");
             * foreach (var s in get2)
             * {
             *  Console.WriteLine(s.Key + "," + s.Value);
             * }
             * Console.WriteLine("Avg successful login");
             * foreach (var s in get3)
             * {
             *  Console.WriteLine(s.Key + "," + s.Value);
             * }
             **/
            //ICollection<DateTime> list = service.CountAverageSessionDuration(1, 2019);
            //for (int i = 0; i < list.Count(); i++)
            //{
            //    Console.WriteLine("Print:" + list.ElementAt(i));
            //}
            long sum = service.CountUniqueLoggedInUsers(1, 2019);

            Console.WriteLine("sum:" + sum);
            //IDictionary<string, long> something3 = service.CountMostUsedFiveFeature(2);
            Console.WriteLine("hi");


            Console.ReadKey();
        }
        // Line Chart

        /// <summary>
        /// Get the list of logged in users and number of total users
        /// </summary>
        /// <returns></returns>
        public IDictionary <string, long> GetSuccessfulLoggedInUsers()
        {
            int duration = BusinessRuleConstants.GetSuccessfulLoggedInUsers_Duartion; // 6
            Dictionary <string, long> successfulLoggedInUsers = new Dictionary <string, long>();
            int monthToday = DateTime.Today.Month;
            int yearToday  = DateTime.Today.Year;

            // Get the number of unique logged in users during the specific month
            // Flaw: request the data to the database for duration(6) times, it slows down the performance
            for (int i = 0; i < duration; i++)
            {
                successfulLoggedInUsers.Add(dateFormatConverter[monthToday], _dashboardService.CountUniqueLoggedInUsers(monthToday, yearToday));
                monthToday--;
                if (monthToday == 0)
                {
                    monthToday = 12; yearToday--;
                }
            }

            return(successfulLoggedInUsers);
        }