Beispiel #1
0
        public void TestETWReaderFactory()
        {
            ETWReaderFactory factory = new ETWReaderFactory();

            //Test for ETWFileReader creation
            AbstractETWReader fileReader = factory.CreateReader("FilePath");

            Assert.AreEqual(fileReader.GetType(), typeof(ETWFileReader));

            //Verify that a string not specified in the factory returns a null reader
            AbstractETWReader nullReader = factory.CreateReader("");

            Assert.IsNull(nullReader);
        }
Beispiel #2
0
        public IActionResult AddEventsFromString([FromBody] AddETWRequest request)
        {
            try
            {
                ETWReaderFactory  factory = new ETWReader.ETWReaderFactory();
                AbstractETWReader reader  = factory.CreateReader(request.SourceType);

                Guid SourceId = Events.AddETWData(Guid.NewGuid(), reader.ReadEvents(request.Source));

                return(new OkObjectResult(SourceId));
            }
            catch (System.UnauthorizedAccessException exception)
            {
                return(BadRequest(new ErrorMessage("This application requires additional authorization to access this log. Please log in as administrator or add permissions to the user running this application.", exception)));
            }
            catch (FileNotFoundException exception)
            {
                return(BadRequest(new ErrorMessage("Error reading events from the specified source.", exception)));
            }
            catch (Exception exception)
            {
                return(BadRequest(new ErrorMessage("An unexpected error as occured. See the message and stacktrace for more information.", exception)));
            }
        }