public override ScanOutput Scan(string FilePath) { try { ScanOutput output = new ScanOutput(); fileLog.Status = ScanStatus.Queued; fileLog.FilePath = FilePath; fileLog.Scanner = _serviceName; Task <List <VTScanResult> > task = Task.Run <List <VTScanResult> >(async() => await RunExample(FilePath, fileLog)); _message = "File is queued! Please check back after some time"; output.Result = false; output.Message = "Please check back in a while"; output.ServiceName = _serviceName; return(output); } catch (Exception ex) { fileLog.Status = ScanStatus.Error; fileLog.Message = ex.Message; throw new AvscanException(ex); } finally { ScanFileLogRepo.Record(fileLog); } }
public override ScanOutput Scan(string FilePath) { ScanOutput output = new ScanOutput(); VTScanResult scanResult = new VTScanResult(); List <VTScanResult> logresult = new List <VTScanResult>(); bool result = false; try { _filepath = FilePath; fileLog.StartTime = DateTime.Now.ToString(); fileLog.Status = ScanStatus.Started; fileLog.FilePath = FilePath; fileLog.Scanner = _serviceName; ScanUtility.ExecuteCommand(RunUtil, RunCommand); _message = (String.IsNullOrEmpty(ScanUtility.Output) ? "(none)" : ScanUtility.Output); result = (ScanUtility.Result == 0) ? false : true; fileLog.FinishTime = DateTime.Now.ToString(); fileLog.Status = (ScanUtility.Result == 0) ? ScanStatus.Passed : ScanStatus.Failed; fileLog.Message = _message; output.Result = result; output.Message = _message; output.ServiceName = _serviceName; } catch (Exception ex) { _message = ex.Message; fileLog.Status = ScanStatus.Error; result = false; //throw new AvscanException(ex); } finally { scanResult.ScanId = _serviceName; scanResult.VirusFound = result; scanResult.Result = _message; logresult.Add(scanResult); fileLog.ScanResults = logresult; ScanFileLogRepo.Record(fileLog); } return(output); }