How can I dynamically add an image logo to ReportViewer Parameters? - reportviewer

I need help adding an image logo in ReportViewer dynamically. I get this image from db, convert it to Base64, and then I need to add it in ReportViewer... This code next:
rpViewer.LocalReport.EnableExternalImages = true;
Company _company = db.Companys.Where(c => c.codCompany == c.codCompany).Single();
//first step
byte[] img = _company.imagem.ToArray(); // i get image from db
MemoryStream _ms = new MemoryStream(img);
string logo = Convert.ToBase64String(img); //convert to base64
// 2 step
List<ReportParameter> lstReportParams = new List<ReportParameter>();//Create params
lstReportParams.Add(new ReportParameter("Logo", logo));
lstReportParams.Add(new ReportParameter("LogoMimeType", "image/png"));
// Doesn't work here (see error below)
this.rpViewer.LocalReport.SetParameters(lstReportParams);
this.rpViewer.RefreshReport();
The error:
{"An error occurred during local report processing."}
{"An attempt was made to set a report parameter 'Logo' that is not defined in this report."}
In Rldc:
MIMEType =Parameters!LogoMimeType.value
Value ="System.Convert.FromBase64String(Parameters!Logo.Value)"
Why doesn't it work?
Why is not recognizing the parameter?
I can load that image in ReportViewer.

Your RDLC file needs to have the Logo parameter created in order for your Parameter List to be reckognized by your report.
You will need to edit your RDLC file, and create a parameter. You can do this by opening the RDLC file in Visual Studio, then click on Report in the file menu, and select Report Parameters.

The error message say's that you have not defined the report parameter Logo. Is this report parameter defined?
You may also be running into problems with the size of the parameters you are sending in.
We had a similar problem, with a report that needed to display different images. In our case there were only about 10 images.
The way we solved it was to place all images on the report, and then set them visable or not depending upon a parameter.

Related

How to dynamically set the datasource for subreports with an Active Reports 13 rdlx report

I have an Active Reports 13 report defined using the rdlx format. The report also contains a number of sub-reports.
When defined in the report designer the data source is set to some test data, however, when the report is embedded in a WPF application we wish to update the location of the database pragmatically.
We have been able to update the data source for the main report, but it is not clear (to us!) how to update the data source for the sub-reports.
string report = _reportPath;
// checked the report file exists ...
if (File.Exists(report))
{
// create and setup the data source
// create an empty page report
GrapeCity.ActiveReports.PageReport def = new GrapeCity.ActiveReports.PageReport();
//load the report layout
def.Load(new System.IO.FileInfo(report));
//setup the dataset
GrapeCity.ActiveReports.PageReportModel.DataSource myDataSource = def.Report.DataSources[0];
def.Report.DataSources[0].ConnectionProperties.DataProvider = "OLEDB";
def.Report.DataSources[0].ConnectionProperties.ConnectString = #"RunData.mdb;provider=Microsoft.Jet.OLEDB.4.0;";
// loop through subreports and set the location of the run data database
// ????
reportViewer.LoadDocument(def.Document);
}
Does anyone have some pointers to how we should be writing the code at "????" above to also update the subreports?
This is done in an event on the report document LocateDataSource
Also, please refer to this sample to see how the LocateDataSource is being used: DataSet DataSource. You can access the sample application by downloading a trial of ActiveReports 13 here.
Best,
GrapeCity Support Team

Export SSRS report in pdf format from SSIS

I've a situation, where I need to export a report from my report server to my local in pdf format through SSIS package.
This can be done from a Script Task. An example of this is below with C# as the language used.
Add an HTTP Connection Manager. For the Server URL enter the url for the report server. You find this in Reporting Services Configuration Manager on the Web Service URL pane. Make sure to use credentials with the appropriate privileges. I recommend testing and verifying the before proceeding.
Add a C# Script Task with the code below. The ServerURL property will be the as follows:
Report server URL + ?/ + report name including the path with the SSRS folder + the command options (beginning with first &rs below). In this case Format=PDF is for saving in PDF format.
// this will be the name that was given to the HTTP Connection manager when it was created
ConnectionManager conn = Dts.Connections["HTTP Connection Manager"];
HttpClientConnection httpConn = new HttpClientConnection(conn.AcquireConnection(null));
// location where PDF will be saved to
string outputPDF = #"C:\Test\NameOfReport.pdf";
httpConn.ServerURL = #"http://YourReportServer?/Folder of Report/Report Name&rs:Command=Render&rs:Format=PDF&rc:Toolbar=False";
// second parameter of true indicates to overwrite file
httpConn.DownloadFile(outputPDF, true);
You could use a Script Task in SSIS to export the report from SSRS. Take a look at the following blog post. It explains how to export an SSRS report via SSIS. https://sqlserverrider.wordpress.com/2013/02/15/generate-pdf-report-from-ssis/
Also, this forum thread has some other examples: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/d6ac1ba5-90a2-403b-898e-edaab3c7b270/generate-ssrs-pdf-from-ssis?forum=sqlintegrationservices

Google Drive - use WebViewLink vs thumbnailLink

I'm using the Google Drive API where I can gain access to 2 pieces of data that I need to display a jpg file oin my program. WebViewLink is the "large" size image while thumbnailLink is the "thumb" smaller size of the same image.
I'm having an issue with downloading the WebViewLink that I do not have with the thumbnailLink. Part of my code calls either exif_imagetype($filename) or getimagesize($filename) so I can retrieve the type, height & width etc for the $filename. This is successful for the thumbnailView but not the WebViewLink...
code snippet...
$WebViewLink = "https://drive.google.com/a/treering.com/file/d/blablabla";
$type = exif_imagetype($WebViewLink);
--- results in the error
"PHP Warning: exif_imagetype(): stream does not support seeking..."
where as...
$thumbnailLink = "https://lh6.googleusercontent.com/blablabla";
$type = exif_imagetype($thumbnailLink);
--- successful
where $type = 2 // a .jpg file
Not sure what I need to do to gain a usable WebViewLink... maybe use the "export" function to copy to a file on my server that is accessible, then use that exported file for the functions that fail above?
Thanks for any help.
John
I think you are using the wrong property to get the image of the file.
WebViewLink
A link for opening the file in a relevant Google editor or viewer in a browser.
thumbnailLink
A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours.
You can try using the iconLink():
A static, unauthenticated link to the file's icon.
Sample image of thumbnailLink:
Sample image of a iconLink:
It will still show relevant image about the file.
Hope it helps!

File download control - delete file without validation?

Hello XPages programmers.
I work on a simple XPages File Library.
To achieve that i use FileUpload control with FileDownload control.
When i create a new file, i enter its name, and select a file.
I set that uploading a file won't activate a validation, so i can attach a file without a specified name. Additionally i set it to do fullrefresh, so uploading a file takes place in an instant and a file is visible in FileDownload control.
Problem occurs, when i want to delete that attachment using garbage icon of FileDownload - i can't set it to run without walidation.
Is there any workaround avaiable?
Any help will be appreciated.
I used the workaround Mark Leusink suggested - created a simmilar button (used image from filedownload control) and then set it for full refresh with process data without validation property.
Code in JSSS
function deleteAttachments()
{
var attList = dDocument.getAttachmentList("Document_Attachment");
for(var i=0; i<attList.size(); i++)
{
var att:String = attList[i];
dDocument.removeAttachment("Document_Attachment", att.getName() );
}
}
Surely it can be used for delete a specific attachment by getting attachment name from rowdata in a repeater and use DATASOURCE.removeAttachment method.
Thanks for your support!

How to link a PDF Document to a Record using Visual Studio LightSwitch 2011?

I'm Stuck the following problem: How can I link a PDF Document to a Record in a Data Grid using Visual Studio LightSwitch 2011 and Visual Basic?
Any help would be awesome, thanks!
Here's the simplest way to do this: add a custom command to the Command Bar of the Data Grid Row for your Data Grid. In this example I'm calling the command Open PDF File. Then add this code to Execute code for the command:
partial void OpenPDFFile_Execute()
{
const string LOCAL_SERVER_PDF_DIR = #"\\MyServer\PDFs\";
const string WEB_SERVER_PDF_DIR = "http://myweb.server/PDFs/";
const string PDF_SUFFIX = ".pdf"; //assumes you do not include the extension in the db field value
if (AutomationFactory.IsAvailable)
{
//if the AutomationFactory is available, this is a desktop deployment
//use the shell to open a PDF file from the local network
dynamic shell = AutomationFactory.CreateObject("Shell.Application");
string filePath = LOCAL_SERVER_PDF_DIR + this.PDFFiles.SelectedItem.FileName + PDF_SUFFIX;
shell.ShellExecute(filePath);
}
else
{
//otherwise this must be a web deployment
//in order to make this work you must add a reference to System.Windows.Browser
//to the Client project of your LS solution
var uri = new Uri(WEB_SERVER_PDF_DIR + this.PDFFiles.SelectedItem.FileName + PDF_SUFFIX);
HtmlPage.Window.Navigate(uri, "_blank");
}
}
You will need to add the following imports to the top of your user code file to make this code compile:
using System.Runtime.InteropServices.Automation;
using System.Windows.Browser;
I should mention that you need a directory to server the PDFs up from. This example is flexible with respect to deployment, because it handles both desktop and web configurations. Since you'll need to set up the PDF directoy, you may want to just handle one configuration option to simply things (or you could expose the same PDF directory over http and as a local network share).
You may also want to present this as a true link instead of a button. In order to do this, you'll need a custom SilverLight control. In any case, I would recommend implementing the PDF link using a button first. You can then move this same code to a link event handler as a separate project if that is worth spending time on.