예제 #1
0
파일: Scanner.cs 프로젝트: lanicon/HawkEye
        public ScanResult Scan(string filename)
        {
            FileInfo       fileInfo = new FileInfo(filename);
            LoggingSection log      = logging.CreateChild(fileInfo.Name);

            log.Verbose($"Starting {GetType().Name} on {fileInfo.FullName}");
            DateTime  timeStarted = DateTime.Now;
            string    result      = null;
            bool      succeeded;
            Exception exception = null;

            try
            {
                result    = DoScan(fileInfo.FullName, log);
                succeeded = true;
                log.Verbose("Scan was successfull");
            }
            catch (Exception e)
            {
                succeeded = false;
                exception = e;
                log.Warning($"Scan failed: {e.Message}{Environment.NewLine}{e.StackTrace}");
            }
            DateTime timeEnded = DateTime.Now;

            log.Dispose();
            return(new ScanResult(result, fileInfo.FullName, this, timeStarted, timeEnded, succeeded, exception));
        }