Пример #1
0
        public IActionResult DeleteLog(int?id)
        {
            if (id != null)
            {
                TestRunnerLog testRunnerLog = _context.TestRunnerLog.Single(m => m.TestRunnerLogID == id);
                _context.TestRunnerLog.Remove(testRunnerLog);
                _context.SaveChanges();

                System.IO.File.Delete(testRunnerLog.FilePath);

                var DateTimeDirectory = Path.Combine(strTestRunnerLogsDirectory, testRunnerLog.DateTime);
                System.IO.Directory.Delete(DateTimeDirectory);

                HttpContext.Session.SetString("Message", "Test Runner Log: " + testRunnerLog.Filename + " successfully deleted");

                return(RedirectToAction("Details", new RouteValueDictionary(new
                {
                    controller = "TestRunners",
                    action = "Details",
                    ID = testRunnerLog.TestRunnerID
                })));
            }

            return(HttpNotFound());
        }
Пример #2
0
        private void AddTestRunnerLog(string strFilePath, string strFilename, int TestRunnerID, string DateTimeForFilename)
        {
            TestRunnerLog testRunnerLog = new TestRunnerLog();

            _context.TestRunnerLog.Add(testRunnerLog);
            testRunnerLog.FilePath     = strFilePath;
            testRunnerLog.Filename     = strFilename;
            testRunnerLog.TestRunnerID = TestRunnerID;
            testRunnerLog.DateTime     = DateTimeForFilename;
            _context.SaveChanges();
        }
Пример #3
0
        public ActionResult ReturnTestRunnerLogFile(int?id)
        {
            if (id != null)
            {
                TestRunnerLog testRunnerLog = _context.TestRunnerLog.Single(m => m.TestRunnerLogID == id);

                var file = new FileStream(testRunnerLog.FilePath, FileMode.Open, FileAccess.ReadWrite);

                return(File(file, "text/HTML", testRunnerLog.Filename));
            }
            return(HttpNotFound());
        }