Error while receiving a byte array from robotic automation
I'm trying to take a screenshot of the web search list (ex: 'keyboard' search on Amazon), convert the png file to byte array, and send the byte array over to pega application.
The following is the C# script I have for doing so:
if (string.IsNullOrEmpty(outputImagePath))
{
return null;
}
OpenSpan.Diagnostics.Diagnostic.TraceVerbose("Script", string.Format("Attempting to grab screen shot {0}/{1}/{2}/{3}", width, height, xCoordinate, yCoordinate));
try
{
Bitmap screenshot = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics screenGraph = Graphics.FromImage(screenshot);
screenGraph.CopyFromScreen(xCoordinate, yCoordinate, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
screenshot.Save(outputImagePath, System.Drawing.Imaging.ImageFormat.Png);
ImageConverter converter = new ImageConverter();
return (byte[])converter.ConvertTo(screenshot, typeof(byte[]));
}
catch (Exception ex)
{
OpenSpan.Diagnostics.Diagnostic.PublishException(ex, null);
return null;
}
I'm trying to send the byte array to a Java Object property in Pega (ByteArray), but when I run the case to see if it got transferred, I get the attached error.
I'm trying to take a screenshot of the web search list (ex: 'keyboard' search on Amazon), convert the png file to byte array, and send the byte array over to pega application.
The following is the C# script I have for doing so:
if (string.IsNullOrEmpty(outputImagePath))
{
return null;
}
OpenSpan.Diagnostics.Diagnostic.TraceVerbose("Script", string.Format("Attempting to grab screen shot {0}/{1}/{2}/{3}", width, height, xCoordinate, yCoordinate));
try
{
Bitmap screenshot = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics screenGraph = Graphics.FromImage(screenshot);
screenGraph.CopyFromScreen(xCoordinate, yCoordinate, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
screenshot.Save(outputImagePath, System.Drawing.Imaging.ImageFormat.Png);
ImageConverter converter = new ImageConverter();
return (byte[])converter.ConvertTo(screenshot, typeof(byte[]));
}
catch (Exception ex)
{
OpenSpan.Diagnostics.Diagnostic.PublishException(ex, null);
return null;
}
I'm trying to send the byte array to a Java Object property in Pega (ByteArray), but when I run the case to see if it got transferred, I get the attached error.
Any suggestions on how to fix this issue, or on the C# code is appreciated. Thanks.