public static string GenerateElementHtml(string data, ReportElementType elementType, string url = "", string width = "200px", string height = "200px") { switch (elementType) { case ReportElementType.Text: return($"<span>{data}</span>"); case ReportElementType.Link: return($"<a href=\"{url}\">{data}</a>"); case ReportElementType.Image: return($"<img class=\"myImg\" src=\"{(url != null ? url.Replace("\\", "/") : "")}\" alt=\"{data}\" width=\"{width}\" height=\"{height}\"/>"); case ReportElementType.Table: { string html = string.Empty; if (!string.IsNullOrEmpty(data) && data.IndexOf(",") != -1) { html += "<table><tbody>"; data.Split(',').ToList().ForEach(item => { html += $"<tr><td>{item}</td></tr>"; }); html += "</tbody></table>"; } else { html += $"<span>{data}</span>"; } return(html); }; default: return(""); } }
public async Task <List <SensorDto> > GetSensorsByReportElementType(ReportElementType type, int dashboardId) { var dashboard = await unitOfWork.DashboardRepo.GetById(dashboardId); var sensors = new List <Sensor>(); if (type == ReportElementType.OnOff) { foreach (var sensorControl in Enum.GetValues(typeof(MeasurementType))) { sensors.AddRange(await unitOfWork.SensorRepo.GetSensorControlsByMeasurementTypeAndUserId((MeasurementType)sensorControl, dashboard.AppUserId)); } } else if (type != ReportElementType.Clock && type != ReportElementType.StatusReport) { if (type == ReportElementType.Columnrange || type == ReportElementType.Gauge || type == ReportElementType.Heatmap || type == ReportElementType.TimeSeries || type == ReportElementType.Wordcloud) { sensors.AddRange(await unitOfWork.SensorRepo.GetSensorsByMeasurementTypeAndUserId(MeasurementType.Int, dashboard.AppUserId)); sensors.AddRange(await unitOfWork.SensorRepo.GetSensorsByMeasurementTypeAndUserId(MeasurementType.Double, dashboard.AppUserId)); } if (type == ReportElementType.TimeSeries || type == ReportElementType.BoolHeatmap) { sensors.AddRange(await unitOfWork.SensorRepo.GetSensorsByMeasurementTypeAndUserId(MeasurementType.Bool, dashboard.AppUserId)); } if (type == ReportElementType.Wordcloud) { sensors.AddRange(await unitOfWork.SensorRepo.GetSensorsByMeasurementTypeAndUserId(MeasurementType.String, dashboard.AppUserId)); } } var res = mapper.Map <List <Sensor>, List <SensorDto> >(sensors); return(res); }
public async Task <IActionResult> GetSensorsByReportElementType(ReportElementType type, int dashboardId) { var res = await _sensorManager.GetSensorsByReportElementType(type, dashboardId); if (res.Count == 0) { return(BadRequest()); } return(Ok(res)); }
public void Report(string title, string message, DifidoTestStatus status, ReportElementType type) { foreach (IReporter reporter in reporters) { lock (syncRoot) { reporter.Report(title, message, status, type); } } }
public void Report(string title, string message, DifidoTestStatus status, ReportElementType type) { ReportElement element = new ReportElement(); if (null == testDetails) { Console.WriteLine("HTML reporter was not initiliazed propertly. No reports would be created."); return; } element.title = title; element.message = message; element.time = DateTime.Now.ToString("HH:mm:ss"); element.status = status.ToString(); element.type = type.ToString(); testDetails.AddReportElement(element); if (type == ReportElementType.lnk || type == ReportElementType.img) { if (File.Exists(message)) { string fileName = FileWasAdded(testDetails, message); if (fileName != null) { element.message = fileName; } } } // The stopwatch is an important mechanism that helps when test is creating a large number of message in short time intervals. if (!stopwatch.IsRunning) { stopwatch.Start(); } else { if (stopwatch.ElapsedMilliseconds <= 100) { return; } } stopwatch.Restart(); TestDetailsWereAdded(testDetails); }
public void OnBeginReportElement(int elementID, int?elementIndentation, string elementName, ReportElementType elementType) { }
public void Report(string title, string message, ReporterTestInfo.TestStatus status, ReportElementType type) { failureReason = title; }
public void Report(string title, string message, ReporterTestInfo.TestStatus status, ReportElementType type) { ReportElement element = new ReportElement(); if (null == testDetails) { Console.WriteLine("HTML reporter was not initiliazed propertly. No reports would be created."); return; } testDetails.AddReportElement(element); element.title = title; element.message = message; element.time = DateTime.Now.ToString("HH:mm:ss"); element.status = status.ToString(); element.type = type.ToString(); if (type == ReportElementType.lnk || type == ReportElementType.img) { if (File.Exists(message)) { string fileName = FileWasAdded(testDetails, message); if (fileName != null) { element.message = fileName; } } } TestDetailsWereAdded(testDetails); }
public override void OnBeginReportElement(int elementID, int?elementIndentation, string elementName, ReportElementType elementType) => InvokeCBreezeParser.OnBeginReportElement?.Invoke(elementID, elementIndentation, elementName, elementType);
public void Report(string title, string message, DifidoTestStatus status, ReportElementType type) { StringBuilder sb = new StringBuilder(); switch (type) { case ReportElementType.regular: break; case ReportElementType.startLevel: sb.Append("[START LEVEL]: "); break; case ReportElementType.step: sb.Append("[STEP]: "); break; case ReportElementType.stopLevel: sb.Append("[STOP LEVEL]"); break; case ReportElementType.img: sb.Append("[IMAGE]: "); break; case ReportElementType.lnk: sb.Append("[LINK]: "); break; } switch (status) { case DifidoTestStatus.success: break; case DifidoTestStatus.warning: sb.Append("[WARNING]: "); break; case DifidoTestStatus.error: sb.Append("[ERROR]: "); break; case DifidoTestStatus.failure: sb.Append("[FAILURE]: "); break; } if (title != null && !title.Equals("")) { if (message != null && !message.Equals("")) { sb.Append(title + " - " + message); } else { sb.Append(title); } } Print(sb.ToString()); }
public void Report(string title, string message, ReporterTestInfo.TestStatus status, ReportElementType type) { ReportElement element = new ReportElement(); if (null == testDetails) { Console.WriteLine("HTML reporter was not initiliazed propertly. No reports would be created."); return; } testDetails.AddReportElement(element); element.title = title; element.message = message; element.time = DateTime.Now.ToString("HH:mm:ss"); element.status = status.ToString(); element.type = type.ToString(); if (type == ReportElementType.lnk || type == ReportElementType.img) { if (File.Exists(message)) { //This is a link to a file. Let's copy it to the report folder CreateTestFolderIfNotExists(); try { string fileName = Path.GetFileName(message); string fileDestination = testFolder + @"\" + fileName; System.IO.File.Copy(message, fileDestination, true); //We need that the link would be to the file in the report folder element.message = fileName; } catch (IOException e) { Console.WriteLine("Failed adding file to the report due to " + e.Message); } } } TestToFile(); }
public static object Deserialize(ReportElementType type, byte[] data) { return(_deserializers[type](data)); }