コード例 #1
0
        public static void SaveReport(string fileName, string _reportName, RE2005.ParameterValue[] para)
        {
            RS2005.ReportingService2005   rs;
            RE2005.ReportExecutionService rsExec;

            // Create a new proxy to the web service
            rs     = new RS2005.ReportingService2005();
            rsExec = new RE2005.ReportExecutionService();

            // Authenticate to the Web service using Windows credentials
            rs.Credentials     = System.Net.CredentialCache.DefaultCredentials;
            rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;

            rs.Url     = "http://spm-sql/reportserver/reportservice2005.asmx";
            rsExec.Url = "http://spm-sql/reportserver/reportexecution2005.asmx";

            const string historyID  = null;
            const string deviceInfo = null;
            const string format     = "PDF";

            Byte[] results;

            const string _historyID    = null;
            const bool   _forRendering = false;

            RS2005.ParameterValue[]        _values      = null;
            RS2005.DataSourceCredentials[] _credentials = null;
            try
            {
                RS2005.ReportParameter[] _parameters = rs.GetReportParameters(_reportName, _historyID, _forRendering, _values, _credentials);
                RE2005.ExecutionInfo     ei          = rsExec.LoadReport(_reportName, historyID);
                RE2005.ParameterValue[]  parameters  = para;

                rsExec.SetExecutionParameters(parameters, "en-us");

                results = rsExec.Render(format, deviceInfo,
                                        out string extension, out string encoding,
                                        out string mimeType, out RE2005.Warning[] warnings, out string[] streamIDs);

                try
                {
                    File.WriteAllBytes(fileName, results);
                }
                catch (Exception e)
                {
                    Debug.Print(e.Message);
                    //MessageBox.Show(e.Message, "SPM Connect - Save Report", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                //throw ex;
            }
        }
コード例 #2
0
        private async Task SaveReport(string invoiceno, string fileName, string paymenttype)
        {
            RS2005.ReportingService2005   rs;
            RE2005.ReportExecutionService rsExec;

            // Create a new proxy to the web service
            rs     = new RS2005.ReportingService2005();
            rsExec = new RE2005.ReportExecutionService();

            // Authenticate to the Web service using Windows credentials
            rs.Credentials     = System.Net.CredentialCache.DefaultCredentials;
            rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;

            rs.Url     = "http://spm-sql/reportserver/reportservice2005.asmx";
            rsExec.Url = "http://spm-sql/reportserver/reportexecution2005.asmx";

            string historyID  = null;
            string deviceInfo = null;
            string format     = "PDF";

            Byte[] results;
            string encoding  = String.Empty;
            string mimeType  = String.Empty;
            string extension = String.Empty;

            RE2005.Warning[] warnings    = null;
            string[]         streamIDs   = null;
            string           _reportName = @"/GeniusReports/Accounting/SPM_EFT";

            string _historyID    = null;
            bool   _forRendering = false;

            RS2005.ParameterValue[]        _values      = null;
            RS2005.DataSourceCredentials[] _credentials = null;
            RS2005.ReportParameter[]       _parameters  = null;

            try
            {
                _parameters = rs.GetReportParameters(_reportName, _historyID, _forRendering, _values, _credentials);
                RE2005.ExecutionInfo    ei         = rsExec.LoadReport(_reportName, historyID);
                RE2005.ParameterValue[] parameters = new RE2005.ParameterValue[2];

                if (_parameters.Length > 0)
                {
                    parameters[0] = new RE2005.ParameterValue
                    {
                        //parameters[0].Label = "";
                        Name  = "pCode",
                        Value = invoiceno
                    };
                    parameters[1] = new RE2005.ParameterValue
                    {
                        //parameters[0].Label = "";
                        Name  = "pTransNo",
                        Value = paymenttype
                    };
                }
                rsExec.SetExecutionParameters(parameters, "en-us");

                results = rsExec.Render(format, deviceInfo,
                                        out extension, out encoding,
                                        out mimeType, out warnings, out streamIDs);

                try
                {
                    File.WriteAllBytes(fileName, results);
                }
                catch (Exception e)
                {
                    Debug.Print(e.Message);
                    //MessageBox.Show(e.Message, "SPM Connect - Save Report", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                //throw ex;
            }
            finally
            {
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Evacameryan/WriteRDLToFile
            //formatType must be: EXCEL, PDF, WORD, CSV, XML, RTF
            public static void SaveRDL(string reportName, string formatType, Dictionary <string, string> dictValues, string _fileName, SSRSServer server = SSRSServer.New2016)
            {
                // Authenticate to the Web service using Windows credentials
                var netCredentials = new System.Net.NetworkCredential("<windowsUserName>", "<windowsUserPassword>", "<Domain>");

                // Create a new proxy to the web service

                ReportingService2005 rs = new ReportingService2005()
                {
                    Credentials = netCredentials
                };

                RE2005.ReportExecutionService rsExec = new RE2005.ReportExecutionService()
                {
                    Credentials = netCredentials
                };

                if (server == SSRSServer.New2016)
                {
                    rs.Url     = $"http://<server>/reportservice2005.asmx";
                    rsExec.Url = $"http://<server>/reportexecution2005.asmx";
                }
                else
                {
                    rs.Url     = $"http://<server>/reportservice2005.asmx";
                    rsExec.Url = $"http://<server>/reportexecution2005.asmx";
                }

                string historyId    = null;
                bool   forRendering = false;

                ParameterValue[]        values      = null;
                DataSourceCredentials[] credentials = null;
                ReportParameter[]       _parameters = null;
                byte[] results;

                try
                {
                    _parameters = rs.GetReportParameters(reportName, historyId, forRendering, values, credentials);

                    if (_parameters != null)
                    {
                        foreach (ReportParameter rp in _parameters)
                        {
                            Console.WriteLine("Name: {0}", rp.Name);
                        }
                    }
                    RE2005.ParameterValue[] parameters = new RE2005.ParameterValue[dictValues.Count];

                    int count = 0;
                    foreach (var item in dictValues)
                    {
                        parameters[count]         = new RE2005.ParameterValue();
                        parameters[count].Label   = item.Key;
                        parameters[count].Name    = item.Key;
                        parameters[count++].Value = item.Value;
                    }

                    RE2005.ExecutionInfo rpt = rsExec.LoadReport(reportName, null);
                    rsExec.SetExecutionParameters(parameters, "en-us");

                    //Render variables
                    string           deviceInfo = null;
                    string           encoding   = String.Empty;
                    string           mimeType   = String.Empty;
                    string           extension  = String.Empty;
                    RE2005.Warning[] warnings   = null;
                    string[]         streamIDs  = null;

                    string formatType2Pass;
                    switch (formatType)
                    {
                    case "RTF":
                        formatType2Pass = "******";      //And we convert afterwards
                        break;

                    case "DOCX":
                        formatType2Pass = "******";
                        break;

                    default:
                        formatType2Pass = formatType;
                        break;
                    }

                    results = rsExec.Render(
                        formatType2Pass,
                        deviceInfo,
                        out extension,
                        out encoding,
                        out mimeType,
                        out warnings,
                        out streamIDs);

                    string fileNameExt;
                    switch (formatType)
                    {
                    case "EXCEL":
                        fileNameExt = ".XLSX";
                        break;

                    case "WORDOPENXML":
                        fileNameExt = ".DOCX";
                        break;

                    case "WORD":
                        fileNameExt = ".DOC";
                        break;

                    case "RTF":
                        fileNameExt = ".DOC";      //And we convert afterwards
                        break;

                    case "PDF":
                    default:
                        fileNameExt = "." + formatType;
                        break;
                    }

                    string fileName = (Path.GetExtension(_fileName) == "") ? _fileName + fileNameExt : _fileName;

                    using (FileStream stream = File.OpenWrite(fileName))
                    {
                        stream.Write(results, 0, results.Length);
                        stream.Dispose();
                    }
                    if (formatType == "RTF")
                    {
                        string fileNameRTF = _fileName + ".rtf";
                        WordToRtf(fileName, fileNameRTF);
                    }
                    File.SetAttributes(fileName, FileAttributes.Normal);
                    rs.Dispose();
                    rsExec.Dispose();
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message);
                }
            }
コード例 #4
0
ファイル: Program.cs プロジェクト: Evacameryan/WriteRDLToFile
            public static byte[] SaveRDLtoFileStream(string reportName, string formatType, Dictionary <string, string> dictValues)
            {
                // Create a new proxy to the web service
                ReportingService2005 rs = new ReportingService2005();

                RE2005.ReportExecutionService rsExec = new RE2005.ReportExecutionService();

                // Authenticate to the Web service using Windows credentials
                rs.Credentials     = System.Net.CredentialCache.DefaultCredentials;
                rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;

                rs.Url     = "http://<server>/reportservice2005.asmx";
                rsExec.Url = "http://<server>/reportexecution2005.asmx";

                string historyId    = null;
                bool   forRendering = false;

                ParameterValue[]        values      = null;
                DataSourceCredentials[] credentials = null;
                ReportParameter[]       _parameters = null;
                byte[] results = new byte[64 * 1024];

                try
                {
                    _parameters = rs.GetReportParameters(reportName, historyId, forRendering, values, credentials);

                    if (_parameters != null)
                    {
                        foreach (ReportParameter rp in _parameters)
                        {
                            Console.WriteLine("Name: {0}", rp.Name);
                        }
                    }
                    RE2005.ParameterValue[] parameters = new RE2005.ParameterValue[dictValues.Count];

                    int count = 0;
                    foreach (var item in dictValues)
                    {
                        parameters[count]         = new RE2005.ParameterValue();
                        parameters[count].Label   = item.Key;
                        parameters[count].Name    = item.Key;
                        parameters[count++].Value = item.Value;
                    }

                    RE2005.ExecutionInfo rpt = rsExec.LoadReport(reportName, null);
                    rsExec.SetExecutionParameters(parameters, "en-us");

                    //Render variables
                    string           deviceInfo = null;
                    string           encoding   = String.Empty;
                    string           mimeType   = String.Empty;
                    string           extension  = String.Empty;
                    RE2005.Warning[] warnings   = null;
                    string[]         streamIDs  = null;

                    results = rsExec.Render(
                        formatType,
                        deviceInfo,
                        out extension,
                        out encoding,
                        out mimeType,
                        out warnings,
                        out streamIDs);
                    return(results);
                }
                catch (Exception e)
                {
                    //Console.WriteLine(e.Message);
                }
                return(results);
            }
コード例 #5
0
ファイル: Heartbeat.cs プロジェクト: JustinSunli/SPM_Connect
        public void SaveReport(string invoiceno, string fileName)
        {
            RS2005.ReportingService2005   rs;
            RE2005.ReportExecutionService rsExec;

            // Create a new proxy to the web service
            rs     = new RS2005.ReportingService2005();
            rsExec = new RE2005.ReportExecutionService();

            // Authenticate to the Web service using Windows credentials
            rs.Credentials     = System.Net.CredentialCache.DefaultCredentials;
            rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;

            rs.Url     = "http://spm-sql/reportserver/reportservice2005.asmx";
            rsExec.Url = "http://spm-sql/reportserver/reportexecution2005.asmx";

            string historyID  = null;
            string deviceInfo = null;
            string format     = "PDF";

            Byte[] results;
            string encoding  = String.Empty;
            string mimeType  = String.Empty;
            string extension = String.Empty;

            RE2005.Warning[] warnings    = null;
            string[]         streamIDs   = null;
            string           _reportName = @"/GeniusReports/Job/SPM_ServiceReport";

            string _historyID    = null;
            bool   _forRendering = false;

            RS2005.ParameterValue[]        _values      = null;
            RS2005.DataSourceCredentials[] _credentials = null;
            RS2005.ReportParameter[]       _parameters  = null;

            try
            {
                _parameters = rs.GetReportParameters(_reportName, _historyID, _forRendering, _values, _credentials);
                RE2005.ExecutionInfo    ei         = rsExec.LoadReport(_reportName, historyID);
                RE2005.ParameterValue[] parameters = new RE2005.ParameterValue[1];

                if (_parameters.Length > 0)
                {
                    parameters[0] = new RE2005.ParameterValue
                    {
                        //parameters[0].Label = "";
                        Name  = "ReqNumber",
                        Value = invoiceno
                    };
                }
                rsExec.SetExecutionParameters(parameters, "en-us");

                results = rsExec.Render(format, deviceInfo,
                                        out extension, out encoding,
                                        out mimeType, out warnings, out streamIDs);

                try
                {
                    File.WriteAllBytes(fileName, results);
                }
                catch (Exception e)
                {
                    Debug.Print(e.Message);
                    //MessageBox.Show(e.Message, "SPM Connect - Save Report", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
            Console.WriteLine("Report Creation completed successfully");
            Console.WriteLine("Sending email out");
            SendEmail("*****@*****.**", "New Service Report " + invoiceno, invoiceno, fileName);
        }