我该如何称呼以下人员

本文关键字: | 更新日期: 2023-09-27 17:58:07

    public class MyReportRenderer
    {
        private rs2005.ReportingService2005 rs;
        private rs2005Execution.ReportExecutionService rsExec;
        //string casenumberKey;
        public void RenderTest()
        {
            string HistoryID = null;
            string deviceInfo = null;
            string encoding = String.Empty;
            string mimeType = String.Empty;
            string extension = String.Empty;
            rs2005Execution.Warning[] warnings = null;
            string[] streamIDs = null;
            rs = new rs2005.ReportingService2005();
            rsExec = new rs2005Execution.ReportExecutionService();
            rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
            rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
            rs.Url = "http://216.40.232.82/ReportServer_DEVELOPMENT/ReportService2005.asmx";
            rsExec.Url = "http://216.40.232.82/ReportServer_DEVELOPMENT/ReportExecution2005.asmx";

            //// pass parameters
            try
            {
                // Get if any parameters needed.

                // Load the selected report.
                rsExec.LoadReport("/LawDept/LawDeptTIC", HistoryID);
                // Prepare report parameter.
                // Set the parameters for the report needed.
                rs2005Execution.ParameterValue[] parameters = new rs2005Execution.ParameterValue[3];
                parameters[0] = new rs2005Execution.ParameterValue();
                parameters[0].Name = "CaseNumberKey";
                parameters[0].Value = "000002";
                //parameters[1] = new rs2005Execution.ParameterValue();
                //parameters[1].Name = "ReportMonth";
                //parameters[1].Value = "6"; // June
                //parameters[2] = new rs2005Execution.ParameterValue();
                //parameters[2].Name = "ReportYear";
                //parameters[2].Value = "2004";
                rsExec.SetExecutionParameters(parameters, "en-us");
                // get pdf of report 
                Byte[] results = rsExec.Render("PDF", deviceInfo,
                out extension, out encoding,
                out mimeType, out warnings, out streamIDs);
                MailMessage message = new MailMessage("george.greiner@gmail.com", "george.greiner@gmail.com", "Hello", "This is a test");
                SmtpClient emailClient = new SmtpClient("localhost");
                message.Attachments.Add(new Attachment(new MemoryStream(results), String.Format("{0}_DocumentSavingsReport.pdf", "ReportName")));
                emailClient.Send(message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }

当我需要执行时,我会调用它吗??

我该如何称呼以下人员

(new MyReportRenderer()).RenderTest();

如果您询问如何在类MyReportRenderer上调用方法RenderTest,您需要实例化MyReportRenderer的实例,然后从实例化的对象调用该方法:

namespace ReportProgram
{
  class Program
  {
    static void Main(string [] args)
    {
      var rr = new MyReportRenderer();
      rr.RenderTest();
    }
  }
}

我称之为"一个名为MyReportRenderer的类"。如果你的意思是"调用一种方法",我认为你需要

var renderer = new MyrReportRenderer();
renderer.RenderTest();
相关文章:
  • 没有找到相关文章