Esempio n. 1
0
 public ActionResult Index()
 {
     var caseProvider = new CaseDataProvider();
     var cases = caseProvider.GetTop100();
     return View(cases);
 }
Esempio n. 2
0
File: Main.cs Progetto: uaans/ocase
        public static void Main(string[] args)
        {
            try
            {
                // organizations and users
                List<Organization> organizations = CreateOrganization();
                List<User> users = CreateUsers();

                // creating cases
                CreateCases(100, organizations, users);
                CreateCases(1000, organizations, users);
                CreateCases(10000, organizations, users);
                CreateCases(500000, organizations, users);
                CreateCases(1000, organizations, users);

                // search cases
                CaseDataProvider provider = new CaseDataProvider();
                List<Case> cases;
                Random r = new Random();

                TimeCounter counter = new TimeCounter("C. Search by year and number");
                int found = 0;
                for (int i = 0; i < Configuration.SearchesNumber; i++)
                {
                    counter.Start();
                    cases = provider.GetByYearAndNumber(2010, r.Next(1, 100000));
                    counter.Stop();
                    found += cases.Count;
                }
                counter.PrintTime();
                counter.PrintLine(string.Format("Found {0} cases, avg. {1} per search.\n", found, found / Configuration.SearchesNumber));

                found = 0;
                counter = new TimeCounter("D. Search by case ID");
                for (int i = 0; i < Configuration.SearchesNumber; i++)
                {
                    counter.Start();
                    Case theCase = provider.GetById(r.Next(1, 100000));
                    counter.Stop();
                    if (theCase != null)
                    {
                        found++;
                    }
                }
                counter.PrintTime();
                counter.PrintLine(string.Format("Found {0} cases, avg. {1} per search.\n", found, found / Configuration.SearchesNumber));

                found = 0;
                counter = new TimeCounter("E. Search by case title");
                for (int i = 0; i < Configuration.SearchesNumber; i++)
                {
                    counter.Start();
                    cases = provider.GetByTitle(PhraseGenerator.GetRandomPhrase(1) + "%", 20);
                    counter.Stop();
                    found += cases.Count;
                }
                counter.PrintTime();
                counter.PrintLine(string.Format("Found {0} cases, avg. {1} per search.\n", found, found / Configuration.SearchesNumber));

                found = 0;
                counter = new TimeCounter("F. Search by custom field value");
                for (int i = 0; i < Configuration.SearchesNumber; i++)
                {
                    counter.Start();
                    cases = provider.GetByCustomFieldValue(PhraseGenerator.GetRandomPhrase(1) + "%", 20);
                    counter.Stop();
                    found += cases.Count;
                }
                counter.PrintTime();
                counter.PrintLine(string.Format("Found {0} cases, avg. {1} per search.\n", found, found / Configuration.SearchesNumber));
                /*
                if (cases.Count > 0)
                {
                    Console.WriteLine(cases[0]);
                }
                */
            }
            catch (Exception e)
            {
                Console.WriteLine("Error occured: {0}", e);
            }
            Console.WriteLine("Done, press a key...");
            Console.ReadKey();
        }