0
votes

I made a rendering extension for SSRS which generate a digitally signed and password protected report in pdf format. For the time being I suppose that user id comes from RDL report parameter So I made a sample RDL report with one parameter. I just want to get that report's parameter value using c# code In my class library project.

  bool IRenderingExtension.Render(Microsoft.ReportingServices.OnDemandReportRendering.Report report, NameValueCollection reportServerParameters, NameValueCollection deviceInfo, NameValueCollection clientCapabilities, ref System.Collections.Hashtable renderProperties, CreateAndRegisterStream createAndRegisterStream)
        {
            pdfheper = new PDFHelper();
            //Get user id from parameter
            try
            {
                pdfRenderer.Render(report, reportServerParameters, deviceInfo, clientCapabilities, ref renderProperties,
                    new CreateAndRegisterStream(IntermediateCreateAndRegisterStream)
                );

                String tempFile = Path.GetTempPath() + report.Name + ".pdf";
                String tempSigned = Path.GetTempPath() + report.Name + "signed.pdf";
                signer = new PDFSigner(Config.CertFilePath, Config.CertFilePass, tempFile, tempSigned);
                //Stream where report capture
                Stream outputStream = createAndRegisterStream(report.Name, "pdf", Encoding.UTF8, "application/pdf", true, StreamOper.CreateAndRegister);
                intermediateStream.Position = 0;
                pdfheper.SaveStreamToFile(tempFile, intermediateStream);
                //Here get value from report parameter
                int userid = 2;
                RendererDAL dsl = new RendererDAL();
                string userPassword = dsl.GetUserPassword(userid);
                //Add Signature
                    if (signer.AddSignature(userPassword))
                    {
                        // convert pdf to stream
                        intermediateStream = pdfheper.FileToStream(tempSigned);
                        //After apply signature copy stream to output stream
                        byte[] buffer = new byte[32 * 1024];
                        while (true)
                        {
                            int read = intermediateStream.Read(buffer, 0, buffer.Length);
                            if (read <= 0) break;
                            outputStream.Write(buffer, 0, read);
                        }
                        intermediateStream.Close();
                        intermediateStream = null;
                        File.Delete(tempFile);
                        File.Delete(tempSigned);
                    }
            }
            catch (Exception ex)
            {
                MyLogManager.Log(ex.ToString());
            }

        return false;
    }
1
Any resolution? Are you using VB? - Hituptony

1 Answers

0
votes

There is a reportServerParameters parameter in your parameter list for the Render method. This is an instance of

System.Collections.Specialized.NameValueCollection

I imagine the code to retrieve a parameter would probably be:

string parameterValue = reportServerParameters.Get(<Parameter Name>);

Or, for a multi-valued parameter:

string[] parameterValues = reportServerParameters.GetValues(<Parameter Name>);

https://msdn.microsoft.com/en-us/library/system.collections.specialized.namevaluecollection.aspx