コード例 #1
0
ファイル: SSRSReport.aspx.cs プロジェクト: Matlwa/source
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    ssrsReportViewer1.ProcessingMode = ProcessingMode.Remote;
                    IReportServerCredentials irsc = new MyReportServerCredentials();
                    ssrsReportViewer1.ServerReport.ReportServerCredentials = irsc;

                    ssrsReportViewer1.ProcessingMode = ProcessingMode.Remote;
                    ssrsReportViewer1.ServerReport.ReportServerUrl = new Uri(_siteConfig.SSRSUrl);
                    ssrsReportViewer1.ServerReport.ReportPath      = "/Unplugg IT Solution BI Reporting/UIS_RPT_AllMembersReport";
                    ssrsReportViewer1.ServerReport.Refresh();
                }
                catch (Exception ex)
                {
                    Response.Write(ex.ToString());
                }
            }
        }
コード例 #2
0
        public void Test()
        {
            //
            ReportViewer rpw = new ReportViewer();

            rpw.ProcessingMode = ProcessingMode.Remote;
            IReportServerCredentials irsc = new MyReportServerCredentials();

            rpw.ServerReport.ReportServerCredentials = irsc;

            rpw.ProcessingMode = ProcessingMode.Remote;
            rpw.ServerReport.ReportServerUrl = new Uri(_siteConfig.SSRSUrl);
            //rpw.ServerReport.ReportPath = "/Unplugg IT Solution BI Reporting/Unplugg IT Busy Days";
            rpw.ServerReport.ReportPath = "/Unplugg IT Solution BI Reporting/" + ddlAdminReort.SelectedItem.Text;

            //

            var p_PayPeriod = new ReportParameter("parlourid", "F7CAF4C0-B3AB-44E0-8C8A-76AA4E8CDA6D");

            //reportParameters.Add(new ReportParameter("parlourid", "F7CAF4C0-B3AB-44E0-8C8A-76AA4E8CDA6D"));
            //rpw.ServerReport.SetParameters(p_PayPeriod);
            //
            Warning[] warnings;
            string[]  streamids;
            string    mimeType;
            string    encoding;
            string    extension;
            string    filename;

            byte[] bytes = rpw.ServerReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);

            filename = string.Format("{0}.{1}", ddlAdminReort.SelectedItem.Text, "pdf");
            Response.ClearHeaders();
            Response.Clear();
            Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
            Response.ContentType = mimeType;
            Response.BinaryWrite(bytes);
            Response.Flush();
            Response.End();
        }
コード例 #3
0
        public void SSRSReport()
        {
            Warning[] warnings;
            string[]  streamIds;
            string    mimeType  = string.Empty;
            string    encoding  = string.Empty;
            string    extension = string.Empty;

            ReportViewer rpw = new ReportViewer();

            rpw.ProcessingMode = ProcessingMode.Remote;
            IReportServerCredentials irsc = new MyReportServerCredentials();

            rpw.ServerReport.ReportServerCredentials = irsc;

            rpw.ProcessingMode = ProcessingMode.Remote;
            rpw.ServerReport.ReportServerUrl = new Uri(_siteConfig.SSRSUrl);
            rpw.ServerReport.ReportPath      = "/Unplugg IT Solution BI Reporting/Unplugg IT Active Parlours";

            //ArrayList reportParam = new ArrayList();
            //reportParam = ReportDefaultPatam();

            //ReportParameter[] param = new ReportParameter[reportParam.Count];
            //for (int k = 0; k < reportParam.Count; k++)
            //{
            //    param[k] = (ReportParameter)reportParam[k];
            //}


            //ReportParameterCollection reportParameters = new ReportParameterCollection();

            //reportParameters.Add(new ReportParameter("parlourid", "6DCBA090-F363-47E6-93F5-6DEF8F80703E"));
            //reportParameters.Add(new ReportParameter("parlourid", "6DCBA090-F363-47E6-93F5-6DEF8F80703E"));
            //reportParameters.Add(new ReportParameter("parlourid", "6DCBA090-F363-47E6-93F5-6DEF8F80703E"));
            //reportParameters.Add(new ReportParameter("parlourid", "6DCBA090-F363-47E6-93F5-6DEF8F80703E"));
            //reportParameters.Add(new ReportParameter("parlourid", "6DCBA090-F363-47E6-93F5-6DEF8F80703E"));
            //reportParameters.Add(new ReportParameter("parlourid", "6DCBA090-F363-47E6-93F5-6DEF8F80703E"));
            //reportParameters.Add(new ReportParameter("parlourid", "6DCBA090-F363-47E6-93F5-6DEF8F80703E"));
            //reportParameters.Add(new ReportParameter("parlourid", "6DCBA090-F363-47E6-93F5-6DEF8F80703E"));

            //ssrsReportViewer1.ServerReport.SetParameters(reportParameters);
            //rpw.ServerReport.SetParameters(param);
            rpw.ServerReport.Refresh();
            byte[] bytes = rpw.ServerReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings);


            // Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
            Response.Buffer = true;
            Response.Clear();
            Response.ContentType = mimeType;
            Response.AddHeader("content-disposition", "attachment; filename=Monthly BI Stats.pdf");
            Response.BinaryWrite(bytes); // create the file
            Response.Flush();            // send it to the client to download


            //ssrsReportViewer1.ProcessingMode = ProcessingMode.Local;
            //IReportServerCredentials irsc = new MyReportServerCredentials();
            //ssrsReportViewer1.ServerReport.ReportServerCredentials = irsc;

            //ssrsReportViewer1.ProcessingMode = ProcessingMode.Remote;
            //ssrsReportViewer1.ServerReport.ReportServerUrl = new Uri(_siteConfig.SSRSUrl);
            //ssrsReportViewer1.ServerReport.ReportPath = "/Unplugg IT Solution BI Reporting/Monthly BI Stats";
            //ssrsReportViewer1.ServerReport.Refresh();
        }
コード例 #4
0
        protected void ExportClickEvent(object sender, EventArgs e)
        {
            try
            {
                //

                ReportViewer rpw = new ReportViewer();
                rpw.ProcessingMode = ProcessingMode.Remote;
                IReportServerCredentials irsc = new MyReportServerCredentials();
                rpw.ServerReport.ReportServerCredentials = irsc;


                rpw.ProcessingMode = ProcessingMode.Remote;
                rpw.ServerReport.ReportServerUrl = new Uri(_siteConfig.SSRSUrl);
                //rpw.ServerReport.ReportPath = "/Unplugg IT Solution BI Reporting/Unplugg IT Busy Days //UIS All Members Report";
                rpw.ServerReport.ReportPath = "/Mosys Reports/" + hfAdminReport.Value;
                //
                ReportParameterCollection reportParameters = new ReportParameterCollection();
                if (!string.IsNullOrEmpty(txtDateFrom.Text))
                {
                    reportParameters.Add(new ReportParameter("StartDateFrom", txtDateFrom.Text));
                }
                if (!string.IsNullOrEmpty(txtDateTo.Text))
                {
                    reportParameters.Add(new ReportParameter("StartDateTo", txtDateTo.Text));
                }

                //if (!string.IsNullOrEmpty(txtDateFrom.Text))
                //    reportParameters.Add(new ReportParameter("DebitDateFrom", txtDebitDateFrom.Text));
                //if (!string.IsNullOrEmpty(txtDateTo.Text))
                //    reportParameters.Add(new ReportParameter("DebitDateTo", txtDebitDateTo.Text));

                if (!string.IsNullOrEmpty(ddlAgent.SelectedItem.Text))
                {
                    reportParameters.Add(new ReportParameter("Agent", ddlAgent.SelectedItem.Text));
                }

                if (!string.IsNullOrEmpty(ddlPolicyStatus.SelectedItem.Text))
                {
                    reportParameters.Add(new ReportParameter("PolicyStatus", ddlPolicyStatus.SelectedItem.Text));
                }


                reportParameters.Add(new ReportParameter("Parlourid", ParlourId.ToString()));

                rpw.ServerReport.SetParameters(reportParameters);
                //
                Warning[] warnings;
                string[]  streamids;
                string    mimeType;
                string    encoding;
                string    extension;
                string    filename;
                //
                string ExportTypeName = rptExportType.SelectedItem.Text;
                string ExportTypeExtensions;
                if (ExportTypeName == "PDF")
                {
                    ExportTypeExtensions = "pdf";
                }
                else if (ExportTypeName == "Word")
                {
                    ExportTypeExtensions = "docx";
                }
                else
                {
                    ExportTypeExtensions = "xls";
                }
                //

                byte[] bytes = rpw.ServerReport.Render(ExportTypeName, null, out mimeType, out encoding, out extension, out streamids, out warnings);
                filename = string.Format("{0}.{1}", hfAdminReport.Value, ExportTypeExtensions);
                //MailSend
                if (!string.IsNullOrEmpty(txtcemail.Text))
                {
                    MemoryStream s = new MemoryStream(bytes);
                    s.Seek(0, SeekOrigin.Begin);
                    Attachment  a       = new Attachment(s, filename);
                    MailMessage message = new MailMessage(ConfigurationManager.AppSettings["ReportEmailSenderId"].ToString().Trim(), txtcemail.Text.Trim(), hfAdminReport.Value, "");
                    message.Attachments.Add(a);
                    SmtpClient client = new SmtpClient();
                    client.Send(message);
                    lblMessage.ForeColor = System.Drawing.Color.Green;
                    lblMessage.Text      = "Email Sent Successfully.";
                }
                //
                else
                {
                    Response.ClearHeaders();
                    Response.Clear();
                    Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);
                    Response.ContentType = mimeType;
                    Response.BinaryWrite(bytes);
                    Response.Flush();
                    Response.End();
                }
            }
            catch (Exception ex)
            {
                ShowMessage(ref lblMessage, MessageType.Danger, ex.Message);
            }
        }