/// <summary> /// Отправить URL на проверку /// </summary> /// <param name="url"> - URL сайта или файла. </param> public static void ScanURL(string url) { try { string p_request = POST($"{URL}/url/scan?apikey={APIKEY}&url={url}"); lastScan = JsonSerializer.Deserialize <RScan>(p_request); } catch (Exception exception) { Console.WriteLine(exception); } }
/// <summary> /// Отправить файл на проверку /// </summary> /// <param name="filePath"> - путь к файлу. </param> public static void ScanFile(string filePath) { try { byte[] p_request = webClient.UploadFile($"{URL}/file/scan?apikey={APIKEY}", filePath); string s_json = Encoding.ASCII.GetString(p_request); lastScan = JsonSerializer.Deserialize <RScan>(s_json); } catch (Exception exception) { Console.WriteLine(exception); } }
/// <summary> /// Получить результат сканирования файла /// </summary> public static void ReportFile() { try { string s_json = GET($"{URL}/file/report?apikey={APIKEY}&resource={lastScan.resource}"); ScanResult scan = JsonSerializer.Deserialize <ScanResult>(s_json); scan.date = DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss"); scans.Insert(0, scan); if (scans.Count >= maxScansList) { scans = SeparateList <ScanResult>(scans, 0, maxScansList); } lastScan = null; } catch (Exception exception) { Console.WriteLine(exception); } }