public static String GetGeneratedReportId(CxRestContext ctx, CancellationToken token, String scanId, ReportTypes type) { var dict = new Dictionary <String, String>() { { "reportType", type.ToString() }, { "scanId", scanId } }; return(WebOperation.ExecutePost <String>( ctx.Json.CreateSastClient , (response) => { using (var sr = new StreamReader(response.Content.ReadAsStreamAsync().Result)) using (var jtr = new JsonTextReader(sr)) { JToken jt = JToken.Load(jtr); return ReadReportId(jt); } } , CxRestContext.MakeUrl(ctx.Url, URL_SUFFIX) , () => new FormUrlEncodedContent(dict) , ctx , token)); }
private void ValidateResultNotWritten(string path, ReportTypes ReportType) { string text = File.ReadAllText(path); foreach (string resultType in ReportType.ToString().Split(',')) { Assert.IsFalse(text.Contains($"{resultType}: "), $"Expected to not find '{resultType}: '"); } }
public static void UpdateReportLogStatus(long rptlogId, ReportTypes reportType, ReportStage reportStage, bool complete) { var cmd = _db.GetStoredProcCommand("[dbo].[uspReportLog_StatusUpdate]"); _db.AddInParameter(cmd, "rptlogId", SqlDbType.BigInt, rptlogId); _db.AddInParameter(cmd, "reportType", SqlDbType.VarChar, reportType.ToString()); _db.AddInParameter(cmd, "reportStage", SqlDbType.VarChar, reportStage.ToString()); _db.AddInParameter(cmd, "complete", SqlDbType.Bit, complete); _db.ExecuteNonQuery(cmd); }
public static String GetGeneratedReportId(CxRestContext ctx, CancellationToken token, String scanId, ReportTypes type) { try { using (var client = ctx.Json.CreateSastClient()) { var dict = new Dictionary <String, String>() { { "reportType", type.ToString() }, { "scanId", scanId } }; using (var payload = new FormUrlEncodedContent(dict)) { using (var scanReportTicket = client.PostAsync( CxRestContext.MakeUrl(ctx.Url, URL_SUFFIX), payload).Result) { if (!scanReportTicket.IsSuccessStatusCode) { throw new InvalidOperationException ($"Scan report generation request for scan {scanId} returned " + $"{scanReportTicket.StatusCode}"); } using (var sr = new StreamReader (scanReportTicket.Content.ReadAsStreamAsync().Result)) using (var jtr = new JsonTextReader(sr)) { JToken jt = JToken.Load(jtr); return(ReadReportId(jt)); } } } } } catch (HttpRequestException hex) { _log.Error("Communication error.", hex); throw hex; } }
/// <summary> /// Displays received or written report data. /// </summary> /// /// <param name="buffer"> contains the report data. </param> /// <param name="currentReportType" > "Input", "Output", or "Feature"</param> /// <param name="currentReadOrWritten" > "read" for Input and IN Feature reports, "written" for Output and OUT Feature reports.</param> private void DisplayReportData(Byte[] buffer, ReportTypes currentReportType, ReportReadOrWritten currentReadOrWritten) { try { Int32 count; LstResults.Items.Add(currentReportType.ToString() + " report has been " + currentReadOrWritten.ToString().ToLower() + "."); // Display the report data received in the form's list box. LstResults.Items.Add(" Report ID: " + String.Format("{0:X2} ", buffer[0])); LstResults.Items.Add(" Report Data:"); TxtBytesReceived.Text = ""; for (count = 1; count <= buffer.Length - 1; count++) { // Display bytes as 2-character Hex strings. String byteValue = String.Format("{0:X2} ", buffer[count]); LstResults.Items.Add(" " + byteValue); // Display the received bytes in the text box. TxtBytesReceived.SelectionStart = TxtBytesReceived.Text.Length; TxtBytesReceived.SelectedText = byteValue + Environment.NewLine; } ScrollToBottomOfListBox(); } catch (Exception ex) { DisplayException(Name, ex); throw; } }