Beispiel #1
0
        /// <summary>
        ///     Get IndexView of the Log
        /// </summary>
        /// <param name="toDate"> Show Logentries before toDate </param>
        /// <param name="testsystem"> ID of testsystem </param>
        /// <param name="fromDate"> Show Logentries after fromDate </param>
        /// <param name="testsuite"> ID of testsuite </param>
        /// <param name="history"> show history (history=1) or current results (history=0) </param>
        /// <returns> Index View </returns>
        public ActionResult Errorlog(string fromDate = "", string toDate = "", int testsystem = 0, int testsuite = 0, int history = 0)
        {
            if (testsystem == 0 && Session["testsystem"] != null)
            {
                testsystem = (int)Session["testsystem"];
            }
            if (testsuite == 0 && Session["testsuite"] != null)
            {
                testsuite = (int)Session["testsuite"];
            }
            Session["testsystem"] = testsystem;
            Session["testsuite"]  = testsuite;

            IList <TestsystemModel> lstTestsystems = Mapper.Map <IList <TestsystemModel> >(_testViewerService.GetTestsystems());

            ViewBag.LstTestsystems = lstTestsystems;
            if (testsystem == 0 && lstTestsystems.Count > 0)
            {
                testsystem = lstTestsystems[0].ID;
            }

            IList <TestsuiteModel> testsuites = Mapper.Map <IList <TestsuiteModel> >(_testViewerService.GetTestSuites(testsystem));

            ViewBag.LstTestsuites = testsuites;
            if ((testsuite == 0 || testsuites.All(t => t.ID != testsuite)) && testsuites.Count > 0)
            {
                testsuite = testsuites[0].ID;
            }

            IList <ErrorOccurrenceGroup> errorOccurrenceGroups;

            DateTime fromDateTime = fromDate == "" ? DateTime.Now : DateTime.Parse(fromDate + " 00:00:00");
            DateTime toDateTime   = toDate == "" ? DateTime.Now : DateTime.Parse(toDate + " 23:59:59");

            if (history == 0)
            {
                errorOccurrenceGroups = _testViewerService.GetCurrentErrorOccurrenceGroups(testsystem, testsuite);
            }
            else
            {
                errorOccurrenceGroups = _testViewerService.GetHistoryErrorOccurrenceGroups(testsystem, testsuite, fromDateTime, toDateTime);
            }

            ViewBag.DateFrom = fromDateTime.ToString("dd.MM.yyyy");
            ViewBag.DateTo   = toDateTime.ToString("dd.MM.yyyy");

            ViewBag.CurrentTestsuite  = testsuites.Single(t => t.ID == testsuite);
            ViewBag.CurrentTestsystem = lstTestsystems.Single(t => t.ID == testsystem);

            ViewBag.ShowHistory = history;

            return(View("Errorlog", errorOccurrenceGroups));
        }