Inheritance: ParameterValueOrFieldReference
Esempio n. 1
0
    private string GenerateReport(Dictionary <string, string> dictParam, bool bGetImagePath, bool preservecomments, string Report_Name)
    {
        string   reportPath      = string.Empty;
        string   sReportFileName = string.Empty;
        FileInfo fi = null;

        reportPath = SSRSLibrary + "/" + Report_Name;

        SSRS.ReportExecutionService rs1 = new SSRS.ReportExecutionService();
        rs1.Credentials = new System.Net.NetworkCredential(ClientConfiguration.WebServiceUserName, ClientConfiguration.WebServicePWD, ClientConfiguration.WebServiceUserDomain);

        ExecutionInfo2 execInfo = new ExecutionInfo2();

        execInfo = rs1.LoadReport2(reportPath, null);
        Int32 counter = 0;


        SSRS.ParameterValue[] parameters = new SSRS.ParameterValue[dictParam.Count];
        foreach (KeyValuePair <string, string> kvp in dictParam)
        {
            Console.WriteLine("Key = {0}, Value = {1}",
                              kvp.Key, kvp.Value);

            // Prepare report parameters

            parameters[counter]       = new SSRS.ParameterValue();
            parameters[counter].Name  = kvp.Key;
            parameters[counter].Value = kvp.Value;
            counter = counter + 1;
        }
        rs1.SetExecutionParameters2(parameters, null);

        //See Readme for different Types

        // Render arguments
        string encoding;
        string mimeType = "html/text";
        string extension;

        SSRS.Warning[] warnings  = null;
        string[]       streamIDs = null;
        string         format    = "HTML4.0";
        string         devInfo   = null;

        byte[] result = null;

        try
        {
            result   = rs1.Render2(format, devInfo, PageCountMode.Estimate, out extension, out mimeType, out encoding, out warnings, out streamIDs);
            execInfo = rs1.GetExecutionInfo2();

            UTF8Encoding enc = new UTF8Encoding();
            string       str = enc.GetString(result);
            //Hide Logo or parse string for anything
            str = str.Replace("<a", "<a style='display:none' ");
            string s = System.Text.ASCIIEncoding.ASCII.GetString(result);
            SendEmail(str, "*****@*****.**");
        }
        catch (SoapException ex)
        {
            Console.WriteLine(ex.Detail.OuterXml);

            return(string.Empty);
        }

        sReportFileName = Report_Name;

        String ReportName = graphicspath + "\\" + sReportFileName + ".html";

        // Write the contents of the report to an MHTML file.
        fi = new FileInfo(ReportName);
        if (fi.Exists)
        {
            fi.Delete();
        }
        using (FileStream stream = File.Create(ReportName, result.Length))
        {
            stream.Write(result, 0, result.Length);
            stream.Close();
        }

        return(string.Empty);
    }
Esempio n. 2
0
    private string GenerateReport(Dictionary<string, string> dictParam, bool bGetImagePath, bool preservecomments, string Report_Name)
    {
        string reportPath = string.Empty;
        string sReportFileName = string.Empty;
        FileInfo fi = null;

        reportPath = SSRSLibrary + "/" + Report_Name;

        SSRS.ReportExecutionService rs1 = new SSRS.ReportExecutionService();
        rs1.Credentials = new System.Net.NetworkCredential(ClientConfiguration.WebServiceUserName, ClientConfiguration.WebServicePWD, ClientConfiguration.WebServiceUserDomain);

        ExecutionInfo2 execInfo = new ExecutionInfo2();
        execInfo = rs1.LoadReport2(reportPath, null);
        Int32 counter = 0;

        SSRS.ParameterValue[] parameters = new SSRS.ParameterValue[dictParam.Count];
        foreach (KeyValuePair<string, string> kvp in dictParam)
        {
            Console.WriteLine("Key = {0}, Value = {1}",
                kvp.Key, kvp.Value);

            // Prepare report parameters

            parameters[counter] = new SSRS.ParameterValue();
            parameters[counter].Name = kvp.Key;
            parameters[counter].Value = kvp.Value;
            counter = counter + 1;
        }
        rs1.SetExecutionParameters2(parameters, null);

        //See Readme for different Types

        // Render arguments
        string encoding;
        string mimeType = "html/text";
        string extension;
        SSRS.Warning[] warnings = null;
        string[] streamIDs = null;
        string format = "HTML4.0";
        string devInfo = null;
        byte[] result = null;

        try
        {

            result = rs1.Render2(format, devInfo, PageCountMode.Estimate, out extension, out mimeType, out encoding, out warnings, out streamIDs);
            execInfo = rs1.GetExecutionInfo2();

            UTF8Encoding enc = new UTF8Encoding();
            string str = enc.GetString(result);
            //Hide Logo or parse string for anything
            str = str.Replace("<a", "<a style='display:none' ");
            string s = System.Text.ASCIIEncoding.ASCII.GetString(result);
            SendEmail(str, "*****@*****.**");

        }
        catch (SoapException ex)
        {
            Console.WriteLine(ex.Detail.OuterXml);

            return string.Empty;
        }

        sReportFileName =Report_Name;

        String ReportName = graphicspath + "\\" + sReportFileName + ".html";
        // Write the contents of the report to an MHTML file.
        fi = new FileInfo(ReportName);
        if (fi.Exists)
        {
            fi.Delete();
        }
        using (FileStream stream = File.Create(ReportName, result.Length))
        {
            stream.Write(result, 0, result.Length);
            stream.Close();
        }

           return string.Empty;
    }
 /// <remarks/>
 public void SetExecutionParametersAsync(ParameterValue[] Parameters, string ParameterLanguage, object userState)
 {
     if ((this.SetExecutionParametersOperationCompleted == null))
     {
         this.SetExecutionParametersOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSetExecutionParametersOperationCompleted);
     }
     this.InvokeAsync("SetExecutionParameters", new object[] {
             Parameters,
             ParameterLanguage}, this.SetExecutionParametersOperationCompleted, userState);
 }
 /// <remarks/>
 public void SetExecutionParametersAsync(ParameterValue[] Parameters, string ParameterLanguage)
 {
     this.SetExecutionParametersAsync(Parameters, ParameterLanguage, null);
 }
 public ExecutionInfo2 SetExecutionParameters2(ParameterValue[] Parameters, string ParameterLanguage)
 {
     object[] results = this.Invoke("SetExecutionParameters2", new object[] {
             Parameters,
             ParameterLanguage});
     return ((ExecutionInfo2)(results[0]));
 }
 /// <remarks/>
 public System.IAsyncResult BeginSetExecutionParameters2(ParameterValue[] Parameters, string ParameterLanguage, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("SetExecutionParameters2", new object[] {
             Parameters,
             ParameterLanguage}, callback, asyncState);
 }